Skip to content

Commit f84c75e

Browse files
committed
Poll program execution status until it stops, print the log in the runtime modal, stop the program when closing the modal
1 parent b4c3ef4 commit f84c75e

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

src/components/Blockly.vue

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@
7777
Esecuzione
7878
</v-card-title>
7979
<v-card-text>
80-
<v-img :src="webcamStream"/>
80+
<v-img :src="webcamStream" />
8181
</v-card-text>
8282
<v-divider></v-divider>
83+
{{ log }}
8384
<v-card-actions>
8485
<v-spacer></v-spacer>
85-
<v-btn color="primary" flat @click="runtimeDialog = false">
86+
<v-btn color="primary" flat @click="runtimeDialog = false; stopProgram()">
8687
Chiudi
8788
</v-btn>
8889
</v-card-actions>
@@ -238,6 +239,7 @@ export default {
238239
},
239240
data: () => ({
240241
242+
log: null,
241243
settings: null,
242244
snackText: null,
243245
snackbar: false,
@@ -372,7 +374,7 @@ export default {
372374
this.$refs.file.click()
373375
},
374376
importProgram(e) {
375-
// Once the file is selected, read it and populate the Blockly
377+
// Once the file is selected, read it and populate the Blockly
376378
// workspace with the contained program
377379
let workspace = this.workspace
378380
const files = e.target.files
@@ -559,6 +561,7 @@ export default {
559561
code
560562
})
561563
.then(function(response) {
564+
562565
console.log(response);
563566
})
564567
} else {
@@ -572,7 +575,7 @@ export default {
572575
let axios = this.$axios
573576
let CB = this.CB
574577
let qs = this.$qs
575-
578+
this.log = ""
576579
// POST /program/save
577580
var xml_code = Blockly.Xml.workspaceToDom(this.workspace);
578581
var dom_code = Blockly.Xml.domToText(xml_code);
@@ -591,10 +594,36 @@ export default {
591594
.then(function(response) {
592595
console.log(response)
593596
this.runtimeDialog = true;
597+
setTimeout(function() {
598+
this.updateExecStatus();
599+
}.bind(this), 1000)
594600
}.bind(this))
595601
596602
}
597603
},
604+
stopProgram(){
605+
console.log("Stopping")
606+
let axios = this.$axios
607+
axios.post(this.CBv1 + '/program/end')
608+
},
609+
updateExecStatus() {
610+
let axios = this.$axios
611+
console.log("Updating Execution status")
612+
axios.get(this.CBv1 + '/program/status')
613+
.then(function(response) {
614+
console.log(response.data)
615+
if (response.data.running) {
616+
// Check again in a second
617+
setTimeout(function() {
618+
this.updateExecStatus();
619+
}.bind(this), 1000)
620+
this.log = response.data.log
621+
} else {
622+
this.log = "Esecuzione conclusa"
623+
}
624+
}.bind(this))
625+
626+
},
598627
blocksExtensions(settings) {
599628
var settings = this.settings
600629
var cfg = Object();

0 commit comments

Comments
 (0)