"Help me pick" button

This commit is contained in:
Luc Mcgrady 2025-07-18 16:55:34 +01:00
parent 5406b6bd5c
commit 78d206b5d5
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C
2 changed files with 25 additions and 38 deletions

View file

@ -299,6 +299,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
}
let simulatorModal: Modal;
let workloadModal: Modal;
</script>
<SpinBoxFloatRow
@ -314,6 +315,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</SettingTitle>
</SpinBoxFloatRow>
<button class="btn btn-primary" on:click={() => workloadModal?.show()}>
{"Help Me Pick"}
</button>
<Warning warning={desiredRetentionChangeInfo} className={"alert-info two-line"} />
<Warning warning={desiredRetentionWarning} className={retentionWarningClass} />
@ -409,6 +414,16 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
{onPresetChange}
/>
<SimulatorModal
bind:modal={workloadModal}
workload
{state}
{simulateFsrsRequest}
{computing}
{openHelpModal}
{onPresetChange}
/>
<style>
.btn {
margin-bottom: 0.375rem;

View file

@ -51,12 +51,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
export let computing: boolean;
export let openHelpModal: (key: string) => void;
export let onPresetChange: () => void;
/** Do not modify this once set */
export let workload: boolean = false;
const config = state.currentConfig;
let simulateSubgraph: SimulateSubgraph = SimulateSubgraph.count;
let simulateWorkloadSubgraph: SimulateWorkloadSubgraph =
SimulateWorkloadSubgraph.ratio;
let workload: boolean = false;
let tableData: TableDatum[] = [];
let simulating: boolean = false;
const fsrs = state.fsrs;
@ -163,8 +164,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
} finally {
simulating = false;
if (resp) {
// Clear the graph if transitioning from workload to simulation
simulationNumber += 1;
const dailyTotalCount = addArrays(
resp.dailyReviewCount,
@ -259,12 +258,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
}
}
function switchModes() {
points = [];
simulationNumber = 0;
workload = !workload;
}
$: if (svg) {
let pointsToRender = points;
if (smooth) {
@ -331,7 +324,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{tr.deckConfigFsrsSimulatorExperimental()}</h5>
<h5 class="modal-title">
{#if workload}
Desired Retention Simulation Graph
{:else}
{tr.deckConfigFsrsSimulatorExperimental()}
{/if}
</h5>
<button
type="button"
class="btn-close"
@ -522,7 +521,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</details>
</div>
<div class="button-row">
<div>
<div>
<button
class="btn {computing ? 'btn-warning' : 'btn-primary'}"
@ -548,23 +547,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
{tr.deckConfigSaveOptionsToPreset()}
</button>
</div>
<h3>
{#if workload}
Desired Retention Mode
{:else}
Simulation Mode
{/if}
</h3>
<div class="mode-switch">
<button
disabled={computing}
class="btn {computing ? 'btn-warning' : 'btn-primary'}"
on:click={switchModes}
>
Switch to {workload ? "Simulation" : "Desired Retention"} Mode
</button>
</div>
</div>
{#if processing}
@ -696,14 +678,4 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
summary {
margin-bottom: 0.5em;
}
.button-row {
display: grid;
grid-template-columns: 1fr auto 1fr;
}
.mode-switch {
display: flex;
flex-direction: row-reverse;
}
</style>