Skip to content

Commit

Permalink
Further adaptions to new urql version
Browse files Browse the repository at this point in the history
  • Loading branch information
spacehamster87 committed May 10, 2023
1 parent 280d63a commit 374a485
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 36 deletions.
25 changes: 13 additions & 12 deletions web/frontend/src/Node.root.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
const ccconfig = getContext('cc-config')
const clusters = getContext('clusters')
const nodesQuery = queryStore({
client: getContextClient(),
query: gql`query($cluster: String!, $nodes: [String!], $from: Time!, $to: Time!) {
const client = getContextClient();
const query = gql`query($cluster: String!, $nodes: [String!], $from: Time!, $to: Time!) {
nodeMetrics(cluster: $cluster, nodes: $nodes, from: $from, to: $to) {
host
subCluster
Expand All @@ -42,15 +40,18 @@
}
}
}
}`,
variables: {
cluster: cluster,
nodes: [hostname],
from: from.toISOString(),
to: to.toISOString() }
})
}`;
$: $nodesQuery.variables = { cluster, nodes: [hostname], from: from.toISOString(), to: to.toISOString() }
$: nodesQuery = queryStore({
client: client,
query: query,
variables: {
cluster: cluster,
nodes: [hostname],
from: from.toISOString(),
to: to.toISOString(),
}
});
let metricUnits = {}
$: if ($nodesQuery.data) {
Expand Down
24 changes: 11 additions & 13 deletions web/frontend/src/PlotSelection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
export let metricsInHistograms
export let metricsInScatterplots
const updateConfigurationMutation = ({ name, value }) => {
result = mutationStore({
client: getContextClient(),
query: gql`mutation($name: String!, $value: String!) {
updateConfiguration(name: $name, value: $value)
}`,
variables: { name, value }
})
const client = getContextClient();
$: updateConfigurationMutation = ({ name, value }) => {
mutationStore({
client: client,
query: gql`mutation($name: String!, $value: String!) {
updateConfiguration(name: $name, value: $value)
}`,
variables: { name, value }
})
}
let isHistogramConfigOpen = false, isScatterPlotConfigOpen = false
Expand All @@ -24,11 +26,7 @@
updateConfigurationMutation({
name: data.name,
value: JSON.stringify(data.value)
})
.then(res => {
if (res.error)
console.error(res.error)
});
})
}
</script>

Expand Down
10 changes: 2 additions & 8 deletions web/frontend/src/Status.root.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
export let cluster
let plotWidths = [], colWidth1 = 0, colWidth2
let from = new Date(Date.now() - 5 * 60 * 1000), to = new Date(Date.now())
const mainQuery = queryStore({
$: mainQuery = queryStore({
client: getContextClient(),
query: gql`query($cluster: String!, $filter: [JobFilter!]!, $metrics: [String!], $from: Time!, $to: Time!) {
nodeMetrics(cluster: $cluster, metrics: $metrics, from: $from, to: $to) {
Expand Down Expand Up @@ -61,7 +61,6 @@
}
}
query(mainQuery)
</script>
<!-- Loading indicator & Refresh -->
Expand All @@ -81,13 +80,8 @@
</Col>
<Col xs="auto" style="margin-left: auto;">
<Refresher initially={120} on:reload={() => {
console.log('reload...')
from = new Date(Date.now() - 5 * 60 * 1000)
to = new Date(Date.now())
$mainQuery.variables = { ...$mainQuery.variables, from: from, to: to }
$mainQuery.reexecute({ requestPolicy: 'network-only' })
}} />
</Col>
</Row>
Expand Down
5 changes: 2 additions & 3 deletions web/frontend/src/Systems.root.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
let hostnameFilter = ''
let selectedMetric = ccconfig.system_view_selectedMetric
const nodesQuery = queryStore({
$: nodesQuery = queryStore({
client: getContextClient(),
query: gql`query($cluster: String!, $metrics: [String!], $from: Time!, $to: Time!) {
nodeMetrics(cluster: $cluster, metrics: $metrics, from: $from, to: $to) {
Expand All @@ -49,7 +49,7 @@
}`,
variables: {
cluster: cluster,
metrics: [],
metrics: [selectedMetric],
from: from.toISOString(),
to: to.toISOString()}
})
Expand All @@ -66,7 +66,6 @@
}
}
$: $nodesQuery.variables = { cluster, metrics: [selectedMetric], from: from.toISOString(), to: to.toISOString() }
</script>

<Row>
Expand Down

0 comments on commit 374a485

Please sign in to comment.