From e55798944e453ec7287854a7c1ac4c70cde88957 Mon Sep 17 00:00:00 2001 From: Christoph Kluge Date: Fri, 10 Jan 2025 18:02:54 +0100 Subject: [PATCH] add navbar select, add continous scroll, paging persistance --- web/frontend/src/Header.svelte | 8 + web/frontend/src/header/NavbarLinks.svelte | 9 ++ web/frontend/src/systems/NodeList.svelte | 177 ++++++++++++++------- web/templates/base.tmpl | 9 +- web/web.go | 11 ++ 5 files changed, 150 insertions(+), 64 deletions(-) diff --git a/web/frontend/src/Header.svelte b/web/frontend/src/Header.svelte index 9a7ae79..573a057 100644 --- a/web/frontend/src/Header.svelte +++ b/web/frontend/src/Header.svelte @@ -26,6 +26,7 @@ export let username; export let authlevel; export let clusters; + export let subClusters; export let roles; let isOpen = false; @@ -138,11 +139,13 @@ {#if screenSize > 1500 || screenSize < 768} item.requiredRole <= authlevel)} /> {:else if screenSize > 1300} item.requiredRole <= authlevel && item.menu != "Info", )} @@ -156,6 +159,7 @@ @@ -168,6 +172,7 @@ {:else} item.requiredRole <= authlevel && item.menu == "none", )} @@ -180,6 +185,7 @@ item.requiredRole <= authlevel && item.menu == 'Jobs', @@ -196,6 +202,7 @@ item.requiredRole <= authlevel && item.menu == 'Groups', @@ -212,6 +219,7 @@ item.requiredRole <= authlevel && item.menu == 'Info', diff --git a/web/frontend/src/header/NavbarLinks.svelte b/web/frontend/src/header/NavbarLinks.svelte index 2772eb7..26e7370 100644 --- a/web/frontend/src/header/NavbarLinks.svelte +++ b/web/frontend/src/header/NavbarLinks.svelte @@ -3,6 +3,7 @@ Properties: - `clusters [String]`: List of cluster names + - `subClusters map[String][]string`: Map of subclusters by cluster names - `links [Object]`: Pre-filtered link objects based on user auth - `direction String?`: The direcion of the drop-down menue [default: down] --> @@ -18,6 +19,7 @@ } from "@sveltestrap/sveltestrap"; export let clusters; + export let subClusters; export let links; export let direction = "down"; @@ -47,6 +49,13 @@ > Node List + {#each subClusters[cluster.name] as subCluster} + + {subCluster} Node List + + {/each} {/each} diff --git a/web/frontend/src/systems/NodeList.svelte b/web/frontend/src/systems/NodeList.svelte index 39319e5..70b28c7 100644 --- a/web/frontend/src/systems/NodeList.svelte +++ b/web/frontend/src/systems/NodeList.svelte @@ -10,15 +10,16 @@ --> -{#if $nodesQuery.error} - - - {$nodesQuery.error.message} - - -{:else if $nodesQuery.fetching } - - - - - -{:else if $initq?.data && $nodesQuery?.data} - -
- - - - + +
+
- {cluster} Node Info -
+ + + - {#each selectedMetrics as metric (metric)} - - {/each} - - - - {#each orderedData as nodeData (nodeData.host)} + {#each selectedMetrics as metric (metric)} + + {/each} + + + + {#if $nodesQuery.error} + + + {$nodesQuery.error.message} + + + {:else} + {#each nodes as nodeData (nodeData.host)} {:else} - + {/each} - -
+ {cluster} Node Info + - {metric} ({systemUnits[metric]}) -
+ {metric} ({systemUnits[metric]}) +
No nodes found No nodes found
-
-
-{/if} + {/if} + {#if $nodesQuery.fetching || !$nodesQuery.data} + + +
+

Loading nodes {nodes.length + 1} to {nodes.length + paging.itemsPerPage} {matchedNodes ? `of ${matchedNodes} total` : ``}

+ +
+ + + {/if} + + + + -{#if true} +{#if usePaging} { - paging = { itemsPerPage: detail.itemsPerPage, page: detail.page } - // if (detail.itemsPerPage != itemsPerPage) { - // updateConfiguration(detail.itemsPerPage.toString(), detail.page); - // } else { - // // nodes = [] - // paging = { itemsPerPage: detail.itemsPerPage, page: detail.page }; - // } + if (detail.itemsPerPage != itemsPerPage) { + updateConfiguration(detail.itemsPerPage.toString(), detail.page); + } else { + nodes = [] + paging = { itemsPerPage: detail.itemsPerPage, page: detail.page }; + } }} /> {/if} diff --git a/web/templates/base.tmpl b/web/templates/base.tmpl index 2464d7f..358f926 100644 --- a/web/templates/base.tmpl +++ b/web/templates/base.tmpl @@ -15,10 +15,11 @@ {{end}} diff --git a/web/web.go b/web/web.go index 1cfa176..45d8646 100644 --- a/web/web.go +++ b/web/web.go @@ -13,6 +13,7 @@ import ( "github.com/ClusterCockpit/cc-backend/internal/config" "github.com/ClusterCockpit/cc-backend/internal/util" + "github.com/ClusterCockpit/cc-backend/pkg/archive" "github.com/ClusterCockpit/cc-backend/pkg/log" "github.com/ClusterCockpit/cc-backend/pkg/schema" ) @@ -95,6 +96,7 @@ type Page struct { Roles map[string]schema.Role // Available roles for frontend render checks Build Build // Latest information about the application Clusters []schema.ClusterConfig // List of all clusters for use in the Header + SubClusters map[string][]string // Map per cluster of all subClusters for use in the Header FilterPresets map[string]interface{} // For pages with the Filter component, this can be used to set initial filters. Infos map[string]interface{} // For generic use (e.g. username for /monitoring/user/, job id for /monitoring/job/) Config map[string]interface{} // UI settings for the currently logged in user (e.g. line width, ...) @@ -114,6 +116,15 @@ func RenderTemplate(rw http.ResponseWriter, file string, page *Page) { } } + if page.SubClusters == nil { + page.SubClusters = make(map[string][]string) + for _, cluster := range archive.Clusters { + for _, sc := range cluster.SubClusters { + page.SubClusters[cluster.Name] = append(page.SubClusters[cluster.Name], sc.Name) + } + } + } + log.Debugf("Page config : %v\n", page.Config) if err := t.Execute(rw, page); err != nil { log.Errorf("Template error: %s", err.Error())