@chrishamm here you have the code I have written.
Only the part of the script, I need the functions work right.
<script>
'use strict'
import { mapState, mapActions, mapGetters } from 'vuex'
export default {
computed: {
...mapState('machine',['sendCode'])
...mapGetters(['isConnected'])
},
data(){
return{
networks:[
{ssid: '',
password: '',
direccionIP: '',
NetMask: '',
GetWay: ''}
],
nuevoWifi: '',
nuevaContraseña: '',
nuevaDireccion: '',
nuevaNetMask: '',
nuevaGetWay: '',
waitingForCode: false
}
},
props: {
code: {
type: String,
required: true
},
},
methods: {
...mapActions('machine',['sendCode']),
agregarWifi() {
this.networks.push({
ssid: this.nuevoWifi,password: this.nuevaContraseña,direccionIP: this.nuevaDireccion,NetMask: this.nuevaNetMask,GetWay: this.nuevaGetWay
});
this.nuevoWifi = '';
this.nuevaContraseña = '';
this.nuevaDireccion = '';
this.nuevaNetMask = '';
this.nuevaGetWay = '';
waitingForCode=false
},
guardarWifi(){
if (!this.isConnected) {
return;
}
this.waitingForCode = true;
try{
this.sendcode({code:`M587 S${this.ssid} P${this.password} I${this.direccionIP} K${this.netMask} J${this.GetWay}`});
}catch (e) {
// handled before we get here
}
this.waitingForCode = false;
}
}, //this is another form I was thinking, here I have to include props(log and noWait)
async eliminarWifi(index){
this.networks.splice(index,1);
if (!this.waitingForCode) {
this.waitingForCode = !this.noWait;
try{
await this.sendcode({code:`M588 S${this.nuevoWifi}`, log:this.log, showSuccess: !this.noWait});
}catch (e) {
// handled before we get here
}
this.waitingForCode = false;
}
}
}
};
</script>