Skip to content

Commit c5f80f3

Browse files
committed
wip #92
1 parent 95ead89 commit c5f80f3

File tree

5 files changed

+44
-49
lines changed

5 files changed

+44
-49
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"vue-i18n": "^9.1.10",
3434
"vue-prism-component": "^2.0.0",
3535
"vue-router": "^4.1.3",
36-
"vuetify": "^3.0.0-beta.8",
36+
"vuetify": "^3.0.0-beta.10",
3737
"vuex": "^4.0.2"
3838
},
3939
"devDependencies": {

src/common/coderbot.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class CoderBot {
109109
async loadMusicPackages() {
110110
const result = await this.$axios.get(`${this.CB}/music/packages`);
111111
const packagesInstalled = [];
112-
const music_packages = JSON.parse(result.data);
112+
const music_packages = result.data;
113113
const musicInstruments = [];
114114
const musicAnimals = [];
115115
Object.entries(music_packages).forEach((key) => {
@@ -132,7 +132,7 @@ class CoderBot {
132132
async loadCNNModels() {
133133
const result = await this.$axios.get(`${this.CB}/cnnmodels`);
134134
const cnnModels = [];
135-
const cnn_models = JSON.parse(result.data);
135+
const cnn_models = result.data;
136136
Object.entries(cnn_models).forEach((entry) => {
137137
const model_key = entry[0];
138138
// const model_data = entry[1];
@@ -306,9 +306,7 @@ class CoderBot {
306306
}
307307

308308
saveActivity(an_activity) {
309-
return this.$axios.post(`${this.CB}/activities`, {
310-
activity: an_activity
311-
});
309+
return this.$axios.post(`${this.CB}/activities`, an_activity);
312310
}
313311

314312
saveProgram(overwrite, name, dom_code, code, is_default) {
@@ -322,7 +320,7 @@ class CoderBot {
322320
}
323321

324322
listPrograms() {
325-
return this.$axios.get(`${this.CB}/programs/list`);
323+
return this.$axios.get(`${this.CB}/programs`);
326324
}
327325

328326
loadProgram(name) {
@@ -335,17 +333,16 @@ class CoderBot {
335333
});
336334
}
337335

338-
runProgram(name, dom_code, code, options) {
336+
runProgram(name, code, options) {
339337
return this.$axios.post(`${this.CB}/programs/${name}/run`, {
340338
name: 'run program',
341-
dom_code,
342-
code,
343-
options
339+
code: code,
340+
options: options
344341
});
345342
}
346343

347344
stopProgram(name) {
348-
return this.$axios.post(`${this.CB}/programs/${name}/end`);
345+
return this.$axios.patch(`${this.CB}/programs/${name}/stop`, {});
349346
}
350347

351348
programStatus(name) {
@@ -362,16 +359,16 @@ class CoderBot {
362359

363360
move(speed, elapse, distance) {
364361
return this.$axios.post(`${this.CB}/control/move`, {
365-
speed,
366-
elapse,
367-
distance
362+
speed: speed,
363+
elapse: elapse,
364+
distance: distance
368365
});
369366
}
370367

371368
turn(speed, elapse) {
372369
return this.$axios.post(`${this.CB}/control/turn`, {
373-
speed,
374-
elapse
370+
speed: speed,
371+
elapse: elapse
375372
});
376373
}
377374

src/components/Activity.vue

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -315,33 +315,33 @@ export default {
315315
setup() {
316316
return {
317317
theme: useTheme(),
318+
settings: null,
319+
cssProps: {
320+
'--bodyFont': 'Roboto',
321+
'--codeFont': 'Ubuntu Mono',
322+
},
323+
experimental: 0,
324+
webcamStream: null,
325+
isDefault: '',
318326
};
319327
},
320328
data: () => ({
321-
cssProps: {
322-
'--bodyFont': 'Roboto',
323-
'--codeFont': 'Ubuntu Mono',
324-
},
325-
activityStyle: null,
326329
activity: {
327330
exec: {},
328331
},
332+
toolbox: null,
333+
dialog: false,
334+
dialogCode: false,
329335
log: null,
330-
settings: null,
331336
snackText: null,
332337
snackbar: false,
333338
drawer: false,
334-
tabs: null,
335-
dialog: false,
336-
dialogCode: false,
337339
status: null,
338340
info: null,
339341
code: '',
340-
toolbox: null,
341342
generalDialog: false,
342343
generalDialogText: null,
343344
generalDialogTitle: null,
344-
experimental: 0,
345345
execMode: 'fullExec', // can be 'fullExec' or 'stepByStep',
346346
carica: false,
347347
programList: '',
@@ -351,9 +351,7 @@ export default {
351351
invalidName: false,
352352
del: false,
353353
clear: false,
354-
webcamStream: null,
355354
runtimeDialog: false,
356-
isDefault: '',
357355
cannotOverwrite: false,
358356
defaultProgramName: '',
359357
overwrite: true,
@@ -641,8 +639,8 @@ export default {
641639
if (this.status) {
642640
// POST /program/save
643641
const options = this.activity;
644-
const { dom_code, code } = this.$refs.workspace.getProgramData();
645-
this.$coderbot.execProgram(dom_code, code, options).then(() => {
642+
const { code } = this.$refs.workspace.getProgramData();
643+
this.$coderbot.runProgram(this.programName, code, options).then(() => {
646644
this.runtimeDialog = true;
647645
setTimeout(() => {
648646
this.updateExecStatus();

src/components/Control.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,37 +232,37 @@ export default {
232232
if (direction == 0) {
233233
// UP, move forward
234234
this.$coderbot.move(
235-
speed = 100,
236-
elapse = -1,
237-
distance = 0
235+
100, // speed
236+
-1, // elapse
237+
null // distance
238238
)
239239
.catch((error) => {
240240
console.log(`move error: ${error}`);
241241
});
242242
} else if (direction == 1) {
243243
// RIGHT, turn right
244244
this.$coderbot.turn(
245-
speed = -80,
246-
elapse = -1
245+
-80, // speed
246+
-1 // elapse
247247
)
248248
.catch((error) => {
249249
console.log(`turn error: ${error}`);
250250
});
251251
} else if (direction == 2) {
252252
// LEFT, turn left
253253
this.$coderbot.turn(
254-
speed = 80,
255-
elapse = -1
254+
80, // speed
255+
-1 // elapse
256256
)
257257
.catch((error) => {
258258
console.log(`turn error: ${error}`);
259259
});
260260
} else if (direction == 3) {
261261
// DOWN, move backwards
262262
this.$coderbot.move(
263-
speed = -100,
264-
elapse = -1,
265-
distance = 0
263+
-100, // speed
264+
-1, // elapse
265+
null // distance
266266
)
267267
.catch((error) => {
268268
console.log(`move error: ${error}`);

0 commit comments

Comments
 (0)