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";
238237import Pagination from " @/components/Pagination" ;
239238import PanelString from " @/components/PanelInputString" ;
240239import PanelToggle from " @/components/PanelToggle" ;
241-
240+ import JQuery from " jquery " ;
242241import { mapMutations } from " vuex" ;
243242
243+ let $ = JQuery
244+
244245export 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