@konfuzio/document-validation-ui 0.1.44-dev.1 → 0.1.44-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/app.css +1 -1
- package/dist/index.html +1 -1
- package/dist/js/app.js +1 -1
- package/dist/js/app.js.map +1 -1
- package/package.json +1 -1
- package/src/api.js +3 -3
- package/src/components/DocumentAnnotations/ChooseLabelSetModal.vue +4 -3
- package/src/components/DocumentAnnotations/DocumentAnnotations.vue +0 -35
- package/src/components/DocumentPage/NewAnnotation.vue +10 -1
- package/src/store/document.js +36 -19
- package/src/store/project.js +0 -26
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -4,8 +4,7 @@ let HTTP, FILE_REQUEST, authToken, appLocale;
|
|
|
4
4
|
const DEFAULT_URL = "https://app.konfuzio.com";
|
|
5
5
|
const FILE_URL = process.env.VUE_APP_IMAGE_URL;
|
|
6
6
|
|
|
7
|
-
axios.defaults.
|
|
8
|
-
axios.defaults.xsrfHeaderName = "X-CSRFToken";
|
|
7
|
+
axios.defaults.withCredentials = true;
|
|
9
8
|
|
|
10
9
|
HTTP = axios.create({
|
|
11
10
|
baseURL: process.env.VUE_APP_API_URL || `${DEFAULT_URL}/api/v3/`,
|
|
@@ -35,8 +34,9 @@ const setLocale = (locale) => {
|
|
|
35
34
|
const getInterceptorConfig = (config) => {
|
|
36
35
|
if (authToken) {
|
|
37
36
|
config.headers["Authorization"] = `Token ${authToken}`;
|
|
38
|
-
config.headers["Accept-Language"] = `${appLocale}-${appLocale}`;
|
|
39
37
|
}
|
|
38
|
+
config.headers["Accept-Language"] = `${appLocale}-${appLocale}`;
|
|
39
|
+
|
|
40
40
|
return config;
|
|
41
41
|
};
|
|
42
42
|
|
|
@@ -75,12 +75,13 @@ export default {
|
|
|
75
75
|
data() {
|
|
76
76
|
return {
|
|
77
77
|
show: true,
|
|
78
|
-
labels: [],
|
|
79
78
|
};
|
|
80
79
|
},
|
|
81
80
|
computed: {
|
|
82
|
-
...mapGetters("
|
|
83
|
-
|
|
81
|
+
...mapGetters("document", [
|
|
82
|
+
"numberOfLabelSetGroup",
|
|
83
|
+
"labelSetsFilteredForAnnotationSetCreation",
|
|
84
|
+
]),
|
|
84
85
|
},
|
|
85
86
|
methods: {
|
|
86
87
|
submit(labelSet) {
|
|
@@ -18,46 +18,12 @@
|
|
|
18
18
|
<LoadingAnnotations />
|
|
19
19
|
</div>
|
|
20
20
|
</div>
|
|
21
|
-
|
|
22
|
-
<!-- When there's no annotation sets but show label sets for annotation creation-->
|
|
23
21
|
<div
|
|
24
22
|
v-else-if="
|
|
25
23
|
getAnnotationsFiltered.annotationSets.length === 0 &&
|
|
26
|
-
labelSets &&
|
|
27
|
-
labelSets.length > 0 &&
|
|
28
24
|
!isSearchingAnnotationList
|
|
29
25
|
"
|
|
30
26
|
class="empty-annotation-sets"
|
|
31
|
-
>
|
|
32
|
-
<div class="annotation-set-list">
|
|
33
|
-
<div
|
|
34
|
-
v-for="labelSet in labelSets"
|
|
35
|
-
:key="labelSet.id"
|
|
36
|
-
class="annotation-set-group"
|
|
37
|
-
>
|
|
38
|
-
<div class="label-set-header">
|
|
39
|
-
<div class="label-set-name">
|
|
40
|
-
{{ `${labelSet.name}` }}
|
|
41
|
-
</div>
|
|
42
|
-
</div>
|
|
43
|
-
|
|
44
|
-
<div v-if="labelSet.labels.length > 0">
|
|
45
|
-
<div v-for="label in labelSet.labels" :key="label.id">
|
|
46
|
-
<div class="labels">
|
|
47
|
-
<DocumentLabel :label="label" :label-set="labelSet" />
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
<div
|
|
55
|
-
v-else-if="
|
|
56
|
-
getAnnotationsFiltered.annotationSets.length === 0 &&
|
|
57
|
-
!isSearchingAnnotationList &&
|
|
58
|
-
(!labelSets || labelSets.length === 0)
|
|
59
|
-
"
|
|
60
|
-
class="empty-annotation-sets"
|
|
61
27
|
>
|
|
62
28
|
<EmptyState />
|
|
63
29
|
</div>
|
|
@@ -236,7 +202,6 @@ export default {
|
|
|
236
202
|
"selectedDocument",
|
|
237
203
|
"splittingSuggestions",
|
|
238
204
|
]),
|
|
239
|
-
...mapState("project", ["labelSets"]),
|
|
240
205
|
...mapGetters("document", [
|
|
241
206
|
"numberOfAnnotationSetGroup",
|
|
242
207
|
"getAnnotationsFiltered",
|
|
@@ -329,12 +329,21 @@ export default {
|
|
|
329
329
|
});
|
|
330
330
|
},
|
|
331
331
|
chooseLabelSet(labelSet) {
|
|
332
|
+
// check if there's already a new entry for that label set to be created
|
|
333
|
+
const existsIndex = this.setsList.findIndex((set) => {
|
|
334
|
+
return set.id === null && set.label_set.id === labelSet.id;
|
|
335
|
+
});
|
|
336
|
+
|
|
332
337
|
const newSet = {
|
|
333
338
|
label_set: labelSet,
|
|
334
339
|
labels: labelSet.labels,
|
|
335
340
|
id: null,
|
|
336
341
|
};
|
|
337
|
-
|
|
342
|
+
if (existsIndex >= 0) {
|
|
343
|
+
this.setsList[existsIndex] = newSet;
|
|
344
|
+
} else {
|
|
345
|
+
this.setsList.push(newSet);
|
|
346
|
+
}
|
|
338
347
|
this.selectedSet = newSet;
|
|
339
348
|
},
|
|
340
349
|
openAnnotationSetCreation() {
|
package/src/store/document.js
CHANGED
|
@@ -440,19 +440,17 @@ const getters = {
|
|
|
440
440
|
let processedLabels = [];
|
|
441
441
|
|
|
442
442
|
annotationSets.forEach((annotationSet) => {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
const labelAnnotations = [];
|
|
443
|
+
labels = [];
|
|
444
|
+
annotationSet.labels.forEach((label) => {
|
|
445
|
+
const labelAnnotations = [];
|
|
447
446
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
}
|
|
447
|
+
// add annotations to the document array
|
|
448
|
+
labelAnnotations.push(...label.annotations);
|
|
449
|
+
labels.push({ ...label, annotations: labelAnnotations });
|
|
450
|
+
processedLabels.push(label);
|
|
451
|
+
annotations.push(...labelAnnotations);
|
|
452
|
+
});
|
|
453
|
+
processedAnnotationSets.push({ ...annotationSet, labels });
|
|
456
454
|
});
|
|
457
455
|
return {
|
|
458
456
|
annotationSets: processedAnnotationSets,
|
|
@@ -523,20 +521,43 @@ const getters = {
|
|
|
523
521
|
orderedAnnotationSets.sort((a, b) => {
|
|
524
522
|
return a.id - b.id || a.label_set.name.localeCompare(b.label_set.name);
|
|
525
523
|
});
|
|
526
|
-
orderedAnnotationSets.
|
|
524
|
+
orderedAnnotationSets.forEach((annotationSetTemp) => {
|
|
527
525
|
if (
|
|
528
526
|
annotationSetTemp.label_set.id === labelSet.id &&
|
|
529
527
|
annotationSetTemp.label_set.name === labelSet.name
|
|
530
528
|
) {
|
|
531
529
|
found = true;
|
|
532
|
-
|
|
530
|
+
// check if annotation set exists, otherwise it will be new
|
|
531
|
+
if (annotationSetTemp.id) {
|
|
532
|
+
index++;
|
|
533
|
+
}
|
|
533
534
|
}
|
|
534
535
|
});
|
|
535
|
-
return found ? `${index + 1}` : "";
|
|
536
|
+
return found ? (index === 0 ? "" : `${index + 1}`) : "";
|
|
536
537
|
}
|
|
537
538
|
return "";
|
|
538
539
|
},
|
|
539
540
|
|
|
541
|
+
/**
|
|
542
|
+
* Gets label sets for an annotation set creation
|
|
543
|
+
*/
|
|
544
|
+
labelSetsFilteredForAnnotationSetCreation: (state) => {
|
|
545
|
+
let returnLabelSets = [];
|
|
546
|
+
if (state.annotationSets) {
|
|
547
|
+
state.annotationSets.forEach((annotationSet) => {
|
|
548
|
+
if (
|
|
549
|
+
annotationSet.id == null ||
|
|
550
|
+
annotationSet.label_set.has_multiple_annotation_sets
|
|
551
|
+
) {
|
|
552
|
+
const labelSet = { ...annotationSet.label_set };
|
|
553
|
+
labelSet.labels = [...annotationSet.labels];
|
|
554
|
+
returnLabelSets.push(labelSet);
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
return returnLabelSets;
|
|
559
|
+
},
|
|
560
|
+
|
|
540
561
|
/**
|
|
541
562
|
* Get label with annotations filtered if the label supports multiple or not
|
|
542
563
|
*/
|
|
@@ -1071,10 +1092,6 @@ const actions = {
|
|
|
1071
1092
|
if (!state.publicView) {
|
|
1072
1093
|
await dispatch("fetchMissingAnnotations");
|
|
1073
1094
|
|
|
1074
|
-
await dispatch("project/fetchLabelSets", null, {
|
|
1075
|
-
root: true,
|
|
1076
|
-
});
|
|
1077
|
-
|
|
1078
1095
|
await dispatch("project/fetchCurrentUser", null, {
|
|
1079
1096
|
root: true,
|
|
1080
1097
|
});
|
package/src/store/project.js
CHANGED
|
@@ -10,31 +10,6 @@ const state = {
|
|
|
10
10
|
showAnnotationTranslations: false,
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const getters = {
|
|
14
|
-
/**
|
|
15
|
-
* Gets label sets for an annotation set creation
|
|
16
|
-
*/
|
|
17
|
-
labelSetsFilteredForAnnotationSetCreation: (state, _, rootState) => {
|
|
18
|
-
let returnLabels = [];
|
|
19
|
-
if (state.labelSets) {
|
|
20
|
-
returnLabels = state.labelSets.filter((labelSet) => {
|
|
21
|
-
// check if label set has multiple and if not, if there's already an annotation set created
|
|
22
|
-
if (!labelSet.has_multiple_annotation_sets) {
|
|
23
|
-
const existingAnnotationSet = rootState.document.annotationSets.find(
|
|
24
|
-
(annSet) => {
|
|
25
|
-
return annSet.label_set.id === labelSet.id;
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
return !existingAnnotationSet;
|
|
29
|
-
} else {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return returnLabels;
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
13
|
const actions = {
|
|
39
14
|
setProjectId: ({ commit }, projectId) => {
|
|
40
15
|
commit("SET_PROJECT_ID", projectId);
|
|
@@ -131,5 +106,4 @@ export default {
|
|
|
131
106
|
state,
|
|
132
107
|
actions,
|
|
133
108
|
mutations,
|
|
134
|
-
getters,
|
|
135
109
|
};
|