From 5b703917b560cfdcd18b1fbb98a99b5a02c0bb2a Mon Sep 17 00:00:00 2001 From: baldo Date: Sun, 12 Jun 2022 13:04:23 +0200 Subject: [PATCH] Showing spinner when loading nodes. --- frontend/src/components/LoadingContainer.vue | 35 +++++++++++ frontend/src/components/Spinner.vue | 29 +++++++++ frontend/src/stores/nodes.ts | 1 - frontend/src/views/AdminNodesView.vue | 66 ++++++++++++-------- 4 files changed, 104 insertions(+), 27 deletions(-) create mode 100644 frontend/src/components/LoadingContainer.vue create mode 100644 frontend/src/components/Spinner.vue diff --git a/frontend/src/components/LoadingContainer.vue b/frontend/src/components/LoadingContainer.vue new file mode 100644 index 0000000..60ac6af --- /dev/null +++ b/frontend/src/components/LoadingContainer.vue @@ -0,0 +1,35 @@ + + + + + diff --git a/frontend/src/components/Spinner.vue b/frontend/src/components/Spinner.vue new file mode 100644 index 0000000..cfa3972 --- /dev/null +++ b/frontend/src/components/Spinner.vue @@ -0,0 +1,29 @@ + + + + + diff --git a/frontend/src/stores/nodes.ts b/frontend/src/stores/nodes.ts index 9af5242..a59a304 100644 --- a/frontend/src/stores/nodes.ts +++ b/frontend/src/stores/nodes.ts @@ -38,7 +38,6 @@ export const useNodesStore = defineStore({ }, actions: { async refresh(page: number, nodesPerPage: number): Promise { - // TODO: Handle paging const result = await internalApi.getPagedList( "nodes", isEnhancedNode, diff --git a/frontend/src/views/AdminNodesView.vue b/frontend/src/views/AdminNodesView.vue index 7373ad2..3043a67 100644 --- a/frontend/src/views/AdminNodesView.vue +++ b/frontend/src/views/AdminNodesView.vue @@ -3,17 +3,28 @@ import {useNodesStore} from "@/stores/nodes"; import {onMounted, ref} from "vue"; import type {EnhancedNode, MAC} from "@/types"; import Pager from "@/components/Pager.vue"; +import LoadingContainer from "@/components/LoadingContainer.vue"; + +const NODE_PER_PAGE = 50; type NodeRedactField = "nickname" | "email" | "token"; type NodeRedactFieldsMap = Partial>; -type NodesRedactFieldsMap = Partial>; +type NodesRedactFieldsMap = Partial>; const nodes = useNodesStore(); const redactFieldsByDefault = ref(true); const nodesRedactFieldsMap = ref({} as NodesRedactFieldsMap) +const loading = ref(false); + async function refresh(page: number): Promise { - await nodes.refresh(page, 50); + loading.value = true; + redactAllFields(true); + try { + await nodes.refresh(page, NODE_PER_PAGE); + } finally { + loading.value = false; + } } function redactAllFields(shallRedactFields: boolean): void { @@ -46,7 +57,7 @@ onMounted(async () => await refresh(1));

Knoten

- Gesamt: {{nodes.getTotalNodes}} + Gesamt: {{ nodes.getTotalNodes }}