Skip to content

Commit ccf2550

Browse files
committed
More work on publish shares page
1 parent 2250f35 commit ccf2550

5 files changed

Lines changed: 57 additions & 62 deletions

File tree

src/routes/(authenticated)/shares/public/+page.svelte

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts">
2+
import Plus from '@lucide/svelte/icons/plus';
23
import RotateCcw from '@lucide/svelte/icons/rotate-ccw';
34
import type { SortingState } from '@tanstack/table-core';
45
import { publicShockerSharesApi } from '$lib/api';
@@ -13,6 +14,8 @@
1314
let data = $state<OwnPublicShareResponse[]>([]);
1415
let sorting = $state<SortingState>([]);
1516
17+
let showAddShareModal = $state<boolean>(false);
18+
1619
function refreshPublicShares() {
1720
publicShockerSharesApi
1821
.shareLinksList()
@@ -35,12 +38,18 @@
3538
<Card.Header class="w-full">
3639
<Card.Title class="flex items-center justify-between space-x-2 text-3xl">
3740
Public Shares
38-
<Button class="text-xl" onclick={refreshPublicShares}>
39-
<RotateCcw />
40-
<span> Refresh </span>
41-
</Button>
41+
<div>
42+
<Button onclick={() => (showAddShareModal = true)}>
43+
<Plus />
44+
Add Share
45+
</Button>
46+
<Button onclick={refreshPublicShares}>
47+
<RotateCcw />
48+
Refresh
49+
</Button>
50+
</div>
4251
</Card.Title>
43-
<Card.Description>This is a list of all the public shares you control.</Card.Description>
52+
<Card.Description>This is a list of all the public shares you own.</Card.Description>
4453
</Card.Header>
4554
<Card.Content class="w-full">
4655
<DataTable {data} {columns} {sorting} />
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<script lang="ts">
2+
import { Pause, Play } from '@lucide/svelte';
3+
import { page } from '$app/state';
4+
import { publicShockerSharesApi } from '$lib/api';
5+
import type { PublicShareResponse } from '$lib/api/internal/v1';
6+
import { Button } from '$lib/components/ui/button';
7+
import { onMount } from 'svelte';
8+
9+
let shareId = $derived(page.params.shareId);
10+
11+
let details = $state<PublicShareResponse>();
12+
13+
onMount(() => {
14+
publicShockerSharesApi.publicGetPublicShare(shareId).then((response) => {
15+
details = response.data;
16+
console.log(response);
17+
});
18+
});
19+
</script>
20+
21+
<ul>
22+
{#each details?.devices ?? [] as device}
23+
{#each device.shockers ?? [] as shocker}
24+
<li class="m-2 flex items-center gap-2">
25+
<Button>
26+
<Pause />
27+
<Play />
28+
</Button>
29+
{shocker.name}
30+
<div class="flex-1"></div>
31+
<Button>Shock</Button>
32+
<Button>Vibrate</Button>
33+
<Button>Sound</Button>
34+
<Button>Remove</Button>
35+
</li>
36+
{/each}
37+
{/each}
38+
</ul>

src/routes/(authenticated)/shares/public/data-table-actions.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
<script lang="ts">
22
import Ellipsis from '@lucide/svelte/icons/ellipsis';
3+
import { goto } from '$app/navigation';
34
import type { OwnPublicShareResponse } from '$lib/api/internal/v1';
45
import { Button } from '$lib/components/ui/button';
56
import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
67
import { toast } from 'svelte-sonner';
7-
import SharelinkDeleteDialog from './dialog-sharelink-delete.svelte';
8-
import SharelinkEditDialog from './dialog-sharelink-edit.svelte';
8+
import SharelinkDeleteDialog from './dialog-publicshare-delete.svelte';
99
1010
interface Props {
1111
publicShare: OwnPublicShareResponse;
1212
}
1313
1414
let { publicShare }: Props = $props();
1515
16-
let editDialogOpen = $state<boolean>(false);
1716
let deleteDialogOpen = $state<boolean>(false);
1817
1918
function copyId() {
@@ -22,7 +21,6 @@
2221
}
2322
</script>
2423

25-
<SharelinkEditDialog bind:open={editDialogOpen} {publicShare} />
2624
<SharelinkDeleteDialog bind:open={deleteDialogOpen} {publicShare} />
2725

2826
<DropdownMenu.Root>
@@ -36,7 +34,9 @@
3634
</DropdownMenu.Trigger>
3735
<DropdownMenu.Content>
3836
<DropdownMenu.Item onclick={copyId}>Copy ID</DropdownMenu.Item>
39-
<DropdownMenu.Item onclick={() => (editDialogOpen = true)}>Edit</DropdownMenu.Item>
37+
<DropdownMenu.Item onclick={() => goto(`/shares/public/${publicShare.id}/edit`)}
38+
>Edit</DropdownMenu.Item
39+
>
4040
<DropdownMenu.Item onclick={() => (deleteDialogOpen = true)}>Delete</DropdownMenu.Item>
4141
</DropdownMenu.Content>
4242
</DropdownMenu.Root>

src/routes/(authenticated)/shares/public/dialog-sharelink-delete.svelte renamed to src/routes/(authenticated)/shares/public/dialog-publicshare-delete.svelte

File renamed without changes.

src/routes/(authenticated)/shares/public/dialog-sharelink-edit.svelte

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)