mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 17:26:36 -04:00
Added: Mode toggle
This commit is contained in:
parent
fe69706255
commit
d8fcd787c8
1 changed files with 76 additions and 59 deletions
|
@ -162,11 +162,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
simulating = false;
|
||||
if (resp) {
|
||||
// Clear the graph if transitioning from workload to simulation
|
||||
if (workload == true) {
|
||||
points = [];
|
||||
simulationNumber = 0;
|
||||
}
|
||||
workload = false;
|
||||
|
||||
simulationNumber += 1;
|
||||
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;
|
||||
updateRequest();
|
||||
try {
|
||||
|
@ -210,13 +205,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 simulation to workload
|
||||
if (workload == false) {
|
||||
points = [];
|
||||
simulationNumber = 0;
|
||||
}
|
||||
workload = true;
|
||||
|
||||
simulationNumber += 1;
|
||||
|
||||
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) {
|
||||
let pointsToRender = points;
|
||||
if (smooth) {
|
||||
|
@ -485,10 +496,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
{/if}
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<div class="button-row">
|
||||
<div>
|
||||
<button
|
||||
class="btn {computing ? 'btn-warning' : 'btn-primary'}"
|
||||
disabled={computing}
|
||||
on:click={simulateFsrs}
|
||||
on:click={workload ? simulateWorkload : simulateFsrs}
|
||||
>
|
||||
{tr.deckConfigSimulate()}
|
||||
</button>
|
||||
|
@ -501,39 +515,32 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
{tr.deckConfigClearLastSimulate()}
|
||||
</button>
|
||||
|
||||
<button
|
||||
disabled={computing}
|
||||
class="btn {computing ? 'btn-warning' : 'btn-primary'}"
|
||||
on:click={workloadGraph}
|
||||
>
|
||||
Display Dr Workloads
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="btn {computing ? 'btn-warning' : 'btn-primary'}"
|
||||
disabled={computing}
|
||||
on:click={() => {
|
||||
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();
|
||||
}
|
||||
}}
|
||||
on:click={saveConfigToPreset}
|
||||
>
|
||||
{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}
|
||||
{tr.actionsProcessing()}
|
||||
|
@ -656,4 +663,14 @@ 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>
|
||||
|
|
Loading…
Reference in a new issue