2020-04-29 23:45:50 +00:00
|
|
|
<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>
|
|
|
|
<nav class="navbar" role="navigation" aria-label="main navigation">
|
|
|
|
<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-04-29 23:45:50 +00:00
|
|
|
|
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">
|
2020-04-29 23:45:50 +00:00
|
|
|
<router-link
|
|
|
|
active-class="is-active"
|
2020-05-01 17:24:22 +00:00
|
|
|
to="/settings"
|
|
|
|
class="navbar-item"
|
2020-04-29 23:45:50 +00:00
|
|
|
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">
|
2020-04-29 23:45:50 +00:00
|
|
|
<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
|
2020-04-30 02:34:14 +00:00
|
|
|
</button>
|
2020-04-29 23:45:50 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
2020-05-01 17:24:22 +00:00
|
|
|
<div v-if="inCall" class="navbar-item">Current Host: {{host.name}}</div>
|
2020-04-29 23:45:50 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-05-01 17:24:22 +00:00
|
|
|
</nav>
|
|
|
|
</div>
|
2020-04-29 23:45:50 +00:00
|
|
|
</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";
|
2020-04-29 23:45:50 +00:00
|
|
|
export default {
|
2020-04-30 02:34:14 +00:00
|
|
|
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 05:55:26 +00:00
|
|
|
async created() {
|
2020-05-01 18:32:29 +00:00
|
|
|
this.callManager = this.ws.callManager;
|
2020-05-01 05:55:26 +00:00
|
|
|
},
|
|
|
|
updated() {
|
|
|
|
if (!this.inCall) {
|
|
|
|
this.subscribedToLobbyEvents = false;
|
|
|
|
}
|
|
|
|
},
|
2020-04-29 23:45:50 +00:00
|
|
|
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
|
2020-04-29 23:45:50 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
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)
|
|
|
|
);
|
|
|
|
}
|
2020-04-29 23:45:50 +00:00
|
|
|
if (this.callManager.isHost) return this.user;
|
|
|
|
return this.callManager.peer;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
2020-05-01 05:55:26 +00:00
|
|
|
...mapGetters(["user", "inCall"])
|
2020-04-29 23:45:50 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2020-05-01 17:24:22 +00:00
|
|
|
onConfirmedEndCall() {
|
|
|
|
this.showConfirmEndCall = false;
|
|
|
|
this.$router.replace({ path: `/` });
|
|
|
|
},
|
2020-04-29 23:45:50 +00:00
|
|
|
changeHost() {
|
|
|
|
this.callManager.changeHost();
|
|
|
|
},
|
2020-04-30 02:34:14 +00:00
|
|
|
backToLobby(payload) {
|
|
|
|
this.callManager.backToLobby();
|
|
|
|
this.$router.replace({ path: `/call/${this.callManager.callId}` });
|
|
|
|
},
|
|
|
|
remoteBackToLobby(payload) {
|
|
|
|
this.$router.replace({ path: `/call/${this.callManager.callId}` });
|
|
|
|
},
|
2020-04-29 23:45:50 +00:00
|
|
|
...mapActions([])
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|