mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-03-21 07:17:30 +01:00
Adopt config to use policy based resampler configuration
Entire-Checkpoint: 7536f551d548
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
import Options from "./admin/Options.svelte";
|
||||
import NoticeEdit from "./admin/NoticeEdit.svelte";
|
||||
import RunTaggers from "./admin/RunTaggers.svelte";
|
||||
import PlotRenderOptions from "./user/PlotRenderOptions.svelte";
|
||||
|
||||
/* Svelte 5 Props */
|
||||
let {
|
||||
@@ -29,6 +30,8 @@
|
||||
/* State Init */
|
||||
let users = $state([]);
|
||||
let roles = $state([]);
|
||||
let message = $state({ msg: "", target: "", color: "#d63384" });
|
||||
let displayMessage = $state(false);
|
||||
|
||||
/* Functions */
|
||||
function getUserList() {
|
||||
@@ -52,6 +55,37 @@
|
||||
getValidRoles();
|
||||
}
|
||||
|
||||
async function handleSettingSubmit(event, setting) {
|
||||
event.preventDefault();
|
||||
|
||||
const selector = setting.selector
|
||||
const target = setting.target
|
||||
let form = document.querySelector(selector);
|
||||
let formData = new FormData(form);
|
||||
try {
|
||||
const res = await fetch(form.action, { method: "POST", body: formData });
|
||||
if (res.ok) {
|
||||
let text = await res.text();
|
||||
popMessage(text, target, "#048109");
|
||||
} else {
|
||||
let text = await res.text();
|
||||
throw new Error("Response Code " + res.status + "-> " + text);
|
||||
}
|
||||
} catch (err) {
|
||||
popMessage(err, target, "#d63384");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function popMessage(response, restarget, rescolor) {
|
||||
message = { msg: response, target: restarget, color: rescolor };
|
||||
displayMessage = true;
|
||||
setTimeout(function () {
|
||||
displayMessage = false;
|
||||
}, 3500);
|
||||
}
|
||||
|
||||
/* on Mount */
|
||||
onMount(() => initAdmin());
|
||||
</script>
|
||||
@@ -73,3 +107,4 @@
|
||||
<NoticeEdit {ncontent}/>
|
||||
<RunTaggers />
|
||||
</Row>
|
||||
<PlotRenderOptions config={ccconfig} bind:message bind:displayMessage updateSetting={(e, newSetting) => handleSettingSubmit(e, newSetting)}/>
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
} = $props();
|
||||
|
||||
const resampleConfig = getContext("resampling");
|
||||
const resamplingEnabled = !!resampleConfig;
|
||||
</script>
|
||||
|
||||
<Row cols={3} class="p-2 g-2">
|
||||
@@ -68,7 +67,7 @@
|
||||
id="lwvalue"
|
||||
name="value"
|
||||
aria-describedby="lineWidthHelp"
|
||||
value={config.plotConfiguration_lineWidth}
|
||||
value={config?.plotConfiguration_lineWidth}
|
||||
min="1"
|
||||
/>
|
||||
<div id="lineWidthHelp" class="form-text">
|
||||
@@ -115,7 +114,7 @@
|
||||
id="pprvalue"
|
||||
name="value"
|
||||
aria-describedby="plotsperrowHelp"
|
||||
value={config.plotConfiguration_plotsPerRow}
|
||||
value={config?.plotConfiguration_plotsPerRow}
|
||||
min="1"
|
||||
/>
|
||||
<div id="plotsperrowHelp" class="form-text">
|
||||
@@ -157,7 +156,7 @@
|
||||
<input type="hidden" name="key" value="plotConfiguration_colorBackground" />
|
||||
<div class="mb-3">
|
||||
<div>
|
||||
{#if config.plotConfiguration_colorBackground}
|
||||
{#if config?.plotConfiguration_colorBackground}
|
||||
<input type="radio" id="colb-true-checked" name="value" value="true" checked />
|
||||
{:else}
|
||||
<input type="radio" id="colb-true" name="value" value="true" />
|
||||
@@ -165,7 +164,7 @@
|
||||
<label for="true">Yes</label>
|
||||
</div>
|
||||
<div>
|
||||
{#if config.plotConfiguration_colorBackground}
|
||||
{#if config?.plotConfiguration_colorBackground}
|
||||
<input type="radio" id="colb-false" name="value" value="false" />
|
||||
{:else}
|
||||
<input type="radio" id="colb-false-checked" name="value" value="false" checked />
|
||||
@@ -224,7 +223,6 @@
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
{#if resamplingEnabled}
|
||||
<!-- RESAMPLE POLICY -->
|
||||
<Col>
|
||||
<Card class="h-100">
|
||||
@@ -255,7 +253,7 @@
|
||||
{#each [["", "Default"], ["low", "Low"], ["medium", "Medium"], ["high", "High"]] as [val, label]}
|
||||
<div>
|
||||
<input type="radio" id="rsp-{val || 'default'}" name="value" value={JSON.stringify(val)}
|
||||
checked={(!config.plotConfiguration_resamplePolicy && val === "") || config.plotConfiguration_resamplePolicy === val} />
|
||||
checked={(!config?.plotConfiguration_resamplePolicy && val === "") || config?.plotConfiguration_resamplePolicy === val} />
|
||||
<label for="rsp-{val || 'default'}">{label}</label>
|
||||
</div>
|
||||
{/each}
|
||||
@@ -298,7 +296,7 @@
|
||||
{#each [["", "Default"], ["lttb", "LTTB"], ["average", "Average"], ["simple", "Simple"]] as [val, label]}
|
||||
<div>
|
||||
<input type="radio" id="rsa-{val || 'default'}" name="value" value={JSON.stringify(val)}
|
||||
checked={(!config.plotConfiguration_resampleAlgo && val === "") || config.plotConfiguration_resampleAlgo === val} />
|
||||
checked={(!config?.plotConfiguration_resampleAlgo && val === "") || config?.plotConfiguration_resampleAlgo === val} />
|
||||
<label for="rsa-{val || 'default'}">{label}</label>
|
||||
</div>
|
||||
{/each}
|
||||
@@ -310,5 +308,4 @@
|
||||
</form>
|
||||
</Card>
|
||||
</Col>
|
||||
{/if}
|
||||
</Row>
|
||||
Reference in New Issue
Block a user