Skip to content

Commit e387d8a

Browse files
committed
wip #44
1 parent 6e72c4b commit e387d8a

File tree

3 files changed

+47
-101
lines changed

3 files changed

+47
-101
lines changed

src/common/coderbot.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,15 @@ class CoderBot {
194194
updatePackages(formdata) {
195195
return this.$axios.post(`${this.CB}/updatePackages`, formdata);
196196
}
197+
198+
loadActivity(activityName, activityDefault) {
199+
return this.$axios.get(`${this.CB}/loadActivity`, {
200+
params: {
201+
name: activityName,
202+
default: activityDefault
203+
},
204+
});
205+
}
197206
}
198207

199208
export default CoderBot;

src/components/Activity.vue

Lines changed: 23 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
<template v-if="button.type == 'text'">
1818
<v-btn @click="_self[button.action]()" text>
1919
<v-icon>{{ button.icon }}</v-icon>
20-
{{ button.label }}
20+
{{ $t(button.label) }}
2121
</v-btn>
2222
</template>
2323
<template v-else>
2424
<v-btn @click="_self[button.action]()" style="height: 70%" :color="button.colorBtn"
2525
:class="button.colorText">
26-
{{ button.label }}
26+
{{ $t(button.label) }}
2727
<v-icon right dark>{{ button.icon }}</v-icon>
2828
</v-btn>
2929
</template>
@@ -373,106 +373,29 @@ export default {
373373
mounted() {
374374
this.settings = this.$store.getters.settings;
375375
// Get the activity
376-
const axios = this.$axios;
377-
const {
378-
CB
379-
} = this;
376+
let activityName = this.$route.params.name;
377+
let activityDefault = false;
380378
if (this.$route.path == '/program') {
381-
console.log('Loading the default activity');
382-
this.activity = {
383-
bodyFont: 'Roboto',
384-
buttons: [
385-
{
386-
action: 'clearProgramDlg',
387-
icon: 'clear',
388-
label: this.$i18n.t('message.activity_program_clear'),
389-
type: 'text',
390-
},
391-
{
392-
action: 'saveProgram',
393-
icon: 'save',
394-
label: this.$i18n.t('message.activity_program_save'),
395-
type: 'text',
396-
},
397-
{
398-
action: 'toggleSaveAs',
399-
icon: 'edit',
400-
label: this.$i18n.t('message.activity_program_save_as'),
401-
type: 'text',
402-
},
403-
{
404-
action: 'loadProgramList',
405-
icon: 'folder_open',
406-
label: this.$i18n.t('message.activity_program_load'),
407-
type: 'text',
408-
},
409-
{
410-
action: 'runProgram',
411-
icon: 'play_arrow',
412-
label: this.$i18n.t('message.activity_program_run'),
413-
type: 'text',
414-
},
415-
{
416-
action: 'getProgramCode',
417-
icon: 'code',
418-
label: this.$i18n.t('message.activity_program_show_code'),
419-
type: 'text',
420-
},
421-
{
422-
action: 'exportProgram',
423-
icon: 'fa-file-export',
424-
label: this.$i18n.t('message.activity_program_export'),
425-
type: 'text',
426-
},
427-
{
428-
action: 'pickFile',
429-
icon: 'fa-file-import',
430-
label: this.$i18n.t('message.activity_program_import'),
431-
type: 'text',
432-
},
433-
],
434-
capsSwitch: false,
435-
codeFont: 'ubuntumono',
436-
description: null,
437-
drawerEnabled: true,
438-
exec: {
439-
camera: true,
440-
log: true,
441-
},
442-
fontSize: 'Medio',
443-
name: this.$i18n.t('message.activity_program_title'),
444-
showName: true,
445-
maxBlocks: null,
446-
};
447-
const toolboxLevel = this.settings.progLevel;
448-
// Decode it and get the clean serialized XML as plain string
449-
this.toolbox = require(`../assets/toolbox_${toolboxLevel}.json`);
450-
this.settings.maxBlocks = null; // default
451-
} else {
452-
console.log('Loading activity', this.$route.params.name);
453-
this.saved = true;
454-
axios.get(`${CB}/loadActivity`, {
455-
params: {
456-
name: this.$route.params.name,
457-
},
458-
}).then((response) => {
459-
console.log('Activity loaded', response.data);
460-
this.activity = response.data;
461-
this.settings.maxBlocks = this.activity.maxBlocks;
462-
this.updateCssProps();
463-
464-
let toolboxJSON = null;
465-
if (this.activity.toolbox == null) {
466-
const toolboxLevel = this.settings.progLevel;
467-
// Decode it and get the clean serialized XML as plain string
468-
toolboxJSON = require(`../assets/toolbox_${toolboxLevel}.json`);
469-
} else {
470-
toolboxJSON = this.activity.toolbox;
471-
}
472-
console.log(this.settings);
473-
this.toolbox = toolboxJSON;
474-
});
379+
activityName = this.$route.params.name;
380+
activityDefault = true;
475381
}
382+
this.$coderbot.loadActivity(activityName, activityDefault).then((activity) => {
383+
this.activity = activity.data;
384+
385+
this.settings.maxBlocks = this.activity.maxBlocks;
386+
this.updateCssProps();
387+
388+
let toolboxJSON = null;
389+
if (this.activity.toolbox == null) {
390+
const toolboxLevel = this.settings.progLevel;
391+
// Decode it and get the clean serialized XML as plain string
392+
toolboxJSON = require(`../assets/toolbox_${toolboxLevel}.json`);
393+
} else {
394+
toolboxJSON = this.activity.toolbox;
395+
}
396+
console.log(this.settings);
397+
this.toolbox = toolboxJSON;
398+
});
476399
477400
this.status = null;
478401
this.pollStatus();

src/components/ActivityEditor.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
v-bind:label="$t('message.activity_predefined_view')" required
4646
@input="$v.activity.defaultView.$touch"
4747
></v-select>
48+
<v-checkbox
49+
v-model="activity.default"
50+
v-bind:label="$t('message.activity_default')"
51+
@input="$v.activity.default.$touch"
52+
></v-checkbox>
4853
</v-form>
4954
</v-card>
5055
<br><br>
@@ -429,6 +434,7 @@ export default {
429434
b: 0,
430435
activity: {
431436
stock: null,
437+
default: null,
432438
uiLang: null,
433439
defaultView: null,
434440
exec: {
@@ -508,7 +514,6 @@ export default {
508514
'Grande',
509515
'Molto grande',
510516
],
511-
512517
daltonicSwitch: 0,
513518
daltonicType: 1,
514519
daltonicModes: [
@@ -560,6 +565,7 @@ export default {
560565
validations() {
561566
return {
562567
activity: {
568+
default: { },
563569
uiLang: { },
564570
defaultView: { },
565571
drawerEnabled: { },
@@ -591,6 +597,13 @@ export default {
591597
},
592598
}).then((response) => {
593599
this.activity = response.data;
600+
if (this.activity.toolbox == null) {
601+
this.activity.toolbox = {
602+
kind: 'flyoutToolbox',
603+
contents: []
604+
};
605+
}
606+
console.log(this.activity);
594607
});
595608
} else {
596609
this.restoreDefaults();
@@ -604,6 +617,7 @@ export default {
604617
},
605618
methods: {
606619
save() {
620+
console.log(this.activity);
607621
if (this.activity.name) {
608622
const axios = this.$axios;
609623
const {

0 commit comments

Comments
 (0)