Skip to content

Commit e0a3f2f

Browse files
committed
Filtering options, closes #7
1 parent 761fe33 commit e0a3f2f

File tree

14 files changed

+131
-22
lines changed

14 files changed

+131
-22
lines changed

app/api/datasets.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from flask import request
12
from flask_restplus import Namespace, Resource, reqparse
23
from flask_login import login_required, current_user
34
from werkzeug.datastructures import FileStorage
@@ -26,7 +27,7 @@
2627
page_data = reqparse.RequestParser()
2728
page_data.add_argument('page', default=1, type=int)
2829
page_data.add_argument('limit', default=20, type=int)
29-
page_data.add_argument('folder', required=False, default='', help='Folder for data')
30+
page_data.add_argument('folder', default='', help='Folder for data')
3031

3132
delete_data = reqparse.RequestParser()
3233
delete_data.add_argument('fully', default=False, type=bool,
@@ -217,6 +218,25 @@ def get(self, dataset_id):
217218
page = args['page']
218219
folder = args['folder']
219220

221+
args = dict(request.args)
222+
if args.get('limit') != None:
223+
del args['limit']
224+
if args.get('page') != None:
225+
del args['page']
226+
if args.get('folder') != None:
227+
del args['folder']
228+
229+
query = {}
230+
for key, value in args.items():
231+
lower = value.lower()
232+
if lower in ["true", "false"]:
233+
value = json.loads(lower)
234+
235+
if len(lower) != 0:
236+
query[key] = value
237+
238+
# print(query, flush=True)
239+
220240
# Check if dataset exists
221241
dataset = current_user.datasets.filter(id=dataset_id, deleted=False).first()
222242
if dataset is None:
@@ -233,9 +253,9 @@ def get(self, dataset_id):
233253
if not os.path.exists(directory):
234254
return {'message': 'Directory does not exist.'}, 400
235255

236-
images = ImageModel.objects(dataset_id=dataset_id, path__startswith=directory, deleted=False) \
256+
images = ImageModel.objects(dataset_id=dataset_id, path__startswith=directory, deleted=False, **query) \
237257
.order_by('file_name').only('id', 'file_name', 'annotating')
238-
258+
239259
pagination = Pagination(images.count(), limit, page)
240260
images = query_util.fix_ids(images[pagination.start:pagination.end])
241261

app/api/images.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
image_all.add_argument('page', default=1, type=int)
2020
image_all.add_argument('perPage', default=50, type=int, required=False)
2121

22-
2322
image_upload = reqparse.RequestParser()
2423
image_upload.add_argument('image', location='files',
2524
type=FileStorage, required=True,
@@ -47,7 +46,7 @@ def get(self):
4746
args = image_all.parse_args()
4847
per_page = args['perPage']
4948
page = args['page']-1
50-
fields = args.get('fields', "")
49+
fields = args.get('fields', '')
5150

5251
images = current_user.images.filter(deleted=False)
5352
total = images.count()
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<template>
2+
<button
3+
class="btn btn-outline-light tool-input-button"
4+
@click="$emit('click', current.value)"
5+
>
6+
{{ current.name }}
7+
</button>
8+
</template>
9+
10+
<script>
11+
export default {
12+
name: "PanelButton",
13+
props: {
14+
name: {
15+
type: String,
16+
required: true
17+
},
18+
options: {
19+
type: Array,
20+
required: true
21+
},
22+
default: {
23+
type: Number,
24+
default: 0
25+
}
26+
},
27+
data() {
28+
return {
29+
currentIndex: this.default
30+
}
31+
}
32+
computed: {
33+
current() {
34+
return this.options[this.currentIndex]
35+
}
36+
}
37+
};
38+
</script>
39+
40+
<style scoped>
41+
.tool-input-button {
42+
height: 20px;
43+
border-color: #4b5162;
44+
padding: 0 0 0 11px;
45+
font-size: 12px;
46+
width: 100%;
47+
}
48+
49+
.tool-input-button:hover {
50+
border-color: lightgray;
51+
background-color: white;
52+
}
53+
</style>

client/src/components/annotator/panels/PanelInputString.vue renamed to client/src/components/PanelInputString.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
<div class="input-group-prepend tool-option-pre">
44
<span class="input-group-text tool-option-font">{{ name }}</span>
55
</div>
6-
<input v-model="localValue" class="form-control tool-option-input" />
6+
<input
7+
v-model="localValue"
8+
class="form-control tool-option-input"
9+
@keyup.enter="$emit('submit')"
10+
/>
711
</div>
812
</template>
913

client/src/components/annotator/Annotation.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,14 @@ export default {
267267
this.$emit("click", this.index);
268268
}
269269
},
270-
onMouseEnter(event) {
270+
onMouseEnter() {
271271
if (this.compoundPath == null) return;
272272
273273
this.compoundPath.selected = true;
274274
},
275-
onMouseLeave(event) {
275+
onMouseLeave() {
276276
if (this.compoundPath == null) return;
277-
277+
278278
this.compoundPath.selected = false;
279279
},
280280
getCompoundPath() {

client/src/components/annotator/panels/BrushPanel.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
</template>
1616

1717
<script>
18-
import PanelInputString from "@/components/annotator/panels/PanelInputString";
19-
import PanelInputNumber from "@/components/annotator/panels/PanelInputNumber";
18+
import PanelInputString from "@/components/PanelInputString";
19+
import PanelInputNumber from "@/components/PanelInputNumber";
2020
2121
export default {
2222
name: "BrushPanel",

client/src/components/annotator/panels/EraserPanel.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
</template>
1616

1717
<script>
18-
import PanelInputString from "@/components/annotator/panels/PanelInputString";
19-
import PanelInputNumber from "@/components/annotator/panels/PanelInputNumber";
18+
import PanelInputString from "@/components/PanelInputString";
19+
import PanelInputNumber from "@/components/PanelInputNumber";
2020
2121
export default {
2222
name: "EraserPanel",

0 commit comments

Comments
 (0)