forked from NdoleStudio/httpsms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessageThreadHeader.vue
More file actions
246 lines (237 loc) · 7.75 KB
/
MessageThreadHeader.vue
File metadata and controls
246 lines (237 loc) · 7.75 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<template>
<v-sheet
class="pa-4 d-flex"
:elevation="$vuetify.breakpoint.lgAndUp ? 0 : 2"
:color="$vuetify.breakpoint.lgAndUp ? 'grey darken-4' : 'black'"
>
<div :class="{ 'px-2': $vuetify.breakpoint.mdAndDown }">
<v-toolbar-title>
<div class="d-flex pt-2" style="width: 245px">
<v-select
outlined
dense
:disabled="owners.length === 0"
placeholder="Phone Numbers"
:class="{ 'mb-n6': !$store.getters.getOwner }"
:items="owners"
:value="$store.getters.getOwner"
@change="onOwnerChanged"
>
</v-select>
<div style="width: 50px">
<v-progress-circular
v-if="$store.getters.getPolling"
indeterminate
:size="20"
:width="1"
class="mt-3 ml-2"
color="success"
></v-progress-circular>
</div>
</div>
</v-toolbar-title>
<div v-if="$store.getters.getOwner" class="d-flex mt-n4">
<p class="text--secondary mb-n1">
{{ $store.getters.getOwner | phoneCountry }}
</p>
<v-tooltip
v-if="$store.getters.getHeartbeat"
right
:open-on-focus="false"
:open-on-hover="true"
open-on-click
>
<template #activator="{ on, attrs }">
<v-btn
x-small
v-bind="attrs"
color="success"
class="ml-2 mt-1 mb-n1"
icon
v-on="on"
>
<v-icon x-small>{{ mdiCircle }}</v-icon>
</v-btn>
</template>
<h4>Last Heartbeat</h4>
{{ $store.getters.getHeartbeat.timestamp | humanizeTime }} ago
</v-tooltip>
</div>
</div>
<v-spacer></v-spacer>
<v-menu offset-y>
<template #activator="{ on }">
<v-btn icon text class="mt-2" v-on="on">
<v-icon>{{ mdiDotsVertical }}</v-icon>
</v-btn>
</template>
<v-list class="px-2" nav :dense="$vuetify.breakpoint.mdAndDown">
<v-list-item-group v-model="selectedMenuItem">
<v-list-item @click.prevent="toggleArchive">
<v-list-item-icon class="pl-2">
<v-icon v-if="!$store.getters.getIsArchived" dense>
{{ mdiPackageDown }}
</v-icon>
<v-icon v-if="$store.getters.getIsArchived" dense>
{{ mdiPackageUp }}
</v-icon>
</v-list-item-icon>
<v-list-item-content class="ml-n3">
<v-list-item-title class="pr-16 py-1">
<span
v-if="!$store.getters.getIsArchived"
:class="{ 'pr-16': $vuetify.breakpoint.mdAndUp }"
>
Archived
</span>
<span
v-if="$store.getters.getIsArchived"
:class="{ 'pr-16': $vuetify.breakpoint.mdAndUp }"
>
Unarchived
</span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item
v-if="$store.getters.getOwner"
:to="{ name: 'messages' }"
exact
>
<v-list-item-icon class="pl-2">
<v-icon dense>{{ mdiPlus }}</v-icon>
</v-list-item-icon>
<v-list-item-content class="ml-n3">
<v-list-item-title class="pr-16 py-1">
<span :class="{ 'pr-16': $vuetify.breakpoint.mdAndUp }">
New Message
</span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item :to="{ name: 'settings' }" exact>
<v-list-item-icon class="pl-2">
<v-icon dense>{{ mdiAccountCog }}</v-icon>
</v-list-item-icon>
<v-list-item-content class="ml-n3">
<v-list-item-title class="pr-16 py-1">
<span :class="{ 'pr-16': $vuetify.breakpoint.mdAndUp }">
Settings
</span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item
v-if="$store.getters.getOwner"
:href="$store.getters.getAppData.appDownloadUrl"
exact
>
<v-list-item-icon class="pl-2">
<v-icon dense>{{ mdiDownload }}</v-icon>
</v-list-item-icon>
<v-list-item-content class="ml-n3">
<v-list-item-title class="pr-16 py-1">
<span :class="{ 'pr-16': $vuetify.breakpoint.mdAndUp }">
Install App
</span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item :to="{ name: 'billing' }" exact>
<v-list-item-icon class="pl-2">
<v-icon dense>{{ mdiFinance }}</v-icon>
</v-list-item-icon>
<v-list-item-content class="ml-n3">
<v-list-item-title class="pr-16 py-1">
<span :class="{ 'pr-16': $vuetify.breakpoint.mdAndUp }">
Usage & Billing
</span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item @click.prevent="logout">
<v-list-item-icon class="pl-2">
<v-icon dense>{{ mdiLogout }}</v-icon>
</v-list-item-icon>
<v-list-item-content class="ml-n3">
<v-list-item-title class="pr-16 py-1">
<span :class="{ 'pr-16': $vuetify.breakpoint.mdAndUp }">
Logout
</span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-menu>
</v-sheet>
</template>
<script lang="ts">
import { Vue, Component } from 'vue-property-decorator'
import {
mdiPlus,
mdiAccountCog,
mdiLogout,
mdiDownload,
mdiFinance,
mdiPackageUp,
mdiPackageDown,
mdiDotsVertical,
mdiCircle,
} from '@mdi/js'
import { SelectItem } from '~/types'
import { Phone } from '~/models/phone'
@Component
export default class MessageThreadHeader extends Vue {
selectedMenuItem = -1
mdiPlus = mdiPlus
mdiAccountCog = mdiAccountCog
mdiLogout = mdiLogout
mdiDownload = mdiDownload
mdiPackageUp = mdiPackageUp
mdiFinance = mdiFinance
mdiPackageDown = mdiPackageDown
mdiDotsVertical = mdiDotsVertical
mdiCircle = mdiCircle
get owners(): Array<SelectItem> {
return this.$store.getters.getPhones.map((phone: Phone): SelectItem => {
return {
text: this.$options.filters?.phoneNumber(phone.phone_number),
value: phone.phone_number,
}
})
}
async onOwnerChanged(owner: string) {
await this.$store.dispatch('setOwner', owner)
if (this.$route.name !== 'threads') {
await this.$store.dispatch('setThreadId', null)
await this.$router.push({ name: 'threads' })
return
}
await this.$store.dispatch('loadThreads')
}
async toggleArchive() {
await this.$store.dispatch('toggleArchive')
setTimeout(() => {
this.selectedMenuItem = -1
}, 1000)
if (this.$route.name !== 'threads') {
await this.$store.dispatch('setThreadId', null)
await this.$router.push({ name: 'threads' })
return
}
await this.$store.dispatch('loadThreads')
}
logout(): void {
this.$fire.auth.signOut().then(() => {
this.$store.dispatch('setAuthUser', null)
this.$store.dispatch('resetState')
this.$store.dispatch('addNotification', {
type: 'info',
message: 'You have successfully logged out',
})
this.$router.push({ name: 'index' })
})
}
}
</script>