Skip to content

Commit b5d2cd0

Browse files
committed
wip #92
1 parent dff5c70 commit b5d2cd0

File tree

9 files changed

+91
-78
lines changed

9 files changed

+91
-78
lines changed

src/App.vue

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<template>
22
<div id="app">
3-
<template v-if="status == 200">
3+
<template v-if="online">
44
<router-view />
55
</template>
66
<template v-else>
77
<v-app id="inspire">
8-
<sidebar></sidebar>
98
<v-app-bar color="indigo" dark fixed app>
109
<v-app-bar-nav-icon></v-app-bar-nav-icon>
1110
<v-app-bar-title class="title"><div>CoderBot</div></v-app-bar-title>
@@ -43,55 +42,25 @@
4342
</template>
4443
<script>
4544
import image_1 from './assets/images/coderbot_wide1.jpg';
46-
import image_2 from './assets/images/coderbot_wide3.jpg';
4745
4846
export default {
4947
data() {
5048
return {
51-
drawer: null,
52-
status: 200,
49+
status: this.$store.getters.status,
5350
dialog: true,
5451
carouselItems: [
5552
{
5653
src: image_1,
5754
},
58-
{
59-
src: image_2,
60-
}
6155
],
6256
};
6357
},
58+
computed: {
59+
online() {
60+
return this.$store.getters.status != {};
61+
}
62+
},
6463
name: 'App',
65-
mounted() {
66-
this.pollStatus();
67-
setInterval(() => {
68-
this.pollStatus();
69-
}, 1000);
70-
},
71-
methods: {
72-
pollStatus() {
73-
this.$coderbot.status()
74-
.then((response) => {
75-
if (this.status == 0 && response.status) {
76-
this.snackText = this.$i18n.t('message.coderbot_status_online');
77-
this.snackbar = true;
78-
}
79-
80-
this.statusData = response.data;
81-
this.status = response.status;
82-
})
83-
.catch((error) => {
84-
// handle error
85-
console.log(`pollStatus error: ${error}`);
86-
87-
if (this.status) {
88-
this.snackText = this.$i18n.t('message.coderbot_offline_2');
89-
this.snackbar = true;
90-
}
91-
this.status = 0;
92-
});
93-
}
94-
}
9564
};
9665
9766
</script>

src/common/coderbot.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,14 @@ class CoderBot {
258258
const p1 = this.$axios.get(`${this.CB}/system/status`)
259259
.then((response) => {
260260
this.$store.commit('setStatus', response.data);
261+
}).catch((error) => {
262+
this.$store.commit('setStatus', {status: "offline"});
261263
});
262264
const p2 = this.$axios.get(`${this.CB}/system/info`)
263265
.then((response) => {
264266
this.$store.commit('setInfo', response.data);
267+
}).catch(error => {
268+
this.$store.commit('setInfo', {});
265269
});
266270
return Promise.all([p1, p2]);
267271
}

src/components/BlocklyWorkspace.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ export default {
8585
/* eslint-enable */
8686
}
8787
},
88-
mounted() {
89-
},
9088
methods: {
9189
initBlockly(settings) {
9290
// Extend the default blocks set

src/components/Control.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,6 @@ export default {
276276
},
277277
};
278278
},
279-
mounted() {
280-
},
281279
};
282280
</script>
283281
<!-- Add "scoped" attribute to limit CSS to this component only -->

src/components/Gallery.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export default {
135135
sidebar
136136
},
137137
name: 'Gallery',
138-
mounted() {
138+
onMmounted() {
139139
this.getPhotos();
140140
},
141141
methods: {

src/components/Settings.vue

Lines changed: 71 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,19 @@
2525
<v-layout row wrap>
2626
<!-- Column A -->
2727
<v-col xs12 md6 offset-md3>
28-
<h3 class="text-xs-left">Stato </h3>
29-
<v-card>
30-
<div class="cardContent">
31-
<div v-for="(value, key) in cb.status" :key="key">
32-
<div v-if="key != 'log'">
33-
{{ key }}: <code>{{ value }}</code>
34-
</div>
35-
</div>
36-
<br>
37-
</div>
38-
</v-card>
39-
<br>
40-
<h3 class="text-xs-left"> {{ $t('message.settings_actions') }} </h3>
4128
<v-card>
29+
<v-card-title>
30+
{{ $t('message.settings_actions') }}
31+
</v-card-title>
32+
<v-card-text>
4233
<div class="d-flex justify-space-around align-center">
4334
<v-btn color="info" @click="dialog_shutdown=true">
4435
<v-icon icon="mdi-power"></v-icon> {{ $t('message.settings_actions_halt') }}
4536
</v-btn>
4637
<v-btn color="info" @click="dialog_reboot=true">
38+
<v-icon icon="mdi-restart"></v-icon> {{ $t('message.settings_actions_reboot') }}
39+
</v-btn>
40+
<v-btn color="info" @click="dialog_restart=true">
4741
<v-icon icon="mdi-restart"></v-icon> {{ $t('message.settings_actions_restart') }}
4842
</v-btn>
4943
<v-btn color="warning" @click="dialog_restore=true">
@@ -73,6 +67,26 @@
7367
</v-card-actions>
7468
</v-card>
7569
</v-dialog>
70+
<v-dialog v-model="dialog_restart" width="500">
71+
<v-card>
72+
<v-card-title class="headline grey lighten-2" primary-title>
73+
<h3>CoderBot - {{ $t('message.settings_actions_restart_title') }}</h3>
74+
</v-card-title>
75+
<v-card-text>
76+
{{ $t('message.settings_actions_restart_text_1') }}
77+
</v-card-text>
78+
<v-divider></v-divider>
79+
<v-card-actions>
80+
<v-spacer></v-spacer>
81+
<v-btn color="primary" @click="dialog_restart=false">
82+
{{ $t('message.cancel') }}
83+
</v-btn>
84+
<v-btn color="error" @click="reboot">
85+
<b>{{ $t('message.settings_actions_restart') }}</b>
86+
</v-btn>
87+
</v-card-actions>
88+
</v-card>
89+
</v-dialog>
7690
<v-dialog v-model="dialog_reboot" width="500">
7791
<v-card>
7892
<v-card-title class="headline grey lighten-2" primary-title>
@@ -134,17 +148,49 @@
134148
</v-card>
135149
</v-dialog>
136150
</div>
151+
</v-card-text>
137152
</v-card>
138153
<br>
139154
<v-card>
140155
<v-card-title>
141-
<h3 class="text-xs-left">{{ $t('message.settings_admin_password_title') }}</h3>
156+
{{ $t('message.settings_admin_password_title') }}
142157
</v-card-title>
143-
<div class="cardContent">
158+
<v-card-text>
144159
<v-text-field v-model="settings.adminPassword"
145160
v-bind:label="$t('message.settings_admin_password')"
146161
@input="v$.settings.motorMode.$touch"
147162
/>
163+
</v-card-text>
164+
</v-card>
165+
<v-card>
166+
<v-card-title>
167+
{{ $t('message.settings_general_info') }}
168+
</v-card-title>
169+
<div class="cardContent">
170+
<v-expansion-panels>
171+
<v-expansion-panel
172+
:title="$t('message.settings_status')"
173+
>
174+
<v-expansion-panel-text>
175+
<div v-for="(value, key) in cb.status" :key="key">
176+
<div v-if="key != 'log'">
177+
{{ key }}: <code>{{ value }}</code>
178+
</div>
179+
</div>
180+
</v-expansion-panel-text>
181+
</v-expansion-panel>
182+
<v-expansion-panel
183+
:title="$t('message.settings_info')"
184+
>
185+
<v-expansion-panel-text>
186+
<div v-for="(value, key) in cb.info" :key="key">
187+
<div v-if="key != 'log'">
188+
{{ key }}: <code>{{ value }}</code>
189+
</div>
190+
</div>
191+
</v-expansion-panel-text>
192+
</v-expansion-panel>
193+
</v-expansion-panels>
148194
</div>
149195
</v-card>
150196
</v-col>
@@ -790,19 +836,14 @@ export default {
790836
mounted() {
791837
this.pollWifiStatus()
792838
setInterval(() => { this.pollWifiStatus(); }, 1000);
793-
this.getInfoAndStatus();
794-
this.prepopulate();
795-
this.settings.packagesInstalled = this.$store.getters.musicPackages;
796-
this.settings.cnnModels = this.$store.getters.cnnModels;
797-
this.cb.info = this.$store.getters.info;
798-
this.cb.status = this.$store.getters.status;
799-
this.adminPassword_dialog = this.settings.adminPassword != null && this.settings.adminPassword != '';
839+
setTimeout(() => {this.prepopulate()}, 1000);
800840
this.$wifi_connect.networks().then((result) => {
801841
this.networks = result.data.ssids;
802842
});
803843
this.$coderbot.listPrograms()
804844
.then((response) => {
805-
this.programList = response.data;
845+
this.programList = [{name:"", code:"", dom_code:"", default: false}];
846+
this.programList = this.programList.concat(response.data);
806847
});
807848
},
808849
beforeRouteLeave(to, from, next) {
@@ -936,10 +977,6 @@ export default {
936977
this.snackbar = true;
937978
});
938979
},
939-
getInfoAndStatus() {
940-
// Get bot info and status
941-
return this.$coderbot.getInfoAndStatus();
942-
},
943980
deletePkg(pkgNameID) {
944981
this.$coderbot.deleteMusicPackage(pkgNameID).then(() => {
945982
console.log('Pacchetto rimosso');
@@ -949,6 +986,9 @@ export default {
949986
},
950987
prepopulate() {
951988
this.settings = this.$store.getters.settings;
989+
this.cb.status = this.$store.getters.status;
990+
this.cb.info = this.$store.getters.info;
991+
this.adminPassword_dialog = this.settings.adminPassword != null && this.settings.adminPassword != '';
952992
},
953993
save() {
954994
if (this.v$.$invalid) {
@@ -972,7 +1012,6 @@ export default {
9721012
this.v$.settings.$reset();
9731013
console.log('set dirty false');
9741014
});
975-
console.log("wifi dirty state: ", this.v$.settings.wifiMode.$dirty || this.v$.settings.wifiSSID.$dirty || this.v$.settings.wifiPsw.$dirty);
9761015
if (this.v$.settings.wifiMode.$dirty || this.v$.settings.wifiSSID.$dirty || this.v$.settings.wifiPsw.$dirty) {
9771016
if(this.settings.wifiMode=="client") {
9781017
const network = this.networks.find(item => { return item.ssid==this.settings.wifiSSID });
@@ -1048,6 +1087,7 @@ export default {
10481087
files: null,
10491088
dialog_shutdown: false,
10501089
dialog_reboot: false,
1090+
dialog_restart: false,
10511091
dialog_restore: false,
10521092
dialog_reset: false,
10531093
lastCommit: 'N/A',
@@ -1100,11 +1140,11 @@ export default {
11001140
startupProgram: null,
11011141
progLevel: null,
11021142
adminPassword: null,
1143+
packagesInstalled: [],
11031144
},
11041145
cb: {
1105-
logs: {
1106-
log: []
1107-
}
1146+
info: {},
1147+
status: {},
11081148
},
11091149
drawer: null,
11101150
tab: null,

src/components/ToolboxEditor.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,7 @@ export default {
106106
category_dialog: null,
107107
category_index: null
108108
}),
109-
110-
beforeCreate() {
111-
},
112-
mounted() {
109+
mmounted() {
113110
// i18n toolbox categories
114111
toolbox_full.contents.forEach((item) => {
115112
if (item.name.startsWith('message.')) {

src/i18n/locales/it/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@
261261
"settings_tabs_camera": "Camera",
262262
"settings_tabs_audio": "Audio",
263263
"settings_tabs_music_packages": "Pacchetti Musica",
264+
"settings_general_info": "Stato e Informazioni",
265+
"settings_info": "Informazioni",
266+
"settings_status": "Stato",
264267
"settings_music_packages": "Gestione Pacchetti",
265268
"settings_music_packages_text_1": "Clicca \"Aggiorna\" per visualizzare le modifiche.",
266269
"settings_music_packages_text_2": "Aggiornamento non avvenuto, il pacchetto è già presente con una versione successiva a quella che vuoi installare.",

src/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,8 @@ function loadConfig() {
7171
setTimeout(loadConfig, 1000);
7272
});
7373
}
74+
$coderbot.getInfoAndStatus();
75+
setInterval(() => {
76+
$coderbot.getInfoAndStatus();
77+
}, 1000);
7478
loadConfig();

0 commit comments

Comments
 (0)