2018-07-06 18:15:15 +00:00
|
|
|
<template>
|
2019-07-17 09:33:59 +00:00
|
|
|
<div v-if="networks.length === 0" class="empty">
|
2018-07-06 18:15:15 +00:00
|
|
|
You are not connected to any networks yet.
|
|
|
|
</div>
|
|
|
|
<Draggable
|
|
|
|
v-else
|
|
|
|
:list="networks"
|
2019-07-12 10:43:47 +00:00
|
|
|
:filter="isCurrentlyInTouch"
|
2019-07-19 11:27:59 +00:00
|
|
|
:prevent-on-filter="false"
|
2019-03-19 13:11:44 +00:00
|
|
|
handle=".lobby"
|
|
|
|
draggable=".network"
|
|
|
|
ghost-class="ui-sortable-ghost"
|
|
|
|
drag-class="ui-sortable-dragged"
|
|
|
|
group="networks"
|
2018-07-06 18:15:15 +00:00
|
|
|
class="networks"
|
|
|
|
@change="onNetworkSort"
|
|
|
|
@start="onDragStart"
|
2019-02-25 05:38:13 +00:00
|
|
|
@end="onDragEnd"
|
|
|
|
>
|
2018-07-06 18:15:15 +00:00
|
|
|
<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"
|
2019-02-25 05:38:13 +00:00
|
|
|
role="region"
|
|
|
|
>
|
2018-07-12 19:24:35 +00:00
|
|
|
<NetworkLobby
|
2018-07-06 18:15:15 +00:00
|
|
|
:network="network"
|
2018-07-12 19:06:17 +00:00
|
|
|
:is-join-channel-shown="network.isJoinChannelShown"
|
2019-02-25 05:38:13 +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]"
|
2019-02-25 05:38:13 +00:00
|
|
|
@toggleJoinChannel="network.isJoinChannelShown = !network.isJoinChannelShown"
|
|
|
|
/>
|
2018-07-06 18:15:15 +00:00
|
|
|
|
|
|
|
<Draggable
|
2019-03-19 13:11:44 +00:00
|
|
|
draggable=".chan"
|
|
|
|
ghost-class="ui-sortable-ghost"
|
|
|
|
drag-class="ui-sortable-dragged"
|
|
|
|
:group="network.uuid"
|
2019-07-12 10:43:47 +00:00
|
|
|
:filter="isCurrentlyInTouch"
|
2019-07-19 11:27:59 +00:00
|
|
|
:prevent-on-filter="false"
|
2018-07-06 18:15:15 +00:00
|
|
|
:list="network.channels"
|
|
|
|
class="channels"
|
|
|
|
@change="onChannelSort"
|
|
|
|
@start="onDragStart"
|
2019-02-25 05:38:13 +00:00
|
|
|
@end="onDragEnd"
|
|
|
|
>
|
2018-07-06 18:15:15 +00:00
|
|
|
<Channel
|
2018-08-30 18:12:53 +00:00
|
|
|
v-for="(channel, index) in network.channels"
|
|
|
|
v-if="index > 0"
|
2018-07-06 18:15:15 +00:00
|
|
|
:key="channel.id"
|
|
|
|
:channel="channel"
|
|
|
|
:network="network"
|
2019-02-25 05:38:13 +00:00
|
|
|
/>
|
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,
|
|
|
|
},
|
2019-11-02 19:40:59 +00:00
|
|
|
computed: {
|
|
|
|
networks() {
|
|
|
|
return this.$store.state.networks;
|
|
|
|
},
|
2018-07-06 18:15:15 +00:00
|
|
|
},
|
2019-07-12 10:43:47 +00:00
|
|
|
methods: {
|
|
|
|
isCurrentlyInTouch(e) {
|
2018-08-30 18:12:53 +00:00
|
|
|
// TODO: Implement a way to sort on touch devices
|
2019-07-12 10:43:47 +00:00
|
|
|
return e.pointerType !== "mouse";
|
2018-08-30 18:12:53 +00:00
|
|
|
},
|
2018-07-06 18:15:15 +00:00
|
|
|
onDragStart(e) {
|
2019-03-19 13:11:44 +00:00
|
|
|
e.target.classList.add("ui-sortable-active");
|
2018-07-06 18:15:15 +00:00
|
|
|
},
|
|
|
|
onDragEnd(e) {
|
2019-03-19 13:11:44 +00:00
|
|
|
e.target.classList.remove("ui-sortable-active");
|
2018-07-06 18:15:15 +00:00
|
|
|
},
|
|
|
|
onNetworkSort(e) {
|
|
|
|
if (!e.moved) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
socket.emit("sort", {
|
|
|
|
type: "networks",
|
|
|
|
order: this.networks.map((n) => n.uuid),
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onChannelSort(e) {
|
|
|
|
if (!e.moved) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-03 14:59:43 +00:00
|
|
|
const channel = this.$store.getters.findChannel(e.moved.element.id);
|
2018-07-06 18:15:15 +00:00
|
|
|
|
|
|
|
if (!channel) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
socket.emit("sort", {
|
|
|
|
type: "channels",
|
|
|
|
target: channel.network.uuid,
|
|
|
|
order: channel.network.channels.map((c) => c.id),
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|