2019-02-18 04:18:32 -05:00
|
|
|
<template>
|
2019-03-01 08:29:00 -05:00
|
|
|
<NetworkForm
|
2019-10-28 09:48:13 -04:00
|
|
|
v-if="networkData"
|
2019-03-01 08:29:00 -05:00
|
|
|
:handle-submit="handleSubmit"
|
2019-10-28 09:48:13 -04:00
|
|
|
:defaults="networkData"
|
2019-03-01 08:29:00 -05:00
|
|
|
:disabled="disabled"
|
|
|
|
/>
|
2019-02-18 04:18:32 -05:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-11-16 12:24:03 -05:00
|
|
|
import socket from "../../js/socket";
|
2019-03-01 08:29:00 -05:00
|
|
|
import NetworkForm from "../NetworkForm.vue";
|
2019-02-18 04:18:32 -05:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "NetworkEdit",
|
|
|
|
components: {
|
2019-03-01 08:29:00 -05:00
|
|
|
NetworkForm,
|
2019-02-18 04:18:32 -05:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2019-03-01 08:29:00 -05:00
|
|
|
disabled: false,
|
2019-10-28 09:48:13 -04:00
|
|
|
networkData: null,
|
2019-02-18 04:18:32 -05:00
|
|
|
};
|
|
|
|
},
|
2019-10-28 09:48:13 -04:00
|
|
|
watch: {
|
|
|
|
"$route.params.uuid"() {
|
|
|
|
this.setNetworkData();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.setNetworkData();
|
|
|
|
},
|
2019-02-18 04:18:32 -05:00
|
|
|
methods: {
|
2019-10-28 09:48:13 -04:00
|
|
|
setNetworkData() {
|
2019-11-02 14:45:00 -04:00
|
|
|
socket.emit("network:get", this.$route.params.uuid);
|
2019-11-03 09:59:43 -05:00
|
|
|
this.networkData = this.$store.getters.findNetwork(this.$route.params.uuid);
|
2019-10-28 09:48:13 -04:00
|
|
|
},
|
2019-03-01 08:29:00 -05:00
|
|
|
handleSubmit(data) {
|
|
|
|
this.disabled = true;
|
|
|
|
socket.emit("network:edit", data);
|
2019-02-18 04:18:32 -05:00
|
|
|
|
2019-03-01 08:29:00 -05:00
|
|
|
// TODO: move networks to vuex and update state when the network info comes in
|
2019-11-03 09:59:43 -05:00
|
|
|
const network = this.$store.getters.findNetwork(data.uuid);
|
2019-03-01 08:29:00 -05:00
|
|
|
network.name = network.channels[0].name = data.name;
|
2019-11-07 04:29:04 -05:00
|
|
|
|
|
|
|
this.$root.switchToChannel(network.channels[0]);
|
2019-02-18 04:18:32 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|