12
12
<v-spacer ></v-spacer >
13
13
<v-chip class =" ma-2" v-if =" activity.maxBlocks > 0" label >{{ $t("message.activity_program_remaining_blocks") }}: {{ remainingCapacity }}</v-chip >
14
14
<!-- If the API is available, show the desired buttons -->
15
- <template v-if =" status == 200 " >
16
- <template v-for =" button in activity .buttons " >
17
- <template v-if =" button .type == ' text' " >
18
- <v-btn @click =" this[button.action]()" >
19
- <v-icon :icon =" button.icon" ></v-icon >
20
- <span v-if =" activity.showButtonLabel" >{{ button.label }}</span >
21
- </v-btn >
22
- </template >
23
- <template v-else >
24
- <v-btn @click =" this[button.action]()" style =" height : 70% " :color =" button.colorBtn"
25
- :class =" button.colorText" >
26
- <v-icon :icon =" button.icon" ></v-icon >
27
- <span v-if =" activity.showButtonLabel" >{{ button.label }}</span >
28
- </v-btn >
29
- </template >
30
-   ;  ;
15
+ <template v-for =" button in activity .buttons " >
16
+ <template v-if =" button .type == ' text' " >
17
+ <v-btn @click =" this[button.action]()" >
18
+ <v-icon :icon =" button.icon" ></v-icon >
19
+ <span v-if =" activity.showButtonLabel" >{{ button.label }}</span >
20
+ </v-btn >
21
+ </template >
22
+ <template v-else >
23
+ <v-btn @click =" this[button.action]()" style =" height : 70% " :color =" button.colorBtn"
24
+ :class =" button.colorText" >
25
+ <v-icon :icon =" button.icon" ></v-icon >
26
+ <span v-if =" activity.showButtonLabel" >{{ button.label }}</span >
27
+ </v-btn >
31
28
</template >
29
+   ;  ;
32
30
</template >
33
- <!-- If the API is not responding, show an error icon -->
34
- <v-btn @click =" dialog = true" icon v-if =" status != 200" >
35
- <v-icon icon =" mdi-error" ></v-icon >
36
- </v-btn >
37
31
</v-app-bar >
38
32
<!-- Page content -->
39
33
<v-main >
239
233
</v-card-actions >
240
234
</v-card >
241
235
</v-dialog >
242
- <!-- Status -->
243
- <v-dialog v-model =" dialog" max-width =" 290" >
244
- <v-card >
245
- <v-card-title class =" headline" >{{ $t("message.coderbot_status") }}</v-card-title >
246
- <v-card-text >
247
- {{ statusText }}
248
- </v-card-text >
249
- <v-card-actions >
250
- <v-spacer ></v-spacer >
251
- <v-btn color =" green darken-1" text =" text" @click =" dialog = false" >
252
- {{ $t("message.ok") }}
253
- </v-btn >
254
- </v-card-actions >
255
- </v-card >
256
- </v-dialog >
257
236
<!-- Generic dialog -->
258
237
<v-dialog v-model =" generalDialog" max-width =" 290" >
259
238
<v-card >
@@ -336,8 +315,6 @@ export default {
336
315
snackText: null ,
337
316
snackbar: false ,
338
317
drawer: false ,
339
- status: null ,
340
- info: null ,
341
318
code: ' ' ,
342
319
generalDialog: false ,
343
320
generalDialogText: null ,
@@ -362,12 +339,6 @@ export default {
362
339
program_status: null
363
340
}),
364
341
computed: {
365
- statusText () {
366
- if (this .status ) {
367
- return this .$i18n .t (' message.coderbot_status_online' );
368
- }
369
- return this .$i18n .t (' message.coderbot_status_offline' );
370
- },
371
342
remainingCapacity () {
372
343
return this .$refs .workspace .remainingCapacity ();
373
344
},
@@ -393,14 +364,6 @@ export default {
393
364
394
365
this .toolbox = this .activity .toolbox ;
395
366
});
396
-
397
- this .status = null ;
398
- this .pollStatus ();
399
-
400
- // Start the polling
401
- setInterval (() => {
402
- this .pollStatus ();
403
- }, 1000 );
404
367
},
405
368
beforeRouteLeave (to , from , next ) {
406
369
if (this .dirty ) {
@@ -603,53 +566,21 @@ export default {
603
566
});
604
567
},
605
568
606
- pollStatus () {
607
- this .$coderbot .status ()
608
- .then ((response ) => {
609
- // If the reconnection happened while in this component, send a notification
610
- if (this .status == 0 && response .status ) {
611
- this .snackText = this .$i18n .t (' message.coderbot_status_online' );
612
- this .snackbar = true ;
613
- }
614
- this .statusData = response .data ;
615
- this .status = response .status ;
616
- });
617
- this .$coderbot .info ()
618
- .then ((response ) => {
619
- this .info = response .data ;
620
- })
621
- .catch ((error ) => {
622
- console .log (` pollStatus error: ${ error} ` );
623
- // If the disconnection happened while in this component, send a notification
624
- if (this .status ) {
625
- this .snackText = this .$i18n .t (' coderbot_offline_2' );
626
- this .snackbar = true ;
627
- }
628
- this .status = 0 ;
629
- });
630
- },
631
-
632
569
getProgramCode () {
633
570
this .code = this .$refs .workspace .getProgramCode ();
634
571
this .dialogCode = true ;
635
572
},
636
573
637
574
runProgram () {
638
- if (this .status ) {
639
- // POST /program/save
640
- const { code } = this .$refs .workspace .getProgramData ();
641
- const programName = this .programName != ' ' ? this .programName : ' untitled' ;
642
- this .$coderbot .runProgram (programName, code).then (() => {
643
- this .runtimeDialog = true ;
644
- setTimeout (() => {
645
- this .updateExecStatus ();
646
- }, 1000 );
647
- });
648
- } else {
649
- this .generalDialog = true ;
650
- this .generalDialogTitle = this .$i18n .t (' error' );
651
- this .generalDialogText = this .$i18n .t (' coderbot_offline_3' );
652
- }
575
+ // POST /program/save
576
+ const { code } = this .$refs .workspace .getProgramData ();
577
+ const programName = this .programName != ' ' ? this .programName : ' untitled' ;
578
+ this .$coderbot .runProgram (programName, code).then (() => {
579
+ this .runtimeDialog = true ;
580
+ setTimeout (() => {
581
+ this .updateExecStatus ();
582
+ }, 1000 );
583
+ });
653
584
},
654
585
655
586
stopProgram () {
0 commit comments