Skip to content

Commit dc279c2

Browse files
committed
fixing musicPackages load/delete
1 parent 2649b6b commit dc279c2

File tree

1 file changed

+31
-50
lines changed

1 file changed

+31
-50
lines changed

src/components/Settings.vue

Lines changed: 31 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@
257257
<v-radio v-bind:label="$t('message.settings_network_mode_client')" value="client"></v-radio>
258258
<v-radio v-bind:label="$t('message.settings_network_mode_ap')" value="ap">
259259
</v-radio>
260-
<v-text-field v-model="settings.wifiSSID" v-bind:label="SSID"></v-text-field>
261-
<v-text-field v-model="settings.wifiPsw" v-bind:label="Password"></v-text-field>
260+
<v-text-field v-model="settings.wifiSSID" v-bind:label="$t('message.settings_network_ssid')"></v-text-field>
261+
<v-text-field v-model="settings.wifiPsw" v-bind:label="$t('message.settings_network_password')"></v-text-field>
262262
</v-radio-group>
263263
<v-card-actions>
264264
<v-btn color="primary" @click.stop="dialog = true" block>Salva</v-btn>
@@ -304,7 +304,7 @@
304304
<v-layout row wrap justify-center>
305305
<!-- switch -->
306306
<v-flex xs12 offset-md2 md5>
307-
<v-switch v-bind:label="Sonar" value="sonar" v-model="checkedTests" color="orange"></v-switch>
307+
<v-switch v-bind:label="$t('message.settings_component_test_sonar')" value="sonar" v-model="checkedTests" color="orange"></v-switch>
308308
</v-flex>
309309
<!-- button state -->
310310
<v-flex xs12 md4>
@@ -334,7 +334,7 @@
334334
<v-layout row wrap justify-center>
335335
<!-- switch -->
336336
<v-flex xs12 offset-md2 md5>
337-
<v-switch v-bind:label="Motors" value="motors" v-model="checkedTests" color="orange">
337+
<v-switch v-bind:label="$t('message.settings_component_test_motors')" value="motors" v-model="checkedTests" color="orange">
338338
</v-switch>
339339
</v-flex>
340340
<!-- button state -->
@@ -366,7 +366,7 @@
366366
<v-layout row wrap justify-center>
367367
<!-- switch -->
368368
<v-flex xs12 offset-md2 md5>
369-
<v-switch v-bind:label="Speaker" value="speaker" v-model="checkedTests" color="orange">
369+
<v-switch v-bind:label="$t('message.settings_component_test_speaker')" value="speaker" v-model="checkedTests" color="orange">
370370
</v-switch>
371371
</v-flex>
372372
<!-- button state -->
@@ -398,7 +398,7 @@
398398
<v-layout row wrap justify-center>
399399
<!-- switch -->
400400
<v-flex xs12 offset-md2 md5>
401-
<v-switch v-bind:label="OCR" value="ocr" v-model="checkedTests" color="orange">
401+
<v-switch v-bind:label="$t('message.settings_component_test_ocr')" value="ocr" v-model="checkedTests" color="orange">
402402
</v-switch>
403403
</v-flex>
404404
<!-- button state -->
@@ -425,10 +425,6 @@
425425
</span>
426426
</v-flex>
427427
</v-layout>
428-
429-
<!-- DEBUG
430-
<span>Checked names: {{ checkedTests }}</span>
431-
-->
432428
</div>
433429
<br>
434430
<v-card-actions>
@@ -439,9 +435,6 @@
439435
<v-btn v-else block disabled>
440436
<v-icon>fas fa-ellipsis-h</v-icon> {{ $t('message.settings_component_test_text_1') }}
441437
</v-btn>
442-
<!-- DEBUG
443-
Running test: {{ cb.logs.runningTest }}
444-
-->
445438
</v-card-actions>
446439
</div>
447440
</v-card>
@@ -483,16 +476,6 @@
483476
</v-btn>
484477
</span>
485478
</li>
486-
<!--
487-
<div v-for="pkgnames in settings.packagesInstalled">
488-
<ul>
489-
<li> nome: {{pkgnames[0][0]}} tipo: {{pkgnames[1]}} <span style="display: flex; justify-content: flex-end"><v-btn @click="deletePkg(pkgnames[0][1])" color="red" dark>
490-
<v-icon>fas fa-trash</v-icon> Rimuovi
491-
</v-btn></span>
492-
</li>
493-
</ul>
494-
</div>
495-
-->
496479
</div>
497480
</v-card>
498481
<br>
@@ -545,18 +528,6 @@
545528
</template>
546529
<script>
547530
import sidebar from '../components/Sidebar';
548-
import * as music_package from '../assets/music_package.json';
549-
550-
const packageList = [];
551-
552-
Object.keys(music_package.packages).forEach((key) => {
553-
const names = [music_package.packages[key].name_IT, key];
554-
if (music_package.packages[key].category == 'instrument') {
555-
packageList[packageList.length] = [names, 'instrument'];
556-
} else if (music_package.packages[key].category == 'animal') {
557-
packageList[packageList.length] = [names, 'animal'];
558-
}
559-
});
560531
561532
export default {
562533
components: {
@@ -570,6 +541,7 @@ export default {
570541
}, 1000);
571542
this.getInfoAndStatus();
572543
this.prepopulate();
544+
this.loadMusicPackages();
573545
},
574546
methods: {
575547
pickFile() {
@@ -584,7 +556,22 @@ export default {
584556
this.formdata = new FormData();
585557
this.formdata.append('file_to_upload', files[0], files[0].name);
586558
},
587-
559+
loadMusicPackages() {
560+
this.$axios.get(`${this.CB}/listMusicPackages`).then((result) => {
561+
this.settings.packagesInstalled = [];
562+
const music_packages = JSON.parse(result.data);
563+
Object.entries(music_packages).forEach((key) => {
564+
const package_key = key[0];
565+
const music_package = key[1];
566+
const names = [music_package.name_IT, package_key];
567+
if (music_package.category == 'instrument') {
568+
this.settings.packagesInstalled.push([names, 'instrument']);
569+
} else if (music_package.category == 'animal') {
570+
this.settings.packagesInstalled.push([names, 'animal']);
571+
}
572+
});
573+
});
574+
},
588575
uploadPackage() {
589576
/*
590577
const qs = this.$qs;
@@ -760,21 +747,15 @@ export default {
760747
});
761748
},
762749
deletePkg(pkgNameID) {
763-
const {
764-
CBv1
765-
} = this;
766750
const axios = this.$axios;
767-
const qs = this.$qs;
768-
const pkgName = qs.stringify({
769-
nameID: pkgNameID,
751+
axios.post(`${this.CB}/deleteMusicPackage`, {
752+
package_name: pkgNameID,
753+
}).then(() => {
754+
console.log('Pacchetto rimosso');
755+
this.snackText = this.$i18n.t('settings_music_package_removed');
756+
this.snackbar = true;
757+
this.loadMusicPackages();
770758
});
771-
axios.post(`${CBv1}/deletepkg`, pkgName)
772-
.then(() => {
773-
console.log('Pacchetto rimosso');
774-
this.snackText = this.$i18n.t('settings_music_package_removed');
775-
this.snackbar = true;
776-
this.packagesInstalled = window.location.reload();
777-
});
778759
},
779760
prepopulate() {
780761
const axios = this.$axios;
@@ -948,7 +929,7 @@ export default {
948929
wifiPsw: null,
949930
950931
audioLevel: null,
951-
packagesInstalled: packageList,
932+
packagesInstalled: null,
952933
moveFwdElapse: null,
953934
moveFwdSpeed: null,
954935
moveTurnElapse: null,

0 commit comments

Comments
 (0)