Added: Mode toggle

This commit is contained in:
Luc Mcgrady 2025-07-13 20:06:11 +01:00
parent fe69706255
commit d8fcd787c8
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C

View file

@ -162,11 +162,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
simulating = false; simulating = false;
if (resp) { if (resp) {
// Clear the graph if transitioning from workload to simulation // Clear the graph if transitioning from workload to simulation
if (workload == true) {
points = [];
simulationNumber = 0;
}
workload = false;
simulationNumber += 1; simulationNumber += 1;
const dailyTotalCount = addArrays( const dailyTotalCount = addArrays(
@ -196,7 +191,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
} }
} }
async function workloadGraph(): Promise<void> { async function simulateWorkload(): Promise<void> {
let resp: SimulateFsrsWorkloadResponse | undefined; let resp: SimulateFsrsWorkloadResponse | undefined;
updateRequest(); updateRequest();
try { try {
@ -210,13 +205,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
} finally { } finally {
simulating = false; simulating = false;
if (resp) { if (resp) {
// Clear the graph if transitioning from simulation to workload
if (workload == false) {
points = [];
simulationNumber = 0;
}
workload = true;
simulationNumber += 1; simulationNumber += 1;
points = points.concat( points = points.concat(
@ -250,6 +238,29 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
); );
} }
function saveConfigToPreset() {
if (confirm(tr.deckConfigSaveOptionsToPresetConfirm())) {
$config.newPerDay = simulateFsrsRequest.newLimit;
$config.reviewsPerDay = simulateFsrsRequest.reviewLimit;
$config.maximumReviewInterval = simulateFsrsRequest.maxInterval;
$config.desiredRetention = simulateFsrsRequest.desiredRetention;
$newCardsIgnoreReviewLimit = simulateFsrsRequest.newCardsIgnoreReviewLimit;
$config.reviewOrder = simulateFsrsRequest.reviewOrder;
$config.leechAction = suspendLeeches
? DeckConfig_Config_LeechAction.SUSPEND
: DeckConfig_Config_LeechAction.TAG_ONLY;
$config.leechThreshold = leechThreshold;
$config.easyDaysPercentages = [...easyDayPercentages];
onPresetChange();
}
}
function switchModes() {
points = [];
simulationNumber = 0;
workload = !workload;
}
$: if (svg) { $: if (svg) {
let pointsToRender = points; let pointsToRender = points;
if (smooth) { if (smooth) {
@ -485,55 +496,51 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
{/if} {/if}
</details> </details>
</div> </div>
<button
class="btn {computing ? 'btn-warning' : 'btn-primary'}"
disabled={computing}
on:click={simulateFsrs}
>
{tr.deckConfigSimulate()}
</button>
<button <div class="button-row">
class="btn {computing ? 'btn-warning' : 'btn-primary'}" <div>
disabled={computing} <button
on:click={clearSimulation} class="btn {computing ? 'btn-warning' : 'btn-primary'}"
> disabled={computing}
{tr.deckConfigClearLastSimulate()} on:click={workload ? simulateWorkload : simulateFsrs}
</button> >
{tr.deckConfigSimulate()}
</button>
<button <button
disabled={computing} class="btn {computing ? 'btn-warning' : 'btn-primary'}"
class="btn {computing ? 'btn-warning' : 'btn-primary'}" disabled={computing}
on:click={workloadGraph} on:click={clearSimulation}
> >
Display Dr Workloads {tr.deckConfigClearLastSimulate()}
</button> </button>
<button <button
class="btn {computing ? 'btn-warning' : 'btn-primary'}" class="btn {computing ? 'btn-warning' : 'btn-primary'}"
disabled={computing} disabled={computing}
on:click={() => { on:click={saveConfigToPreset}
if (confirm(tr.deckConfigSaveOptionsToPresetConfirm())) { >
$config.newPerDay = simulateFsrsRequest.newLimit; {tr.deckConfigSaveOptionsToPreset()}
$config.reviewsPerDay = simulateFsrsRequest.reviewLimit; </button>
$config.maximumReviewInterval = </div>
simulateFsrsRequest.maxInterval; <h3>
$config.desiredRetention = {#if workload}
simulateFsrsRequest.desiredRetention; Desired Retention Mode
$newCardsIgnoreReviewLimit = {:else}
simulateFsrsRequest.newCardsIgnoreReviewLimit; Simulation Mode
$config.reviewOrder = simulateFsrsRequest.reviewOrder; {/if}
$config.leechAction = suspendLeeches </h3>
? DeckConfig_Config_LeechAction.SUSPEND
: DeckConfig_Config_LeechAction.TAG_ONLY; <div class="mode-switch">
$config.leechThreshold = leechThreshold; <button
$config.easyDaysPercentages = [...easyDayPercentages]; disabled={computing}
onPresetChange(); class="btn {computing ? 'btn-warning' : 'btn-primary'}"
} on:click={switchModes}
}} >
> Switch to {workload ? "Simulation" : "Desired Retention"} Mode
{tr.deckConfigSaveOptionsToPreset()} </button>
</button> </div>
</div>
{#if processing} {#if processing}
{tr.actionsProcessing()} {tr.actionsProcessing()}
@ -656,4 +663,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
summary { summary {
margin-bottom: 0.5em; margin-bottom: 0.5em;
} }
.button-row {
display: grid;
grid-template-columns: 1fr auto 1fr;
}
.mode-switch {
display: flex;
flex-direction: row-reverse;
}
</style> </style>