flotilla/src/app/components/Alerts.svelte

44 lines
1.3 KiB
Svelte
Raw Normal View History

2025-02-25 21:36:32 +00:00
<script lang="ts">
2025-06-30 17:25:34 +00:00
import {getTagValue} from "@welshman/util"
2025-02-25 21:36:32 +00:00
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
import AlertAdd from "@app/components/AlertAdd.svelte"
import AlertItem from "@app/components/AlertItem.svelte"
import {pushModal} from "@app/modal"
import {alerts} from "@app/state"
2025-06-30 17:25:34 +00:00
type Props = {
url?: string
channel?: string
hideSpaceField?: boolean
}
2025-03-20 19:55:12 +00:00
2025-06-30 17:25:34 +00:00
const {url = "", channel = "push", hideSpaceField = false}: Props = $props()
const startAlert = () => pushModal(AlertAdd, {url, channel, hideSpaceField})
const filteredAlerts = $derived(
url ? $alerts.filter(a => getTagValue("feed", a.tags)?.includes(url)) : $alerts,
)
2025-02-25 21:36:32 +00:00
</script>
<div class="card2 bg-alt flex flex-col gap-6 shadow-xl">
<div class="flex items-center justify-between">
2025-03-04 18:58:14 +00:00
<strong class="flex items-center gap-3">
<Icon icon="inbox" />
Alerts
</strong>
2025-02-25 21:36:32 +00:00
<Button class="btn btn-primary btn-sm" onclick={startAlert}>
<Icon icon="add-circle" />
Add Alert
</Button>
</div>
<div class="col-4">
2025-06-30 17:25:34 +00:00
{#each filteredAlerts as alert (alert.event.id)}
2025-02-25 21:36:32 +00:00
<AlertItem {alert} />
{:else}
2025-06-30 17:25:34 +00:00
<p class="text-center opacity-75 py-12">Nothing here yet!</p>
2025-02-25 21:36:32 +00:00
{/each}
</div>
</div>