Skip to content

Commit

Permalink
feat(events): wrap up events list mvp
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnk committed Feb 15, 2024
1 parent 1ccb216 commit 141ba90
Show file tree
Hide file tree
Showing 25 changed files with 684 additions and 301 deletions.
2 changes: 0 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
PUBLIC_APP_URL=http://localhost:5173
PUBLIC_SELF_HOSTED=true
SECRET_PLUNK_API_KEY=
SECRET_DB_DRIVER=turso
SECRET_SQLITE_URL=file:./data/sqlite.db
SECRET_SQLITE_KEY=
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Logo](https://supso.co/logo.svg)
![Logo](https://supso.co/logo-dark.png)

# Supso

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ CREATE TABLE `board` (
FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `comment` (
`id` text PRIMARY KEY NOT NULL,
`event_id` text NOT NULL,
`user_id` text NOT NULL,
`content` text NOT NULL,
`created_at` text,
`updated_at` text,
FOREIGN KEY (`event_id`) REFERENCES `event`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `event` (
`id` text PRIMARY KEY NOT NULL,
`project_id` text NOT NULL,
Expand All @@ -28,6 +39,8 @@ CREATE TABLE `event` (
`content` text,
`emoji` text,
`notify` numeric DEFAULT 'false',
`resolved` numeric DEFAULT 'false',
`customName` text,
`tags` text,
`context` text,
`priority` text DEFAULT 'normal' NOT NULL,
Expand Down
95 changes: 94 additions & 1 deletion drizzle/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "5",
"dialect": "sqlite",
"id": "101a376c-2848-40be-991c-14ec81fef5fb",
"id": "6f0c003b-0d0a-48b6-b80a-f31d1d667ea1",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"access_token": {
Expand Down Expand Up @@ -149,6 +149,84 @@
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"comment": {
"name": "comment",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"event_id": {
"name": "event_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"content": {
"name": "content",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"comment_event_id_event_id_fk": {
"name": "comment_event_id_event_id_fk",
"tableFrom": "comment",
"tableTo": "event",
"columnsFrom": [
"event_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"comment_user_id_user_id_fk": {
"name": "comment_user_id_user_id_fk",
"tableFrom": "comment",
"tableTo": "user",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"event": {
"name": "event",
"columns": {
Expand Down Expand Up @@ -202,6 +280,21 @@
"autoincrement": false,
"default": "'false'"
},
"resolved": {
"name": "resolved",
"type": "numeric",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "'false'"
},
"customName": {
"name": "customName",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"tags": {
"name": "tags",
"type": "text",
Expand Down
4 changes: 2 additions & 2 deletions drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
{
"idx": 0,
"version": "5",
"when": 1707858219034,
"tag": "0000_bent_gauntlet",
"when": 1708010108881,
"tag": "0000_reflective_korg",
"breakpoints": true
}
]
Expand Down
14 changes: 11 additions & 3 deletions src/lib/components/charts/events-chart.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<script lang="ts">
import '@carbon/charts-svelte/styles.css';
import { BarChartSimple, ChartTheme, ScaleTypes } from '@carbon/charts-svelte';
import {
BarChartSimple,
ChartTheme,
ScaleTypes,
type ChartTabularData
} from '@carbon/charts-svelte';
export let data;
export let data: ChartTabularData;
</script>

<BarChartSimple
{data}
options={{
theme: ChartTheme.G100,
height: '400px',
height: '368px',
grid: {
x: {
enabled: false
Expand All @@ -33,6 +38,9 @@
Qty: '#14b8a6',
Misc: '#14b8a6'
}
},
toolbar: {
enabled: false
}
}}
/>
5 changes: 4 additions & 1 deletion src/lib/components/dashboard/combobox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
</Popover.Trigger>
<Popover.Content class="w-[200px] p-0">
<Command.Root>
<Command.Input {placeholder} />
<Command.Input
{placeholder}
class={cn('text-muted-foreground', $value && 'text-foreground')}
/>
<Command.Empty>No option found.</Command.Empty>
<Command.Group>
{#each options as option}
Expand Down
47 changes: 47 additions & 0 deletions src/lib/components/dashboard/events-date-picker.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<script lang="ts">
import { Calendar } from '$lib/components/ui/calendar';
import * as Popover from '$lib/components/ui/popover';
import { Button } from '$lib/components/ui/button';
import { cn } from '$lib/utils';
import { CalendarIcon } from 'lucide-svelte';
import { DateFormatter, CalendarDate } from '@internationalized/date';
import { derived, type Writable } from 'svelte/store';
const df = new DateFormatter('en-US', {
dateStyle: 'long'
});
export let placeholder: string;
export let value: Writable<string | null>;
export const calendarValue = derived(value, ($value) => {
if (!$value) return;
const date = new Date(parseInt($value));
return new CalendarDate(date.getFullYear(), date.getMonth(), date.getDate());
});
</script>

<Popover.Root>
<Popover.Trigger asChild let:builder>
<Button
variant="outline"
class={cn(
'w-[180px] justify-start text-left font-normal',
!$value && 'text-muted-foreground'
)}
builders={[builder]}
>
<CalendarIcon class="mr-2 h-4 w-4" />
{$value ? df.format(new Date(parseInt($value))) : placeholder}
</Button>
</Popover.Trigger>
<Popover.Content class="w-auto p-0" align="start">
<Calendar
value={$calendarValue}
onValueChange={(newDate) => {
if (!newDate) return value.set(null);
value.set(newDate.toDate('UTC').getTime().toString());
}}
class="rounded-md border shadow"
/>
</Popover.Content>
</Popover.Root>
49 changes: 0 additions & 49 deletions src/lib/components/dashboard/events-table-short.svelte

This file was deleted.

72 changes: 72 additions & 0 deletions src/lib/components/dashboard/events-table.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<script lang="ts">
import { type Event } from '$lib/db/schema';
import * as Table from '$lib/components/ui/table';
import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
import { Badge } from '$lib/components/ui/badge';
import { Button } from '$lib/components/ui/button';
import { CheckIcon, XIcon, MoreVerticalIcon } from 'lucide-svelte';
import { formatDate } from '$lib/format/date';
export let events: Event[];
export let hideActions: boolean = false;
</script>

<Table.Root>
<Table.Header>
<Table.Row>
<Table.Head>Event</Table.Head>
<Table.Head>Channel</Table.Head>
<Table.Head>Notify</Table.Head>
<Table.Head>Created</Table.Head>
{#if !hideActions}
<Table.Head class="text-right">Actions</Table.Head>
{/if}
</Table.Row>
</Table.Header>
<Table.Body>
{#each events as event}
<Table.Row>
<Table.Cell>
<a href={`/events/${event.id}`} class="flex items-center gap-2">
{#if event.emoji}
<Badge variant="secondary" class="text-lg">{event.emoji}</Badge>
{/if}
<span>{event.event}</span>
</a>
</Table.Cell>
<Table.Cell>
<Button
href={`/projects/${event.projectId}/events?channel=${event.channel}`}
variant="link"
class="text-foreground"
>
#{event.channel}
</Button>
</Table.Cell>
<Table.Cell>
{#if event.notify}
<CheckIcon size={16} />
{:else}
<XIcon size={16} />
{/if}
</Table.Cell>
<Table.Cell>
{formatDate(event.createdAt ?? '')}
</Table.Cell>
{#if !hideActions}
<Table.Cell class="flex items-center justify-end">
<DropdownMenu.Root>
<DropdownMenu.Trigger>
<Button size="icon" variant="secondary"><MoreVerticalIcon size={16} /></Button>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Item>Assign to me</DropdownMenu.Item>
<DropdownMenu.Item>Delete Event</DropdownMenu.Item></DropdownMenu.Content
>
</DropdownMenu.Root></Table.Cell
>
{/if}
</Table.Row>
{/each}
</Table.Body>
</Table.Root>
Loading

0 comments on commit 141ba90

Please sign in to comment.