This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
seepur/resources/scripts/applications/shared/components/TopNavbar.vue

171 lines
5 KiB
Vue
Raw Normal View History

<template>
2020-05-01 17:24:22 +00:00
<div>
<!-- End Call Modal -->
<Modal
title="Are You Sure?"
:isActive="showConfirmEndCall"
acceptText="End"
rejectText="Cancel"
@accept="onConfirmedEndCall()"
@close="showConfirmEndCall=false"
>
<p>End Call?</p>
</Modal>
2020-05-15 17:53:05 +00:00
<nav class="navbar is-light" role="navigation" aria-label="main navigation">
2020-05-01 17:24:22 +00:00
<div class="navbar-brand">
<router-link to="/" class="navbar-item" exact v-if="!inCall">
<strong>Seepur</strong>
</router-link>
<!-- <a class="navbar-item" href="/">
</a>-->
<a
id="menu-button"
role="button"
class="navbar-burger burger"
@click="showMenu=!showMenu"
aria-label="menu"
aria-expanded="false"
data-target="navbarBasicExample"
>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
2020-05-01 17:24:22 +00:00
<div id="nav-menu" :class="['navbar-menu', {'is-active':showMenu}]">
<div class="navbar-start">
<!-- Normal Nav -->
<router-link active-class="is-active" to="/" class="navbar-item" exact v-if="!inCall">Home</router-link>
<router-link
active-class="is-active"
to="/about"
class="navbar-item"
exact
v-if="!inCall"
>About</router-link>
<!-- In call Nav -->
<div class="navbar-item" v-if="inCall">
<div class="field is-grouped">
<p class="control">
<button @click="showConfirmEndCall = true" class="button is-danger" v-if="inCall">
<i class="fa fa-fw fa-times-circle-o"></i> End Call
</button>
</p>
<p class="control">
<button
class="button is-info"
append
replace
v-if="inCall && $route.name==='book'"
:disabled="!callManager.isHost"
@click="backToLobby(true)"
>
<i class="fa fa-fw fa-arrow-circle-o-left"></i> Back
</button>
</p>
</div>
</div>
</div>
<div class="navbar-end">
<div class="navbar-item has-dropdown is-hoverable is-dark" v-if="!inCall">
<a class="navbar-link">{{user.name}}</a>
<div class="navbar-dropdown">
<router-link
active-class="is-active"
2020-05-01 17:24:22 +00:00
to="/settings"
class="navbar-item"
exact
2020-05-01 17:24:22 +00:00
>Settings</router-link>
<a class="navbar-item" href="/logout">Logout</a>
<hr class="navbar-divider" v-if="user.is_admin" />
<a class="navbar-item" href="/admin/" v-if="user.is_admin">Admin Settigns</a>
</div>
</div>
<div class="navbar-item" v-if="inCall">
<p class="control">
2020-05-01 17:24:22 +00:00
<button class="button" @click="changeHost()">
<i class="fa fa-fw fa-refresh"></i> Change Host
</button>
</p>
</div>
2020-05-01 17:24:22 +00:00
<div v-if="inCall" class="navbar-item">Current Host: {{host.name}}</div>
</div>
</div>
2020-05-01 17:24:22 +00:00
</nav>
</div>
</template>
<script lang="ts">
import { mapGetters, mapActions } from "vuex";
2020-05-01 05:55:26 +00:00
import CallManager, { ECallEvents } from "../../home/ws/call.manager";
import WebsocketService from "../../home/ws/websocket.service";
2020-05-01 17:24:22 +00:00
import Modal from "../../shared/components/Modal/Modal.vue";
export default {
name: "TobNavbar",
2020-05-01 18:32:29 +00:00
props: ["ws"],
2020-05-01 17:24:22 +00:00
components: {
Modal
},
2020-05-01 18:37:20 +00:00
watch: {
ws(val, oldVal) {
if (val != null) {
this.callManager = this.ws.callManager;
}
}
2020-05-01 05:55:26 +00:00
},
2020-05-01 18:37:20 +00:00
async created() {},
2020-05-01 05:55:26 +00:00
updated() {
if (!this.inCall) {
this.subscribedToLobbyEvents = false;
}
},
data() {
return {
2020-05-01 17:24:22 +00:00
showConfirmEndCall: false,
2020-05-01 05:55:26 +00:00
showMenu: false,
subscribedToLobbyEvents: false,
callManager: null as CallManager
};
},
computed: {
host() {
if (this.inCall) {
2020-05-01 05:55:26 +00:00
if (!this.subscribedToLobbyEvents) {
console.log("TopNav subscribe to back_to_lobby");
this.subscribedToLobbyEvents = true;
this.callManager.on(
ECallEvents.CALL_VIEW_LOBBY,
this.remoteBackToLobby.bind(this)
);
}
if (this.callManager.isHost) return this.user;
return this.callManager.peer;
}
return null;
},
2020-05-01 05:55:26 +00:00
...mapGetters(["user", "inCall"])
},
methods: {
2020-05-01 17:24:22 +00:00
onConfirmedEndCall() {
this.showConfirmEndCall = false;
this.$router.replace({ path: `/` });
},
changeHost() {
this.callManager.changeHost();
},
backToLobby(payload) {
this.callManager.backToLobby();
this.$router.replace({ path: `/call/${this.callManager.callId}` });
},
remoteBackToLobby(payload) {
this.$router.replace({ path: `/call/${this.callManager.callId}` });
},
...mapActions([])
}
};
</script>