flotilla/src/app/components/AlertItem.svelte

43 lines
1.4 KiB
Svelte
Raw Normal View History

2025-02-25 21:36:32 +00:00
<script lang="ts">
2025-06-24 21:15:36 +00:00
import {parseJson} from "@welshman/lib"
2025-04-28 16:48:09 +00:00
import {displayFeeds} from "@welshman/feeds"
2025-09-11 19:43:18 +00:00
import {getTagValue, getTagValues} from "@welshman/util"
2025-09-10 22:26:39 +00:00
import TrashBin2 from "@assets/icons/trash-bin-2.svg?dataurl"
2025-02-25 21:36:32 +00:00
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
import AlertDelete from "@app/components/AlertDelete.svelte"
import AlertStatus from "@app/components/AlertStatus.svelte"
import type {Alert} from "@app/core/state"
import {pushModal} from "@app/util/modal"
2025-02-25 21:36:32 +00:00
type Props = {
alert: Alert
}
const {alert}: Props = $props()
const cron = $derived(getTagValue("cron", alert.tags))
2025-11-03 19:10:16 +00:00
const channel = $derived(getTagValue("channel", alert.tags))
2025-04-28 16:48:09 +00:00
const feeds = $derived(getTagValues("feed", alert.tags))
const description = $derived(
getTagValue("description", alert.tags) ||
[
`${cron?.endsWith("1") ? "Weekly" : "Daily"} alert for events`,
displayFeeds(feeds.map(parseJson)),
2025-11-03 19:10:16 +00:00
`sent via ${channel}.`,
2025-04-28 16:48:09 +00:00
].join(" "),
)
2025-02-25 21:36:32 +00:00
const startDelete = () => pushModal(AlertDelete, {alert})
</script>
<div class="flex items-start justify-between gap-4">
2025-04-23 18:05:28 +00:00
<div class="flex items-start gap-4">
<Button class="py-1" onclick={startDelete}>
2025-09-10 22:26:39 +00:00
<Icon icon={TrashBin2} />
2025-04-23 18:05:28 +00:00
</Button>
2025-04-28 16:48:09 +00:00
<div class="flex-inline gap-1">{description}</div>
2025-02-25 21:36:32 +00:00
</div>
<AlertStatus {alert} />
2025-02-25 21:36:32 +00:00
</div>