mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-11-10 00:47:26 +01:00
Improve resources filter
This commit is contained in:
parent
f0685919fd
commit
2146fccaae
@ -21,6 +21,8 @@ Changes: remove dependency, text inputs, configurable value ranges, on:change ev
|
||||
export let max;
|
||||
export let firstSlider;
|
||||
export let secondSlider;
|
||||
export let inputFieldFrom = 0;
|
||||
export let inputFieldTo = 0;
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
@ -33,7 +35,6 @@ Changes: remove dependency, text inputs, configurable value ranges, on:change ev
|
||||
let leftHandle;
|
||||
let body;
|
||||
let slider;
|
||||
let inputFieldFrom, inputFieldTo;
|
||||
|
||||
let timeoutId = null;
|
||||
function queueChangeEvent() {
|
||||
@ -45,10 +46,10 @@ Changes: remove dependency, text inputs, configurable value ranges, on:change ev
|
||||
timeoutId = null;
|
||||
|
||||
// Show selection but avoid feedback loop
|
||||
if (values[0] != null && inputFieldFrom.value != values[0].toString())
|
||||
inputFieldFrom.value = values[0].toString();
|
||||
if (values[1] != null && inputFieldTo.value != values[1].toString())
|
||||
inputFieldTo.value = values[1].toString();
|
||||
if (values[0] != null && inputFieldFrom != values[0].toString())
|
||||
inputFieldFrom = values[0].toString();
|
||||
if (values[1] != null && inputFieldTo != values[1].toString())
|
||||
inputFieldTo = values[1].toString();
|
||||
|
||||
dispatch('change', values);
|
||||
}, 250);
|
||||
@ -176,7 +177,7 @@ Changes: remove dependency, text inputs, configurable value ranges, on:change ev
|
||||
|
||||
const leftHandleLeft = leftHandle.getBoundingClientRect().left;
|
||||
|
||||
const pxStart = clamp((leftHandleLeft + event.detail.dx) - left, 0, parentWidth - width);
|
||||
const pxStart = clamp((leftHandleLeft + evt.detail.dx) - left, 0, parentWidth - width);
|
||||
const pxEnd = clamp(pxStart + width, width, parentWidth);
|
||||
|
||||
const pStart = pxStart / parentWidth;
|
||||
@ -190,12 +191,12 @@ Changes: remove dependency, text inputs, configurable value ranges, on:change ev
|
||||
|
||||
<div class="double-range-container">
|
||||
<div class="header">
|
||||
<input class="form-control" type="text" placeholder="from..." bind:this={inputFieldFrom}
|
||||
<input class="form-control" type="text" placeholder="from..." bind:value={inputFieldFrom}
|
||||
on:input={(e) => inputChanged(0, e)} />
|
||||
|
||||
<span>Full Range: <b> {min} </b> - <b> {max} </b></span>
|
||||
|
||||
<input class="form-control" type="text" placeholder="to..." bind:this={inputFieldTo}
|
||||
<input class="form-control" type="text" placeholder="to..." bind:value={inputFieldTo}
|
||||
on:input={(e) => inputChanged(1, e)} />
|
||||
</div>
|
||||
<div class="slider" bind:this={slider}>
|
||||
|
@ -60,7 +60,10 @@
|
||||
isTagsOpen = false,
|
||||
isDurationOpen = false,
|
||||
isResourcesOpen = false,
|
||||
isStatsOpen = false
|
||||
isStatsOpen = false,
|
||||
isNodesModified = false,
|
||||
isHwthreadsModified = false,
|
||||
isAccsModified = false
|
||||
|
||||
// Can be called from the outside to trigger a 'update' event from this component.
|
||||
export function update(additionalFilters = null) {
|
||||
@ -181,7 +184,7 @@
|
||||
<Icon name="tags"/> Tags
|
||||
</DropdownItem>
|
||||
<DropdownItem on:click={() => (isResourcesOpen = true)}>
|
||||
<Icon name="hdd-stack"/> Nodes/Accelerators
|
||||
<Icon name="hdd-stack"/> Resources
|
||||
</DropdownItem>
|
||||
<DropdownItem on:click={() => (isStatsOpen = true)}>
|
||||
<Icon name="bar-chart" on:click={() => (isStatsOpen = true)}/> Statistics
|
||||
@ -268,9 +271,15 @@
|
||||
</Info>
|
||||
{/if}
|
||||
|
||||
{#if filters.numNodes.from != null || filters.numNodes.to != null}
|
||||
{#if filters.numNodes.from != null || filters.numNodes.to != null ||
|
||||
filters.numHWThreads.from != null || filters.numHWThreads.to != null ||
|
||||
filters.numAccelerators.from != null || filters.numAccelerators.to != null }
|
||||
<Info icon="hdd-stack" on:click={() => (isResourcesOpen = true)}>
|
||||
Nodes: {filters.numNodes.from} - {filters.numNodes.to}
|
||||
{#if isNodesModified } Nodes: {filters.numNodes.from} - {filters.numNodes.to} {/if}
|
||||
{#if isNodesModified && isHwthreadsModified }, {/if}
|
||||
{#if isHwthreadsModified } HWThreads: {filters.numHWThreads.from} - {filters.numHWThreads.to} {/if}
|
||||
{#if (isNodesModified || isHwthreadsModified) && isAccsModified }, {/if}
|
||||
{#if isAccsModified } Accelerators: {filters.numAccelerators.from} - {filters.numAccelerators.to} {/if}
|
||||
</Info>
|
||||
{/if}
|
||||
|
||||
@ -316,6 +325,9 @@
|
||||
bind:numNodes={filters.numNodes}
|
||||
bind:numHWThreads={filters.numHWThreads}
|
||||
bind:numAccelerators={filters.numAccelerators}
|
||||
bind:isNodesModified={isNodesModified}
|
||||
bind:isHwthreadsModified={isHwthreadsModified}
|
||||
bind:isAccsModified={isAccsModified}
|
||||
on:update={() => update()} />
|
||||
|
||||
<Statistics cluster={filters.cluster}
|
||||
|
@ -9,21 +9,24 @@
|
||||
dispatch = createEventDispatcher()
|
||||
|
||||
export let cluster = null
|
||||
export let isModified = false
|
||||
export let isOpen = false
|
||||
export let numNodes = { from: null, to: null }
|
||||
export let numHWThreads = { from: null, to: null }
|
||||
export let numAccelerators = { from: null, to: null }
|
||||
export let isNodesModified = false
|
||||
export let isHwthreadsModified = false
|
||||
export let isAccsModified = false
|
||||
|
||||
let pendingNumNodes = numNodes, pendingNumHWThreads = numHWThreads, pendingNumAccelerators = numAccelerators
|
||||
$: isModified = pendingNumNodes.from != numNodes.from || pendingNumNodes.to != numNodes.to
|
||||
|| pendingNumHWThreads.from != numHWThreads.from || pendingNumHWThreads.to != numHWThreads.to
|
||||
|| pendingNumAccelerators.from != numAccelerators.from || pendingNumAccelerators.to != numAccelerators.to
|
||||
|
||||
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)
|
||||
|
||||
// console.log(header)
|
||||
// Limited to Single-Node Thread Count
|
||||
const findMaxNumHWTreadsPerNode = clusters => clusters.reduce((max, cluster) => Math.max(max,
|
||||
cluster.subClusters.reduce((max, sc) => Math.max(max, (sc.threadsPerCore * sc.coresPerSocket * sc.socketsPerNode) || 0), 0)), 0)
|
||||
|
||||
// console.log(header)
|
||||
let minNumNodes = 1, maxNumNodes = 0, minNumHWThreads = 1, maxNumHWThreads = 0, minNumAccelerators = 0, maxNumAccelerators = 0
|
||||
$: {
|
||||
if ($initialized) {
|
||||
@ -33,11 +36,13 @@
|
||||
minNumNodes = filterRanges.numNodes.from
|
||||
maxNumNodes = filterRanges.numNodes.to
|
||||
maxNumAccelerators = findMaxNumAccels([{ subClusters }])
|
||||
maxNumHWThreads = findMaxNumHWTreadsPerNode([{ subClusters }])
|
||||
} else if (clusters.length > 0) {
|
||||
const { filterRanges } = header.clusters[0]
|
||||
minNumNodes = filterRanges.numNodes.from
|
||||
maxNumNodes = filterRanges.numNodes.to
|
||||
maxNumAccelerators = findMaxNumAccels(clusters)
|
||||
maxNumHWThreads = findMaxNumHWTreadsPerNode(clusters)
|
||||
for (let cluster of header.clusters) {
|
||||
const { filterRanges } = cluster
|
||||
minNumNodes = Math.min(minNumNodes, filterRanges.numNodes.from)
|
||||
@ -52,27 +57,53 @@
|
||||
pendingNumNodes = { from: 0, to: maxNumNodes }
|
||||
}
|
||||
}
|
||||
|
||||
$: {
|
||||
if (isOpen && $initialized && pendingNumHWThreads.from == null && pendingNumHWThreads.to == null) {
|
||||
pendingNumHWThreads = { from: 0, to: maxNumHWThreads }
|
||||
}
|
||||
}
|
||||
|
||||
$: if ( maxNumAccelerators != null && maxNumAccelerators > 1 ) {
|
||||
if (isOpen && $initialized && pendingNumAccelerators.from == null && pendingNumAccelerators.to == null) {
|
||||
pendingNumAccelerators = { from: 0, to: maxNumAccelerators }
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal isOpen={isOpen} toggle={() => (isOpen = !isOpen)}>
|
||||
<ModalHeader>
|
||||
Select Number of Nodes, HWThreads and Accelerators
|
||||
Select number of utilized Resources
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<h4>Number of Nodes</h4>
|
||||
<h6>Number of Nodes</h6>
|
||||
<DoubleRangeSlider
|
||||
on:change={({ detail }) => (pendingNumNodes = { from: detail[0], to: detail[1] })}
|
||||
on:change={({ detail }) => {
|
||||
pendingNumNodes = { from: detail[0], to: detail[1] }
|
||||
isNodesModified = true
|
||||
}}
|
||||
min={minNumNodes} max={maxNumNodes}
|
||||
firstSlider={pendingNumNodes.from} secondSlider={pendingNumNodes.to} />
|
||||
<!-- <DoubleRangeSlider
|
||||
on:change={({ detail }) => (pendingNumHWThreads = { from: detail[0], to: detail[1] })}
|
||||
firstSlider={pendingNumNodes.from} secondSlider={pendingNumNodes.to}
|
||||
inputFieldFrom={pendingNumNodes.from} inputFieldTo={pendingNumNodes.to}/>
|
||||
<h6 style="margin-top: 1rem;">Number of HWThreads (Use for Single-Node Jobs)</h6>
|
||||
<DoubleRangeSlider
|
||||
on:change={({ detail }) => {
|
||||
pendingNumHWThreads = { from: detail[0], to: detail[1] }
|
||||
isHwthreadsModified = true
|
||||
}}
|
||||
min={minNumHWThreads} max={maxNumHWThreads}
|
||||
firstSlider={pendingNumHWThreads.from} secondSlider={pendingNumHWThreads.to} /> -->
|
||||
firstSlider={pendingNumHWThreads.from} secondSlider={pendingNumHWThreads.to}
|
||||
inputFieldFrom={pendingNumHWThreads.from} inputFieldTo={pendingNumHWThreads.to}/>
|
||||
{#if maxNumAccelerators != null && maxNumAccelerators > 1}
|
||||
<h6 style="margin-top: 1rem;">Number of Accelerators</h6>
|
||||
<DoubleRangeSlider
|
||||
on:change={({ detail }) => (pendingNumAccelerators = { from: detail[0], to: detail[1] })}
|
||||
on:change={({ detail }) => {
|
||||
pendingNumAccelerators = { from: detail[0], to: detail[1] }
|
||||
isAccsModified = true
|
||||
}}
|
||||
min={minNumAccelerators} max={maxNumAccelerators}
|
||||
firstSlider={pendingNumAccelerators.from} secondSlider={pendingNumAccelerators.to} />
|
||||
firstSlider={pendingNumAccelerators.from} secondSlider={pendingNumAccelerators.to}
|
||||
inputFieldFrom={pendingNumAccelerators.from} inputFieldTo={pendingNumAccelerators.to}/>
|
||||
{/if}
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
@ -80,7 +111,10 @@
|
||||
disabled={pendingNumNodes.from == null || pendingNumNodes.to == null}
|
||||
on:click={() => {
|
||||
isOpen = false
|
||||
numNodes = { from: pendingNumNodes.from, to: pendingNumNodes.to }
|
||||
pendingNumNodes = isNodesModified ? pendingNumNodes : { from: null, to: null }
|
||||
pendingNumHWThreads = isHwthreadsModified ? pendingNumHWThreads : { from: null, to: null }
|
||||
pendingNumAccelerators = isAccsModified ? pendingNumAccelerators : { from: null, to: null }
|
||||
numNodes ={ from: pendingNumNodes.from, to: pendingNumNodes.to }
|
||||
numHWThreads = { from: pendingNumHWThreads.from, to: pendingNumHWThreads.to }
|
||||
numAccelerators = { from: pendingNumAccelerators.from, to: pendingNumAccelerators.to }
|
||||
dispatch('update', { numNodes, numHWThreads, numAccelerators })
|
||||
@ -95,6 +129,9 @@
|
||||
numNodes = { from: pendingNumNodes.from, to: pendingNumNodes.to }
|
||||
numHWThreads = { from: pendingNumHWThreads.from, to: pendingNumHWThreads.to }
|
||||
numAccelerators = { from: pendingNumAccelerators.from, to: pendingNumAccelerators.to }
|
||||
isNodesModified = false
|
||||
isHwthreadsModified = false
|
||||
isAccsModified = false
|
||||
dispatch('update', { numNodes, numHWThreads, numAccelerators })
|
||||
}}>Reset</Button>
|
||||
<Button on:click={() => (isOpen = false)}>Close</Button>
|
||||
|
@ -93,7 +93,8 @@
|
||||
<DoubleRangeSlider
|
||||
on:change={({ detail }) => (stat.from = detail[0], stat.to = detail[1], stat.enabled = true)}
|
||||
min={0} max={stat.peak}
|
||||
firstSlider={stat.from} secondSlider={stat.to} />
|
||||
firstSlider={stat.from} secondSlider={stat.to}
|
||||
inputFieldFrom={stat.from} inputFieldTo={stat.to}/>
|
||||
{/each}
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
@ -104,7 +105,8 @@
|
||||
}}>Close & Apply</Button>
|
||||
<Button color="danger" on:click={() => {
|
||||
isOpen = false
|
||||
statistics.forEach(stat => stat.enabled = false)
|
||||
resetRange($initialized, cluster)
|
||||
statistics.forEach(stat => (stat.enabled = false))
|
||||
stats = []
|
||||
dispatch('update', { stats })
|
||||
}}>Reset</Button>
|
||||
|
Loading…
Reference in New Issue
Block a user