From 9802339199ed840e326a2e89f90bce6a8d513e82 Mon Sep 17 00:00:00 2001 From: Alexander Maushammer Date: Wed, 7 Aug 2024 14:03:32 +0200 Subject: [PATCH 1/5] feat(notifications): implement notifications table, use backend types for dashboard table --- frontend/components/bc/table/TablePager.vue | 1 + .../notifications/DashboardsTable.vue | 88 +++++------ .../NotificationsNetworkTable.vue | 148 ++++++++++++++++++ frontend/i18n/en.json | 13 +- frontend/pages/notifications.vue | 2 +- .../public/mock/notifications/dashboards.json | 55 ------- .../useNotificationsDashboardStore.ts | 30 ++-- .../useNotificationsNetworkStore.ts | 59 +++++++ frontend/types/customFetch.ts | 7 +- frontend/types/notifications/dashboards.ts | 18 --- 10 files changed, 285 insertions(+), 136 deletions(-) create mode 100644 frontend/components/notifications/NotificationsNetworkTable.vue delete mode 100644 frontend/public/mock/notifications/dashboards.json create mode 100644 frontend/stores/notifications/useNotificationsNetworkStore.ts delete mode 100644 frontend/types/notifications/dashboards.ts diff --git a/frontend/components/bc/table/TablePager.vue b/frontend/components/bc/table/TablePager.vue index 7d98c5239..25d9bacac 100644 --- a/frontend/components/bc/table/TablePager.vue +++ b/frontend/components/bc/table/TablePager.vue @@ -149,6 +149,7 @@ watch(() => data.value.lastPage && data.value.lastPage < data.value.page, (match position: absolute; display: flex; flex-direction: row; + flex-wrap: wrap; width: 100%; .left-info { margin-right: auto; diff --git a/frontend/components/notifications/DashboardsTable.vue b/frontend/components/notifications/DashboardsTable.vue index 02fddf133..eaa5af29c 100644 --- a/frontend/components/notifications/DashboardsTable.vue +++ b/frontend/components/notifications/DashboardsTable.vue @@ -6,7 +6,8 @@ import { import IconValidator from '../icon/IconValidator.vue' import IconAccount from '../icon/IconAccount.vue' import type { Cursor } from '~/types/datatable' -import { getGroupLabel } from '~/utils/dashboard/group' +import type { DashboardType } from '~/types/dashboard' +import { useUserDashboardStore } from '~/stores/dashboard/useUserDashboardStore' defineEmits<{(e: 'openDialog'): void }>() @@ -14,9 +15,13 @@ const cursor = ref() const pageSize = ref(10) const { t: $t } = useTranslation() -const { onSort, setCursor, setPageSize, setSearch, notificationsDashboards, query, isLoading } = useNotificationsDashboardStore() +// TODO: replace currentNetwork with selection from NETWORK_SWITCHER_COMPONENT that has yet to be implemented +const { currentNetwork } = useNetworkStore() +const networkId = ref(currentNetwork.value ?? 1) -const { groups } = useValidatorDashboardGroups() +const { onSort, setCursor, setPageSize, setSearch, notificationsDashboards, query, isLoading } = useNotificationsDashboardStore(networkId) + +const { getDashboardLabel } = useUserDashboardStore() const { width } = useWindowSize() const colsVisible = computed(() => { @@ -27,27 +32,13 @@ const colsVisible = computed(() => { } }) -const groupNameLabel = (groupId?: number) => { - return getGroupLabel($t, groupId, groups.value, 'Σ') -} - const openDialog = () => { // TODO: implement dialog alert('not implemented yet 😪') } -const notificationsDashboardsWithUniqueIdentifier = computed(() => { - if (!notificationsDashboards.value) { - return - } - return { - paging: notificationsDashboards.value.paging, - // TODO: set unique identifier after backend is ready - data: notificationsDashboards.value.data - .map((item, index) => ({ ...item, identifier: index })) - // .filter(() => false) // comment in to test empty table - } -}) +const getDashboardType = (isAccount: boolean):DashboardType => isAccount ? 'account' : 'validator' +