mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-27 05:49:04 +01:00
Inject cluster config in header variable
This commit is contained in:
parent
10c6b366a5
commit
9a4d279c5a
@ -42,8 +42,8 @@
|
|||||||
</DropdownToggle>
|
</DropdownToggle>
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
{#each clusters as cluster}
|
{#each clusters as cluster}
|
||||||
<DropdownItem href={item.href + cluster} active={window.location.pathname == item.href + cluster}>
|
<DropdownItem href={item.href + cluster.name} active={window.location.pathname == item.href + cluster.name}>
|
||||||
{cluster}
|
{cluster.name}
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
{/each}
|
{/each}
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<script>
|
<script>
|
||||||
import { createEventDispatcher, getContext } from 'svelte'
|
import { createEventDispatcher, getContext } from 'svelte'
|
||||||
import { Button, Modal, ModalBody, ModalHeader, ModalFooter } from 'sveltestrap'
|
import { Button, Modal, ModalBody, ModalHeader, ModalFooter } from 'sveltestrap'
|
||||||
|
import Header from '../Header.svelte';
|
||||||
import DoubleRangeSlider from './DoubleRangeSlider.svelte'
|
import DoubleRangeSlider from './DoubleRangeSlider.svelte'
|
||||||
|
|
||||||
const clusters = getContext('clusters'),
|
const clusters = getContext('clusters'),
|
||||||
ccconfig = getContext('cc-config'),
|
|
||||||
initialized = getContext('initialized'),
|
initialized = getContext('initialized'),
|
||||||
dispatch = createEventDispatcher()
|
dispatch = createEventDispatcher()
|
||||||
|
|
||||||
@ -23,21 +23,22 @@
|
|||||||
const findMaxNumAccels = clusters => clusters.reduce((max, cluster) => Math.max(max,
|
const findMaxNumAccels = clusters => clusters.reduce((max, cluster) => Math.max(max,
|
||||||
cluster.subClusters.reduce((max, sc) => Math.max(max, sc.topology.accelerators?.length || 0), 0)), 0)
|
cluster.subClusters.reduce((max, sc) => Math.max(max, sc.topology.accelerators?.length || 0), 0)), 0)
|
||||||
|
|
||||||
|
console.log(header)
|
||||||
let minNumNodes = 1, maxNumNodes = 0, minNumHWThreads = 1, maxNumHWThreads = 0, minNumAccelerators = 0, maxNumAccelerators = 0
|
let minNumNodes = 1, maxNumNodes = 0, minNumHWThreads = 1, maxNumHWThreads = 0, minNumAccelerators = 0, maxNumAccelerators = 0
|
||||||
$: {
|
$: {
|
||||||
if ($initialized) {
|
if ($initialized) {
|
||||||
if (cluster != null) {
|
if (cluster != null) {
|
||||||
const { subClusters } = clusters.find(c => c.name == cluster)
|
const { subClusters } = clusters.find(c => c.name == cluster)
|
||||||
const { filterRanges } = ccconfig.clusters.find(c => c.name == cluster)
|
const { filterRanges } = header.clusters.find(c => c.name == cluster)
|
||||||
minNumNodes = filterRanges.numNodes.from
|
minNumNodes = filterRanges.numNodes.from
|
||||||
maxNumNodes = filterRanges.numNodes.to
|
maxNumNodes = filterRanges.numNodes.to
|
||||||
maxNumAccelerators = findMaxNumAccels([{ subClusters }])
|
maxNumAccelerators = findMaxNumAccels([{ subClusters }])
|
||||||
} else if (clusters.length > 0) {
|
} else if (clusters.length > 0) {
|
||||||
const { filterRanges } = ccconfig.clusters[0]
|
const { filterRanges } = header.clusters[0]
|
||||||
minNumNodes = filterRanges.numNodes.from
|
minNumNodes = filterRanges.numNodes.from
|
||||||
maxNumNodes = filterRanges.numNodes.to
|
maxNumNodes = filterRanges.numNodes.to
|
||||||
maxNumAccelerators = findMaxNumAccels(clusters)
|
maxNumAccelerators = findMaxNumAccels(clusters)
|
||||||
for (let cluster of ccconfig.clusters) {
|
for (let cluster of header.clusters) {
|
||||||
const { filterRanges } = cluster
|
const { filterRanges } = cluster
|
||||||
minNumNodes = Math.min(minNumNodes, filterRanges.numNodes.from)
|
minNumNodes = Math.min(minNumNodes, filterRanges.numNodes.from)
|
||||||
maxNumNodes = Math.max(maxNumNodes, filterRanges.numNodes.to)
|
maxNumNodes = Math.max(maxNumNodes, filterRanges.numNodes.to)
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
|
|
||||||
"github.com/ClusterCockpit/cc-backend/internal/config"
|
"github.com/ClusterCockpit/cc-backend/internal/config"
|
||||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||||
|
"github.com/ClusterCockpit/cc-backend/pkg/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
/// Go's embed is only allowed to embed files in a subdirectory of the embedding package ([see here](https://github.com/golang/go/issues/46056)).
|
/// Go's embed is only allowed to embed files in a subdirectory of the embedding package ([see here](https://github.com/golang/go/issues/46056)).
|
||||||
@ -62,7 +63,7 @@ type Page struct {
|
|||||||
Error string // For generic use (e.g. the exact error message on /login)
|
Error string // For generic use (e.g. the exact error message on /login)
|
||||||
Info string // For generic use (e.g. "Logout successfull" on /login)
|
Info string // For generic use (e.g. "Logout successfull" on /login)
|
||||||
User User // Information about the currently logged in user
|
User User // Information about the currently logged in user
|
||||||
Clusters []string // List of all clusters for use in the Header
|
Clusters []schema.ClusterConfig // List of all clusters for use in the Header
|
||||||
FilterPresets map[string]interface{} // For pages with the Filter component, this can be used to set initial filters.
|
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/<id>, job id for /monitoring/job/<id>)
|
Infos map[string]interface{} // For generic use (e.g. username for /monitoring/user/<id>, job id for /monitoring/job/<id>)
|
||||||
Config map[string]interface{} // UI settings for the currently logged in user (e.g. line width, ...)
|
Config map[string]interface{} // UI settings for the currently logged in user (e.g. line width, ...)
|
||||||
@ -76,10 +77,11 @@ func RenderTemplate(rw http.ResponseWriter, r *http.Request, file string, page *
|
|||||||
|
|
||||||
if page.Clusters == nil {
|
if page.Clusters == nil {
|
||||||
for _, c := range config.Keys.Clusters {
|
for _, c := range config.Keys.Clusters {
|
||||||
page.Clusters = append(page.Clusters, c.Name)
|
page.Clusters = append(page.Clusters, schema.ClusterConfig{Name: c.Name, FilterRanges: c.FilterRanges, MetricDataRepository: nil})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Infof("%v\n", page.Config)
|
||||||
if err := t.Execute(rw, page); err != nil {
|
if err := t.Execute(rw, page); err != nil {
|
||||||
log.Errorf("template error: %s", err.Error())
|
log.Errorf("template error: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user