A bit more polish

This commit is contained in:
Sagi Dayan 2020-05-01 13:24:22 -04:00
parent beb38b10c5
commit 8acef2bf39
13 changed files with 182 additions and 120 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -6969,3 +6969,9 @@ video {
.book-thumb.enabled:hover { .book-thumb.enabled:hover {
transform: scale(1.1); transform: scale(1.1);
z-index: 10; } z-index: 10; }
.fade-enter-active, .fade-leave-active {
transition: opacity .2s; }
.fade-enter, .fade-leave-to {
opacity: 0; }

View file

@ -263,3 +263,10 @@ video{
z-index: 10; z-index: 10;
} }
} }
//Fade vue transition
.fade-enter-active, .fade-leave-active {
transition: opacity .2s;
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
opacity: 0;
}

View file

@ -148,7 +148,7 @@ export default {
async makeCall(event) { async makeCall(event) {
try { try {
const response = await Services.ApiService.createCall(event); const response = await Services.ApiService.createCall(event);
this.notify({ message: `Connectiong...` }); this.notify({ message: `Connecting...` });
this.$router.push({ path: `/call/${response.data.id}` }); this.$router.push({ path: `/call/${response.data.id}` });
} catch (e) { } catch (e) {
console.error(e); console.error(e);

View file

@ -58,7 +58,7 @@
<h4 class="subtitle">{{user.name}}</h4> <h4 class="subtitle">{{user.name}}</h4>
</div> </div>
<div class="columns"> <div class="columns">
<div class="column is-one-quarter"> <div class="column is-5">
<figure class="image is-128x128 m-auto"> <figure class="image is-128x128 m-auto">
<img class="is-rounded is-avatar" :src="user.avatar" /> <img class="is-rounded is-avatar" :src="user.avatar" />
</figure> </figure>

View file

@ -219,8 +219,8 @@ export default class CallManager {
} }
close() { close() {
console.log('Closing...');
if (!this.inCall) return; if (!this.inCall) return;
console.log('Closing...');
this.emit(ECallEvents.CLOSE, this.callId); this.emit(ECallEvents.CLOSE, this.callId);
if (this.signalingChannel) this.signalingChannel.close(); if (this.signalingChannel) this.signalingChannel.close();
this.signalingChannel = null; this.signalingChannel = null;

View file

@ -1,16 +1,31 @@
export default class ApiService { export default class ApiService {
static async getUser(userId?: number) { static async getUser(userId?: number) {
try {
return (await fetch('/api/v1/client/user/')).json(); return (await fetch('/api/v1/client/user/')).json();
} catch (e) {
console.error(`getUser ERROR: ${e.message}`);
return e;
}
} }
static async getAllUsers() { static async getAllUsers() {
try {
return (await fetch('/api/v1/admin/users')).json(); return (await fetch('/api/v1/admin/users')).json();
} catch (e) {
console.error(`getAllUsers ERROR: ${e.message}`);
return e;
}
} }
static async getChild(id: number): Promise<IApiResponse> { static async getChild(id: number): Promise<IApiResponse> {
try {
return (await fetch(`/api/v1/client/child/${id}`)).json(); return (await fetch(`/api/v1/client/child/${id}`)).json();
} catch (e) {
console.error(`getChild ERROR: ${e.message}`);
return e;
}
} }
static async createConnection(payload: { child_id: number, email: string, is_parent: boolean }) { static async createConnection(payload: { child_id: number, email: string, is_parent: boolean }) {
@ -23,8 +38,9 @@ export default class ApiService {
} }
try { try {
return (await fetch('/api/v1/client/connections/create', options)).json(); return (await fetch('/api/v1/client/connections/create', options)).json();
} catch (error) { } catch (e) {
return error; console.error(`createConnection ERROR: ${e.message}`);
return e;
} }
} }
@ -44,7 +60,7 @@ export default class ApiService {
return response.json(); return response.json();
} catch (e) { } catch (e) {
console.error(e); console.error(`updateChildCover ERROR: ${e.message}`);
return false; return false;
} }
}; };
@ -62,7 +78,7 @@ export default class ApiService {
return response.json(); return response.json();
} catch (e) { } catch (e) {
console.error(e); console.error(`createCall ERROR: ${e.message}`);
return false; return false;
} }
} }
@ -87,7 +103,7 @@ export default class ApiService {
return response.json(); return response.json();
} catch (e) { } catch (e) {
console.error(e); console.error(`createChild ERROR: ${e.message}`);
return false; return false;
} }
} }

View file

@ -1,5 +1,6 @@
<template> <template>
<div :class="['modal', { 'is-active': !!isActive }]"> <transition name="fade">
<div :class="['modal', { 'is-active': !!isActive }]" v-if="!!isActive">
<div class="modal-background" @click="close()"></div> <div class="modal-background" @click="close()"></div>
<div class="modal-card"> <div class="modal-card">
<header class="modal-card-head" v-if="showTitle"> <header class="modal-card-head" v-if="showTitle">
@ -10,26 +11,30 @@
<slot></slot> <slot></slot>
</section> </section>
<footer class="modal-card-foot" v-if="showButtons"> <footer class="modal-card-foot" v-if="showButtons">
<button class="button is-success" v-if="!!acceptText" @click="$emit('accept')">{{acceptText}}</button> <button
class="button is-success"
v-if="!!acceptText"
@click="$emit('accept')"
>{{acceptText}}</button>
<button class="button" @click="close()" v-if="!!rejectText">{{rejectText}}</button> <button class="button" @click="close()" v-if="!!rejectText">{{rejectText}}</button>
</footer> </footer>
</div> </div>
</div> </div>
</transition>
</template> </template>
<script lang="ts"> <script lang="ts">
export default { export default {
props: ["title", "isActive", "acceptText", "rejectText"], props: ["title", "isActive", "acceptText", "rejectText"],
data() { data() {
return { return {
showTitle: !!this.title, showTitle: !!this.title,
showButtons: this.acceptText || this.rejectText showButtons: this.acceptText || this.rejectText
} };
}, },
methods: { methods: {
close() { close() {
this.$emit('close'); this.$emit("close");
} }
} }
}; };

View file

@ -1,16 +1,24 @@
<template> <template>
<div <transition name="fade">
:class="['notification','notification-fade' ,'is-light', `is-${notification.level || 'info'}`]" <div :class="['notification' ,'is-light', `is-${notification.level || 'info'}`]" v-if="ready">
>
<button class="delete" @click="close()"></button> <button class="delete" @click="close()"></button>
{{notification.message}} {{notification.message}}
</div> </div>
</transition>
</template> </template>
<script lang="ts"> <script lang="ts">
export default { export default {
name: "Notification", name: "Notification",
props: ["notification"], props: ["notification"],
mounted() {
this.ready = true;
},
data() {
return {
ready: false
};
},
methods: { methods: {
close() { close() {
this.$emit("onClose"); this.$emit("onClose");

View file

@ -1,4 +1,16 @@
<template> <template>
<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"> <nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand"> <div class="navbar-brand">
<router-link to="/" class="navbar-item" exact v-if="!inCall"> <router-link to="/" class="navbar-item" exact v-if="!inCall">
@ -36,16 +48,9 @@
<div class="navbar-item" v-if="inCall"> <div class="navbar-item" v-if="inCall">
<div class="field is-grouped"> <div class="field is-grouped">
<p class="control"> <p class="control">
<router-link <button @click="showConfirmEndCall = true" class="button is-danger" v-if="inCall">
active-class="is-active"
to="/"
class="button is-danger"
exact
replace
v-if="inCall"
>
<i class="fa fa-fw fa-times-circle-o"></i> End Call <i class="fa fa-fw fa-times-circle-o"></i> End Call
</router-link> </button>
</p> </p>
<p class="control"> <p class="control">
<button <button
@ -68,7 +73,12 @@
<a class="navbar-link">{{user.name}}</a> <a class="navbar-link">{{user.name}}</a>
<div class="navbar-dropdown"> <div class="navbar-dropdown">
<router-link active-class="is-active" to="/settings" class="navbar-item" exact>Settings</router-link> <router-link
active-class="is-active"
to="/settings"
class="navbar-item"
exact
>Settings</router-link>
<a class="navbar-item" href="/logout">Logout</a> <a class="navbar-item" href="/logout">Logout</a>
<hr class="navbar-divider" v-if="user.is_admin" /> <hr class="navbar-divider" v-if="user.is_admin" />
<a class="navbar-item" href="/admin/" v-if="user.is_admin">Admin Settigns</a> <a class="navbar-item" href="/admin/" v-if="user.is_admin">Admin Settigns</a>
@ -85,14 +95,19 @@
</div> </div>
</div> </div>
</nav> </nav>
</div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { mapGetters, mapActions } from "vuex"; import { mapGetters, mapActions } from "vuex";
import CallManager, { ECallEvents } from "../../home/ws/call.manager"; import CallManager, { ECallEvents } from "../../home/ws/call.manager";
import WebsocketService from "../../home/ws/websocket.service"; import WebsocketService from "../../home/ws/websocket.service";
import Modal from "../../shared/components/Modal/Modal.vue";
export default { export default {
name: "TobNavbar", name: "TobNavbar",
components: {
Modal
},
async created() { async created() {
const ws = await WebsocketService.getInstance(); const ws = await WebsocketService.getInstance();
this.callManager = ws.callManager; this.callManager = ws.callManager;
@ -104,6 +119,7 @@ export default {
}, },
data() { data() {
return { return {
showConfirmEndCall: false,
showMenu: false, showMenu: false,
subscribedToLobbyEvents: false, subscribedToLobbyEvents: false,
callManager: null as CallManager callManager: null as CallManager
@ -128,6 +144,10 @@ export default {
...mapGetters(["user", "inCall"]) ...mapGetters(["user", "inCall"])
}, },
methods: { methods: {
onConfirmedEndCall() {
this.showConfirmEndCall = false;
this.$router.replace({ path: `/` });
},
changeHost() { changeHost() {
this.callManager.changeHost(); this.callManager.changeHost();
}, },