2023-12-01 13:22:01 +01:00
|
|
|
<script>
|
|
|
|
import { Modal, ModalBody, ModalHeader, ModalFooter,
|
2023-12-06 12:58:03 +01:00
|
|
|
Button, ListGroup, ListGroupItem } from 'sveltestrap'
|
2023-12-01 13:22:01 +01:00
|
|
|
import { gql, getContextClient , mutationStore } from '@urql/svelte'
|
|
|
|
|
|
|
|
export let cluster
|
|
|
|
export let metricsInHistograms
|
2023-12-06 12:58:03 +01:00
|
|
|
export let isOpen
|
|
|
|
|
2024-02-09 16:49:56 +01:00
|
|
|
let availableMetrics = ['cpu_load', 'flops_any', 'mem_used', 'mem_bw'] // 'net_bw', 'file_bw'
|
2023-12-06 12:58:03 +01:00
|
|
|
let pendingMetrics = [...metricsInHistograms] // Copy
|
|
|
|
const client = getContextClient()
|
2023-12-01 13:22:01 +01:00
|
|
|
|
|
|
|
const updateConfigurationMutation = ({ name, value }) => {
|
|
|
|
return mutationStore({
|
|
|
|
client: client,
|
|
|
|
query: gql`mutation($name: String!, $value: String!) {
|
|
|
|
updateConfiguration(name: $name, value: $value)
|
|
|
|
}`,
|
|
|
|
variables: { name, value }
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateConfiguration(data) {
|
|
|
|
updateConfigurationMutation({
|
|
|
|
name: data.name,
|
|
|
|
value: JSON.stringify(data.value)
|
|
|
|
}).subscribe(res => {
|
|
|
|
if (res.fetching === false && res.error) {
|
|
|
|
throw res.error
|
|
|
|
// console.log('Error on subscription: ' + res.error)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-12-06 12:58:03 +01:00
|
|
|
function closeAndApply() {
|
|
|
|
metricsInHistograms = [...pendingMetrics] // Set for parent
|
2023-12-12 15:42:14 +01:00
|
|
|
isOpen = !isOpen
|
2023-12-06 12:58:03 +01:00
|
|
|
updateConfiguration({
|
|
|
|
name: cluster ? `user_view_histogramMetrics:${cluster}` : 'user_view_histogramMetrics',
|
|
|
|
value: metricsInHistograms
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<Modal {isOpen}
|
|
|
|
toggle={() => (isOpen = !isOpen)}>
|
2023-12-01 13:22:01 +01:00
|
|
|
<ModalHeader>
|
|
|
|
Select metrics presented in histograms
|
|
|
|
</ModalHeader>
|
|
|
|
<ModalBody>
|
|
|
|
<ListGroup>
|
|
|
|
{#each availableMetrics as metric (metric)}
|
|
|
|
<ListGroupItem>
|
2023-12-06 12:58:03 +01:00
|
|
|
<input type="checkbox" bind:group={pendingMetrics} value={metric}>
|
2023-12-01 13:22:01 +01:00
|
|
|
{metric}
|
|
|
|
</ListGroupItem>
|
|
|
|
{/each}
|
|
|
|
</ListGroup>
|
|
|
|
</ModalBody>
|
|
|
|
<ModalFooter>
|
2023-12-06 12:58:03 +01:00
|
|
|
<Button color="primary" on:click={closeAndApply}> Close & Apply </Button>
|
2023-12-12 15:42:14 +01:00
|
|
|
<Button color="secondary" on:click={() => (isOpen = !isOpen)}> Close </Button>
|
2023-12-01 13:22:01 +01:00
|
|
|
</ModalFooter>
|
|
|
|
</Modal>
|