Skip to content

Commit 690df14

Browse files
committed
Define the default Blockly view with a standard activity
1 parent 8e58f3a commit 690df14

File tree

2 files changed

+88
-19
lines changed

2 files changed

+88
-19
lines changed

src/components/Activity.vue

Lines changed: 86 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@
1414
<!-- If the API is available, show the desired buttons -->
1515
<template v-if="status == 200">
1616
<template v-for="button, i in activity.buttons">
17-
<v-btn @click="_self[button.action]()" style="height: 70%" :color="button.colorBtn" :class="button.colorText">
18-
{{ button.label }}
19-
<v-icon right dark>{{ button.icon }}</v-icon>
20-
</v-btn>
17+
<template v-if="button.type == 'flat'">
18+
<v-btn @click="_self[button.action]()" flat>
19+
<v-icon>{{ button.icon }}</v-icon>
20+
{{ button.label }}
21+
</v-btn>
22+
</template>
23+
<template v-else>
24+
<v-btn @click="_self[button.action]()" style="height: 70%" :color="button.colorBtn" :class="button.colorText">
25+
{{ button.label }}
26+
<v-icon right dark>{{ button.icon }}</v-icon>
27+
</v-btn>
28+
</template>
2129
&nbsp;&nbsp;
2230
</template>
2331
</template>
@@ -299,20 +307,80 @@ export default {
299307
// Get the activity
300308
let axios = this.$axios
301309
let CB = this.CB
302-
console.log("Loading activity", this.$route.params.name)
303-
this.saved = true;
304-
axios.get(CB + '/loadActivity', {
305-
params: {
306-
name: this.$route.params.name
307-
}
308-
})
309-
.then(function(response) {
310-
console.log("Activity loaded", response.data)
311-
this.activity = response.data
312-
this.updateCssProps()
313-
314-
}.bind(this))
315-
310+
if (this.$route.path == '/program') {
311+
console.log('Loading the default activity')
312+
this.activity = {
313+
"bodyFont": "Roboto",
314+
"buttons": [{
315+
"action": "saveProgram",
316+
"icon": "save",
317+
"label": "Salva",
318+
"type": "flat"
319+
},
320+
{
321+
"action": "toggleSaveAs",
322+
"icon": "edit",
323+
"label": "Salva con Nome",
324+
"type": "flat"
325+
},
326+
{
327+
"action": "loadProgramList",
328+
"icon": "folder_open",
329+
"label": "Carica",
330+
"type": "flat"
331+
},
332+
{
333+
"action": "runProgramLegacy",
334+
"icon": "play_arrow",
335+
"label": "Esegui",
336+
"type": "flat"
337+
},
338+
{
339+
"action": "getProgramCode",
340+
"icon": "code",
341+
"label": "Mostra codice",
342+
"type": "flat"
343+
},
344+
{
345+
"action": "exportProgram",
346+
"icon": "fa-file-export",
347+
"label": "Esporta",
348+
"type": "flat"
349+
},
350+
{
351+
"action": "pickFile",
352+
"icon": "fa-file-import",
353+
"label": "Importa",
354+
"type": "flat"
355+
},
356+
357+
],
358+
"capsSwitch": false,
359+
"codeFont": "ubuntumono",
360+
"description": null,
361+
"drawerEnabled": true,
362+
"exec": {
363+
"camera": true,
364+
"log": true
365+
},
366+
"fontSize": "Medio",
367+
"name": "Programma",
368+
"showName": true
369+
}
370+
} else {
371+
console.log("Loading activity", this.$route.params.name)
372+
this.saved = true;
373+
axios.get(CB + '/loadActivity', {
374+
params: {
375+
name: this.$route.params.name
376+
}
377+
})
378+
.then(function(response) {
379+
console.log("Activity loaded", response.data)
380+
this.activity = response.data
381+
this.updateCssProps()
382+
}.bind(this))
383+
}
316384
317385
this.status = null
318386
this.pollStatus();

src/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ Vue.config.productionTip = false;
6464
const routes = [
6565
{ path: '/', component: landing, meta: {title: 'CoderBot'} },
6666
{ path: '/control', component: control, meta: {title: 'CoderBot - Controlla'} },
67-
{ path: '/program', component: blockly, meta: {title: 'CoderBot - Blockly'}},
67+
{ path: '/programOld', component: blockly, meta: {title: 'CoderBot - Blockly'}},
68+
{ path: '/program', component: activity, meta: {title: 'CoderBot - Blockly'}},
6869
{ path: '/settings', component: settings , meta: {title: 'CoderBot - Impostazioni'}},
6970
{ path: '/gallery', component: gallery, meta: {title: 'CoderBot - Galleria'}},
7071
//{ path: '/help', component: help, meta: {title: 'CoderBot - Aiuto'}},

0 commit comments

Comments
 (0)