2017-05-18 20:08:54 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const $ = require("jquery");
|
|
|
|
const socket = require("../socket");
|
2018-07-19 18:03:53 +00:00
|
|
|
const {vueApp, initChannel, findChannel} = require("../vue");
|
2017-05-18 20:08:54 +00:00
|
|
|
|
|
|
|
socket.on("network", function(data) {
|
2018-07-12 18:33:52 +00:00
|
|
|
const network = data.networks[0];
|
2017-05-18 20:08:54 +00:00
|
|
|
|
2018-07-12 19:06:17 +00:00
|
|
|
network.isJoinChannelShown = false;
|
|
|
|
network.isCollapsed = false;
|
2018-07-18 18:40:09 +00:00
|
|
|
network.channels.forEach(initChannel);
|
2018-07-12 19:06:17 +00:00
|
|
|
|
2018-07-12 18:33:52 +00:00
|
|
|
vueApp.networks.push(network);
|
2019-10-25 21:37:40 +00:00
|
|
|
vueApp.switchToChannel(network.channels[0]);
|
2017-05-18 20:08:54 +00:00
|
|
|
|
|
|
|
$("#connect")
|
|
|
|
.find(".btn")
|
2017-09-12 12:52:16 +00:00
|
|
|
.prop("disabled", false);
|
2017-05-18 20:08:54 +00:00
|
|
|
});
|
|
|
|
|
2018-07-19 17:44:24 +00:00
|
|
|
socket.on("network:options", function(data) {
|
2018-07-06 18:15:15 +00:00
|
|
|
vueApp.networks.find((n) => n.uuid === data.network).serverOptions = data.serverOptions;
|
2017-05-18 20:08:54 +00:00
|
|
|
});
|
2018-02-19 11:12:01 +00:00
|
|
|
|
|
|
|
socket.on("network:status", function(data) {
|
2018-07-06 18:15:15 +00:00
|
|
|
const network = vueApp.networks.find((n) => n.uuid === data.network);
|
2018-09-19 14:48:13 +00:00
|
|
|
|
|
|
|
if (!network) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-06 18:15:15 +00:00
|
|
|
network.status.connected = data.connected;
|
|
|
|
network.status.secure = data.secure;
|
2018-07-19 18:03:53 +00:00
|
|
|
|
|
|
|
if (!data.connected) {
|
2018-08-24 08:29:03 +00:00
|
|
|
network.channels.forEach((channel) => {
|
|
|
|
channel.users = [];
|
|
|
|
channel.state = 0;
|
|
|
|
});
|
2018-07-19 18:03:53 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
socket.on("channel:state", function(data) {
|
|
|
|
const channel = findChannel(data.chan);
|
|
|
|
|
|
|
|
if (channel) {
|
|
|
|
channel.channel.state = data.state;
|
|
|
|
}
|
2018-02-19 11:12:01 +00:00
|
|
|
});
|
2018-03-15 08:37:32 +00:00
|
|
|
|
|
|
|
socket.on("network:info", function(data) {
|
2019-03-01 13:29:00 +00:00
|
|
|
vueApp.$store.commit("currentNetworkConfig", data.defaults);
|
|
|
|
vueApp.$store.commit("activeWindow", "NetworkEdit");
|
|
|
|
vueApp.activeChannel = null;
|
2018-03-15 08:37:32 +00:00
|
|
|
});
|