-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathself-view.vue
110 lines (107 loc) · 2.87 KB
/
self-view.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<template>
<div v-if="session" class="uk-card uk-card-small uk-card-default">
<div class="uk-card-header">
<div uk-grid class="uk-flex-between">
<div>
<h2 class="uk-card-title">Caller #{{ caller.callerId }}</h2>
</div>
<div>
<div v-if="!agentConnected && !onHold" class="uk-label uk-label-default">
In queue
</div>
<div v-if="onHold" class="uk-label uk-label-warning">
On hold
</div>
<div v-if="agentConnected && !onHold" class="uk-label uk-label-success">
Live
</div>
</div>
</div>
</div>
<div class="uk-card-body uk-position-relative">
<ot-publisher :session="session" :opts="publisherOpts" @error="errorEmit" @publisherCreated="handlePublisher"
class="uk-width-small uk-height-small">
</ot-publisher>
<div v-show="isMuted"
class="uk-badge uk-label-warning uk-position-top-right uk-margin-small-top uk-margin-small-right">
Muted
</div>
</div>
<div v-if="otPublisher" class="uk-card-footer">
<button @click="toggleMute" class="uk-button uk-width-1-1 uk-margin-small-bottom"
:class="[ isMuted ? 'uk-button-primary' : 'uk-button-secondary' ]">
{{ isMuted ? 'Unmute' : 'Mute'}}
</button>
<button @click="endCall"
class="uk-button uk-width-1-1 uk-margin-small-bottom uk-button-danger">
End call
</button>
</div>
</div>
</template>
<script>
import OtPublisher from './ot-publisher'
export default {
name: 'self-view',
components: { OtPublisher },
data () {
return {
otPublisher: null,
isMuted: false
}
},
computed: {
publisherOpts: function () {
const _opts = {
// Don't show OpenTok's default UI controls
// See: https://tokbox.com/developer/guides/customize-ui/js/#hiding_ui_controls
showControls: false
}
if (this.audioVideo === 'audioOnly') {
_opts.videoSource = null
}
return _opts
}
},
beforeDestroy () {
if (this.otPublisher && this.session) {
this.session.unpublish(this.otPublisher)
}
},
props: {
caller: Object,
session: Object,
errorHandler: Function,
agentConnected: {
type: Boolean,
default: false
},
onHold: {
type: Boolean,
default: false
},
audioVideo: {
type: String,
default: 'audioVideo'
}
},
methods: {
errorEmit: function (err) {
this.$emit('error', err)
},
handlePublisher: function (p) {
this.otPublisher = p
},
toggleMute: function () {
if (this.otPublisher) {
this.otPublisher.publishAudio(this.isMuted)
this.$emit('publisherMuted', !this.isMuted)
this.isMuted = !this.isMuted
}
},
endCall: function () {
this.$emit('endCall')
}
}
}
</script>