Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into update-model-page
Browse files Browse the repository at this point in the history
  • Loading branch information
micque01 committed Dec 12, 2023
2 parents f3037db + b4e31fe commit e9815e2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/components/TrainModelFirstTitle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
<StandardButton onClick={() => navigate(Paths.DATA)}>
{$t('content.model.addData')}
</StandardButton>
<TrainingButton type="secondary" />
<TrainingButton type="secondary" action="navigate" />
</div>
</div>
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 action="navigate" />
{/if}
</main>
8 changes: 2 additions & 6 deletions src/pages/model/stackview/ModelPageStackView.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
(c) 2023, Center for Computational Thinking and Design at Aarhus University and contributors
SPDX-License-Identifier: MIT
-->

Expand Down Expand Up @@ -91,11 +91,7 @@
<!-- Main pane -->
<main class="h-full flex flex-col">
{#if $state.isPredicting}
{#if $state.isInputReady}
<ModelPageStackViewContent />
{:else}
<PleaseConnectFirst />
{/if}
<ModelPageStackViewContent />
{:else}
<TrainModelFirstTitle />
{/if}
Expand Down
31 changes: 7 additions & 24 deletions src/pages/training/TrainingButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import StandardButton, { ButtonVariant } 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: ButtonVariant = 'primary';
export let action: 'navigate' | 'train' = 'train';
$: trainButtonLabel = !$state.isPredicting
? 'menu.trainer.trainModelButton'
Expand All @@ -30,36 +30,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={action === 'navigate' ? navitgateToTrainingPage : startTraining}
disabled={trainingButtonDisabled}
{type}
>{$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} onClick={startTraining}
>{$t('content.data.trainDialog.title')}</StandardButton>
</div>
</div>
</StandardDialog>

0 comments on commit e9815e2

Please sign in to comment.