admin-users-edit.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. <template lang='pug'>
  2. v-container(fluid, grid-list-lg)
  3. v-layout(row, wrap)
  4. v-flex(xs12)
  5. .admin-header
  6. img.animated.fadeInUp(src='/svg/icon-male-user.svg', :alt='$t(`admin:users.edit`)', style='width: 80px;')
  7. .admin-header-title
  8. .headline.blue--text.text--darken-2.animated.fadeInLeft {{$t('admin:users.edit')}}
  9. .subtitle-1.grey--text.animated.fadeInLeft.wait-p2s {{user.name}}
  10. v-spacer
  11. template(v-if='user.isActive')
  12. status-indicator.mr-3(positive, pulse)
  13. .caption.green--text {{$t('admin:users.active')}}
  14. template(v-else)
  15. status-indicator.mr-3(negative, pulse)
  16. .caption.red--text {{$t('admin:users.inactive')}}
  17. template(v-if='user.isVerified')
  18. status-indicator.mr-3.ml-4(active, pulse)
  19. .caption.blue--text {{$t('admin:users.verified')}}
  20. template(v-else)
  21. status-indicator.mr-3.ml-4(intermediary, pulse)
  22. .caption.deep-orange--text {{$t('admin:users.unverified')}}
  23. v-spacer
  24. i18next.caption.grey--text.animated.fadeInRight.wait-p5s(path='admin:users.id', tag='div')
  25. strong(place='id') {{user.id}}
  26. v-divider.animated.fadeInRight.wait-p4s.ml-3(vertical)
  27. v-btn.ml-3.animated.fadeInDown.wait-p3s(color='grey', large, outlined, to='/users')
  28. v-icon mdi-arrow-left
  29. v-menu(offset-y, origin='top right')
  30. template(v-slot:activator='{ on }')
  31. v-btn.ml-3.animated.fadeInDown.wait-p2s(color='indigo', v-on='on', large, depressed, dark)
  32. span Actions
  33. v-icon(right) mdi-chevron-down
  34. v-list(dense, nav)
  35. v-list-item(v-if='!user.isActive', @click='activateUser')
  36. v-list-item-icon
  37. v-icon(color='purple') mdi-steering
  38. v-list-item-title Activate
  39. v-list-item(v-else, @click='deactivateUser', :disabled='user.id == currentUserId || user.isSystem')
  40. v-list-item-icon
  41. v-icon(color='purple') mdi-cancel
  42. v-list-item-title Deactivate
  43. v-list-item(@click='deleteUserDialog = true', :disabled='user.id == currentUserId || user.isSystem')
  44. v-list-item-icon
  45. v-icon(color='red') mdi-trash-can-outline
  46. v-list-item-title Delete
  47. v-btn.ml-3.animated.fadeInDown(color='primary', large, depressed, @click='updateUser')
  48. v-icon(left) mdi-check
  49. span {{$t('admin:users.updateUser')}}
  50. v-flex(xs6)
  51. v-card.animated.fadeInUp
  52. v-toolbar(color='primary', dense, dark, flat)
  53. v-icon.mr-2 mdi-information-variant
  54. span {{$t('admin:users.basicInfo')}}
  55. v-list.py-0(two-line, dense)
  56. v-list-item
  57. v-list-item-avatar(size='32')
  58. v-icon mdi-email-variant
  59. v-list-item-content
  60. v-list-item-title {{$t('admin:users.email')}}
  61. v-list-item-subtitle {{ user.email }}
  62. v-list-item-action(v-if='!user.isSystem && user.providerKey === `local`')
  63. v-menu(
  64. v-model='editPop.email'
  65. :close-on-content-click='false'
  66. min-width='350'
  67. left
  68. )
  69. template(v-slot:activator='{ on }')
  70. v-btn(icon, color='grey', x-small, v-on='on', @click='focusField(`iptEmail`)')
  71. v-icon mdi-pencil
  72. v-card
  73. v-text-field(
  74. ref='iptEmail'
  75. v-model='user.email'
  76. :label='$t(`admin:users.email`)'
  77. solo
  78. hide-details
  79. append-icon='mdi-check'
  80. @click:append='editPop.email = false'
  81. @keydown.enter='editPop.email = false'
  82. @keydown.esc='editPop.email = false'
  83. )
  84. v-divider
  85. v-list-item
  86. v-list-item-avatar(size='32')
  87. v-icon mdi-account
  88. v-list-item-content
  89. v-list-item-title {{$t('admin:users.displayName')}}
  90. v-list-item-subtitle {{ user.name }}
  91. v-list-item-action
  92. v-menu(
  93. v-model='editPop.name'
  94. :close-on-content-click='false'
  95. min-width='350'
  96. left
  97. )
  98. template(v-slot:activator='{ on }')
  99. v-btn(icon, color='grey', x-small, v-on='on', @click='focusField(`iptDisplayName`)')
  100. v-icon mdi-pencil
  101. v-card
  102. v-text-field(
  103. ref='iptDisplayName'
  104. v-model='user.name'
  105. :label='$t(`admin:users.displayName`)'
  106. solo
  107. hide-details
  108. append-icon='mdi-check'
  109. @click:append='editPop.name = false'
  110. @keydown.enter='editPop.name = false'
  111. @keydown.esc='editPop.name = false'
  112. )
  113. v-card.mt-3.animated.fadeInUp.wait-p2s(v-if='!user.isSystem')
  114. v-toolbar(color='primary', dense, dark, flat)
  115. v-icon.mr-2 mdi-lock-outline
  116. span {{$t('admin:users.authentication')}}
  117. v-list.py-0(two-line, dense)
  118. v-list-item
  119. v-list-item-avatar(size='32')
  120. v-icon mdi-domain
  121. v-list-item-content
  122. v-list-item-title {{$t('admin:users.authProvider')}}
  123. v-list-item-subtitle {{ user.providerKey }}
  124. //- v-list-item-action
  125. //- v-img(src='https://static.requarks.io/logo/wikijs.svg', alt='', contain, max-height='32', position='center right')
  126. template(v-if='user.providerKey === `local`')
  127. v-divider
  128. v-list-item
  129. v-list-item-avatar(size='32')
  130. v-icon mdi-textbox-password
  131. v-list-item-content
  132. v-list-item-title {{$t('admin:users.password')}}
  133. v-list-item-subtitle &bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;
  134. v-list-item-action
  135. v-menu(
  136. v-model='editPop.newPassword'
  137. :close-on-content-click='false'
  138. min-width='350'
  139. left
  140. )
  141. template(v-slot:activator='{ on: menu }')
  142. v-tooltip(top)
  143. template(v-slot:activator='{ on: tooltip }')
  144. v-btn(icon, color='grey', x-small, v-on='{ ...menu, ...tooltip }', @click='focusField(`iptNewPassword`)')
  145. v-icon mdi-cached
  146. span {{$t('admin:users.changePassword')}}
  147. v-card
  148. v-text-field(
  149. ref='iptNewPassword'
  150. v-model='newPassword'
  151. :label='$t(`admin:users.newPassword`)'
  152. solo
  153. hide-details
  154. append-icon='mdi-check'
  155. type='password'
  156. @click:append='editPop.newPassword = false'
  157. @keydown.enter='editPop.newPassword = false'
  158. @keydown.esc='editPop.newPassword = false'
  159. )
  160. v-list-item-action
  161. v-tooltip(top)
  162. template(v-slot:activator='{ on }')
  163. v-btn(icon, color='grey', x-small, v-on='on', disabled)
  164. v-icon mdi-email
  165. span Send Password Reset Email
  166. v-divider
  167. v-list-item
  168. v-list-item-avatar(size='32')
  169. v-icon mdi-two-factor-authentication
  170. v-list-item-content
  171. v-list-item-title {{$t('admin:users.tfa')}}
  172. v-list-item-subtitle.red--text Inactive
  173. v-list-item-action
  174. v-tooltip(top)
  175. template(v-slot:activator='{ on }')
  176. v-btn(icon, color='grey', x-small, v-on='on', disabled)
  177. v-icon mdi-power
  178. span {{$t('admin:users.toggle2FA')}}
  179. template(v-if='user.providerId')
  180. v-divider
  181. v-list-item
  182. v-list-item-avatar(size='32')
  183. v-icon mdi-music-accidental-sharp
  184. v-list-item-content
  185. v-list-item-title {{$t('admin:users.authProviderId')}}
  186. v-list-item-subtitle {{ user.providerId }}
  187. v-card.mt-3.animated.fadeInUp.wait-p4s
  188. v-toolbar(color='primary', dense, dark, flat)
  189. v-icon.mr-2 mdi-account-group
  190. span {{$t('admin:users.groups')}}
  191. v-list(dense)
  192. template(v-for='(group, idx) in user.groups')
  193. v-list-item(:key='`group-` + group.id')
  194. v-list-item-avatar(size='32')
  195. v-icon mdi-account-group-outline
  196. v-list-item-content
  197. v-list-item-title {{group.name}}
  198. v-list-item-action(v-if='!user.isSystem')
  199. v-btn(icon, color='red', x-small, @click='unassignGroup(group.id)')
  200. v-icon mdi-close
  201. v-divider(v-if='idx < user.groups.length - 1')
  202. v-alert.mx-3(v-if='user.groups.length < 1', outlined, color='grey darken-1', icon='mdi-alert')
  203. .caption {{$t('admin:users.noGroupAssigned')}}
  204. v-card-chin(v-if='!user.isSystem')
  205. v-spacer
  206. v-select(
  207. ref='iptAssignGroup'
  208. :items='groups'
  209. v-model='newGroup'
  210. :label='$t(`admin:users.selectGroup`)'
  211. item-value='id'
  212. item-text='name'
  213. item-disabled='isSystem'
  214. solo
  215. flat
  216. hide-details
  217. @keydown.esc='editPop.assignGroup = false'
  218. style='max-width: 300px;'
  219. )
  220. v-btn.ml-2.px-4(depressed, color='primary', height='48', @click='assignGroup', :disabled='newGroup === 0')
  221. v-icon(left) mdi-clipboard-account-outline
  222. span {{$t('admin:users.groupAssign')}}
  223. v-system-bar(window, :color='$vuetify.theme.dark ? `grey darken-4-l3` : `grey lighten-3`')
  224. v-spacer
  225. .caption {{$t('admin:users.groupAssignNotice')}}
  226. v-flex(xs6)
  227. v-card.animated.fadeInUp.wait-p2s
  228. v-toolbar(color='primary', dense, dark, flat)
  229. v-icon.mr-2 mdi-account-badge-outline
  230. span {{$t('admin:users.extendedMetadata')}}
  231. v-list.py-0(two-line, dense)
  232. v-list-item
  233. v-list-item-avatar(size='32')
  234. v-icon mdi-map-marker
  235. v-list-item-content
  236. v-list-item-title {{$t('admin:users.location')}}
  237. v-list-item-subtitle {{ user.location }}
  238. v-list-item-action
  239. v-menu(
  240. v-model='editPop.location'
  241. :close-on-content-click='false'
  242. min-width='350'
  243. left
  244. )
  245. template(v-slot:activator='{ on }')
  246. v-btn(icon, color='grey', x-small, v-on='on', @click='focusField(`iptLocation`)')
  247. v-icon mdi-pencil
  248. v-card
  249. v-text-field(
  250. ref='iptLocation'
  251. v-model='user.location'
  252. :label='$t(`admin:users.location`)'
  253. solo
  254. hide-details
  255. append-icon='mdi-check'
  256. @click:append='editPop.location = false'
  257. @keydown.enter='editPop.location = false'
  258. @keydown.esc='editPop.location = false'
  259. )
  260. v-divider
  261. v-list-item
  262. v-list-item-avatar(size='32')
  263. v-icon mdi-account-badge-horizontal-outline
  264. v-list-item-content
  265. v-list-item-title {{$t('admin:users.jobTitle')}}
  266. v-list-item-subtitle {{ user.jobTitle }}
  267. v-list-item-action
  268. v-menu(
  269. v-model='editPop.jobTitle'
  270. :close-on-content-click='false'
  271. min-width='350'
  272. left
  273. )
  274. template(v-slot:activator='{ on }')
  275. v-btn(icon, color='grey', x-small, v-on='on', @click='focusField(`iptJobTitle`)')
  276. v-icon mdi-pencil
  277. v-card
  278. v-text-field(
  279. ref='iptJobTitle'
  280. v-model='user.jobTitle'
  281. :label='$t(`admin:users.jobTitle`)'
  282. solo
  283. hide-details
  284. append-icon='mdi-check'
  285. @click:append='editPop.jobTitle = false'
  286. @keydown.enter='editPop.jobTitle = false'
  287. @keydown.esc='editPop.jobTitle = false'
  288. )
  289. v-divider
  290. v-list-item
  291. v-list-item-avatar(size='32')
  292. v-icon mdi-map-clock-outline
  293. v-list-item-content
  294. v-list-item-title {{$t('admin:users.timezone')}}
  295. v-list-item-subtitle {{ user.timezone }}
  296. v-list-item-action
  297. v-menu(
  298. v-model='editPop.timezone'
  299. :close-on-content-click='false'
  300. min-width='350'
  301. left
  302. )
  303. template(v-slot:activator='{ on }')
  304. v-btn(icon, color='grey', x-small, v-on='on', @click='focusField(`iptTimezone`)')
  305. v-icon mdi-pencil
  306. v-card
  307. v-select(
  308. ref='iptTimezone'
  309. :items='timezones'
  310. v-model='user.timezone'
  311. :label='$t(`admin:users.timezone`)'
  312. solo
  313. dense
  314. hide-details
  315. append-icon='mdi-check'
  316. @click:append='editPop.timezone = false'
  317. @keydown.enter='editPop.timezone = false'
  318. @keydown.esc='editPop.timezone = false'
  319. )
  320. v-card.mt-3.animated.fadeInUp.wait-p4s
  321. v-toolbar(color='primary', dense, dark, flat)
  322. v-icon.mr-2 mdi-file-document-box-multiple-outline
  323. span Content
  324. v-card-text
  325. em.caption.grey--text Coming soon
  326. v-dialog(v-model='deleteUserDialog', max-width='500')
  327. v-card
  328. .dialog-header.is-red {{$t('admin:users.deleteConfirmTitle')}}
  329. v-card-text.pt-5
  330. i18next(path='admin:users.deleteConfirmText', tag='span')
  331. strong(place='username') {{ user.email }}
  332. .caption.mt-3 {{$t('admin:users.deleteConfirmForeignNotice')}}
  333. v-card-actions
  334. v-spacer
  335. v-btn(text, @click='deleteUserDialog = false') {{$t('common:actions.cancel')}}
  336. v-btn(color='red', dark, @click='deleteUser') {{$t('common:actions.delete')}}
  337. </template>
  338. <script>
  339. import _ from 'lodash'
  340. import { get } from 'vuex-pathify'
  341. import { StatusIndicator } from 'vue-status-indicator'
  342. import userQuery from 'gql/admin/users/users-query-single.gql'
  343. import groupsQuery from 'gql/admin/users/users-query-groups.gql'
  344. import updateUserMutation from 'gql/admin/users/users-mutation-update.gql'
  345. import deleteUserMutation from 'gql/admin/users/users-mutation-delete.gql'
  346. export default {
  347. components: {
  348. StatusIndicator
  349. },
  350. data() {
  351. return {
  352. deleteUserDialog: false,
  353. editPop: {
  354. email: false,
  355. name: false,
  356. pwd: false,
  357. location: false,
  358. jobTitle: false,
  359. timezone: false,
  360. newPassword: false,
  361. assignGroup: false
  362. },
  363. newGroup: 0,
  364. newPassword: '',
  365. user: {
  366. email: '',
  367. name: '',
  368. location: '',
  369. jobTitle: '',
  370. timezone: '',
  371. groups: [],
  372. isActive: false,
  373. isVerified: false
  374. },
  375. timezones: [
  376. { text: '(GMT-11:00) Niue', value: 'Pacific/Niue' },
  377. { text: '(GMT-11:00) Pago Pago', value: 'Pacific/Pago_Pago' },
  378. { text: '(GMT-10:00) Hawaii Time', value: 'Pacific/Honolulu' },
  379. { text: '(GMT-10:00) Rarotonga', value: 'Pacific/Rarotonga' },
  380. { text: '(GMT-10:00) Tahiti', value: 'Pacific/Tahiti' },
  381. { text: '(GMT-09:30) Marquesas', value: 'Pacific/Marquesas' },
  382. { text: '(GMT-09:00) Alaska Time', value: 'America/Anchorage' },
  383. { text: '(GMT-09:00) Gambier', value: 'Pacific/Gambier' },
  384. { text: '(GMT-08:00) Pacific Time', value: 'America/Los_Angeles' },
  385. { text: '(GMT-08:00) Pacific Time - Tijuana', value: 'America/Tijuana' },
  386. { text: '(GMT-08:00) Pacific Time - Vancouver', value: 'America/Vancouver' },
  387. { text: '(GMT-08:00) Pacific Time - Whitehorse', value: 'America/Whitehorse' },
  388. { text: '(GMT-08:00) Pitcairn', value: 'Pacific/Pitcairn' },
  389. { text: '(GMT-07:00) Mountain Time', value: 'America/Denver' },
  390. { text: '(GMT-07:00) Mountain Time - Arizona', value: 'America/Phoenix' },
  391. { text: '(GMT-07:00) Mountain Time - Chihuahua, Mazatlan', value: 'America/Mazatlan' },
  392. { text: '(GMT-07:00) Mountain Time - Dawson Creek', value: 'America/Dawson_Creek' },
  393. { text: '(GMT-07:00) Mountain Time - Edmonton', value: 'America/Edmonton' },
  394. { text: '(GMT-07:00) Mountain Time - Hermosillo', value: 'America/Hermosillo' },
  395. { text: '(GMT-07:00) Mountain Time - Yellowknife', value: 'America/Yellowknife' },
  396. { text: '(GMT-06:00) Belize', value: 'America/Belize' },
  397. { text: '(GMT-06:00) Central Time', value: 'America/Chicago' },
  398. { text: '(GMT-06:00) Central Time - Mexico City', value: 'America/Mexico_City' },
  399. { text: '(GMT-06:00) Central Time - Regina', value: 'America/Regina' },
  400. { text: '(GMT-06:00) Central Time - Tegucigalpa', value: 'America/Tegucigalpa' },
  401. { text: '(GMT-06:00) Central Time - Winnipeg', value: 'America/Winnipeg' },
  402. { text: '(GMT-06:00) Costa Rica', value: 'America/Costa_Rica' },
  403. { text: '(GMT-06:00) El Salvador', value: 'America/El_Salvador' },
  404. { text: '(GMT-06:00) Galapagos', value: 'Pacific/Galapagos' },
  405. { text: '(GMT-06:00) Guatemala', value: 'America/Guatemala' },
  406. { text: '(GMT-06:00) Managua', value: 'America/Managua' },
  407. { text: '(GMT-05:00) America Cancun', value: 'America/Cancun' },
  408. { text: '(GMT-05:00) Bogota', value: 'America/Bogota' },
  409. { text: '(GMT-05:00) Easter Island', value: 'Pacific/Easter' },
  410. { text: '(GMT-05:00) Eastern Time', value: 'America/New_York' },
  411. { text: '(GMT-05:00) Eastern Time - Iqaluit', value: 'America/Iqaluit' },
  412. { text: '(GMT-05:00) Eastern Time - Toronto', value: 'America/Toronto' },
  413. { text: '(GMT-05:00) Guayaquil', value: 'America/Guayaquil' },
  414. { text: '(GMT-05:00) Havana', value: 'America/Havana' },
  415. { text: '(GMT-05:00) Jamaica', value: 'America/Jamaica' },
  416. { text: '(GMT-05:00) Lima', value: 'America/Lima' },
  417. { text: '(GMT-05:00) Nassau', value: 'America/Nassau' },
  418. { text: '(GMT-05:00) Panama', value: 'America/Panama' },
  419. { text: '(GMT-05:00) Port-au-Prince', value: 'America/Port-au-Prince' },
  420. { text: '(GMT-05:00) Rio Branco', value: 'America/Rio_Branco' },
  421. { text: '(GMT-04:00) Atlantic Time - Halifax', value: 'America/Halifax' },
  422. { text: '(GMT-04:00) Barbados', value: 'America/Barbados' },
  423. { text: '(GMT-04:00) Bermuda', value: 'Atlantic/Bermuda' },
  424. { text: '(GMT-04:00) Boa Vista', value: 'America/Boa_Vista' },
  425. { text: '(GMT-04:00) Caracas', value: 'America/Caracas' },
  426. { text: '(GMT-04:00) Curacao', value: 'America/Curacao' },
  427. { text: '(GMT-04:00) Grand Turk', value: 'America/Grand_Turk' },
  428. { text: '(GMT-04:00) Guyana', value: 'America/Guyana' },
  429. { text: '(GMT-04:00) La Paz', value: 'America/La_Paz' },
  430. { text: '(GMT-04:00) Manaus', value: 'America/Manaus' },
  431. { text: '(GMT-04:00) Martinique', value: 'America/Martinique' },
  432. { text: '(GMT-04:00) Port of Spain', value: 'America/Port_of_Spain' },
  433. { text: '(GMT-04:00) Porto Velho', value: 'America/Porto_Velho' },
  434. { text: '(GMT-04:00) Puerto Rico', value: 'America/Puerto_Rico' },
  435. { text: '(GMT-04:00) Santo Domingo', value: 'America/Santo_Domingo' },
  436. { text: '(GMT-04:00) Thule', value: 'America/Thule' },
  437. { text: '(GMT-03:30) Newfoundland Time - St. Johns', value: 'America/St_Johns' },
  438. { text: '(GMT-03:00) Araguaina', value: 'America/Araguaina' },
  439. { text: '(GMT-03:00) Asuncion', value: 'America/Asuncion' },
  440. { text: '(GMT-03:00) Belem', value: 'America/Belem' },
  441. { text: '(GMT-03:00) Buenos Aires', value: 'America/Argentina/Buenos_Aires' },
  442. { text: '(GMT-03:00) Campo Grande', value: 'America/Campo_Grande' },
  443. { text: '(GMT-03:00) Cayenne', value: 'America/Cayenne' },
  444. { text: '(GMT-03:00) Cuiaba', value: 'America/Cuiaba' },
  445. { text: '(GMT-03:00) Fortaleza', value: 'America/Fortaleza' },
  446. { text: '(GMT-03:00) Godthab', value: 'America/Godthab' },
  447. { text: '(GMT-03:00) Maceio', value: 'America/Maceio' },
  448. { text: '(GMT-03:00) Miquelon', value: 'America/Miquelon' },
  449. { text: '(GMT-03:00) Montevideo', value: 'America/Montevideo' },
  450. { text: '(GMT-03:00) Palmer', value: 'Antarctica/Palmer' },
  451. { text: '(GMT-03:00) Paramaribo', value: 'America/Paramaribo' },
  452. { text: '(GMT-03:00) Punta Arenas', value: 'America/Punta_Arenas' },
  453. { text: '(GMT-03:00) Recife', value: 'America/Recife' },
  454. { text: '(GMT-03:00) Rothera', value: 'Antarctica/Rothera' },
  455. { text: '(GMT-03:00) Salvador', value: 'America/Bahia' },
  456. { text: '(GMT-03:00) Santiago', value: 'America/Santiago' },
  457. { text: '(GMT-03:00) Stanley', value: 'Atlantic/Stanley' },
  458. { text: '(GMT-02:00) Noronha', value: 'America/Noronha' },
  459. { text: '(GMT-02:00) Sao Paulo', value: 'America/Sao_Paulo' },
  460. { text: '(GMT-02:00) South Georgia', value: 'Atlantic/South_Georgia' },
  461. { text: '(GMT-01:00) Azores', value: 'Atlantic/Azores' },
  462. { text: '(GMT-01:00) Cape Verde', value: 'Atlantic/Cape_Verde' },
  463. { text: '(GMT-01:00) Scoresbysund', value: 'America/Scoresbysund' },
  464. { text: '(GMT+00:00) Abidjan', value: 'Africa/Abidjan' },
  465. { text: '(GMT+00:00) Accra', value: 'Africa/Accra' },
  466. { text: '(GMT+00:00) Bissau', value: 'Africa/Bissau' },
  467. { text: '(GMT+00:00) Canary Islands', value: 'Atlantic/Canary' },
  468. { text: '(GMT+00:00) Casablanca', value: 'Africa/Casablanca' },
  469. { text: '(GMT+00:00) Danmarkshavn', value: 'America/Danmarkshavn' },
  470. { text: '(GMT+00:00) Dublin', value: 'Europe/Dublin' },
  471. { text: '(GMT+00:00) El Aaiun', value: 'Africa/El_Aaiun' },
  472. { text: '(GMT+00:00) Faeroe', value: 'Atlantic/Faroe' },
  473. { text: '(GMT+00:00) GMT (no daylight saving)', value: 'Etc/GMT' },
  474. { text: '(GMT+00:00) Lisbon', value: 'Europe/Lisbon' },
  475. { text: '(GMT+00:00) London', value: 'Europe/London' },
  476. { text: '(GMT+00:00) Monrovia', value: 'Africa/Monrovia' },
  477. { text: '(GMT+00:00) Reykjavik', value: 'Atlantic/Reykjavik' },
  478. { text: '(GMT+01:00) Algiers', value: 'Africa/Algiers' },
  479. { text: '(GMT+01:00) Amsterdam', value: 'Europe/Amsterdam' },
  480. { text: '(GMT+01:00) Andorra', value: 'Europe/Andorra' },
  481. { text: '(GMT+01:00) Berlin', value: 'Europe/Berlin' },
  482. { text: '(GMT+01:00) Brussels', value: 'Europe/Brussels' },
  483. { text: '(GMT+01:00) Budapest', value: 'Europe/Budapest' },
  484. { text: '(GMT+01:00) Central European Time - Belgrade', value: 'Europe/Belgrade' },
  485. { text: '(GMT+01:00) Central European Time - Prague', value: 'Europe/Prague' },
  486. { text: '(GMT+01:00) Ceuta', value: 'Africa/Ceuta' },
  487. { text: '(GMT+01:00) Copenhagen', value: 'Europe/Copenhagen' },
  488. { text: '(GMT+01:00) Gibraltar', value: 'Europe/Gibraltar' },
  489. { text: '(GMT+01:00) Lagos', value: 'Africa/Lagos' },
  490. { text: '(GMT+01:00) Luxembourg', value: 'Europe/Luxembourg' },
  491. { text: '(GMT+01:00) Madrid', value: 'Europe/Madrid' },
  492. { text: '(GMT+01:00) Malta', value: 'Europe/Malta' },
  493. { text: '(GMT+01:00) Monaco', value: 'Europe/Monaco' },
  494. { text: '(GMT+01:00) Ndjamena', value: 'Africa/Ndjamena' },
  495. { text: '(GMT+01:00) Oslo', value: 'Europe/Oslo' },
  496. { text: '(GMT+01:00) Paris', value: 'Europe/Paris' },
  497. { text: '(GMT+01:00) Rome', value: 'Europe/Rome' },
  498. { text: '(GMT+01:00) Stockholm', value: 'Europe/Stockholm' },
  499. { text: '(GMT+01:00) Tirane', value: 'Europe/Tirane' },
  500. { text: '(GMT+01:00) Tunis', value: 'Africa/Tunis' },
  501. { text: '(GMT+01:00) Vienna', value: 'Europe/Vienna' },
  502. { text: '(GMT+01:00) Warsaw', value: 'Europe/Warsaw' },
  503. { text: '(GMT+01:00) Zurich', value: 'Europe/Zurich' },
  504. { text: '(GMT+02:00) Amman', value: 'Asia/Amman' },
  505. { text: '(GMT+02:00) Athens', value: 'Europe/Athens' },
  506. { text: '(GMT+02:00) Beirut', value: 'Asia/Beirut' },
  507. { text: '(GMT+02:00) Bucharest', value: 'Europe/Bucharest' },
  508. { text: '(GMT+02:00) Cairo', value: 'Africa/Cairo' },
  509. { text: '(GMT+02:00) Chisinau', value: 'Europe/Chisinau' },
  510. { text: '(GMT+02:00) Damascus', value: 'Asia/Damascus' },
  511. { text: '(GMT+02:00) Gaza', value: 'Asia/Gaza' },
  512. { text: '(GMT+02:00) Helsinki', value: 'Europe/Helsinki' },
  513. { text: '(GMT+02:00) Jerusalem', value: 'Asia/Jerusalem' },
  514. { text: '(GMT+02:00) Johannesburg', value: 'Africa/Johannesburg' },
  515. { text: '(GMT+02:00) Khartoum', value: 'Africa/Khartoum' },
  516. { text: '(GMT+02:00) Kiev', value: 'Europe/Kiev' },
  517. { text: '(GMT+02:00) Maputo', value: 'Africa/Maputo' },
  518. { text: '(GMT+02:00) Moscow-01 - Kaliningrad', value: 'Europe/Kaliningrad' },
  519. { text: '(GMT+02:00) Nicosia', value: 'Asia/Nicosia' },
  520. { text: '(GMT+02:00) Riga', value: 'Europe/Riga' },
  521. { text: '(GMT+02:00) Sofia', value: 'Europe/Sofia' },
  522. { text: '(GMT+02:00) Tallinn', value: 'Europe/Tallinn' },
  523. { text: '(GMT+02:00) Tripoli', value: 'Africa/Tripoli' },
  524. { text: '(GMT+02:00) Vilnius', value: 'Europe/Vilnius' },
  525. { text: '(GMT+02:00) Windhoek', value: 'Africa/Windhoek' },
  526. { text: '(GMT+03:00) Baghdad', value: 'Asia/Baghdad' },
  527. { text: '(GMT+03:00) Istanbul', value: 'Europe/Istanbul' },
  528. { text: '(GMT+03:00) Minsk', value: 'Europe/Minsk' },
  529. { text: '(GMT+03:00) Moscow+00 - Moscow', value: 'Europe/Moscow' },
  530. { text: '(GMT+03:00) Nairobi', value: 'Africa/Nairobi' },
  531. { text: '(GMT+03:00) Qatar', value: 'Asia/Qatar' },
  532. { text: '(GMT+03:00) Riyadh', value: 'Asia/Riyadh' },
  533. { text: '(GMT+03:00) Syowa', value: 'Antarctica/Syowa' },
  534. { text: '(GMT+03:30) Tehran', value: 'Asia/Tehran' },
  535. { text: '(GMT+04:00) Baku', value: 'Asia/Baku' },
  536. { text: '(GMT+04:00) Dubai', value: 'Asia/Dubai' },
  537. { text: '(GMT+04:00) Mahe', value: 'Indian/Mahe' },
  538. { text: '(GMT+04:00) Mauritius', value: 'Indian/Mauritius' },
  539. { text: '(GMT+04:00) Moscow+01 - Samara', value: 'Europe/Samara' },
  540. { text: '(GMT+04:00) Reunion', value: 'Indian/Reunion' },
  541. { text: '(GMT+04:00) Tbilisi', value: 'Asia/Tbilisi' },
  542. { text: '(GMT+04:00) Yerevan', value: 'Asia/Yerevan' },
  543. { text: '(GMT+04:30) Kabul', value: 'Asia/Kabul' },
  544. { text: '(GMT+05:00) Aqtau', value: 'Asia/Aqtau' },
  545. { text: '(GMT+05:00) Aqtobe', value: 'Asia/Aqtobe' },
  546. { text: '(GMT+05:00) Ashgabat', value: 'Asia/Ashgabat' },
  547. { text: '(GMT+05:00) Dushanbe', value: 'Asia/Dushanbe' },
  548. { text: '(GMT+05:00) Karachi', value: 'Asia/Karachi' },
  549. { text: '(GMT+05:00) Kerguelen', value: 'Indian/Kerguelen' },
  550. { text: '(GMT+05:00) Maldives', value: 'Indian/Maldives' },
  551. { text: '(GMT+05:00) Mawson', value: 'Antarctica/Mawson' },
  552. { text: '(GMT+05:00) Moscow+02 - Yekaterinburg', value: 'Asia/Yekaterinburg' },
  553. { text: '(GMT+05:00) Tashkent', value: 'Asia/Tashkent' },
  554. { text: '(GMT+05:30) Colombo', value: 'Asia/Colombo' },
  555. { text: '(GMT+05:30) India Standard Time', value: 'Asia/Kolkata' },
  556. { text: '(GMT+05:45) Kathmandu', value: 'Asia/Kathmandu' },
  557. { text: '(GMT+06:00) Almaty', value: 'Asia/Almaty' },
  558. { text: '(GMT+06:00) Bishkek', value: 'Asia/Bishkek' },
  559. { text: '(GMT+06:00) Chagos', value: 'Indian/Chagos' },
  560. { text: '(GMT+06:00) Dhaka', value: 'Asia/Dhaka' },
  561. { text: '(GMT+06:00) Moscow+03 - Omsk', value: 'Asia/Omsk' },
  562. { text: '(GMT+06:00) Thimphu', value: 'Asia/Thimphu' },
  563. { text: '(GMT+06:00) Vostok', value: 'Antarctica/Vostok' },
  564. { text: '(GMT+06:30) Cocos', value: 'Indian/Cocos' },
  565. { text: '(GMT+06:30) Rangoon', value: 'Asia/Yangon' },
  566. { text: '(GMT+07:00) Bangkok', value: 'Asia/Bangkok' },
  567. { text: '(GMT+07:00) Christmas', value: 'Indian/Christmas' },
  568. { text: '(GMT+07:00) Davis', value: 'Antarctica/Davis' },
  569. { text: '(GMT+07:00) Hanoi', value: 'Asia/Saigon' },
  570. { text: '(GMT+07:00) Hovd', value: 'Asia/Hovd' },
  571. { text: '(GMT+07:00) Jakarta', value: 'Asia/Jakarta' },
  572. { text: '(GMT+07:00) Moscow+04 - Krasnoyarsk', value: 'Asia/Krasnoyarsk' },
  573. { text: '(GMT+08:00) Brunei', value: 'Asia/Brunei' },
  574. { text: '(GMT+08:00) China Time - Beijing', value: 'Asia/Shanghai' },
  575. { text: '(GMT+08:00) Choibalsan', value: 'Asia/Choibalsan' },
  576. { text: '(GMT+08:00) Hong Kong', value: 'Asia/Hong_Kong' },
  577. { text: '(GMT+08:00) Kuala Lumpur', value: 'Asia/Kuala_Lumpur' },
  578. { text: '(GMT+08:00) Macau', value: 'Asia/Macau' },
  579. { text: '(GMT+08:00) Makassar', value: 'Asia/Makassar' },
  580. { text: '(GMT+08:00) Manila', value: 'Asia/Manila' },
  581. { text: '(GMT+08:00) Moscow+05 - Irkutsk', value: 'Asia/Irkutsk' },
  582. { text: '(GMT+08:00) Singapore', value: 'Asia/Singapore' },
  583. { text: '(GMT+08:00) Taipei', value: 'Asia/Taipei' },
  584. { text: '(GMT+08:00) Ulaanbaatar', value: 'Asia/Ulaanbaatar' },
  585. { text: '(GMT+08:00) Western Time - Perth', value: 'Australia/Perth' },
  586. { text: '(GMT+08:30) Pyongyang', value: 'Asia/Pyongyang' },
  587. { text: '(GMT+09:00) Dili', value: 'Asia/Dili' },
  588. { text: '(GMT+09:00) Jayapura', value: 'Asia/Jayapura' },
  589. { text: '(GMT+09:00) Moscow+06 - Yakutsk', value: 'Asia/Yakutsk' },
  590. { text: '(GMT+09:00) Palau', value: 'Pacific/Palau' },
  591. { text: '(GMT+09:00) Seoul', value: 'Asia/Seoul' },
  592. { text: '(GMT+09:00) Tokyo', value: 'Asia/Tokyo' },
  593. { text: '(GMT+09:30) Central Time - Darwin', value: 'Australia/Darwin' },
  594. { text: '(GMT+10:00) Dumont D\'Urville', value: 'Antarctica/DumontDUrville' },
  595. { text: '(GMT+10:00) Eastern Time - Brisbane', value: 'Australia/Brisbane' },
  596. { text: '(GMT+10:00) Guam', value: 'Pacific/Guam' },
  597. { text: '(GMT+10:00) Moscow+07 - Vladivostok', value: 'Asia/Vladivostok' },
  598. { text: '(GMT+10:00) Port Moresby', value: 'Pacific/Port_Moresby' },
  599. { text: '(GMT+10:00) Truk', value: 'Pacific/Chuuk' },
  600. { text: '(GMT+10:30) Central Time - Adelaide', value: 'Australia/Adelaide' },
  601. { text: '(GMT+11:00) Casey', value: 'Antarctica/Casey' },
  602. { text: '(GMT+11:00) Eastern Time - Hobart', value: 'Australia/Hobart' },
  603. { text: '(GMT+11:00) Eastern Time - Melbourne, Sydney', value: 'Australia/Sydney' },
  604. { text: '(GMT+11:00) Efate', value: 'Pacific/Efate' },
  605. { text: '(GMT+11:00) Guadalcanal', value: 'Pacific/Guadalcanal' },
  606. { text: '(GMT+11:00) Kosrae', value: 'Pacific/Kosrae' },
  607. { text: '(GMT+11:00) Moscow+08 - Magadan', value: 'Asia/Magadan' },
  608. { text: '(GMT+11:00) Norfolk', value: 'Pacific/Norfolk' },
  609. { text: '(GMT+11:00) Noumea', value: 'Pacific/Noumea' },
  610. { text: '(GMT+11:00) Ponape', value: 'Pacific/Pohnpei' },
  611. { text: '(GMT+12:00) Funafuti', value: 'Pacific/Funafuti' },
  612. { text: '(GMT+12:00) Kwajalein', value: 'Pacific/Kwajalein' },
  613. { text: '(GMT+12:00) Majuro', value: 'Pacific/Majuro' },
  614. { text: '(GMT+12:00) Moscow+09 - Petropavlovsk-Kamchatskiy', value: 'Asia/Kamchatka' },
  615. { text: '(GMT+12:00) Nauru', value: 'Pacific/Nauru' },
  616. { text: '(GMT+12:00) Tarawa', value: 'Pacific/Tarawa' },
  617. { text: '(GMT+12:00) Wake', value: 'Pacific/Wake' },
  618. { text: '(GMT+12:00) Wallis', value: 'Pacific/Wallis' },
  619. { text: '(GMT+13:00) Auckland', value: 'Pacific/Auckland' },
  620. { text: '(GMT+13:00) Enderbury', value: 'Pacific/Enderbury' },
  621. { text: '(GMT+13:00) Fakaofo', value: 'Pacific/Fakaofo' },
  622. { text: '(GMT+13:00) Fiji', value: 'Pacific/Fiji' },
  623. { text: '(GMT+13:00) Tongatapu', value: 'Pacific/Tongatapu' },
  624. { text: '(GMT+14:00) Apia', value: 'Pacific/Apia' },
  625. { text: '(GMT+14:00) Kiritimati', value: 'Pacific/Kiritimati' }
  626. ]
  627. }
  628. },
  629. computed: {
  630. currentUserId: get('user/id')
  631. },
  632. methods: {
  633. async activateUser () {
  634. },
  635. async deactivateUser () {
  636. this.$store.commit('showNotification', {
  637. style: 'indigo',
  638. message: `Coming soon...`,
  639. icon: 'directions_boat'
  640. })
  641. },
  642. async deleteUser () {
  643. this.$store.commit(`loadingStart`, 'admin-users-delete')
  644. const resp = await this.$apollo.mutate({
  645. mutation: deleteUserMutation,
  646. variables: {
  647. id: this.user.id
  648. }
  649. })
  650. if (_.get(resp, 'data.users.delete.responseResult.succeeded', false)) {
  651. this.$store.commit('showNotification', {
  652. style: 'success',
  653. message: this.$t('admin:users.userDeleteSuccess'),
  654. icon: 'check'
  655. })
  656. this.$router.push('/users')
  657. } else {
  658. this.$store.commit('showNotification', {
  659. style: 'red',
  660. message: _.get(resp, 'data.users.delete.responseResult.message', 'An unexpected error occured.'),
  661. icon: 'warning'
  662. })
  663. }
  664. this.deleteUserDialog = false
  665. this.$store.commit(`loadingStop`, 'admin-users-delete')
  666. },
  667. async updateUser() {
  668. this.$store.commit(`loadingStart`, 'admin-users-update')
  669. const resp = await this.$apollo.mutate({
  670. mutation: updateUserMutation,
  671. variables: {
  672. id: this.user.id,
  673. email: this.user.email,
  674. name: this.user.name,
  675. newPassword: this.newPassword,
  676. groups: _.map(this.user.groups, 'id'),
  677. location: this.user.location,
  678. jobTitle: this.user.jobTitle,
  679. timezone: this.user.timezone
  680. }
  681. })
  682. if (_.get(resp, 'data.users.update.responseResult.succeeded', false)) {
  683. this.$store.commit('showNotification', {
  684. style: 'success',
  685. message: this.$t('admin:users.userUpdateSuccess'),
  686. icon: 'check'
  687. })
  688. this.$router.push('/users')
  689. } else {
  690. this.$store.commit('showNotification', {
  691. style: 'red',
  692. message: _.get(resp, 'data.users.update.responseResult.message', 'An unexpected error occured.'),
  693. icon: 'warning'
  694. })
  695. }
  696. this.$store.commit(`loadingStop`, 'admin-users-update')
  697. },
  698. focusField (ipt) {
  699. this.$nextTick(() => {
  700. _.delay(() => {
  701. this.$refs[ipt].focus()
  702. }, 200)
  703. })
  704. },
  705. assignGroup() {
  706. if (_.some(this.user.groups, ['id', this.newGroup])) {
  707. this.$store.commit('showNotification', {
  708. message: this.$t('admin:users.userAlreadyAssignedToGroup'),
  709. style: 'error',
  710. icon: 'alert'
  711. })
  712. } else {
  713. this.user.groups.push(_.find(this.groups, ['id', this.newGroup]))
  714. this.newGroup = 0
  715. }
  716. },
  717. unassignGroup(gid) {
  718. this.user.groups = _.reject(this.user.groups, ['id', gid])
  719. }
  720. },
  721. apollo: {
  722. user: {
  723. query: userQuery,
  724. variables() {
  725. return {
  726. id: _.toSafeInteger(this.$route.params.id)
  727. }
  728. },
  729. fetchPolicy: 'network-only',
  730. update: (data) => data.users.single,
  731. watchLoading (isLoading) {
  732. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-users-refresh')
  733. }
  734. },
  735. groups: {
  736. query: groupsQuery,
  737. fetchPolicy: 'network-only',
  738. update: (data) => data.groups.list,
  739. watchLoading (isLoading) {
  740. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-refresh')
  741. }
  742. }
  743. }
  744. }
  745. </script>
  746. <style lang='scss'>
  747. </style>