diff --git a/ui/app/components/NotifyDropdown.vue b/ui/app/components/NotifyDropdown.vue
index 8ff79681..ed3df1c2 100644
--- a/ui/app/components/NotifyDropdown.vue
+++ b/ui/app/components/NotifyDropdown.vue
@@ -45,11 +45,12 @@
-
- {{ store.unreadCount }}
+
+ {{ store.unreadCount }}
/
{{ store.notifications.length }}
+
diff --git a/ui/app/pages/index.vue b/ui/app/pages/index.vue
index fb91ba69..727512af 100644
--- a/ui/app/pages/index.vue
+++ b/ui/app/pages/index.vue
@@ -204,7 +204,7 @@ const pauseDownload = () => {
dialog_confirm.value.visible = true
dialog_confirm.value.html_message = `
-
+
Pause All non-active downloads?
diff --git a/ui/app/stores/NotificationStore.ts b/ui/app/stores/NotificationStore.ts
index 3a8bef71..3bbc2225 100644
--- a/ui/app/stores/NotificationStore.ts
+++ b/ui/app/stores/NotificationStore.ts
@@ -2,10 +2,46 @@ import { defineStore } from 'pinia'
import { useStorage } from '@vueuse/core'
import type { notification, notificationType } from '~/composables/useNotification'
+const _map: Record = {
+ 'error': { level: 3, color: 'is-danger', icon: 'fas fa-circle-exclamation' },
+ 'warning': { level: 2, color: 'is-warning', icon: 'fas fa-triangle-exclamation' },
+ 'success': { level: 1, color: 'is-primary', icon: 'fas fa-circle-check' },
+ 'info': { level: 0, color: 'is-info', icon: 'fas fa-circle-info' }
+}
+
export const useNotificationStore = defineStore('notifications', () => {
const notifications = useStorage('notifications', [])
const unreadCount = computed(() => notifications.value.filter(n => !n.seen).length)
+ const severityLevel = computed(() => {
+ const unread = notifications.value.filter(n => !n.seen)
+ if (0 === unread.length) {
+ return null
+ }
+
+ return unread.reduce((h, n) => _map[n.level].level > _map[h.level].level ? n : h).level
+ })
+
+ const severityColor = computed(() => {
+ const level = severityLevel.value
+ return level ? _map[level].color : ''
+ })
+
+ const severityIcon = computed(() => {
+ const level = severityLevel.value
+ return level ? _map[level].icon : ''
+ })
+
+ const sortedNotifications = computed(() => {
+ return [...notifications.value].sort((a, b) => {
+ const severityDiff = _map[b.level].level - _map[a.level].level
+ if (0 !== severityDiff) {
+ return severityDiff
+ }
+ return (new Date(b.created).getTime()) - (new Date(a.created).getTime())
+ })
+ })
+
const add = (level: notificationType, message: string, seen: boolean = false): string => {
const id = Array.from(
window.crypto.getRandomValues(new Uint8Array(14 / 2)),
@@ -43,5 +79,18 @@ export const useNotificationStore = defineStore('notifications', () => {
const remove = (id: string) => notifications.value = notifications.value.filter(n => n.id !== id)
- return { notifications, unreadCount, add, get, markAllRead, clear, markRead, remove }
+ return {
+ notifications,
+ unreadCount,
+ severityLevel,
+ severityColor,
+ severityIcon,
+ sortedNotifications,
+ add,
+ get,
+ markAllRead,
+ clear,
+ markRead,
+ remove
+ }
})