|
|
|
@ -12,6 +12,7 @@
|
|
|
|
import { Input } from '$lib/components/ui/input'
|
|
|
|
import { Input } from '$lib/components/ui/input'
|
|
|
|
import { Label } from '$lib/components/ui/label'
|
|
|
|
import { Label } from '$lib/components/ui/label'
|
|
|
|
import { Badge } from '$lib/components/ui/badge'
|
|
|
|
import { Badge } from '$lib/components/ui/badge'
|
|
|
|
|
|
|
|
import { Checkbox } from '$lib/components/ui/checkbox'
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
BarChart,
|
|
|
|
BarChart,
|
|
|
|
ExternalLink,
|
|
|
|
ExternalLink,
|
|
|
|
@ -35,6 +36,7 @@
|
|
|
|
let editShortenerCode = ''
|
|
|
|
let editShortenerCode = ''
|
|
|
|
let editShortenerLink = ''
|
|
|
|
let editShortenerLink = ''
|
|
|
|
let editShortenerCategory: any = undefined
|
|
|
|
let editShortenerCategory: any = undefined
|
|
|
|
|
|
|
|
let editShortenerActive = false
|
|
|
|
let isEditLoading = false
|
|
|
|
let isEditLoading = false
|
|
|
|
|
|
|
|
|
|
|
|
let open: boolean = false
|
|
|
|
let open: boolean = false
|
|
|
|
@ -42,15 +44,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
$: selectedProject = data.selected_project.label
|
|
|
|
$: selectedProject = data.selected_project.label
|
|
|
|
|
|
|
|
|
|
|
|
const openEditDialog = (code: string, link: string) => {
|
|
|
|
const openEditDialog = (
|
|
|
|
|
|
|
|
code: string,
|
|
|
|
|
|
|
|
link: string,
|
|
|
|
|
|
|
|
projectId: number | null,
|
|
|
|
|
|
|
|
projectName: string | undefined,
|
|
|
|
|
|
|
|
active: boolean,
|
|
|
|
|
|
|
|
) => {
|
|
|
|
editDialogOpen = true
|
|
|
|
editDialogOpen = true
|
|
|
|
editShortenerCode = code
|
|
|
|
editShortenerCode = code
|
|
|
|
editShortenerLink = link
|
|
|
|
editShortenerLink = link
|
|
|
|
|
|
|
|
editShortenerActive = active
|
|
|
|
|
|
|
|
if (projectId) {
|
|
|
|
|
|
|
|
editShortenerCategory = { value: projectId, label: projectName }
|
|
|
|
|
|
|
|
} else {
|
|
|
|
editShortenerCategory = undefined
|
|
|
|
editShortenerCategory = undefined
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const editShortener = async (code: string, link: string) => {
|
|
|
|
const editShortener = async (code: string, link: string) => {
|
|
|
|
isEditLoading = true
|
|
|
|
isEditLoading = true
|
|
|
|
|
|
|
|
console.log(editShortenerCategory)
|
|
|
|
await fetch(`/api/shortener/${code}`, {
|
|
|
|
await fetch(`/api/shortener/${code}`, {
|
|
|
|
method: 'put',
|
|
|
|
method: 'put',
|
|
|
|
body: JSON.stringify({
|
|
|
|
body: JSON.stringify({
|
|
|
|
@ -58,6 +72,7 @@
|
|
|
|
projectId: editShortenerCategory
|
|
|
|
projectId: editShortenerCategory
|
|
|
|
? editShortenerCategory.value
|
|
|
|
? editShortenerCategory.value
|
|
|
|
: undefined,
|
|
|
|
: undefined,
|
|
|
|
|
|
|
|
active: editShortenerActive,
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
await invalidateAll()
|
|
|
|
await invalidateAll()
|
|
|
|
@ -169,10 +184,25 @@
|
|
|
|
</a>
|
|
|
|
</a>
|
|
|
|
<ExternalLink size={16} />
|
|
|
|
<ExternalLink size={16} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<Badge variant="default"
|
|
|
|
<div class="flex gap-4">
|
|
|
|
|
|
|
|
<Badge variant="outline" class="flex gap-2">
|
|
|
|
|
|
|
|
{#if shortener.active}
|
|
|
|
|
|
|
|
<span
|
|
|
|
|
|
|
|
class="relative inline-flex h-2 w-2 rounded-full bg-green-400"
|
|
|
|
|
|
|
|
></span>
|
|
|
|
|
|
|
|
Active
|
|
|
|
|
|
|
|
{:else}
|
|
|
|
|
|
|
|
<span
|
|
|
|
|
|
|
|
class="relative inline-flex h-2 w-2 rounded-full bg-gray-600"
|
|
|
|
|
|
|
|
></span>
|
|
|
|
|
|
|
|
Inactive
|
|
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
</Badge>
|
|
|
|
|
|
|
|
<Badge variant="secondary"
|
|
|
|
>{shortener.project
|
|
|
|
>{shortener.project
|
|
|
|
? shortener.project.name
|
|
|
|
? shortener.project.name
|
|
|
|
: 'Uncategorized'}</Badge>
|
|
|
|
: 'Uncategorized'}</Badge>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</Card.Title>
|
|
|
|
</Card.Title>
|
|
|
|
<Card.Description>{shortener.link}</Card.Description>
|
|
|
|
<Card.Description>{shortener.link}</Card.Description>
|
|
|
|
</Card.Header>
|
|
|
|
</Card.Header>
|
|
|
|
@ -201,7 +231,13 @@
|
|
|
|
<DropdownMenu.Group>
|
|
|
|
<DropdownMenu.Group>
|
|
|
|
<DropdownMenu.Item
|
|
|
|
<DropdownMenu.Item
|
|
|
|
on:click={() =>
|
|
|
|
on:click={() =>
|
|
|
|
openEditDialog(shortener.code, shortener.link)}>
|
|
|
|
openEditDialog(
|
|
|
|
|
|
|
|
shortener.code,
|
|
|
|
|
|
|
|
shortener.link,
|
|
|
|
|
|
|
|
shortener.projectId,
|
|
|
|
|
|
|
|
shortener.project?.name,
|
|
|
|
|
|
|
|
shortener.active,
|
|
|
|
|
|
|
|
)}>
|
|
|
|
Edit
|
|
|
|
Edit
|
|
|
|
</DropdownMenu.Item>
|
|
|
|
</DropdownMenu.Item>
|
|
|
|
<DropdownMenu.Item
|
|
|
|
<DropdownMenu.Item
|
|
|
|
@ -253,6 +289,17 @@
|
|
|
|
</Select.Content>
|
|
|
|
</Select.Content>
|
|
|
|
</Select.Root>
|
|
|
|
</Select.Root>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="grid grid-cols-4 items-center gap-4">
|
|
|
|
|
|
|
|
<div></div>
|
|
|
|
|
|
|
|
<div class="flex items-center gap-4">
|
|
|
|
|
|
|
|
<Checkbox id="terms" bind:checked={editShortenerActive} />
|
|
|
|
|
|
|
|
<Label
|
|
|
|
|
|
|
|
for="terms"
|
|
|
|
|
|
|
|
class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
|
|
|
|
|
|
|
|
Active
|
|
|
|
|
|
|
|
</Label>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<Dialog.Footer>
|
|
|
|
<Dialog.Footer>
|
|
|
|
<Button
|
|
|
|
<Button
|
|
|
|
|