2020-01-26 22:16:16 +00:00
|
|
|
<template>
|
|
|
|
<div class="app">
|
2020-04-12 14:25:42 +00:00
|
|
|
<!-- <Header :appName="appName" /> -->
|
2020-05-01 18:32:29 +00:00
|
|
|
<TopNavbar :ws="this.ws" />
|
2020-04-12 14:25:42 +00:00
|
|
|
<div class="loading" v-if="loading">
|
|
|
|
<Loading />
|
|
|
|
</div>
|
|
|
|
<div class v-else>
|
|
|
|
<div class="notifications">
|
|
|
|
<Notification
|
|
|
|
v-for="notification in notifications"
|
|
|
|
:key="notification.id"
|
|
|
|
:notification="notification"
|
|
|
|
@onClose="onNotificationClose(notification)"
|
|
|
|
/>
|
2020-01-26 22:16:16 +00:00
|
|
|
</div>
|
2020-04-29 23:45:50 +00:00
|
|
|
<div class="app-content m-t-xs is-fullheight">
|
|
|
|
<div class="application">
|
|
|
|
<router-view></router-view>
|
2020-01-26 22:16:16 +00:00
|
|
|
</div>
|
2020-04-12 14:25:42 +00:00
|
|
|
</div>
|
2020-01-26 22:16:16 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2020-02-02 22:42:18 +00:00
|
|
|
<script lang="ts">
|
|
|
|
import Header from "./components/Header.vue";
|
2020-03-17 22:16:34 +00:00
|
|
|
import Services from "../services/index";
|
2020-04-12 14:25:42 +00:00
|
|
|
import Notification from "../shared/components/Notification.vue";
|
|
|
|
import { mapActions, mapGetters } from "vuex";
|
|
|
|
import Loading from "../shared/components/Loading/Loading.vue";
|
2020-04-29 23:45:50 +00:00
|
|
|
import TopNavbar from "../shared/components/TopNavbar.vue";
|
2020-05-01 05:55:26 +00:00
|
|
|
import WebsocketService from "./ws/websocket.service";
|
2020-02-02 22:42:18 +00:00
|
|
|
// import AppRouter from "./router/router.vue";
|
2020-04-29 23:45:50 +00:00
|
|
|
|
2020-03-17 22:16:34 +00:00
|
|
|
// Services.ApiService.getConnections();
|
2020-02-02 22:42:18 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "App",
|
|
|
|
// router: AppRouter,
|
|
|
|
components: {
|
2020-04-12 14:25:42 +00:00
|
|
|
Header,
|
|
|
|
Notification,
|
2020-04-29 23:45:50 +00:00
|
|
|
Loading,
|
|
|
|
TopNavbar
|
2020-04-12 14:25:42 +00:00
|
|
|
},
|
|
|
|
async created() {
|
2020-05-01 05:55:26 +00:00
|
|
|
const u = await this.getUser();
|
|
|
|
// console.log(u);
|
2020-04-12 14:25:42 +00:00
|
|
|
this.ws = await WebsocketService.getInstance();
|
|
|
|
this.ws.on(WebsocketService.Events.CONNECTION_ONLINE, user => {
|
|
|
|
console.log(`User Online: ${JSON.stringify(user, null, 2)}`);
|
|
|
|
this.notify({ message: `${user.name} is online!`, level: "success" });
|
|
|
|
});
|
|
|
|
this.ws.on(WebsocketService.Events.CONNECTION_OFFLINE, user => {
|
|
|
|
this.notify({ message: `${user.name} disconnected`, level: "warning" });
|
|
|
|
});
|
2020-04-13 01:28:33 +00:00
|
|
|
this.ws.on(
|
|
|
|
WebsocketService.Events.INCOMING_CALL,
|
|
|
|
this.onIncomingCall.bind(this)
|
|
|
|
);
|
2020-04-12 14:25:42 +00:00
|
|
|
this.loading = false;
|
|
|
|
return true;
|
2020-02-02 22:42:18 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
appName: "Seepur",
|
2020-04-12 14:25:42 +00:00
|
|
|
loading: true,
|
|
|
|
ws: null
|
2020-02-02 22:42:18 +00:00
|
|
|
};
|
2020-04-12 14:25:42 +00:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters(["notifications"])
|
|
|
|
},
|
|
|
|
methods: {
|
2020-04-13 01:28:33 +00:00
|
|
|
onIncomingCall(payload: { callId: number; child: any }) {
|
|
|
|
this.notify({
|
|
|
|
message: `New call from ${payload.child.name}`,
|
|
|
|
level: "success"
|
|
|
|
});
|
2020-04-29 23:45:50 +00:00
|
|
|
this.$router.replace({ path: `/call/${payload.callId}` });
|
2020-04-13 01:28:33 +00:00
|
|
|
},
|
2020-04-12 14:25:42 +00:00
|
|
|
onNotificationClose(notification) {
|
|
|
|
this.dismissNotification(notification.id);
|
|
|
|
},
|
|
|
|
...mapActions(["dismissNotification", "getUser", "notify"])
|
2020-02-02 22:42:18 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|