2018-07-06 18:15:15 +00:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
v-if="networks.length === 0"
|
|
|
|
class="empty">
|
|
|
|
You are not connected to any networks yet.
|
|
|
|
</div>
|
|
|
|
<Draggable
|
|
|
|
v-else
|
|
|
|
:list="networks"
|
|
|
|
:options="{ handle: '.lobby', draggable: '.network', ghostClass: 'network-placeholder' }"
|
|
|
|
class="networks"
|
|
|
|
@change="onNetworkSort"
|
|
|
|
@start="onDragStart"
|
|
|
|
@end="onDragEnd"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
v-for="network in networks"
|
2018-07-29 17:57:14 +00:00
|
|
|
:id="'network-' + network.uuid"
|
2018-07-06 18:15:15 +00:00
|
|
|
:key="network.uuid"
|
2018-07-08 20:08:08 +00:00
|
|
|
:class="{
|
|
|
|
collapsed: network.isCollapsed,
|
|
|
|
'not-connected': !network.status.connected,
|
|
|
|
'not-secure': !network.status.secure,
|
|
|
|
}"
|
2018-07-06 18:15:15 +00:00
|
|
|
:data-uuid="network.uuid"
|
|
|
|
:data-nick="network.nick"
|
|
|
|
class="network"
|
2018-07-29 17:57:14 +00:00
|
|
|
role="region">
|
2018-07-12 19:24:35 +00:00
|
|
|
<NetworkLobby
|
2018-07-06 18:15:15 +00:00
|
|
|
:network="network"
|
|
|
|
:active-channel="activeChannel"
|
2018-07-12 19:06:17 +00:00
|
|
|
:is-join-channel-shown="network.isJoinChannelShown"
|
2018-07-29 17:57:14 +00:00
|
|
|
@toggleJoinChannel="network.isJoinChannelShown = !network.isJoinChannelShown" />
|
2018-07-12 19:06:17 +00:00
|
|
|
<JoinChannel
|
|
|
|
v-if="network.isJoinChannelShown"
|
2018-07-23 09:14:35 +00:00
|
|
|
:network="network"
|
2018-07-12 19:06:17 +00:00
|
|
|
:channel="network.channels[0]"
|
2018-07-29 17:57:14 +00:00
|
|
|
@toggleJoinChannel="network.isJoinChannelShown = !network.isJoinChannelShown" />
|
2018-07-06 18:15:15 +00:00
|
|
|
|
|
|
|
<Draggable
|
|
|
|
:options="{ draggable: '.chan', ghostClass: 'chan-placeholder' }"
|
|
|
|
:list="network.channels"
|
|
|
|
class="channels"
|
|
|
|
@change="onChannelSort"
|
|
|
|
@start="onDragStart"
|
|
|
|
@end="onDragEnd"
|
|
|
|
>
|
|
|
|
<Channel
|
2018-07-29 17:57:14 +00:00
|
|
|
v-for="channel in getChannelsWithoutLobby(network)"
|
2018-07-06 18:15:15 +00:00
|
|
|
:key="channel.id"
|
|
|
|
:channel="channel"
|
|
|
|
:network="network"
|
2018-07-29 17:57:14 +00:00
|
|
|
:active-channel="activeChannel" />
|
2018-07-06 18:15:15 +00:00
|
|
|
</Draggable>
|
|
|
|
</div>
|
|
|
|
</Draggable>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Draggable from "vuedraggable";
|
2018-07-12 19:24:35 +00:00
|
|
|
import NetworkLobby from "./NetworkLobby.vue";
|
2018-07-06 18:15:15 +00:00
|
|
|
import Channel from "./Channel.vue";
|
2018-07-12 19:24:35 +00:00
|
|
|
import JoinChannel from "./JoinChannel.vue";
|
2018-07-06 18:15:15 +00:00
|
|
|
|
|
|
|
import socket from "../js/socket";
|
|
|
|
|
|
|
|
export default {
|
2018-07-12 19:24:35 +00:00
|
|
|
name: "NetworkList",
|
2018-07-06 18:15:15 +00:00
|
|
|
components: {
|
|
|
|
JoinChannel,
|
2018-07-12 19:24:35 +00:00
|
|
|
NetworkLobby,
|
2018-07-06 18:15:15 +00:00
|
|
|
Channel,
|
|
|
|
Draggable,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
activeChannel: Object,
|
|
|
|
networks: Array,
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onDragStart(e) {
|
|
|
|
e.target.classList.add("ui-sortable-helper");
|
|
|
|
},
|
|
|
|
onDragEnd(e) {
|
|
|
|
e.target.classList.remove("ui-sortable-helper");
|
|
|
|
},
|
|
|
|
onNetworkSort(e) {
|
|
|
|
if (!e.moved) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
socket.emit("sort", {
|
|
|
|
type: "networks",
|
|
|
|
order: this.networks.map((n) => n.uuid),
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onChannelSort(e) {
|
|
|
|
if (!e.moved) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-14 08:06:30 +00:00
|
|
|
const {findChannel} = require("../js/vue");
|
2018-07-06 18:15:15 +00:00
|
|
|
const channel = findChannel(e.moved.element.id);
|
|
|
|
|
|
|
|
if (!channel) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
socket.emit("sort", {
|
|
|
|
type: "channels",
|
|
|
|
target: channel.network.uuid,
|
|
|
|
order: channel.network.channels.map((c) => c.id),
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|