Skip to content

Commit

Permalink
fix: #364
Browse files Browse the repository at this point in the history
  • Loading branch information
khansadaoudi committed Nov 4, 2024
1 parent eaafbff commit 5c19719
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/components/parsing/ParsingPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@
</q-item>
<q-separator />
<div v-if="parserData.taskStatus !== null">
<div v-if="parserData.taskStatus.taskType === 'ASK_TRAINING' || parserData.taskStatus.taskType === 'TRAINING'" class="text-subtitle5 q-mb-xs">
The training will continue even if you close the window
</div>
<div class="text-subtitle5 q-mb-xs">{{ $t('parser.currentTask') }}: {{ parserData.taskStatus.taskType }}</div>
<div v-if="parserData.taskStatus.taskAdditionalMessage" class="text-subtitle5 q-mb-xs">
{{ parserData.taskStatus.taskAdditionalMessage }}
Expand Down Expand Up @@ -237,7 +240,7 @@
</q-dialog>
</template>
<script lang="ts">
import { mapState } from 'pinia';
import { mapState, mapWritableState } from 'pinia';
import api from 'src/api/backend-api';
import { ModelInfo_t, ParsingSettings_t, sample_t } from 'src/api/backend-types';
import { useProjectStore } from 'src/pinia/modules/project';
Expand Down Expand Up @@ -299,6 +302,18 @@ export default defineComponent({
components: {
ConfirmAction,
},
beforeRouteLeave(to, from, next) {
if (this.parserData.taskStatus?.taskType == 'PARSING') {
const answer = window.confirm('Do you really want to leave? you have already stared parsing, the new trees will not be saved');
if (answer) {
next();
} else {
next(false);
}
} else {
next();
}
},
props: {
samples: {
type: Array as PropType<sample_t[]>,
Expand Down Expand Up @@ -398,6 +413,7 @@ export default defineComponent({
};
},
computed: {
...mapWritableState(useProjectStore, ['tab']),
...mapState(useProjectStore, ['name']),
...mapState(useUserStore, ['isSuperAdmin', 'username']),
allSamplesNames() {
Expand Down Expand Up @@ -717,10 +733,17 @@ export default defineComponent({
this.clearCurrentTask();
this.parentGetProjectSamples();
notifyMessage({ message: 'Sentences parsing ended!', timeout: 0, });
} else if (this.parserData.taskStatus && Date.now() - this.parserData.taskStatus.taskTimeStarted > TIMEOUT_TASK_STATUS_CHECKER) {
this.tab = 'samples';
}
else if (this.parserData.taskStatus && Date.now() - this.parserData.taskStatus.taskTimeStarted > TIMEOUT_TASK_STATUS_CHECKER) {
// 3 hours
this.clearCurrentTask();
}
else if (this.parserData.taskStatus) {
window.onbeforeunload = function () {
return 'You have already started parsing, if you leave the page the changes will not be saved';
}
}
})
.catch((error) => {
console.log(error);
Expand Down

0 comments on commit 5c19719

Please sign in to comment.