-
Couldn't load subscription status.
- Fork 11
feat(web): enhance notifications indicator in UPC #950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
19ebc26
feat(web): scaffold ui for notifications indicator
pujitm 43d3578
refactor(web): poll for notification overview instead of subscription
pujitm 0382154
fix(web): update graphql codegen
pujitm ed26254
test: rm failing notifications.resolver test stub
pujitm e17f994
feat(web): pulse indicator when new notifications are received
pujitm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
api/src/unraid-api/graph/resolvers/notifications/notifications.resolver.spec.ts
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| <script setup lang="ts"> | ||
| import { useQuery } from "@vue/apollo-composable"; | ||
| import { unreadOverview } from "./graphql/notification.query"; | ||
| import { Importance } from "~/composables/gql/graphql"; | ||
| import { | ||
| BellIcon, | ||
| ExclamationTriangleIcon, | ||
| ShieldExclamationIcon, | ||
| } from "@heroicons/vue/24/solid"; | ||
| import { cn } from '~/components/shadcn/utils' | ||
| import { onWatcherCleanup } from "vue"; | ||
| const { result } = useQuery(unreadOverview, null, { | ||
| pollInterval: 2_000, // 2 seconds | ||
| }); | ||
pujitm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const overview = computed(() => { | ||
| if (!result.value) { | ||
| return; | ||
| } | ||
| return result.value.notifications.overview.unread; | ||
| }); | ||
| const indicatorLevel = computed(() => { | ||
| if (!overview.value) { | ||
| return undefined; | ||
| } | ||
| switch (true) { | ||
| case overview.value.alert > 0: | ||
| return Importance.Alert; | ||
| case overview.value.warning > 0: | ||
| return Importance.Warning; | ||
| case overview.value.total > 0: | ||
| return "UNREAD"; | ||
| default: | ||
| return undefined; | ||
| } | ||
| }); | ||
| const icon = computed<{ component: Component; color: string } | null>(() => { | ||
| switch (indicatorLevel.value) { | ||
| case Importance.Warning: | ||
| return { | ||
| component: ExclamationTriangleIcon, | ||
| color: "text-yellow-500 translate-y-0.5", | ||
| }; | ||
| case Importance.Alert: | ||
| return { | ||
| component: ShieldExclamationIcon, | ||
| color: "text-red-500", | ||
| }; | ||
| } | ||
| return null; | ||
| }); | ||
| /** whether new notifications ocurred */ | ||
| const hasNewNotifications = ref(false); | ||
| // watch for new notifications, set a temporary indicator when they're reveived | ||
| watch(overview, (newVal, oldVal) => { | ||
| if (!newVal || !oldVal) { | ||
| return; | ||
| } | ||
| hasNewNotifications.value = newVal.total > oldVal.total; | ||
| // lifetime of 'new notification' state | ||
| const msToLive = 30_000; | ||
| const timeout = setTimeout(() => { | ||
| hasNewNotifications.value = false; | ||
| }, msToLive); | ||
| onWatcherCleanup(() => clearTimeout(timeout)); | ||
| }); | ||
| </script> | ||
|
|
||
| <template> | ||
| <div class="flex items-end gap-1"> | ||
| <div class="relative"> | ||
| <BellIcon class="w-6 h-6" /> | ||
| <div | ||
| v-if="indicatorLevel" | ||
| :class=" | ||
| cn('absolute top-0 right-0 size-2.5 rounded-full', { | ||
| 'bg-unraid-red': indicatorLevel === Importance.Alert, | ||
| 'bg-yellow-500': indicatorLevel === Importance.Warning, | ||
| 'bg-green-500': indicatorLevel === 'UNREAD', | ||
| }) | ||
| " | ||
| /> | ||
| <div | ||
| v-if="hasNewNotifications || indicatorLevel === Importance.Alert" | ||
| class="absolute top-0 right-0 size-2.5 rounded-full bg-unraid-red animate-ping" | ||
pujitm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /> | ||
| </div> | ||
| <component | ||
| :is="icon.component" | ||
| v-if="icon" | ||
| :class="cn('size-6', icon.color)" | ||
| /> | ||
| </div> | ||
| </template> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.