Skip to content

Commit

Permalink
display message when we refresh browser while parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
khansadaoudi committed Nov 5, 2024
1 parent 5c19719 commit f62fc91
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/parsing/ParsingPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ export default defineComponent({
this.clearCurrentTask();
} else if (response.data.data.ready) {
this.clearCurrentTask();
this.$emit('parsing-status', '');
this.parentGetProjectSamples();
notifyMessage({ message: 'Sentences parsing ended!', timeout: 0, });
this.tab = 'samples';
Expand All @@ -739,7 +740,8 @@ export default defineComponent({
// 3 hours
this.clearCurrentTask();
}
else if (this.parserData.taskStatus) {
else if (this.parserData.taskStatus?.taskType === 'PARSING') {
this.$emit('parsing-status', this.parserData.taskStatus.taskType);
window.onbeforeunload = function () {
return 'You have already started parsing, if you leave the page the changes will not be saved';
}
Expand Down
19 changes: 18 additions & 1 deletion src/pages/Project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<GrewSearch :search-scope="projectName" :samples="samples" @reload="loadProjectData" :key="reloadGrew" />
</q-tab-panel>
<q-tab-panel class="q-pa-none" name="parser">
<ParsingPanel :samples="samples" :parentGetProjectSamples="getProjectSamples"></ParsingPanel>
<ParsingPanel :samples="samples" :parentGetProjectSamples="getProjectSamples" @parsing-status="getParsingStatus"></ParsingPanel>
</q-tab-panel>
<q-tab-panel class="q-pa-none" name="lexicon">
<LexiconMain :samples="samples"></LexiconMain>
Expand Down Expand Up @@ -179,6 +179,19 @@ export default defineComponent({
StatisticsProject,
Breadcrumbs,
},
beforeRouteLeave(to, from, next) {
if (this.parsingStatus == '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) {
this.parsingStatus = '';
next();
} else {
next(false);
}
} else {
next();
}
},
data() {
const samples: sample_t[] = [];
const selectedSamples: sample_t[] = [];
Expand All @@ -195,6 +208,7 @@ export default defineComponent({
showStats: false,
syncGithubRepo: '',
reload: 0,
parsingStatus: '',
};
},
computed: {
Expand Down Expand Up @@ -273,6 +287,9 @@ export default defineComponent({
notifyError({ error });
});
},
getParsingStatus(value: any) {
this.parsingStatus = value as string;
}
},
});
</script>

0 comments on commit f62fc91

Please sign in to comment.