mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-02-04 15:25:17 +01:00
Merge pull request #330 from ClusterCockpit/dev
Fix crash if no data on metric-store side
This commit is contained in:
commit
86d85f12be
@ -207,9 +207,9 @@ func (ccms *CCMetricStore) LoadData(
|
|||||||
jobData[metric] = make(map[schema.MetricScope]*schema.JobMetric)
|
jobData[metric] = make(map[schema.MetricScope]*schema.JobMetric)
|
||||||
}
|
}
|
||||||
|
|
||||||
res := row[0].Resolution
|
res := mc.Timestep
|
||||||
if res == 0 {
|
if len(row) > 0 {
|
||||||
res = mc.Timestep
|
res = row[0].Resolution
|
||||||
}
|
}
|
||||||
|
|
||||||
jobMetric, ok := jobData[metric][scope]
|
jobMetric, ok := jobData[metric][scope]
|
||||||
@ -784,9 +784,9 @@ func (ccms *CCMetricStore) LoadNodeListData(
|
|||||||
scope := assignedScope[i]
|
scope := assignedScope[i]
|
||||||
mc := archive.GetMetricConfig(cluster, metric)
|
mc := archive.GetMetricConfig(cluster, metric)
|
||||||
|
|
||||||
res := row[0].Resolution
|
res := mc.Timestep
|
||||||
if res == 0 {
|
if len(row) > 0 {
|
||||||
res = mc.Timestep
|
res = row[0].Resolution
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init Nested Map Data Structures If Not Found
|
// Init Nested Map Data Structures If Not Found
|
||||||
|
@ -43,10 +43,33 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let displayCheck = false;
|
||||||
function clipJwt() {
|
function clipJwt() {
|
||||||
navigator.clipboard
|
displayCheck = true;
|
||||||
.writeText(jwt)
|
// Navigator clipboard api needs a secure context (https)
|
||||||
.catch((reason) => console.error(reason));
|
if (navigator.clipboard && window.isSecureContext) {
|
||||||
|
navigator.clipboard
|
||||||
|
.writeText(jwt)
|
||||||
|
.catch((reason) => console.error(reason));
|
||||||
|
} else {
|
||||||
|
// Workaround: Create, Fill, And Copy Content of Textarea
|
||||||
|
const textArea = document.createElement("textarea");
|
||||||
|
textArea.value = jwt;
|
||||||
|
textArea.style.position = "absolute";
|
||||||
|
textArea.style.left = "-999999px";
|
||||||
|
document.body.prepend(textArea);
|
||||||
|
textArea.select();
|
||||||
|
try {
|
||||||
|
document.execCommand('copy');
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
} finally {
|
||||||
|
textArea.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setTimeout(function () {
|
||||||
|
displayCheck = false;
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
@ -120,6 +143,11 @@
|
|||||||
<p class="mt-2">
|
<p class="mt-2">
|
||||||
Your token is displayed on the right. Press this button to copy it to the clipboard.
|
Your token is displayed on the right. Press this button to copy it to the clipboard.
|
||||||
</p>
|
</p>
|
||||||
|
{#if displayCheck}
|
||||||
|
<p class="mt-2">
|
||||||
|
<span class="text-success">Copied!</span>
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
<Button color="success" on:click={getUserJwt(username)}>
|
<Button color="success" on:click={getUserJwt(username)}>
|
||||||
Generate JWT for '{username}'
|
Generate JWT for '{username}'
|
||||||
|
Loading…
Reference in New Issue
Block a user