@konfuzio/document-validation-ui 0.1.1
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/.eslintrc.js +11 -0
- package/.prettierrc.json +1 -0
- package/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/css/app.0c8973f8.css +1 -0
- package/dist/css/chunk-vendors.053b6b6e.css +5 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.html +1 -0
- package/dist/js/app.17fe48c4.js +2 -0
- package/dist/js/app.17fe48c4.js.map +1 -0
- package/dist/js/chunk-vendors.a48fca3f.js +47 -0
- package/dist/js/chunk-vendors.a48fca3f.js.map +1 -0
- package/jest.config.js +4 -0
- package/package.json +60 -0
- package/src/.DS_Store +0 -0
- package/src/api.js +49 -0
- package/src/assets/images/AcceptedCheckMark.vue +8 -0
- package/src/assets/images/AcceptedUser.vue +8 -0
- package/src/assets/images/ActionIcon.vue +60 -0
- package/src/assets/images/ArrowDownKey.vue +11 -0
- package/src/assets/images/ArrowUpKey.vue +11 -0
- package/src/assets/images/CategoryIconImg.vue +13 -0
- package/src/assets/images/CheckMark.vue +8 -0
- package/src/assets/images/EditDocIcon.vue +12 -0
- package/src/assets/images/EmptyStateImg.vue +129 -0
- package/src/assets/images/ErrorIcon.vue +28 -0
- package/src/assets/images/EyeIcon.vue +11 -0
- package/src/assets/images/FileNameNotSavedImage.vue +26 -0
- package/src/assets/images/FileNameSavedImage.vue +14 -0
- package/src/assets/images/FitZoomIcon.vue +16 -0
- package/src/assets/images/KeyboardIcon.vue +16 -0
- package/src/assets/images/MinusIcon.vue +13 -0
- package/src/assets/images/NotOptimizedIllustration.vue +651 -0
- package/src/assets/images/PlusIcon.vue +13 -0
- package/src/assets/images/QuestionMark.vue +12 -0
- package/src/assets/images/ServerImage.vue +63 -0
- package/src/assets/images/SplitLines.vue +18 -0
- package/src/assets/images/SplitZigZag.vue +16 -0
- package/src/assets/images/StatusImg.vue +14 -0
- package/src/assets/images/UserIcon.vue +8 -0
- package/src/assets/scss/annotation_details.scss +126 -0
- package/src/assets/scss/categorize_modal.scss +42 -0
- package/src/assets/scss/choose_label_set_modal.scss +62 -0
- package/src/assets/scss/document_action_bar.scss +37 -0
- package/src/assets/scss/document_annotations.scss +472 -0
- package/src/assets/scss/document_category.scss +80 -0
- package/src/assets/scss/document_dashboard.scss +47 -0
- package/src/assets/scss/document_dataset_status.scss +46 -0
- package/src/assets/scss/document_edit.scss +431 -0
- package/src/assets/scss/document_error.scss +81 -0
- package/src/assets/scss/document_handover.scss +200 -0
- package/src/assets/scss/document_name.scss +62 -0
- package/src/assets/scss/document_page.scss +8 -0
- package/src/assets/scss/document_thumbnails.scss +41 -0
- package/src/assets/scss/document_toolbar.scss +89 -0
- package/src/assets/scss/document_top_bar.scss +139 -0
- package/src/assets/scss/document_viewport_modal.scss +25 -0
- package/src/assets/scss/documents_list.scss +130 -0
- package/src/assets/scss/empty_state.scss +34 -0
- package/src/assets/scss/extracting_data.scss +35 -0
- package/src/assets/scss/imports.scss +1 -0
- package/src/assets/scss/main.scss +24 -0
- package/src/assets/scss/multi_ann_table_popup.scss +12 -0
- package/src/assets/scss/new_annotation.scss +86 -0
- package/src/assets/scss/scrolling_document.scss +19 -0
- package/src/assets/scss/variables.scss +696 -0
- package/src/components/App.vue +112 -0
- package/src/components/DocumentAnnotations/ActionButtons.vue +237 -0
- package/src/components/DocumentAnnotations/AnnotationContent.vue +249 -0
- package/src/components/DocumentAnnotations/AnnotationDetails.vue +292 -0
- package/src/components/DocumentAnnotations/AnnotationRow.vue +616 -0
- package/src/components/DocumentAnnotations/CategorizeModal.vue +159 -0
- package/src/components/DocumentAnnotations/ChooseLabelSetModal.vue +155 -0
- package/src/components/DocumentAnnotations/DocumentAnnotations.vue +502 -0
- package/src/components/DocumentAnnotations/DocumentLabel.vue +148 -0
- package/src/components/DocumentAnnotations/EmptyAnnotation.vue +222 -0
- package/src/components/DocumentAnnotations/EmptyState.vue +21 -0
- package/src/components/DocumentAnnotations/ExtractingData.vue +29 -0
- package/src/components/DocumentAnnotations/LoadingAnnotations.vue +43 -0
- package/src/components/DocumentAnnotations/LoadingLabels.vue +43 -0
- package/src/components/DocumentAnnotations/RejectedLabels.vue +96 -0
- package/src/components/DocumentAnnotations/index.js +8 -0
- package/src/components/DocumentCategory.vue +156 -0
- package/src/components/DocumentDashboard.vue +159 -0
- package/src/components/DocumentEdit/DocumentEdit.vue +279 -0
- package/src/components/DocumentEdit/EditPages.vue +213 -0
- package/src/components/DocumentEdit/EditSidebar.vue +118 -0
- package/src/components/DocumentEdit/SplitOverview.vue +182 -0
- package/src/components/DocumentEdit/index.js +4 -0
- package/src/components/DocumentError.vue +53 -0
- package/src/components/DocumentPage/ActionBar.vue +48 -0
- package/src/components/DocumentPage/BoxSelection.vue +149 -0
- package/src/components/DocumentPage/DocumentPage.vue +517 -0
- package/src/components/DocumentPage/DocumentToolbar.vue +145 -0
- package/src/components/DocumentPage/DummyPage.vue +53 -0
- package/src/components/DocumentPage/MultiAnnSelection.vue +302 -0
- package/src/components/DocumentPage/MultiAnnotationTablePopup.vue +253 -0
- package/src/components/DocumentPage/NewAnnotation.vue +283 -0
- package/src/components/DocumentPage/ScrollingDocument.vue +108 -0
- package/src/components/DocumentPage/ScrollingPage.vue +184 -0
- package/src/components/DocumentPage/index.js +5 -0
- package/src/components/DocumentThumbnails/DocumentThumbnails.vue +92 -0
- package/src/components/DocumentThumbnails/LoadingThumbnail.vue +25 -0
- package/src/components/DocumentThumbnails/index.js +1 -0
- package/src/components/DocumentTopBar/DocumentDatasetStatus.vue +103 -0
- package/src/components/DocumentTopBar/DocumentHandover.vue +202 -0
- package/src/components/DocumentTopBar/DocumentName.vue +224 -0
- package/src/components/DocumentTopBar/DocumentTopBar.vue +144 -0
- package/src/components/DocumentTopBar/DocumentTopBarButtons.vue +148 -0
- package/src/components/DocumentTopBar/KeyboardActionsDescription.vue +71 -0
- package/src/components/DocumentTopBar/index.js +5 -0
- package/src/components/DocumentsList/DocumentsList.vue +126 -0
- package/src/components/DocumentsList/index.js +1 -0
- package/src/components/ErrorMessage.vue +40 -0
- package/src/components/NotOptimizedViewportModal.vue +54 -0
- package/src/constants.js +4 -0
- package/src/directives/scroll.js +28 -0
- package/src/i18n.js +23 -0
- package/src/locales/de.json +114 -0
- package/src/locales/en.json +114 -0
- package/src/locales/es.json +113 -0
- package/src/main.js +87 -0
- package/src/store/category.js +193 -0
- package/src/store/display.js +238 -0
- package/src/store/document.js +1057 -0
- package/src/store/edit.js +210 -0
- package/src/store/index.js +22 -0
- package/src/store/project.js +95 -0
- package/src/store/selection.js +179 -0
- package/src/utils/utils.js +3 -0
- package/vue.config.js +13 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import {
|
|
3
|
+
PIXEL_RATIO,
|
|
4
|
+
VIEWPORT_RATIO,
|
|
5
|
+
MINIMUM_APP_WIDTH,
|
|
6
|
+
MINIMUM_OPTIMIZED_APP_WIDTH,
|
|
7
|
+
} from "../constants";
|
|
8
|
+
const debounce = (cb, duration) => {
|
|
9
|
+
let timer;
|
|
10
|
+
return (...args) => {
|
|
11
|
+
clearTimeout(timer);
|
|
12
|
+
timer = setTimeout(() => {
|
|
13
|
+
cb(...args);
|
|
14
|
+
}, duration);
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const floor = (value, precision) => {
|
|
19
|
+
const multiplier = Math.pow(10, precision || 0);
|
|
20
|
+
return Math.floor(value * multiplier) / multiplier;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const state = {
|
|
24
|
+
scale: undefined,
|
|
25
|
+
optimalScale: undefined,
|
|
26
|
+
fit: "width",
|
|
27
|
+
currentPage: 1,
|
|
28
|
+
optimalResolution: true,
|
|
29
|
+
interactionBlocked: false,
|
|
30
|
+
documentActionBar: null, // document action bar properties
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const getters = {
|
|
34
|
+
isMinimumWidth: (state) => (width) => {
|
|
35
|
+
return width >= MINIMUM_APP_WIDTH;
|
|
36
|
+
},
|
|
37
|
+
pageWidthScale: (state) => (elementsWidth, clientWidth, viewportWidth) => {
|
|
38
|
+
return (
|
|
39
|
+
((clientWidth - elementsWidth) * PIXEL_RATIO * VIEWPORT_RATIO) /
|
|
40
|
+
viewportWidth
|
|
41
|
+
);
|
|
42
|
+
},
|
|
43
|
+
pageHeightScale: (state) => (clientHeight, viewportHeight) => {
|
|
44
|
+
return (clientHeight * PIXEL_RATIO * VIEWPORT_RATIO) / viewportHeight;
|
|
45
|
+
},
|
|
46
|
+
visiblePageRange: (state, getters, rootState, rootGetters) => {
|
|
47
|
+
const pageCount = rootGetters.pageCount;
|
|
48
|
+
const previousPage = state.currentPage - 1 < 1 ? 1 : state.currentPage - 1;
|
|
49
|
+
const nextPage =
|
|
50
|
+
state.currentPage + 1 > pageCount ? pageCount : state.currentPage + 1;
|
|
51
|
+
return [previousPage, state.currentPage, nextPage];
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The proportion between the original size of the page and the
|
|
56
|
+
* image rendering.
|
|
57
|
+
*/
|
|
58
|
+
imageScale: (state) => (page) => {
|
|
59
|
+
return new BigNumber(page.size[0]).div(page.original_size[0]).toNumber();
|
|
60
|
+
},
|
|
61
|
+
bboxToRect:
|
|
62
|
+
(state, getters) =>
|
|
63
|
+
(page, bbox, hasOffset = false) => {
|
|
64
|
+
const imageScale = getters.imageScale(page);
|
|
65
|
+
const { x0, x1, y0, y1 } = bbox;
|
|
66
|
+
const pageHeight = new BigNumber(page.original_size[1]);
|
|
67
|
+
const rect = {
|
|
68
|
+
// left
|
|
69
|
+
x: new BigNumber(x0)
|
|
70
|
+
.minus(hasOffset ? 1 : 0)
|
|
71
|
+
.times(state.scale)
|
|
72
|
+
.times(imageScale)
|
|
73
|
+
.div(PIXEL_RATIO)
|
|
74
|
+
.toNumber(),
|
|
75
|
+
// top
|
|
76
|
+
y: pageHeight
|
|
77
|
+
.minus(new BigNumber(y1))
|
|
78
|
+
.minus(hasOffset ? 17.1 : 0)
|
|
79
|
+
.times(state.scale)
|
|
80
|
+
.times(imageScale)
|
|
81
|
+
.div(PIXEL_RATIO)
|
|
82
|
+
.toNumber(),
|
|
83
|
+
width: new BigNumber(x1)
|
|
84
|
+
.minus(x0)
|
|
85
|
+
.abs()
|
|
86
|
+
.times(state.scale)
|
|
87
|
+
.times(imageScale)
|
|
88
|
+
.div(PIXEL_RATIO)
|
|
89
|
+
.toNumber(),
|
|
90
|
+
height: new BigNumber(y1)
|
|
91
|
+
.minus(y0)
|
|
92
|
+
.times(state.scale)
|
|
93
|
+
.times(imageScale)
|
|
94
|
+
.div(PIXEL_RATIO)
|
|
95
|
+
.toNumber(),
|
|
96
|
+
};
|
|
97
|
+
return rect;
|
|
98
|
+
},
|
|
99
|
+
clientToBbox: (state, getters) => (page, start, end) => {
|
|
100
|
+
/**
|
|
101
|
+
* The backend bbox's `y0` and `y1` attributes depend on knowing the
|
|
102
|
+
* page's height.
|
|
103
|
+
*/
|
|
104
|
+
const pageHeight = new BigNumber(page.original_size[1]);
|
|
105
|
+
const imageScale = getters.imageScale(page);
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* We use `Math.min` and `Math.max` because depending on how the area
|
|
109
|
+
* selection is made the `start` and `end` attributes might be reversed.
|
|
110
|
+
*/
|
|
111
|
+
const x0 = new BigNumber(Math.min(start.x, end.x))
|
|
112
|
+
.div(state.scale)
|
|
113
|
+
.div(imageScale)
|
|
114
|
+
.times(PIXEL_RATIO)
|
|
115
|
+
.dp(3, BigNumber.ROUND_DOWN)
|
|
116
|
+
.toNumber();
|
|
117
|
+
const x1 = new BigNumber(Math.max(start.x, end.x))
|
|
118
|
+
.div(state.scale)
|
|
119
|
+
.div(imageScale)
|
|
120
|
+
.times(PIXEL_RATIO)
|
|
121
|
+
.dp(3, BigNumber.ROUND_UP)
|
|
122
|
+
.toNumber();
|
|
123
|
+
const top = new BigNumber(Math.min(start.y, end.y))
|
|
124
|
+
.div(state.scale)
|
|
125
|
+
.div(imageScale)
|
|
126
|
+
.times(PIXEL_RATIO)
|
|
127
|
+
.dp(3)
|
|
128
|
+
.toNumber();
|
|
129
|
+
const bottom = new BigNumber(Math.max(start.y, end.y))
|
|
130
|
+
.div(state.scale)
|
|
131
|
+
.div(imageScale)
|
|
132
|
+
.times(PIXEL_RATIO)
|
|
133
|
+
.dp(3)
|
|
134
|
+
.toNumber();
|
|
135
|
+
const y0 = pageHeight.minus(bottom).dp(3, BigNumber.ROUND_DOWN).toNumber();
|
|
136
|
+
const y1 = pageHeight.minus(top).dp(3, BigNumber.ROUND_UP).toNumber();
|
|
137
|
+
|
|
138
|
+
const bbox = {
|
|
139
|
+
x0,
|
|
140
|
+
x1,
|
|
141
|
+
y0,
|
|
142
|
+
y1,
|
|
143
|
+
page_index: page.number - 1,
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
return bbox;
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const actions = {
|
|
151
|
+
updateScale({ commit, getters }, { elementsWidth, client, viewport, scale }) {
|
|
152
|
+
/**
|
|
153
|
+
* Determine an ideal scale using viewport of document's first page, the pixel ratio
|
|
154
|
+
* from the browser and a subjective scale factor based on the screen size.
|
|
155
|
+
*/
|
|
156
|
+
switch (state.fit) {
|
|
157
|
+
case "width":
|
|
158
|
+
commit(
|
|
159
|
+
"SET_SCALE",
|
|
160
|
+
getters.pageWidthScale(elementsWidth, client.width, viewport.width)
|
|
161
|
+
);
|
|
162
|
+
break;
|
|
163
|
+
case "auto":
|
|
164
|
+
const pageWidthScale = getters.pageWidthScale(
|
|
165
|
+
elementsWidth,
|
|
166
|
+
client.width,
|
|
167
|
+
viewport.width
|
|
168
|
+
);
|
|
169
|
+
const pageHeightScale = getters.pageWidthScale(
|
|
170
|
+
client.height,
|
|
171
|
+
viewport.height
|
|
172
|
+
);
|
|
173
|
+
const autoScale = Math.min(pageWidthScale, pageHeightScale);
|
|
174
|
+
commit("SET_SCALE", autoScale);
|
|
175
|
+
break;
|
|
176
|
+
case "custom": {
|
|
177
|
+
if (scale) {
|
|
178
|
+
commit("SET_SCALE", scale);
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
default:
|
|
183
|
+
console.log("No fit defined");
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
updateFit({ commit }, fit) {
|
|
189
|
+
commit("SET_FIT", fit);
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
debounceUpdateCurrentPage: debounce(({ commit, dispatch }, pageNumber) => {
|
|
193
|
+
dispatch("updateCurrentPage", pageNumber);
|
|
194
|
+
}, 300),
|
|
195
|
+
|
|
196
|
+
updateCurrentPage({ commit }, pageNumber) {
|
|
197
|
+
commit("SET_CURRENT_PAGE", pageNumber);
|
|
198
|
+
},
|
|
199
|
+
updateOptimalResolution({ commit }, width) {
|
|
200
|
+
commit("SET_OPTIMAL_RESOLUTION", width >= MINIMUM_OPTIMIZED_APP_WIDTH);
|
|
201
|
+
},
|
|
202
|
+
showDocumentActionBar({ commit }, { icon, text, action, show, loading }) {
|
|
203
|
+
commit(
|
|
204
|
+
"SET_DOCUMENT_ACTION_BAR",
|
|
205
|
+
show ? { icon, text, action, loading } : null
|
|
206
|
+
);
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const mutations = {
|
|
211
|
+
SET_SCALE: (state, scale) => {
|
|
212
|
+
state.scale = floor(scale, 2);
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
SET_FIT: (state, fit) => {
|
|
216
|
+
state.fit = fit;
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
SET_OPTIMAL_RESOLUTION: (state, isOptimal) => {
|
|
220
|
+
state.optimalResolution = isOptimal;
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
SET_CURRENT_PAGE: (state, currentPage) => {
|
|
224
|
+
state.currentPage = currentPage;
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
SET_DOCUMENT_ACTION_BAR: (state, actionBar) => {
|
|
228
|
+
state.documentActionBar = actionBar;
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export default {
|
|
233
|
+
namespaced: true,
|
|
234
|
+
state,
|
|
235
|
+
getters,
|
|
236
|
+
actions,
|
|
237
|
+
mutations,
|
|
238
|
+
};
|