Skip to content

Commit f8a0a5f

Browse files
committed
refactor: cleaned up the UI a bit
1 parent 986a8a9 commit f8a0a5f

File tree

10 files changed

+116
-107
lines changed

10 files changed

+116
-107
lines changed

src/App.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@
88
@drop.stop.prevent="onDrop"
99
>
1010
<div :style="{ 'pointer-events': overlayActive ? 'none' : 'auto' }">
11-
<q-layout view="hHh lpR fFf">
11+
<q-layout view="hHh lpR lFf">
1212
<menu-bar />
1313

14-
<q-drawer bordered :class="$q.dark.isActive ? 'bg-dark' : 'bg-grey-2'">
14+
<q-drawer
15+
behavior="desktop"
16+
bordered
17+
side="left"
18+
:model-value="currentPage === 'annotate'"
19+
:class="$q.dark.isActive ? 'bg-dark' : 'bg-grey-2'"
20+
>
1521
<annotation-sidebar />
1622
</q-drawer>
1723

src/components/AnnotationPage.vue

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
<template>
22
<div>
33
<classes-block />
4-
<div
5-
class="q-pa-lg"
6-
style="height:60vh; overflow-y:scroll;"
7-
>
4+
<div class="q-pa-lg" style="height: 60vh; overflow-y: scroll">
85
<component
96
:is="t.type === 'token' ? 'Token' : 'TokenBlock'"
107
v-for="t in tm.tokens"
@@ -16,10 +13,7 @@
1613
/>
1714
</div>
1815

19-
<div
20-
class="q-pa-md"
21-
style="border-top: 1px solid #ccc"
22-
>
16+
<div class="q-pa-md" style="border-top: 1px solid #ccc">
2317
<q-btn
2418
color="red"
2519
outline
@@ -67,7 +61,7 @@ export default {
6761
TokenBlock,
6862
ClassesBlock,
6963
},
70-
data: function() {
64+
data: function () {
7165
return {
7266
tm: new TokenManager([]),
7367
currentSentence: {},
@@ -101,14 +95,14 @@ export default {
10195
},
10296
annotationPrecision() {
10397
this.tokenizeCurrentSentence();
104-
}
98+
},
10599
},
106100
created() {
107101
if (this.inputSentences.length) {
108102
this.tokenizeCurrentSentence();
109103
}
110104
document.addEventListener("mouseup", this.selectTokens);
111-
document.addEventListener('keydown', this.keypress);
105+
document.addEventListener("keydown", this.keypress);
112106
},
113107
beforeUnmount() {
114108
document.removeEventListener("mouseup", this.selectTokens);
@@ -118,19 +112,23 @@ export default {
118112
...mapMutations(["nextSentence", "previousSentence", "resetIndex"]),
119113
keypress(event) {
120114
if (!this.enableKeyboardShortcuts) {
121-
return
115+
return;
122116
}
123-
if (event.keyCode == 32) { // Space
117+
if (event.keyCode == 32) {
118+
// Space
124119
this.saveTags();
125-
} else if (event.keyCode == 39) { // right arrow
120+
} else if (event.keyCode == 39) {
121+
// right arrow
126122
this.skipCurrentSentence();
127-
} else if (event.keyCode == 37) { // left arrow
123+
} else if (event.keyCode == 37) {
124+
// left arrow
128125
this.backOneSentence();
129-
} else if (event.keyCode == 82 || event.keyCode == 27) { // r / R or ESC
126+
} else if (event.keyCode == 82 || event.keyCode == 27) {
127+
// r / R or ESC
130128
this.resetBlocks();
131129
}
132130
// stop event from bubbling up
133-
event.stopPropagation()
131+
event.stopPropagation();
134132
},
135133
tokenizeCurrentSentence() {
136134
this.currentSentence = this.inputSentences[this.currentIndex];
@@ -139,8 +137,8 @@ export default {
139137
let tokens, spans;
140138
141139
if (this.$store.state.annotationPrecision == "char") {
142-
tokens = this.currentSentence.text.split('');
143-
spans = []
140+
tokens = this.currentSentence.text.split("");
141+
spans = [];
144142
for (let i = 0; i < this.currentSentence.text.length; i++) {
145143
spans.push([i, i + 1]);
146144
}
@@ -163,22 +161,26 @@ export default {
163161
) {
164162
return;
165163
}
166-
164+
167165
const rangeStart = selection.getRangeAt(0);
168166
const rangeEnd = selection.getRangeAt(selection.rangeCount - 1);
169167
let start, end;
170168
try {
171-
start = parseInt(rangeStart.startContainer.parentElement.id.replace("t", ""));
172-
let offsetEnd = parseInt(rangeEnd.endContainer.parentElement.id.replace("t", ""));
169+
start = parseInt(
170+
rangeStart.startContainer.parentElement.id.replace("t", "")
171+
);
172+
let offsetEnd = parseInt(
173+
rangeEnd.endContainer.parentElement.id.replace("t", "")
174+
);
173175
end = offsetEnd + rangeEnd.endOffset;
174-
if(!end){
175-
/*
176-
If last node of selected text contains tag name
176+
if (!end) {
177+
/*
178+
If last node of selected text contains tag name
177179
Fetch the previous node
178180
*/
179181
const endContainerParent = rangeEnd.endContainer.parentNode;
180182
const previousNode = endContainerParent.previousSibling;
181-
offsetEnd = parseInt(previousNode.parentElement.id.replace("t",""))
183+
offsetEnd = parseInt(previousNode.parentElement.id.replace("t", ""));
182184
end = offsetEnd + rangeEnd.endOffset;
183185
}
184186
} catch {
@@ -192,7 +194,7 @@ export default {
192194
selection.empty();
193195
return;
194196
}
195-
197+
196198
this.tm.addNewBlock(start, end, this.currentClass);
197199
selection.empty();
198200
},

src/components/HelpDialog.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
<q-card>
44
<q-bar>
55
<q-space />
6-
<q-btn dense flat icon="close" v-close-popup @click="$emit('hide')">
6+
<q-btn
7+
dense
8+
flat
9+
icon="fa fa-close"
10+
v-close-popup
11+
@click="$emit('hide')"
12+
>
713
<q-tooltip class="bg-white text-primary">Close</q-tooltip>
814
</q-btn>
915
</q-bar>

src/components/StartPage.vue

Lines changed: 47 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,61 @@
11
<template>
22
<div class="q-mx-auto q-my-xl" style="max-width: 600px">
33
<h1 class="text-h4 q-mb-sm text-center">NER Text Annotator</h1>
4-
<p class="text-caption text-center">
4+
<p class="text-subtitle1 text-center">
55
Annotate text for spaCy NER Model training
66
</p>
77

88
<div class="q-my-xl q-py-md column">
9-
<div class="row justify-between items-center">
10-
<div>
11-
<p
12-
:class="[
13-
'text-h6 q-my-md',
14-
$q.dark.isActive ? 'text-grey-4' : 'text-grey-7',
15-
]"
16-
>
17-
Select your file(s), then press 'Begin'!
18-
</p>
19-
<p
20-
:class="[
21-
'text-subtitle1 q-my-md',
22-
$q.dark.isActive ? 'text-grey-4' : 'text-grey-7',
23-
]"
24-
>
25-
Hint: You can also drag and drop files into this window!
26-
</p>
27-
</div>
28-
<q-btn
29-
v-close-popup
30-
outline
31-
label="Begin!"
32-
:color="!textFile ? 'grey-7' : 'blue'"
33-
:disable="!textFile"
34-
@click="onConfirmation"
35-
/>
36-
</div>
37-
<div class="row items-center">
9+
<div class="row justify-around q-my-xl">
3810
<q-file
3911
class="col-5 q-mx-sm"
4012
v-model="textFile"
4113
accept=".txt"
4214
filled
43-
label="Text file"
44-
:bg-color="$q.dark.isActive ? 'black-1' : 'light-blue-1'"
45-
@rejected="fileSelectionError('Invalid text file')"
15+
label="Open text file"
16+
color="primary"
17+
@rejected="
18+
fileSelectionError(
19+
'Only text files (.txt) can be used for creating annotations.'
20+
)
21+
"
4622
>
47-
<template #prepend>
48-
<q-icon name="fas fa-upload" />
49-
</template>
50-
</q-file>
51-
<q-file
52-
class="col-5 q-mx-sm"
53-
v-model="annotationFile"
54-
accept=".json"
55-
filled
56-
label="(Optional) Annotations"
57-
:bg-color="$q.dark.isActive ? 'black-1' : 'light-blue-1'"
58-
@rejected="fileSelectionError('Invalid annotation file')"
59-
>
60-
<template #prepend>
61-
<q-icon name="fas fa-upload" />
23+
<template v-slot:prepend>
24+
<q-icon name="fas fa-file-text" />
6225
</template>
6326
</q-file>
27+
<div>
28+
<q-file
29+
class="col-5 q-mx-sm"
30+
v-model="annotationFile"
31+
accept=".json"
32+
filled
33+
label="Load Annotations"
34+
color="teal"
35+
@rejected="fileSelectionError('Invalid annotation file')"
36+
>
37+
<template #prepend>
38+
<q-icon name="fas fa-file-code" />
39+
</template>
40+
</q-file>
41+
<p class="text-caption q-mx-sm q-my-sm text-grey-8">Optional</p>
42+
</div>
43+
</div>
44+
45+
<div class="row">
46+
<p class="col-12 q-my-md text-blue-7 text-center">
47+
<q-icon name="fa fa-lightbulb" />
48+
You can also drag and drop files into this window!
49+
</p>
50+
</div>
51+
<div class="row justify-center q-my-xl">
52+
<q-btn
53+
v-close-popup
54+
label="Start Annotating"
55+
class="full-width"
56+
color="primary"
57+
@click="onConfirmation"
58+
/>
6459
</div>
6560
</div>
6661
</div>
@@ -112,11 +107,11 @@ export default {
112107
},
113108
fileSelectionError(msg) {
114109
this.$q.notify({
115-
icon: "fas fa-exclamation-circle",
110+
type: "negative",
111+
icon: "fas fa-explosion",
116112
message: msg,
117-
color: "red-6",
118-
position: "top",
119-
timeout: 2000,
113+
position: "center",
114+
timeout: 5000,
120115
actions: [{ label: "Dismiss", color: "white" }],
121116
});
122117
},

src/components/TokenBlock.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default {
3939
},
4040
},
4141
emits: ["remove-block"],
42-
data: function() {
42+
data: function () {
4343
return {
4444
showClose: false,
4545
};
@@ -48,20 +48,19 @@ export default {
4848
</script>
4949

5050
<style lang="scss">
51-
@import 'quasar/src/css/variables';
51+
@import "quasar/src/css/variables";
5252
5353
mark {
5454
padding: 0.5rem;
5555
position: relative;
5656
background-color: burlywood;
57-
border: 1px solid $grey-7;
58-
border-radius: 0.35rem;
57+
box-shadow: 2px 2px 4px rgba(180, 180, 180, 0.4);
58+
border-radius: 0.25rem;
5959
}
6060
.tag {
6161
background-color: whitesmoke;
6262
padding: 4px 0 4px 8px;
63-
border: 1px solid grey;
64-
border-radius: 0.35rem;
63+
border-radius: 0.25rem;
6564
font-size: x-small;
6665
}
6766
.close-btn {

src/components/menubar/MenuBar.vue

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<div class="q-ml-md cursor-pointer non-selectable">
1414
<span> File </span>
15-
<q-menu style="border-radius: 0.5rem">
15+
<q-menu>
1616
<q-list dense style="min-width: 100px">
1717
<q-item v-close-popup clickable @click="pendingClick = $refs.file">
1818
<q-item-section>Open File</q-item-section>
@@ -30,7 +30,7 @@
3030

3131
<div class="q-ml-md cursor-pointer non-selectable">
3232
<span> Annotations </span>
33-
<q-menu style="border-radius: 0.5rem">
33+
<q-menu>
3434
<q-list dense style="min-width: 100px">
3535
<export-annotations />
3636
<q-item v-close-popup clickable @click="pendingClick = $refs.file">
@@ -49,7 +49,7 @@
4949

5050
<div class="q-ml-md cursor-pointer non-selectable">
5151
<span> Tags </span>
52-
<q-menu style="border-radius: 0.5rem">
52+
<q-menu>
5353
<q-list dense style="min-width: 100px">
5454
<q-item v-close-popup clickable @click="exportTags()">
5555
<q-item-section>Export</q-item-section>
@@ -70,18 +70,19 @@
7070

7171
<q-space />
7272

73-
<q-icon
74-
style="margin-top: 5px"
75-
color="white"
76-
:name="$q.dark.isActive ? 'fas fa-sun' : 'fas fa-moon'"
77-
class="cursor-pointer"
78-
@click="toggleDarkMode"
79-
/>
73+
<div class="q-ml-md">
74+
<q-icon
75+
color="white"
76+
:name="$q.dark.isActive ? 'fa fa-sun' : 'fa fa-moon'"
77+
class="cursor-pointer"
78+
@click="toggleDarkMode"
79+
/>
80+
</div>
8081

8182
<div class="q-ml-md cursor-pointer non-selectable">
8283
<span>Help</span>
8384

84-
<q-menu style="border-radius: 0.5rem">
85+
<q-menu>
8586
<q-list dense style="min-width: 100px">
8687
<q-item v-close-popup clickable @click="showHelp = true">
8788
How to use?

src/main.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { createApp } from "vue";
22
import { Quasar } from "quasar";
3-
import "@quasar/extras/material-icons/material-icons.css";
43
import "quasar/src/css/index.sass";
54

65
import App from "./App.vue";

0 commit comments

Comments
 (0)