more progress with explore tab

This commit is contained in:
supertiger1234 2019-08-30 16:59:45 +01:00
parent 7e04ad01c0
commit ae3c0c5cae
6 changed files with 126 additions and 35 deletions

View file

@ -1,42 +1,51 @@
<template> <template>
<div class="content-inner" v-if="server"> <div class="content-inner" v-if="server">
<div class="details">Making your server visibility public means that your server will be shown publicly in the Nertivia's "Explore" tab.</div> <div class="details">Making your server visibility public means that your server will be shown publicly in the Nertivia's "Explore" tab.</div>
<div class="content"> <div class="content">
<div class="toggle"> <div class="toggle">
<div class="title">Server Visibility</div> <div class="title">Server Visibility</div>
<div class="item" @click="privateServer = false"><div class="box" :class="{selected: !privateServer}"></div> Public</div> <div class="item" @click="privateServer = true">
<div class="item" @click="privateServer = true"><div class="box" :class="{selected: privateServer}"></div> Private</div> <div class="box" :class="{selected: privateServer}"></div>Private
</div>
<div class="item" @click="privateServer = false">
<div class="box" :class="{selected: !privateServer}"></div>Public
</div>
</div>
<div class="public-settings" v-if="!privateServer">
<div class="input">
<div class="title">Description (<span :class="{warn: description.length > 150}">{{description.length}}</span>/150)</div>
<textarea placeholder="Description" v-model="description"></textarea>
</div> </div>
</div> </div>
</div> </div>
</div>
</template> </template>
<script> <script>
import config from "@/config.js"; import config from "@/config.js";
import { bus } from "@/main"; import { bus } from "@/main";
export default { export default {
components: {}, components: {},
data() { data() {
return { return {
privateServer: true privateServer: true,
} description: '',
};
}, },
methods: { methods: {
}, },
computed: { computed: {
server() { server() {
const serverID = this.$store.state.popoutsModule.serverSettings.serverID const serverID = this.$store.state.popoutsModule.serverSettings.serverID;
return this.$store.getters['servers/servers'][serverID] return this.$store.getters["servers/servers"][serverID];
} }
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.content-inner { .content-inner {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -50,6 +59,7 @@ export default {
.content { .content {
display: flex; display: flex;
flex-direction: column;
} }
.toggle { .toggle {
@ -59,6 +69,7 @@ export default {
margin-left: 10px; margin-left: 10px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-self: flex-start;
.item { .item {
display: flex; display: flex;
margin: 3px; margin: 3px;
@ -76,6 +87,37 @@ export default {
} }
} }
.public-settings {
display: flex;
}
.input{
background: rgb(46, 46, 46);
border-radius: 5px;
padding: 5px;
margin: 10px;
align-self: flex-start;
height: 155px;
width: 300px;
display: flex;
flex-direction: column;
.title {
margin-bottom: 5px;
}
textarea {
background: rgb(34, 34, 34);
resize: none;
outline: none;
padding: 10px;
border: none;
border-radius: 5px;
color: white;
flex: 1;
}
.warn {
color: rgb(255, 67, 67);
}
}
.button { .button {
padding: 10px; padding: 10px;

View file

@ -110,15 +110,27 @@ export default {
justify-content: center; justify-content: center;
flex-shrink: 0; flex-shrink: 0;
width: 100px; width: 100px;
position: relative;
.material-icons { .material-icons {
font-size: 70px; font-size: 70px;
} }
&::after{
content: 'BETA';
position: absolute;
background: #ff3333;
border-radius: 5px;
font-size: 10px;
padding: 2px;
bottom: 15px;
z-index: 999;
}
} }
.details { .details {
align-self: center; align-self: center;
.title { .title {
font-size: 20px; font-size: 20px;
margin-bottom: 5px; margin-bottom: 5px;
position: relative;
} }
.description { .description {
opacity: 0.7; opacity: 0.7;

View file

@ -1,12 +1,15 @@
<template> <template>
<div class="item"> <div class="item">
<div class="top"> <div class="top">
<div class="avatar"></div> <profile-picture
<div class="name">{{server.name}}</div> size="90px"
:url="`${avatarDomain}/${server.server.avatar}`"
/>
<div class="name">{{server.server.name}}</div>
</div> </div>
<div class="bottom"> <div class="bottom">
<div class="description">{{server.description}}</div> <div class="description">{{server.description}}</div>
<div class="button" :class="{selected: joinClicked || joined}" @click="joinButton"> <div class="button" :class="{selected: joined}" @click="joinButton">
<span v-if="joined">Joined</span> <span v-if="joined">Joined</span>
<spinner v-else-if="joinClicked" :size="30"/> <spinner v-else-if="joinClicked" :size="30"/>
<span v-else-if="!joinClicked">Join Server</span> <span v-else-if="!joinClicked">Join Server</span>
@ -18,32 +21,34 @@
<script> <script>
import Spinner from "@/components/Spinner"; import Spinner from "@/components/Spinner";
import ServerService from "@/services/ServerService"; import ServerService from "@/services/ServerService";
import config from "@/config.js";
import ProfilePicture from "@/components/ProfilePictureTemplate.vue";
export default { export default {
components: {Spinner}, components: {Spinner, ProfilePicture},
props: [ props: [
'server', 'server',
], ],
data() { data() {
return { return {
joinClicked: false, joinClicked: false,
avatarDomain: config.domain + "/avatars"
} }
}, },
methods: { methods: {
async joinButton(event) { async joinButton(event) {
if (this.joinClicked|| this.joined) return; if (this.joinClicked|| this.joined) return;
this.joinClicked = true; this.joinClicked = true;
return;
const { ok, error, result } = await ServerService.joinServer( const { ok, error, result } = await ServerService.joinServer(this.server.invite_code);
);
if (ok) { if (ok) {
this.closeMenu(); this.joinClicked = false;
} }
} }
}, },
computed: { computed: {
joined() { joined() {
return this.$store.getters["servers/servers"][this.server.server_id]; return this.$store.getters["servers/servers"][this.server.server.server_id];
} }
} }
}; };
@ -52,7 +57,7 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.item { .item {
width: 250px; width: 250px;
height: 270px; height: 300px;
background: rgba(0, 0, 0, 0.479); background: rgba(0, 0, 0, 0.479);
opacity: 0.9; opacity: 0.9;
margin: 5px; margin: 5px;
@ -70,7 +75,7 @@ export default {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 100%; width: 100%;
height: 140px; height: 150px;
justify-content: center; justify-content: center;
align-content: center; align-content: center;
align-items: center; align-items: center;
@ -83,7 +88,13 @@ export default {
margin-bottom: 10px; margin-bottom: 10px;
} }
.name { .name {
font-size: 23px; margin-top: 9px;
font-size: 21px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
text-align: center;
} }
} }
.bottom { .bottom {
@ -91,12 +102,17 @@ export default {
flex-direction: column; flex-direction: column;
background: rgba(0, 0, 0, 0.194); background: rgba(0, 0, 0, 0.194);
flex: 1; flex: 1;
height: 100%;
flex-shrink: 0;
.description { .description {
margin: 20px; margin: 10px;
margin-top: 20px; flex: 1;
margin-bottom: 10px;
height: 100%;
opacity: 0.9; opacity: 0.9;
overflow: auto;
font-size: 14px;
word-break: break-word;
white-space: pre-wrap;
overflow-wrap: anywhere;
} }
.button { .button {
display: flex; display: flex;

View file

@ -4,7 +4,7 @@
<div class="items-main-container"> <div class="items-main-container">
<div class="items-container"> <div class="items-container">
<div class="items"> <div class="items">
<server-template :server="serverData[0]"/> <server-template v-for="server in publicServers" :key="server.id" :server="server"/>
</div> </div>
@ -16,15 +16,26 @@
<script> <script>
import searchHeader from "./searchHeader"; import searchHeader from "./searchHeader";
import serverTemplate from './serverTemplate'; import serverTemplate from './serverTemplate';
import exploreService from '@/services/exploreService';
export default { export default {
components: { searchHeader, serverTemplate }, components: { searchHeader, serverTemplate },
data() { data() {
return { return {
serverData: [ publicServers: null,
{server_id: "6572151490335477760", name: 'Nertivia', description: 'Nertivia is a cool server.', code: ''},
]
} }
},
methods: {
async getServersList() {
const {ok, result, error} = await exploreService.getServersList();
if (ok) {
this.publicServers = result.data;
}
}
},
mounted() {
this.getServersList();
} }
}; };
</script> </script>

View file

@ -0,0 +1,8 @@
import {instance, wrapper} from './Api';
export default {
getServersList () {
return wrapper(instance().get(`explore/servers`))
},
}

View file

@ -312,7 +312,9 @@ export default {
-webkit-app-region: no-drag; -webkit-app-region: no-drag;
margin-top: 5px; margin-top: 5px;
cursor: pointer; cursor: pointer;
position: relative;
} }
.tab.selected { .tab.selected {
background: rgba(71, 71, 71, 0.637); background: rgba(71, 71, 71, 0.637);
} }