mlp-server-tools/webclient/src/App.vue

78 lines
1.6 KiB
Vue
Raw Normal View History

2019-06-06 14:07:36 +00:00
<template>
2019-06-06 16:07:15 +00:00
<div id="app">
2019-06-07 13:32:43 +00:00
<section class="hero is-primary">
2019-06-06 16:07:15 +00:00
<div class="hero-body">
<div class="container">
<h1 class="title">{{ title }}</h1>
<h2 class="subtitle">{{ subtitle }}</h2>
</div>
</div>
</section>
<div class="container">
<ConnectForm v-if="!isConnected" />
2019-06-07 13:32:43 +00:00
<RoomList v-if="inLobby" />
<RoomLog v-if="inRoom" />
2019-06-06 16:07:15 +00:00
</div>
</div>
2019-06-06 14:07:36 +00:00
</template>
2019-06-07 13:32:43 +00:00
<style lang="scss" scoped>
.hero {
margin-bottom: 2rem;
}
</style>
2019-06-06 14:07:36 +00:00
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
2019-06-06 16:07:15 +00:00
import { State } from "vuex-class";
import ConnectForm from "@/components/ConnectForm.vue";
import RoomList from "@/components/RoomList.vue";
2019-06-07 13:32:43 +00:00
import RoomLog from "@/components/RoomLog.vue";
2019-06-06 16:07:15 +00:00
import { ServerState } from "./store/server";
2019-06-07 13:32:43 +00:00
import { RoomState } from "./store/room";
2019-06-06 14:07:36 +00:00
2019-06-06 16:07:15 +00:00
@Component({
components: {
ConnectForm,
2019-06-07 13:32:43 +00:00
RoomList,
RoomLog
2019-06-06 16:07:15 +00:00
}
})
export default class App extends Vue {
@State("server") private server!: ServerState;
2019-06-07 13:32:43 +00:00
@State("room") private room!: RoomState;
2019-06-06 14:07:36 +00:00
2019-06-06 16:07:15 +00:00
private data() {
2019-06-07 13:32:43 +00:00
return {};
2019-06-06 16:07:15 +00:00
}
2019-06-07 13:32:43 +00:00
private get isConnected(): boolean {
2019-06-06 16:07:15 +00:00
return this.server.connected;
}
2019-06-07 13:32:43 +00:00
private get inLobby(): boolean {
return this.isConnected && !this.room.in_room;
}
private get inRoom(): boolean {
return this.isConnected && this.room.in_room;
}
private get title(): string {
return "Cardgage test client";
}
private get subtitle(): string {
if (this.inRoom && this.room.room) {
return `Inside room "${this.room.room.name}" (${
this.room.room.id
})`;
}
if (this.isConnected) {
return "Browsing " + this.server.server;
}
return "";
}
2019-06-06 16:07:15 +00:00
}
</script>