Change color of info box depending on retention; increase limit to 0.99

Closes #2803
This commit is contained in:
Damien Elmes 2023-11-07 12:59:26 +10:00
parent 0b8b168df1
commit 82aaa913a6
2 changed files with 15 additions and 3 deletions

View file

@ -274,7 +274,7 @@ pub(crate) fn ensure_deck_config_values_valid(config: &mut DeckConfigInner) {
&mut config.desired_retention,
default.desired_retention,
0.7,
0.97,
0.99,
);
ensure_f32_valid(&mut config.sm2_retention, default.sm2_retention, 0.7, 0.97)
}

View file

@ -44,6 +44,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
$: computing = computingWeights || checkingWeights || computingRetention;
$: customSearch = `preset:"${$presetName}"`;
$: desiredRetentionWarning = getRetentionWarning($config.desiredRetention);
$: retentionWarningClass = getRetentionWarningClass($config.desiredRetention);
let computeRetentionProgress:
| ComputeWeightsProgress
@ -67,6 +68,17 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
}
return tr.deckConfigA100DayInterval({ days });
}
function getRetentionWarningClass(retention: number): string {
if (retention < 0.7 || retention > 0.97) {
return "alert-danger";
} else if (retention < 0.85 || retention > 0.95) {
return "alert-warning";
} else {
return "alert-info";
}
}
async function computeWeights(): Promise<void> {
if (computingWeights) {
await setWantsAbort({});
@ -221,14 +233,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
bind:value={$config.desiredRetention}
defaultValue={defaults.desiredRetention}
min={0.7}
max={0.97}
max={0.99}
>
<SettingTitle on:click={() => openHelpModal("desiredRetention")}>
{tr.deckConfigDesiredRetention()}
</SettingTitle>
</SpinBoxFloatRow>
<Warning warning={desiredRetentionWarning} className="alert-info" />
<Warning warning={desiredRetentionWarning} className={retentionWarningClass} />
<SpinBoxFloatRow
bind:value={$config.sm2Retention}