|
5 | 5 |
|
6 | 6 | <script setup lang="ts"> |
7 | 7 | import ApplicationsTable from '@/components/applications/ApplicationsTable.vue' |
8 | | -import { NeHeading } from '@nethesis/vue-components' |
9 | | -
|
10 | | -//// review (search "system") |
11 | | -
|
12 | | -// const { //// |
13 | | -// state, |
14 | | -// debouncedTextFilter, |
15 | | -// productFilter, |
16 | | -// createdByFilter, |
17 | | -// versionFilter, |
18 | | -// statusFilter, |
19 | | -// sortBy, |
20 | | -// sortDescending, |
21 | | -// } = useApplications() |
22 | | -
|
23 | | -// const applicationsPage = computed(() => { |
24 | | -// return state.value.data?.applications || [] |
25 | | -// }) |
| 8 | +import { |
| 9 | + APPLICATIONS_TOTAL_KEY, |
| 10 | + getApplicationsTotal, |
| 11 | + saveShowUnassignedAppsNotificationToStorage, |
| 12 | + SHOW_UNASSIGNED_APPS_NOTIFICATION, |
| 13 | +} from '@/lib/applications/applications' |
| 14 | +import { useApplications } from '@/queries/applications' |
| 15 | +import { useLoginStore } from '@/stores/login' |
| 16 | +import { getPreference, NeButton, NeHeading, NeInlineNotification } from '@nethesis/vue-components' |
| 17 | +import { useQuery } from '@pinia/colada' |
| 18 | +import { computed, ref } from 'vue' |
| 19 | +import { useI18n } from 'vue-i18n' |
| 20 | +
|
| 21 | +const { t } = useI18n() |
| 22 | +const loginStore = useLoginStore() |
| 23 | +
|
| 24 | +const { state: applicationsTotal } = useQuery({ |
| 25 | + key: [APPLICATIONS_TOTAL_KEY], |
| 26 | + enabled: () => !!loginStore.jwtToken, |
| 27 | + query: getApplicationsTotal, |
| 28 | +}) |
| 29 | +
|
| 30 | +const { organizationFilter } = useApplications() |
| 31 | +
|
| 32 | +const justHiddenUnassignedAppsNotification = ref(false) |
| 33 | +
|
| 34 | +const showUnassignedAppsNotification = computed(() => { |
| 35 | + const username = loginStore.userInfo?.email |
| 36 | +
|
| 37 | + if (!username || justHiddenUnassignedAppsNotification.value) { |
| 38 | + return false |
| 39 | + } |
| 40 | +
|
| 41 | + let showNotificationFromPreference = getPreference(SHOW_UNASSIGNED_APPS_NOTIFICATION, username) |
| 42 | +
|
| 43 | + if (showNotificationFromPreference === undefined) { |
| 44 | + // default to true if not set |
| 45 | + showNotificationFromPreference = true |
| 46 | + } |
| 47 | +
|
| 48 | + return applicationsTotal.value.data?.unassigned && showNotificationFromPreference |
| 49 | +}) |
| 50 | +
|
| 51 | +const showUnassignedApps = () => { |
| 52 | + organizationFilter.value = ['no_org'] |
| 53 | +} |
| 54 | +
|
| 55 | +const dontShowUnassignedAppsNotificationAgain = () => { |
| 56 | + saveShowUnassignedAppsNotificationToStorage(false) |
| 57 | + justHiddenUnassignedAppsNotification.value = true |
| 58 | +} |
26 | 59 | </script> |
27 | 60 |
|
28 | 61 | <template> |
29 | 62 | <div> |
30 | 63 | <NeHeading tag="h3" class="mb-7">{{ $t('applications.title') }}</NeHeading> |
31 | | - <div class="mb-8 flex flex-col items-start justify-between gap-6 xl:flex-row"> |
32 | | - <div class="max-w-2xl text-gray-500 dark:text-gray-400"> |
33 | | - {{ $t('applications.page_description') }} |
34 | | - </div> |
| 64 | + <div class="mb-8 max-w-2xl text-gray-500 dark:text-gray-400"> |
| 65 | + {{ $t('applications.page_description') }} |
35 | 66 | </div> |
36 | | - <!-- //// todo applications without org notification --> |
| 67 | + <NeInlineNotification |
| 68 | + v-if="showUnassignedAppsNotification" |
| 69 | + kind="info" |
| 70 | + :description=" |
| 71 | + $t('applications.num_applications_not_assigned', { |
| 72 | + num: applicationsTotal.data?.unassigned, |
| 73 | + }) |
| 74 | + " |
| 75 | + :primary-button-label="t('applications.show_unassigned')" |
| 76 | + :secondary-button-label="t('applications.dont_show_again')" |
| 77 | + class="mb-8" |
| 78 | + @primary-click="showUnassignedApps" |
| 79 | + @secondary-click="dontShowUnassignedAppsNotificationAgain" |
| 80 | + /> |
| 81 | + <!-- //// --> |
| 82 | + <!-- showUnassignedAppsNotification {{ showUnassignedAppsNotification }} |
| 83 | + <NeButton @click="saveShowUnassignedAppsNotificationToStorage(true)" |
| 84 | + >Show Unassigned Apps</NeButton |
| 85 | + > --> |
37 | 86 | <ApplicationsTable /> |
38 | 87 | </div> |
39 | 88 | </template> |
0 commit comments