Skip to content

Commit fa1ea6a

Browse files
committed
Button tasks progress bars
1 parent f423c81 commit fa1ea6a

File tree

3 files changed

+41
-33
lines changed

3 files changed

+41
-33
lines changed

app/util/task_util.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ def scan_func(task, socket, dataset):
2222
pass
2323

2424
for file in files:
25-
time.sleep()
26-
2725
path = os.path.join(root, file)
2826

2927
if path.endswith(ImageModel.PATTERN):
@@ -92,7 +90,7 @@ def import_coco_func(task, socket, dataset, coco_json):
9290

9391
# update progress
9492
progress += 1
95-
task.set_progress((progress/total_items)*100)
93+
task.set_progress((progress/total_items)*100, socket=socket)
9694

9795
dataset.update(set__categories=dataset.categories)
9896

@@ -107,7 +105,7 @@ def import_coco_func(task, socket, dataset, coco_json):
107105

108106
# update progress
109107
progress += 1
110-
task.set_progress((progress/total_items)*100)
108+
task.set_progress((progress/total_items)*100, socket=socket)
111109

112110
image_model = images.filter(file_name__exact=image_filename).all()
113111

@@ -132,7 +130,7 @@ def import_coco_func(task, socket, dataset, coco_json):
132130
is_crowd = annotation.get('iscrowed', False)
133131

134132
progress += 1
135-
task.set_progress((progress/total_items)*100)
133+
task.set_progress((progress/total_items)*100, socket=socket)
136134

137135
if len(segmentation) == 0:
138136
task.warning(f"Annotation {annotation.get('id')} has no segmentation")
@@ -167,6 +165,6 @@ def import_coco_func(task, socket, dataset, coco_json):
167165
else:
168166
task.info(f"Annotation already exists (i:{image_id}, c:{category_id})")
169167

170-
task.set_progress(100)
168+
task.set_progress(100, socket=socket)
171169

172170

client/src/components/tasks/Task.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ export default {
9797
}
9898
},
9999
watch: {
100-
showLogs: "getLogs"
100+
showLogs: "getLogs",
101+
completed() {
102+
if (this.showLogs) {
103+
this.getLogs()
104+
}
105+
}
101106
},
102107
computed: {
103108
warnings() {

client/src/views/Dataset.vue

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@
7474
<button
7575
type="button"
7676
class="btn btn-primary btn-block"
77-
data-toggle="modal"
78-
data-target="#cocoUpload"
77+
@click="importModal"
7978
>
8079
<div v-if="importing.id != null" class="progress">
8180
<div
@@ -238,9 +237,11 @@ import ImageCard from "@/components/cards/ImageCard";
238237
import Pagination from "@/components/Pagination";
239238
import PanelString from "@/components/PanelInputString";
240239
import PanelToggle from "@/components/PanelToggle";
241-
240+
import JQuery from "jquery";
242241
import { mapMutations } from "vuex";
243242
243+
let $ = JQuery
244+
244245
export default {
245246
name: "Dataset",
246247
components: {
@@ -346,23 +347,15 @@ export default {
346347
.finally(() => this.removeProcess(process));
347348
},
348349
createScanTask() {
350+
if (this.scan.id != null) {
351+
this.$router.push({ path: "/tasks", query: { id: this.scan.id } });
352+
return;
353+
}
354+
349355
Dataset.scan(this.dataset.id)
350356
.then(response => {
351-
let options = {
352-
progressBar: true,
353-
positionClass: "toast-bottom-left",
354-
onclick: () => {
355-
let id = response.data.id;
356-
this.$router.push({ path: "/tasks", query: { id: id } });
357-
}
358-
};
359-
this.$toastr.success(
360-
`Scanning task created with id ${
361-
response.data.id
362-
} (click to view).`,
363-
"Scanning Dataset",
364-
options
365-
);
357+
let id = response.data.id;
358+
this.scan.id = id;
366359
})
367360
.catch(error => {
368361
this.axiosReqestError(
@@ -376,17 +369,20 @@ export default {
376369
let index = this.folders.indexOf(folder);
377370
this.folders.splice(index + 1, this.folders.length);
378371
},
372+
importModal() {
373+
if (this.importing.id != null) {
374+
this.$router.push({ path: "/tasks", query: { id: this.importing.id } });
375+
return;
376+
}
377+
378+
$('#cocoUpload').modal('show');
379+
},
379380
importCOCO() {
380-
let process = "Uploading COCO annotation file";
381-
this.addProcess(process);
382-
383381
let uploaded = document.getElementById("coco");
384382
Dataset.uploadCoco(this.dataset.id, uploaded.files[0])
385383
.then(response => {
386-
this.axiosReqestSuccess(
387-
"Importing COCO",
388-
`Task has been created with id ${response.data.id}`
389-
);
384+
let id = response.data.id;
385+
this.importing.id = id;
390386
})
391387
.catch(error => {
392388
this.axiosReqestError("Importing COCO", error.response.data.message);
@@ -430,6 +426,7 @@ export default {
430426
},
431427
sockets: {
432428
taskProgress(data) {
429+
433430
if (data.id === this.scan.id) {
434431
this.scan.progress = data.progress;
435432
}
@@ -478,7 +475,15 @@ export default {
478475
setTimeout(() => {
479476
this.scan.progress = 0;
480477
this.scan.id = null;
481-
}, 500);
478+
}, 1000);
479+
}
480+
},
481+
"importing.progress"(progress) {
482+
if (progress >= 100) {
483+
setTimeout(() => {
484+
this.importing.progress = 0;
485+
this.importing.id = null;
486+
}, 1000);
482487
}
483488
}
484489
},

0 commit comments

Comments
 (0)