Skip to content

Commit

Permalink
count annotation schema changes for github commits
Browse files Browse the repository at this point in the history
  • Loading branch information
khansadaoudi committed Sep 24, 2024
1 parent 77ac5fc commit ad319bf
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/api/backend-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default {
getProjectConlluSchema(projectName: string) {
return API.get<getProjectConlluSchema_RV>(`projects/${projectName}/conll-schema`);
},
updateProjectConlluSchema(projectName: string, data: updateProjectConlluSchema_ED) {
updateProjectConlluSchema(projectName: string, data: any) {
return API.put(`projects/${projectName}/conll-schema`, data);
},
getProjectUsersAccess(projectName: string) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/project/CreaProjectCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ export default defineComponent({
this.parentGetProjects();
this.submitting = false;
if (this.project.config === 'ud') {
this.updateProjectConlluSchema(this.project.projectName, this.annotationFeaturesUD);
this.updateProjectConlluSchema(this.project.projectName, this.annotationFeaturesUD, false);
} else {
this.updateProjectConlluSchema(this.project.projectName, this.annotationFeaturesSUD);
this.updateProjectConlluSchema(this.project.projectName, this.annotationFeaturesSUD, false);
}
if (this.loggedWithGithub && !this.project.blindAnnotationMode) {
this.progress = 0.4;
Expand Down
16 changes: 13 additions & 3 deletions src/components/project/ProjectSettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
<script lang="ts">
import JsonEditorVue from 'json-editor-vue';
import { mapActions, mapState, mapWritableState } from 'pinia';
import { sample_t } from 'src/api/backend-types';
import { sample_t, annotationFeatures_t } from 'src/api/backend-types';
import { useProjectStore } from 'src/pinia/modules/project';
import { notifyError, notifyMessage } from 'src/utils/notify';
import { PropType, defineComponent } from 'vue';
Expand Down Expand Up @@ -276,7 +276,8 @@ export default defineComponent({
mode: 'text',
tabSize: 4,
indentation: 4,
}
},
currentFeatures: {} as annotationFeatures_t,
};
},
computed: {
Expand Down Expand Up @@ -380,6 +381,7 @@ export default defineComponent({
},
mounted() {
this.annotationFeaturesJson = JSON.stringify(this.annotationFeatures, null, 4);
this.currentFeatures = this.annotationFeatures;
},
watch: {
annotationFeaturesJson(newValue) {
Expand Down Expand Up @@ -407,13 +409,21 @@ export default defineComponent({
}
},
saveAnnotationSettings() {
this.updateProjectConlluSchema(this.projectName, JSON.parse(this.annotationFeaturesJson))
const parsedAnnotFeatures = JSON.parse(this.annotationFeaturesJson);
const featsChanged = JSON.stringify(parsedAnnotFeatures.FEATS) !== JSON.stringify(this.currentFeatures.FEATS);
const miscChanged = JSON.stringify(parsedAnnotFeatures.MISC) !== JSON.stringify(this.currentFeatures.MISC);
const updateCommits = featsChanged || miscChanged // if the feats or misc changed the data in grew will be modified in this case we need to count it as change to commit
this.updateProjectConlluSchema(this.projectName, parsedAnnotFeatures, updateCommits)
.then(() => {
notifyMessage({ message: 'New annotation settings saved on the server', icon: 'save' });
})
.catch((error) => {
notifyError({ error });
});
this.$emit('reload');
},
resetAnnotationFeaturesWrapper() {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
</q-card>
</q-dialog>
<q-dialog v-model="projectSettingsDial">
<ProjectSettingsView :projectName="projectName" :samples="samples" />
<ProjectSettingsView :projectName="projectName" :samples="samples" @reload="loadProjectData()" />
</q-dialog>
<UploadDialog v-model:uploadDial="uploadDial" :samples="samples" @uploaded:sample="loadProjectData()" />
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/pinia/modules/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,12 @@ export const useProjectStore = defineStore('project', {
});
});
},
updateProjectConlluSchema(projectName: string, annotationFeatures: annotationFeatures_t) {
updateProjectConlluSchema(projectName: string, annotationFeatures: annotationFeatures_t, updateCommit: boolean) {
return new Promise((resolve, reject) => {
api
.updateProjectConlluSchema(projectName, {
config: annotationFeatures,
updateCommit: updateCommit
})
.then((response) => {
this.annotationFeatures = annotationFeatures;
Expand Down

0 comments on commit ad319bf

Please sign in to comment.