diff --git a/eslint-suppressions.json b/eslint-suppressions.json index ad5244136..36cb008ce 100644 --- a/eslint-suppressions.json +++ b/eslint-suppressions.json @@ -194,31 +194,6 @@ "count": 2 } }, - "src/components/standalone/dashboard/InternetConnectionCard.vue": { - "@typescript-eslint/no-explicit-any": { - "count": 4 - } - }, - "src/components/standalone/dashboard/OpenVpnTunnelOrIpsecCard.vue": { - "@typescript-eslint/no-explicit-any": { - "count": 1 - } - }, - "src/components/standalone/dashboard/ServiceCard.vue": { - "@typescript-eslint/no-explicit-any": { - "count": 4 - } - }, - "src/components/standalone/dashboard/SystemInfoCard.vue": { - "@typescript-eslint/no-explicit-any": { - "count": 2 - } - }, - "src/components/standalone/dashboard/ThreatShieldIpCard.vue": { - "@typescript-eslint/no-explicit-any": { - "count": 6 - } - }, "src/components/standalone/dns_dhcp/CreateOrEditDnsRecordDrawer.vue": { "@typescript-eslint/no-explicit-any": { "count": 1 diff --git a/src/components/standalone/dashboard/BackupStatusCard.vue b/src/components/standalone/dashboard/BackupStatusCard.vue index f141d65f5..af6c0f0c1 100644 --- a/src/components/standalone/dashboard/BackupStatusCard.vue +++ b/src/components/standalone/dashboard/BackupStatusCard.vue @@ -2,19 +2,21 @@ import { formatDateLoc, getAxiosErrorMessage, - NeBadge, + NeBadgeV2, NeCard, NeLink } from '@nethesis/vue-components' import { useSubscriptionStore } from '@/stores/standalone/subscription.ts' import { getStandaloneRoutePrefix } from '@/lib/router.ts' import { useI18n } from 'vue-i18n' -import { computed, ref, watchEffect } from 'vue' +import { computed } from 'vue' import { faClock, faTriangleExclamation } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' import { ubusCall } from '@/lib/standalone/ubus.ts' +import { useQuery } from '@tanstack/vue-query' import type { AxiosResponse } from 'axios' import { useBackupsStore } from '@/stores/standalone/backups.ts' +import { DASHBOARD_REFRESH_INTERVAL } from '@/composables/useDashboardOverview' type BackupData = { created: number @@ -35,31 +37,24 @@ const backups = useBackupsStore() const { t } = useI18n() -const latestBackupLoading = ref(true) -const latestBackupError = ref() -const lastBackup = ref() - -watchEffect(() => { - if (subscription.isActive) { - latestBackupError.value = undefined - latestBackupLoading.value = true - ubusCall('ns.backup', 'registered-list-backups') - .then((response: BackupResponse) => { - const backup = response.data.values.backups.sort((a, b) => b.created - a.created).shift() - if (backup != undefined) { - lastBackup.value = formatDateLoc(new Date(backup.created * 1000), 'PPpp') - } else { - lastBackup.value = undefined - } - }) - .catch(() => { - lastBackup.value = undefined - }) - } +const { + data: lastBackup, + isPending: latestBackupLoading, + error: latestBackupError +} = useQuery({ + queryKey: ['dashboard', 'backup', 'last'], + queryFn: ({ signal }) => + ubusCall('ns.backup', 'registered-list-backups', {}, { signal }), + select: (response) => { + const backup = response.data.values.backups.sort((a, b) => b.created - a.created).shift() + return backup != undefined ? formatDateLoc(new Date(backup.created * 1000), 'PPpp') : undefined + }, + enabled: () => subscription.isActive, + refetchInterval: DASHBOARD_REFRESH_INTERVAL }) const loading = computed((): boolean => { - return [subscription.loading, latestBackupLoading.value, backups.loading].every((entry) => entry) + return [subscription.loading, latestBackupLoading.value, backups.loading].some((entry) => entry) }) const error = computed((): string | undefined => { @@ -101,13 +96,10 @@ const error = computed((): string | undefined => { {{ t('standalone.backup_and_restore.backup.no_backups') }}

- + + + {{ t('standalone.backup_and_restore.backup.passphrase_not_configured') }} + diff --git a/src/components/standalone/dashboard/HaStatusCard.vue b/src/components/standalone/dashboard/HaStatusCard.vue index ea8112ecd..e4b56da95 100644 --- a/src/components/standalone/dashboard/HaStatusCard.vue +++ b/src/components/standalone/dashboard/HaStatusCard.vue @@ -1,58 +1,65 @@