Skip to content

Commit

Permalink
Merge pull request #58 from microbit-foundation/remove-training-dialog
Browse files Browse the repository at this point in the history
Remove training dialog
  • Loading branch information
micque01 authored Dec 12, 2023
2 parents 3f4c781 + 98c6375 commit b4e31fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/pages/DataPage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@

<NewGestureButton />
</div>
<TrainingButton />
<TrainingButton type="navigate" />
{/if}
</main>
32 changes: 8 additions & 24 deletions src/pages/training/TrainingButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
import StandardButton from '../../components/StandardButton.svelte';
import { trainModel } from '../../script/ml';
import { t } from '../../i18n';
import StandardDialog from '../../components/dialogs/StandardDialog.svelte';
import { Paths, navigate } from '../../router/paths';
import { gestures } from '../../script/stores/Stores';
export let type: 'navigate' | 'train' = 'train';
$: trainButtonLabel = !$state.isPredicting
? 'menu.trainer.trainModelButton'
: 'menu.trainer.trainNewModelButton';
Expand All @@ -28,36 +29,19 @@
trainingDialogOpen = false;
};
const startTraining = async (): Promise<void> => {
const startTraining = () => {
closeTrainingDialog();
trainModel();
};
const navitgateToTrainingPage = () => {
navigate(Paths.TRAINING);
const shouldRedirect = await trainModel();
if (shouldRedirect) {
navigate(Paths.MODEL);
}
};
</script>

<StandardButton
onClick={() => {
trainingDialogOpen = true;
}}
onClick={type === 'navigate' ? navitgateToTrainingPage : startTraining}
disabled={trainingButtonDisabled}
type="primary"
>{$t(trainButtonLabel)}
</StandardButton>

<StandardDialog
isOpen={trainingDialogOpen && !$state.isTraining}
onClose={closeTrainingDialog}>
<div class="w-150">
<h1 class="text-xl font-bold mb-4">{$t('content.data.trainDialog.title')}</h1>
<p>{$t('content.data.trainDialog.text')}</p>
<div class="flex justify-end gap-3">
<StandardButton onClick={closeTrainingDialog}
>{$t('connectMB.backButton')}</StandardButton>
<StandardButton type="primary" onClick={startTraining}
>{$t('content.data.trainDialog.title')}</StandardButton>
</div>
</div>
</StandardDialog>

0 comments on commit b4e31fe

Please sign in to comment.