profile.vue 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  1. <template lang='pug'>
  2. v-container(fluid, grid-list-lg)
  3. v-layout(row wrap)
  4. v-flex(xs12)
  5. .profile-header
  6. img.animated.fadeInUp(src='/_assets/svg/icon-profile.svg', alt='Users', style='width: 80px;')
  7. .profile-header-title
  8. .headline.primary--text.animated.fadeInLeft {{$t('profile:title')}}
  9. .subheading.grey--text.animated.fadeInLeft {{$t('profile:subtitle')}}
  10. v-spacer
  11. v-btn.animated.fadeInDown(color='success', depressed, @click='saveProfile', :loading='saveLoading', large)
  12. v-icon(left) mdi-check
  13. span {{$t('common:actions.save')}}
  14. //- v-btn.animated.fadeInDown(outlined, color='primary', disabled).mr-0
  15. //- v-icon(left) mdi-earth
  16. //- span {{$t('profile:viewPublicProfile')}}
  17. v-flex(lg6 xs12)
  18. v-card.animated.fadeInUp
  19. v-toolbar(color='blue-grey', dark, dense, flat)
  20. v-toolbar-title.subtitle-1 {{$t('profile:myInfo')}}
  21. v-list(two-line, dense)
  22. v-list-item
  23. v-list-item-avatar(size='32')
  24. v-icon mdi-account
  25. v-list-item-content
  26. v-list-item-title {{$t('profile:displayName')}}
  27. v-list-item-subtitle {{ user.name }}
  28. v-list-item-action
  29. v-menu(
  30. v-model='editPop.name'
  31. :close-on-content-click='false'
  32. min-width='350'
  33. left
  34. )
  35. template(v-slot:activator='{ on }')
  36. v-btn(text, color='grey', small, v-on='on', @click='focusField(`iptDisplayName`)')
  37. v-icon(left) mdi-pencil
  38. span {{ $t('common:actions:edit') }}
  39. v-card
  40. v-text-field(
  41. ref='iptDisplayName'
  42. v-model='user.name'
  43. :label='$t(`profile:displayName`)'
  44. solo
  45. hide-details
  46. append-icon='mdi-check'
  47. @click:append='editPop.name = false'
  48. @keydown.enter='editPop.name = false'
  49. @keydown.esc='editPop.name = false'
  50. )
  51. v-divider
  52. v-list-item
  53. v-list-item-avatar(size='32')
  54. v-icon mdi-map-marker
  55. v-list-item-content
  56. v-list-item-title {{$t('profile:location')}}
  57. v-list-item-subtitle {{ user.location }}
  58. v-list-item-action
  59. v-menu(
  60. v-model='editPop.location'
  61. :close-on-content-click='false'
  62. min-width='350'
  63. left
  64. )
  65. template(v-slot:activator='{ on }')
  66. v-btn(text, color='grey', small, v-on='on', @click='focusField(`iptLocation`)')
  67. v-icon(left) mdi-pencil
  68. span {{ $t('common:actions:edit') }}
  69. v-card
  70. v-text-field(
  71. ref='iptLocation'
  72. v-model='user.location'
  73. :label='$t(`profile:location`)'
  74. solo
  75. hide-details
  76. append-icon='mdi-check'
  77. @click:append='editPop.location = false'
  78. @keydown.enter='editPop.location = false'
  79. @keydown.esc='editPop.location = false'
  80. )
  81. v-divider
  82. v-list-item
  83. v-list-item-avatar(size='32')
  84. v-icon mdi-briefcase
  85. v-list-item-content
  86. v-list-item-title {{$t('profile:jobTitle')}}
  87. v-list-item-subtitle {{ user.jobTitle }}
  88. v-list-item-action
  89. v-menu(
  90. v-model='editPop.jobTitle'
  91. :close-on-content-click='false'
  92. min-width='350'
  93. left
  94. )
  95. template(v-slot:activator='{ on }')
  96. v-btn(text, color='grey', small, v-on='on', @click='focusField(`iptJobTitle`)')
  97. v-icon(left) mdi-pencil
  98. span {{ $t('common:actions:edit') }}
  99. v-card
  100. v-text-field(
  101. ref='iptJobTitle'
  102. v-model='user.jobTitle'
  103. :label='$t(`profile:jobTitle`)'
  104. solo
  105. hide-details
  106. append-icon='mdi-check'
  107. @click:append='editPop.jobTitle = false'
  108. @keydown.enter='editPop.jobTitle = false'
  109. @keydown.esc='editPop.jobTitle = false'
  110. )
  111. v-card.mt-3.animated.fadeInUp.wait-p2s
  112. v-toolbar(color='blue-grey', dark, dense, flat)
  113. v-toolbar-title
  114. .subtitle-1 {{$t('profile:auth.title')}}
  115. v-card-text.pt-0
  116. v-subheader.pl-0: span.subtitle-2 {{$t('profile:auth.provider')}}
  117. v-toolbar(
  118. flat
  119. :color='$vuetify.theme.dark ? "grey darken-2" : "purple lighten-5"'
  120. dense
  121. :class='$vuetify.theme.dark ? "grey--text text--lighten-1" : "purple--text text--darken-4"'
  122. )
  123. v-icon(:color='$vuetify.theme.dark ? "grey lighten-1" : "purple darken-4"') mdi-shield-lock
  124. .subheading.ml-3 {{ user.providerName }}
  125. //- v-divider.mt-3
  126. //- v-subheader.pl-0: span.subtitle-2 Two-Factor Authentication (2FA)
  127. //- .caption.mb-2 2FA adds an extra layer of security by requiring a unique code generated on your smartphone when signing in.
  128. //- v-btn(color='purple darken-4', disabled).ml-0 Enable 2FA
  129. //- v-btn(color='purple darken-4', dark, depressed, disabled).ml-0 Disable 2FA
  130. template(v-if='user.providerKey === `local`')
  131. v-divider.mt-3
  132. v-subheader.pl-0: span.subtitle-2 {{$t('profile:auth.changePassword')}}
  133. v-text-field(
  134. ref='iptCurrentPass'
  135. v-model='currentPass'
  136. outlined
  137. :label='$t(`profile:auth.currentPassword`)'
  138. type='password'
  139. prepend-inner-icon='mdi-form-textbox-password'
  140. )
  141. v-text-field(
  142. ref='iptNewPass'
  143. v-model='newPass'
  144. outlined
  145. :label='$t(`profile:auth.newPassword`)'
  146. type='password'
  147. prepend-inner-icon='mdi-form-textbox-password'
  148. autocomplete='off'
  149. counter='255'
  150. loading
  151. )
  152. password-strength(slot='progress', v-model='newPass')
  153. v-text-field(
  154. ref='iptVerifyPass'
  155. v-model='verifyPass'
  156. outlined
  157. :label='$t(`profile:auth.verifyPassword`)'
  158. type='password'
  159. prepend-inner-icon='mdi-form-textbox-password'
  160. autocomplete='off'
  161. hide-details
  162. )
  163. v-card-chin(v-if='user.providerKey === `local`')
  164. v-spacer
  165. v-btn.px-4(color='purple darken-4', dark, depressed, @click='changePassword', :loading='changePassLoading')
  166. v-icon(left) mdi-progress-check
  167. span {{$t('profile:auth.changePassword')}}
  168. v-flex(lg6 xs12)
  169. //- v-card
  170. //- v-toolbar(color='blue-grey', dark, dense, flat)
  171. //- v-toolbar-title
  172. //- .subtitle-1 Picture
  173. //- v-card-title
  174. //- v-avatar.blue(v-if='picture.kind === `initials`', :size='40')
  175. //- span.white--text.subheading {{picture.initials}}
  176. //- v-avatar(v-else-if='picture.kind === `image`', :size='40')
  177. //- v-img(:src='picture.url')
  178. //- v-btn(outlined).mx-4 Upload Picture
  179. //- v-btn(outlined, disabled) Remove Picture
  180. v-card.animated.fadeInUp.wait-p2s
  181. v-toolbar(color='blue-grey', dark, dense, flat)
  182. v-toolbar-title.subtitle-1 {{$t('profile:preferences')}}
  183. v-list(two-line, dense)
  184. v-list-item
  185. v-list-item-avatar(size='32')
  186. v-icon mdi-map-clock-outline
  187. v-list-item-content
  188. v-list-item-title {{$t('profile:timezone')}}
  189. v-list-item-subtitle {{ user.timezone }}
  190. v-list-item-action
  191. v-menu(
  192. v-model='editPop.timezone'
  193. :close-on-content-click='false'
  194. min-width='350'
  195. max-width='350'
  196. left
  197. )
  198. template(v-slot:activator='{ on }')
  199. v-btn(text, color='grey', small, v-on='on', @click='focusField(`iptTimezone`)')
  200. v-icon(left) mdi-pencil
  201. span {{ $t('common:actions:edit') }}
  202. v-card(flat)
  203. v-select(
  204. ref='iptTimezone'
  205. :items='timezones'
  206. v-model='user.timezone'
  207. :label='$t(`profile:timezone`)'
  208. solo
  209. flat
  210. dense
  211. hide-details
  212. @keydown.enter='editPop.timezone = false'
  213. @keydown.esc='editPop.timezone = false'
  214. style='height: 38px;'
  215. )
  216. v-card-chin
  217. v-spacer
  218. v-btn(
  219. small
  220. text
  221. color='primary'
  222. @click='editPop.timezone = false'
  223. )
  224. v-icon(left) mdi-check
  225. span {{$t('common:actions.ok')}}
  226. v-divider
  227. v-list-item
  228. v-list-item-avatar(size='32')
  229. v-icon mdi-calendar-month-outline
  230. v-list-item-content
  231. v-list-item-title {{$t('profile:dateFormat')}}
  232. v-list-item-subtitle {{ user.dateFormat && user.dateFormat.length > 0 ? user.dateFormat : $t('profile:localeDefault') }}
  233. v-list-item-action
  234. v-menu(
  235. v-model='editPop.dateFormat'
  236. :close-on-content-click='false'
  237. min-width='350'
  238. max-width='350'
  239. left
  240. )
  241. template(v-slot:activator='{ on }')
  242. v-btn(text, color='grey', small, v-on='on', @click='focusField(`iptDateFormat`)')
  243. v-icon(left) mdi-pencil
  244. span {{ $t('common:actions:edit') }}
  245. v-card(flat)
  246. v-select(
  247. ref='iptDateFormat'
  248. :items='dateFormats'
  249. v-model='user.dateFormat'
  250. :label='$t(`profile:dateFormat`)'
  251. solo
  252. flat
  253. dense
  254. hide-details
  255. @keydown.enter='editPop.dateFormat = false'
  256. @keydown.esc='editPop.dateFormat = false'
  257. style='height: 38px;'
  258. )
  259. v-card-chin
  260. v-spacer
  261. v-btn(
  262. small
  263. text
  264. color='primary'
  265. @click='editPop.dateFormat = false'
  266. )
  267. v-icon(left) mdi-check
  268. span {{$t('common:actions.ok')}}
  269. v-divider
  270. v-list-item
  271. v-list-item-avatar(size='32')
  272. v-icon mdi-palette
  273. v-list-item-content
  274. v-list-item-title {{$t('profile:appearance')}}
  275. v-list-item-subtitle {{ currentAppearance }}
  276. v-list-item-action
  277. v-menu(
  278. v-model='editPop.appearance'
  279. :close-on-content-click='false'
  280. min-width='350'
  281. max-width='350'
  282. left
  283. )
  284. template(v-slot:activator='{ on }')
  285. v-btn(text, color='grey', small, v-on='on', @click='focusField(`iptAppearance`)')
  286. v-icon(left) mdi-pencil
  287. span {{ $t('common:actions:edit') }}
  288. v-card(flat)
  289. v-select(
  290. ref='iptAppearance'
  291. :items='appearances'
  292. v-model='user.appearance'
  293. :label='$t(`profile:appearance`)'
  294. solo
  295. flat
  296. dense
  297. hide-details
  298. @keydown.enter='editPop.appearance = false'
  299. @keydown.esc='editPop.appearance = false'
  300. style='height: 38px;'
  301. )
  302. v-card-chin
  303. v-spacer
  304. v-btn(
  305. small
  306. text
  307. color='primary'
  308. @click='editPop.appearance = false'
  309. )
  310. v-icon(left) mdi-check
  311. span {{$t('common:actions.ok')}}
  312. v-card.mt-3.animated.fadeInUp.wait-p3s
  313. v-toolbar(color='primary', dark, dense, flat)
  314. v-toolbar-title
  315. .subtitle-1 {{$t('profile:groups.title')}}
  316. v-list(dense)
  317. template(v-for='(grp, idx) of user.groups')
  318. v-list-item(:key='`grp-id-` + grp')
  319. v-list-item-avatar(size='32')
  320. v-icon mdi-account-group
  321. v-list-item-content
  322. v-list-item-title.body-2 {{grp}}
  323. v-divider(v-if='idx < user.groups.length - 1')
  324. v-card.mt-3.animated.fadeInUp.wait-p4s
  325. v-toolbar(color='teal', dark, dense, flat)
  326. v-toolbar-title
  327. .subtitle-1 {{$t('profile:activity.title')}}
  328. v-card-text.grey--text.text--darken-2
  329. .caption.grey--text {{$t('profile:activity.joinedOn')}}
  330. .body-2: strong {{ user.createdAt | moment('LLLL') }}
  331. .caption.grey--text.mt-3 {{$t('profile:activity.lastUpdatedOn')}}
  332. .body-2: strong {{ user.updatedAt | moment('LLLL') }}
  333. .caption.grey--text.mt-3 {{$t('profile:activity.lastLoginOn')}}
  334. .body-2: strong {{ user.lastLoginAt | moment('LLLL') }}
  335. v-divider.mt-3
  336. .caption.grey--text.mt-3 {{$t('profile:activity.pagesCreated')}}
  337. .body-2: strong {{ user.pagesTotal }}
  338. .caption.grey--text.mt-3 {{$t('profile:activity.commentsPosted')}}
  339. .body-2: strong 0
  340. </template>
  341. <script>
  342. import { get } from 'vuex-pathify'
  343. import gql from 'graphql-tag'
  344. import _ from 'lodash'
  345. import Cookies from 'js-cookie'
  346. import validate from 'validate.js'
  347. import PasswordStrength from '../common/password-strength.vue'
  348. /* global WIKI, siteConfig */
  349. export default {
  350. i18nOptions: {
  351. namespaces: ['profile', 'auth']
  352. },
  353. components: {
  354. PasswordStrength
  355. },
  356. data() {
  357. return {
  358. saveLoading: false,
  359. changePassLoading: false,
  360. user: {
  361. name: 'unknown',
  362. location: '',
  363. jobTitle: '',
  364. timezone: '',
  365. dateFormat: '',
  366. appearance: '',
  367. createdAt: '1970-01-01',
  368. updatedAt: '1970-01-01',
  369. lastLoginAt: '1970-01-01',
  370. groups: []
  371. },
  372. currentPass: '',
  373. newPass: '',
  374. verifyPass: '',
  375. editPop: {
  376. name: false,
  377. location: false,
  378. jobTitle: false,
  379. timezone: false,
  380. dateFormat: false,
  381. appearance: false
  382. },
  383. timezones: [
  384. { text: '(GMT-11:00) Niue', value: 'Pacific/Niue' },
  385. { text: '(GMT-11:00) Pago Pago', value: 'Pacific/Pago_Pago' },
  386. { text: '(GMT-10:00) Hawaii Time', value: 'Pacific/Honolulu' },
  387. { text: '(GMT-10:00) Rarotonga', value: 'Pacific/Rarotonga' },
  388. { text: '(GMT-10:00) Tahiti', value: 'Pacific/Tahiti' },
  389. { text: '(GMT-09:30) Marquesas', value: 'Pacific/Marquesas' },
  390. { text: '(GMT-09:00) Alaska Time', value: 'America/Anchorage' },
  391. { text: '(GMT-09:00) Gambier', value: 'Pacific/Gambier' },
  392. { text: '(GMT-08:00) Pacific Time', value: 'America/Los_Angeles' },
  393. { text: '(GMT-08:00) Pacific Time - Tijuana', value: 'America/Tijuana' },
  394. { text: '(GMT-08:00) Pacific Time - Vancouver', value: 'America/Vancouver' },
  395. { text: '(GMT-08:00) Pacific Time - Whitehorse', value: 'America/Whitehorse' },
  396. { text: '(GMT-08:00) Pitcairn', value: 'Pacific/Pitcairn' },
  397. { text: '(GMT-07:00) Mountain Time', value: 'America/Denver' },
  398. { text: '(GMT-07:00) Mountain Time - Arizona', value: 'America/Phoenix' },
  399. { text: '(GMT-07:00) Mountain Time - Chihuahua, Mazatlan', value: 'America/Mazatlan' },
  400. { text: '(GMT-07:00) Mountain Time - Dawson Creek', value: 'America/Dawson_Creek' },
  401. { text: '(GMT-07:00) Mountain Time - Edmonton', value: 'America/Edmonton' },
  402. { text: '(GMT-07:00) Mountain Time - Hermosillo', value: 'America/Hermosillo' },
  403. { text: '(GMT-07:00) Mountain Time - Yellowknife', value: 'America/Yellowknife' },
  404. { text: '(GMT-06:00) Belize', value: 'America/Belize' },
  405. { text: '(GMT-06:00) Central Time', value: 'America/Chicago' },
  406. { text: '(GMT-06:00) Central Time - Mexico City', value: 'America/Mexico_City' },
  407. { text: '(GMT-06:00) Central Time - Regina', value: 'America/Regina' },
  408. { text: '(GMT-06:00) Central Time - Tegucigalpa', value: 'America/Tegucigalpa' },
  409. { text: '(GMT-06:00) Central Time - Winnipeg', value: 'America/Winnipeg' },
  410. { text: '(GMT-06:00) Costa Rica', value: 'America/Costa_Rica' },
  411. { text: '(GMT-06:00) El Salvador', value: 'America/El_Salvador' },
  412. { text: '(GMT-06:00) Galapagos', value: 'Pacific/Galapagos' },
  413. { text: '(GMT-06:00) Guatemala', value: 'America/Guatemala' },
  414. { text: '(GMT-06:00) Managua', value: 'America/Managua' },
  415. { text: '(GMT-05:00) America Cancun', value: 'America/Cancun' },
  416. { text: '(GMT-05:00) Bogota', value: 'America/Bogota' },
  417. { text: '(GMT-05:00) Easter Island', value: 'Pacific/Easter' },
  418. { text: '(GMT-05:00) Eastern Time', value: 'America/New_York' },
  419. { text: '(GMT-05:00) Eastern Time - Iqaluit', value: 'America/Iqaluit' },
  420. { text: '(GMT-05:00) Eastern Time - Toronto', value: 'America/Toronto' },
  421. { text: '(GMT-05:00) Guayaquil', value: 'America/Guayaquil' },
  422. { text: '(GMT-05:00) Havana', value: 'America/Havana' },
  423. { text: '(GMT-05:00) Jamaica', value: 'America/Jamaica' },
  424. { text: '(GMT-05:00) Lima', value: 'America/Lima' },
  425. { text: '(GMT-05:00) Nassau', value: 'America/Nassau' },
  426. { text: '(GMT-05:00) Panama', value: 'America/Panama' },
  427. { text: '(GMT-05:00) Port-au-Prince', value: 'America/Port-au-Prince' },
  428. { text: '(GMT-05:00) Rio Branco', value: 'America/Rio_Branco' },
  429. { text: '(GMT-04:00) Atlantic Time - Halifax', value: 'America/Halifax' },
  430. { text: '(GMT-04:00) Barbados', value: 'America/Barbados' },
  431. { text: '(GMT-04:00) Bermuda', value: 'Atlantic/Bermuda' },
  432. { text: '(GMT-04:00) Boa Vista', value: 'America/Boa_Vista' },
  433. { text: '(GMT-04:00) Caracas', value: 'America/Caracas' },
  434. { text: '(GMT-04:00) Curacao', value: 'America/Curacao' },
  435. { text: '(GMT-04:00) Grand Turk', value: 'America/Grand_Turk' },
  436. { text: '(GMT-04:00) Guyana', value: 'America/Guyana' },
  437. { text: '(GMT-04:00) La Paz', value: 'America/La_Paz' },
  438. { text: '(GMT-04:00) Manaus', value: 'America/Manaus' },
  439. { text: '(GMT-04:00) Martinique', value: 'America/Martinique' },
  440. { text: '(GMT-04:00) Port of Spain', value: 'America/Port_of_Spain' },
  441. { text: '(GMT-04:00) Porto Velho', value: 'America/Porto_Velho' },
  442. { text: '(GMT-04:00) Puerto Rico', value: 'America/Puerto_Rico' },
  443. { text: '(GMT-04:00) Santo Domingo', value: 'America/Santo_Domingo' },
  444. { text: '(GMT-04:00) Thule', value: 'America/Thule' },
  445. { text: '(GMT-03:30) Newfoundland Time - St. Johns', value: 'America/St_Johns' },
  446. { text: '(GMT-03:00) Araguaina', value: 'America/Araguaina' },
  447. { text: '(GMT-03:00) Asuncion', value: 'America/Asuncion' },
  448. { text: '(GMT-03:00) Belem', value: 'America/Belem' },
  449. { text: '(GMT-03:00) Buenos Aires', value: 'America/Argentina/Buenos_Aires' },
  450. { text: '(GMT-03:00) Campo Grande', value: 'America/Campo_Grande' },
  451. { text: '(GMT-03:00) Cayenne', value: 'America/Cayenne' },
  452. { text: '(GMT-03:00) Cuiaba', value: 'America/Cuiaba' },
  453. { text: '(GMT-03:00) Fortaleza', value: 'America/Fortaleza' },
  454. { text: '(GMT-03:00) Godthab', value: 'America/Godthab' },
  455. { text: '(GMT-03:00) Maceio', value: 'America/Maceio' },
  456. { text: '(GMT-03:00) Miquelon', value: 'America/Miquelon' },
  457. { text: '(GMT-03:00) Montevideo', value: 'America/Montevideo' },
  458. { text: '(GMT-03:00) Palmer', value: 'Antarctica/Palmer' },
  459. { text: '(GMT-03:00) Paramaribo', value: 'America/Paramaribo' },
  460. { text: '(GMT-03:00) Punta Arenas', value: 'America/Punta_Arenas' },
  461. { text: '(GMT-03:00) Recife', value: 'America/Recife' },
  462. { text: '(GMT-03:00) Rothera', value: 'Antarctica/Rothera' },
  463. { text: '(GMT-03:00) Salvador', value: 'America/Bahia' },
  464. { text: '(GMT-03:00) Santiago', value: 'America/Santiago' },
  465. { text: '(GMT-03:00) Sao Paulo', value: 'America/Sao_Paulo' },
  466. { text: '(GMT-03:00) Stanley', value: 'Atlantic/Stanley' },
  467. { text: '(GMT-02:00) Noronha', value: 'America/Noronha' },
  468. { text: '(GMT-02:00) South Georgia', value: 'Atlantic/South_Georgia' },
  469. { text: '(GMT-01:00) Azores', value: 'Atlantic/Azores' },
  470. { text: '(GMT-01:00) Cape Verde', value: 'Atlantic/Cape_Verde' },
  471. { text: '(GMT-01:00) Scoresbysund', value: 'America/Scoresbysund' },
  472. { text: '(GMT+00:00) Abidjan', value: 'Africa/Abidjan' },
  473. { text: '(GMT+00:00) Accra', value: 'Africa/Accra' },
  474. { text: '(GMT+00:00) Bissau', value: 'Africa/Bissau' },
  475. { text: '(GMT+00:00) Canary Islands', value: 'Atlantic/Canary' },
  476. { text: '(GMT+00:00) Casablanca', value: 'Africa/Casablanca' },
  477. { text: '(GMT+00:00) Danmarkshavn', value: 'America/Danmarkshavn' },
  478. { text: '(GMT+00:00) Dublin', value: 'Europe/Dublin' },
  479. { text: '(GMT+00:00) El Aaiun', value: 'Africa/El_Aaiun' },
  480. { text: '(GMT+00:00) Faeroe', value: 'Atlantic/Faroe' },
  481. { text: '(GMT+00:00) GMT (no daylight saving)', value: 'Etc/GMT' },
  482. { text: '(GMT+00:00) Lisbon', value: 'Europe/Lisbon' },
  483. { text: '(GMT+00:00) London', value: 'Europe/London' },
  484. { text: '(GMT+00:00) Monrovia', value: 'Africa/Monrovia' },
  485. { text: '(GMT+00:00) Reykjavik', value: 'Atlantic/Reykjavik' },
  486. { text: '(GMT+01:00) Algiers', value: 'Africa/Algiers' },
  487. { text: '(GMT+01:00) Amsterdam', value: 'Europe/Amsterdam' },
  488. { text: '(GMT+01:00) Andorra', value: 'Europe/Andorra' },
  489. { text: '(GMT+01:00) Berlin', value: 'Europe/Berlin' },
  490. { text: '(GMT+01:00) Brussels', value: 'Europe/Brussels' },
  491. { text: '(GMT+01:00) Budapest', value: 'Europe/Budapest' },
  492. { text: '(GMT+01:00) Central European Time - Belgrade', value: 'Europe/Belgrade' },
  493. { text: '(GMT+01:00) Central European Time - Prague', value: 'Europe/Prague' },
  494. { text: '(GMT+01:00) Ceuta', value: 'Africa/Ceuta' },
  495. { text: '(GMT+01:00) Copenhagen', value: 'Europe/Copenhagen' },
  496. { text: '(GMT+01:00) Gibraltar', value: 'Europe/Gibraltar' },
  497. { text: '(GMT+01:00) Lagos', value: 'Africa/Lagos' },
  498. { text: '(GMT+01:00) Luxembourg', value: 'Europe/Luxembourg' },
  499. { text: '(GMT+01:00) Madrid', value: 'Europe/Madrid' },
  500. { text: '(GMT+01:00) Malta', value: 'Europe/Malta' },
  501. { text: '(GMT+01:00) Monaco', value: 'Europe/Monaco' },
  502. { text: '(GMT+01:00) Ndjamena', value: 'Africa/Ndjamena' },
  503. { text: '(GMT+01:00) Oslo', value: 'Europe/Oslo' },
  504. { text: '(GMT+01:00) Paris', value: 'Europe/Paris' },
  505. { text: '(GMT+01:00) Rome', value: 'Europe/Rome' },
  506. { text: '(GMT+01:00) Stockholm', value: 'Europe/Stockholm' },
  507. { text: '(GMT+01:00) Tirane', value: 'Europe/Tirane' },
  508. { text: '(GMT+01:00) Tunis', value: 'Africa/Tunis' },
  509. { text: '(GMT+01:00) Vienna', value: 'Europe/Vienna' },
  510. { text: '(GMT+01:00) Warsaw', value: 'Europe/Warsaw' },
  511. { text: '(GMT+01:00) Zurich', value: 'Europe/Zurich' },
  512. { text: '(GMT+02:00) Amman', value: 'Asia/Amman' },
  513. { text: '(GMT+02:00) Athens', value: 'Europe/Athens' },
  514. { text: '(GMT+02:00) Beirut', value: 'Asia/Beirut' },
  515. { text: '(GMT+02:00) Bucharest', value: 'Europe/Bucharest' },
  516. { text: '(GMT+02:00) Cairo', value: 'Africa/Cairo' },
  517. { text: '(GMT+02:00) Chisinau', value: 'Europe/Chisinau' },
  518. { text: '(GMT+02:00) Damascus', value: 'Asia/Damascus' },
  519. { text: '(GMT+02:00) Gaza', value: 'Asia/Gaza' },
  520. { text: '(GMT+02:00) Helsinki', value: 'Europe/Helsinki' },
  521. { text: '(GMT+02:00) Jerusalem', value: 'Asia/Jerusalem' },
  522. { text: '(GMT+02:00) Johannesburg', value: 'Africa/Johannesburg' },
  523. { text: '(GMT+02:00) Khartoum', value: 'Africa/Khartoum' },
  524. { text: '(GMT+02:00) Kyiv', value: 'Europe/Kyiv' },
  525. { text: '(GMT+02:00) Maputo', value: 'Africa/Maputo' },
  526. { text: '(GMT+02:00) Moscow-01 - Kaliningrad', value: 'Europe/Kaliningrad' },
  527. { text: '(GMT+02:00) Nicosia', value: 'Asia/Nicosia' },
  528. { text: '(GMT+02:00) Riga', value: 'Europe/Riga' },
  529. { text: '(GMT+02:00) Sofia', value: 'Europe/Sofia' },
  530. { text: '(GMT+02:00) Tallinn', value: 'Europe/Tallinn' },
  531. { text: '(GMT+02:00) Tripoli', value: 'Africa/Tripoli' },
  532. { text: '(GMT+02:00) Vilnius', value: 'Europe/Vilnius' },
  533. { text: '(GMT+02:00) Windhoek', value: 'Africa/Windhoek' },
  534. { text: '(GMT+03:00) Baghdad', value: 'Asia/Baghdad' },
  535. { text: '(GMT+03:00) Istanbul', value: 'Europe/Istanbul' },
  536. { text: '(GMT+03:00) Minsk', value: 'Europe/Minsk' },
  537. { text: '(GMT+03:00) Moscow+00 - Moscow', value: 'Europe/Moscow' },
  538. { text: '(GMT+03:00) Nairobi', value: 'Africa/Nairobi' },
  539. { text: '(GMT+03:00) Qatar', value: 'Asia/Qatar' },
  540. { text: '(GMT+03:00) Riyadh', value: 'Asia/Riyadh' },
  541. { text: '(GMT+03:00) Syowa', value: 'Antarctica/Syowa' },
  542. { text: '(GMT+03:30) Tehran', value: 'Asia/Tehran' },
  543. { text: '(GMT+04:00) Baku', value: 'Asia/Baku' },
  544. { text: '(GMT+04:00) Dubai', value: 'Asia/Dubai' },
  545. { text: '(GMT+04:00) Mahe', value: 'Indian/Mahe' },
  546. { text: '(GMT+04:00) Mauritius', value: 'Indian/Mauritius' },
  547. { text: '(GMT+04:00) Moscow+01 - Samara', value: 'Europe/Samara' },
  548. { text: '(GMT+04:00) Reunion', value: 'Indian/Reunion' },
  549. { text: '(GMT+04:00) Tbilisi', value: 'Asia/Tbilisi' },
  550. { text: '(GMT+04:00) Yerevan', value: 'Asia/Yerevan' },
  551. { text: '(GMT+04:30) Kabul', value: 'Asia/Kabul' },
  552. { text: '(GMT+05:00) Aqtau', value: 'Asia/Aqtau' },
  553. { text: '(GMT+05:00) Aqtobe', value: 'Asia/Aqtobe' },
  554. { text: '(GMT+05:00) Ashgabat', value: 'Asia/Ashgabat' },
  555. { text: '(GMT+05:00) Dushanbe', value: 'Asia/Dushanbe' },
  556. { text: '(GMT+05:00) Karachi', value: 'Asia/Karachi' },
  557. { text: '(GMT+05:00) Kerguelen', value: 'Indian/Kerguelen' },
  558. { text: '(GMT+05:00) Maldives', value: 'Indian/Maldives' },
  559. { text: '(GMT+05:00) Mawson', value: 'Antarctica/Mawson' },
  560. { text: '(GMT+05:00) Moscow+02 - Yekaterinburg', value: 'Asia/Yekaterinburg' },
  561. { text: '(GMT+05:00) Tashkent', value: 'Asia/Tashkent' },
  562. { text: '(GMT+05:30) Colombo', value: 'Asia/Colombo' },
  563. { text: '(GMT+05:30) India Standard Time', value: 'Asia/Kolkata' },
  564. { text: '(GMT+05:45) Kathmandu', value: 'Asia/Kathmandu' },
  565. { text: '(GMT+06:00) Almaty', value: 'Asia/Almaty' },
  566. { text: '(GMT+06:00) Bishkek', value: 'Asia/Bishkek' },
  567. { text: '(GMT+06:00) Chagos', value: 'Indian/Chagos' },
  568. { text: '(GMT+06:00) Dhaka', value: 'Asia/Dhaka' },
  569. { text: '(GMT+06:00) Moscow+03 - Omsk', value: 'Asia/Omsk' },
  570. { text: '(GMT+06:00) Thimphu', value: 'Asia/Thimphu' },
  571. { text: '(GMT+06:00) Vostok', value: 'Antarctica/Vostok' },
  572. { text: '(GMT+06:30) Cocos', value: 'Indian/Cocos' },
  573. { text: '(GMT+06:30) Rangoon', value: 'Asia/Yangon' },
  574. { text: '(GMT+07:00) Bangkok', value: 'Asia/Bangkok' },
  575. { text: '(GMT+07:00) Christmas', value: 'Indian/Christmas' },
  576. { text: '(GMT+07:00) Davis', value: 'Antarctica/Davis' },
  577. { text: '(GMT+07:00) Hanoi', value: 'Asia/Saigon' },
  578. { text: '(GMT+07:00) Hovd', value: 'Asia/Hovd' },
  579. { text: '(GMT+07:00) Jakarta', value: 'Asia/Jakarta' },
  580. { text: '(GMT+07:00) Moscow+04 - Krasnoyarsk', value: 'Asia/Krasnoyarsk' },
  581. { text: '(GMT+08:00) Brunei', value: 'Asia/Brunei' },
  582. { text: '(GMT+08:00) China Time - Beijing', value: 'Asia/Shanghai' },
  583. { text: '(GMT+08:00) Choibalsan', value: 'Asia/Choibalsan' },
  584. { text: '(GMT+08:00) Hong Kong', value: 'Asia/Hong_Kong' },
  585. { text: '(GMT+08:00) Kuala Lumpur', value: 'Asia/Kuala_Lumpur' },
  586. { text: '(GMT+08:00) Macau', value: 'Asia/Macau' },
  587. { text: '(GMT+08:00) Makassar', value: 'Asia/Makassar' },
  588. { text: '(GMT+08:00) Manila', value: 'Asia/Manila' },
  589. { text: '(GMT+08:00) Moscow+05 - Irkutsk', value: 'Asia/Irkutsk' },
  590. { text: '(GMT+08:00) Singapore', value: 'Asia/Singapore' },
  591. { text: '(GMT+08:00) Taipei', value: 'Asia/Taipei' },
  592. { text: '(GMT+08:00) Ulaanbaatar', value: 'Asia/Ulaanbaatar' },
  593. { text: '(GMT+08:00) Western Time - Perth', value: 'Australia/Perth' },
  594. { text: '(GMT+08:30) Pyongyang', value: 'Asia/Pyongyang' },
  595. { text: '(GMT+09:00) Dili', value: 'Asia/Dili' },
  596. { text: '(GMT+09:00) Jayapura', value: 'Asia/Jayapura' },
  597. { text: '(GMT+09:00) Moscow+06 - Yakutsk', value: 'Asia/Yakutsk' },
  598. { text: '(GMT+09:00) Palau', value: 'Pacific/Palau' },
  599. { text: '(GMT+09:00) Seoul', value: 'Asia/Seoul' },
  600. { text: '(GMT+09:00) Tokyo', value: 'Asia/Tokyo' },
  601. { text: '(GMT+09:30) Central Time - Darwin', value: 'Australia/Darwin' },
  602. { text: '(GMT+10:00) Dumont D\'Urville', value: 'Antarctica/DumontDUrville' },
  603. { text: '(GMT+10:00) Eastern Time - Brisbane', value: 'Australia/Brisbane' },
  604. { text: '(GMT+10:00) Guam', value: 'Pacific/Guam' },
  605. { text: '(GMT+10:00) Moscow+07 - Vladivostok', value: 'Asia/Vladivostok' },
  606. { text: '(GMT+10:00) Port Moresby', value: 'Pacific/Port_Moresby' },
  607. { text: '(GMT+10:00) Truk', value: 'Pacific/Chuuk' },
  608. { text: '(GMT+10:30) Central Time - Adelaide', value: 'Australia/Adelaide' },
  609. { text: '(GMT+11:00) Casey', value: 'Antarctica/Casey' },
  610. { text: '(GMT+11:00) Eastern Time - Hobart', value: 'Australia/Hobart' },
  611. { text: '(GMT+11:00) Eastern Time - Melbourne, Sydney', value: 'Australia/Sydney' },
  612. { text: '(GMT+11:00) Efate', value: 'Pacific/Efate' },
  613. { text: '(GMT+11:00) Guadalcanal', value: 'Pacific/Guadalcanal' },
  614. { text: '(GMT+11:00) Kosrae', value: 'Pacific/Kosrae' },
  615. { text: '(GMT+11:00) Moscow+08 - Magadan', value: 'Asia/Magadan' },
  616. { text: '(GMT+11:00) Norfolk', value: 'Pacific/Norfolk' },
  617. { text: '(GMT+11:00) Noumea', value: 'Pacific/Noumea' },
  618. { text: '(GMT+11:00) Ponape', value: 'Pacific/Pohnpei' },
  619. { text: '(GMT+12:00) Funafuti', value: 'Pacific/Funafuti' },
  620. { text: '(GMT+12:00) Kwajalein', value: 'Pacific/Kwajalein' },
  621. { text: '(GMT+12:00) Majuro', value: 'Pacific/Majuro' },
  622. { text: '(GMT+12:00) Moscow+09 - Petropavlovsk-Kamchatskiy', value: 'Asia/Kamchatka' },
  623. { text: '(GMT+12:00) Nauru', value: 'Pacific/Nauru' },
  624. { text: '(GMT+12:00) Tarawa', value: 'Pacific/Tarawa' },
  625. { text: '(GMT+12:00) Wake', value: 'Pacific/Wake' },
  626. { text: '(GMT+12:00) Wallis', value: 'Pacific/Wallis' },
  627. { text: '(GMT+13:00) Auckland', value: 'Pacific/Auckland' },
  628. { text: '(GMT+13:00) Enderbury', value: 'Pacific/Enderbury' },
  629. { text: '(GMT+13:00) Fakaofo', value: 'Pacific/Fakaofo' },
  630. { text: '(GMT+13:00) Fiji', value: 'Pacific/Fiji' },
  631. { text: '(GMT+13:00) Tongatapu', value: 'Pacific/Tongatapu' },
  632. { text: '(GMT+14:00) Apia', value: 'Pacific/Apia' },
  633. { text: '(GMT+14:00) Kiritimati', value: 'Pacific/Kiritimati' }
  634. ]
  635. }
  636. },
  637. computed: {
  638. dateFormats () {
  639. return [
  640. { text: this.$t('profile:localeDefault'), value: '' },
  641. { text: 'DD/MM/YYYY', value: 'DD/MM/YYYY' },
  642. { text: 'DD.MM.YYYY', value: 'DD.MM.YYYY' },
  643. { text: 'MM/DD/YYYY', value: 'MM/DD/YYYY' },
  644. { text: 'YYYY-MM-DD', value: 'YYYY-MM-DD' },
  645. { text: 'YYYY/MM/DD', value: 'YYYY/MM/DD' }
  646. ]
  647. },
  648. appearances () {
  649. return [
  650. { text: this.$t('profile:appearanceDefault'), value: '' },
  651. { text: this.$t('profile:appearanceLight'), value: 'light' },
  652. { text: this.$t('profile:appearanceDark'), value: 'dark' }
  653. ]
  654. },
  655. currentAppearance () {
  656. return _.get(_.find(this.appearances, ['value', this.user.appearance]), 'text', false) || this.$t('profile:appearanceDefault')
  657. },
  658. pictureUrl: get('user/pictureUrl'),
  659. picture () {
  660. if (this.pictureUrl && this.pictureUrl.length > 1) {
  661. return {
  662. kind: 'image',
  663. url: this.pictureUrl
  664. }
  665. } else {
  666. const nameParts = this.user.name.toUpperCase().split(' ')
  667. let initials = _.head(nameParts).charAt(0)
  668. if (nameParts.length > 1) {
  669. initials += _.last(nameParts).charAt(0)
  670. }
  671. return {
  672. kind: 'initials',
  673. initials
  674. }
  675. }
  676. }
  677. },
  678. watch: {
  679. 'user.appearance': (newValue, oldValue) => {
  680. if (newValue === '') {
  681. WIKI.$vuetify.theme.dark = siteConfig.darkMode
  682. } else {
  683. WIKI.$vuetify.theme.dark = (newValue === 'dark')
  684. }
  685. },
  686. 'user.dateFormat': (newValue, oldValue) => {
  687. if (newValue === '') {
  688. WIKI.$moment.updateLocale(WIKI.$moment.locale(), null)
  689. } else {
  690. WIKI.$moment.updateLocale(WIKI.$moment.locale(), {
  691. longDateFormat: {
  692. 'L': newValue
  693. }
  694. })
  695. }
  696. },
  697. 'user.timezone': (newValue, oldValue) => {
  698. if (newValue === '') {
  699. WIKI.$moment.tz.setDefault()
  700. } else {
  701. WIKI.$moment.tz.setDefault(newValue)
  702. }
  703. }
  704. },
  705. methods: {
  706. /**
  707. * Focus an input after delay
  708. */
  709. focusField (ipt) {
  710. this.$nextTick(() => {
  711. _.delay(() => {
  712. this.$refs[ipt].focus()
  713. }, 200)
  714. })
  715. },
  716. /**
  717. * Save User Profile
  718. */
  719. async saveProfile () {
  720. this.saveLoading = true
  721. this.$store.commit(`loadingStart`, 'profile-save')
  722. try {
  723. const respRaw = await this.$apollo.mutate({
  724. mutation: gql`
  725. mutation ($name: String!, $location: String!, $jobTitle: String!, $timezone: String!, $dateFormat: String!, $appearance: String!) {
  726. users {
  727. updateProfile(name: $name, location: $location, jobTitle: $jobTitle, timezone: $timezone, dateFormat: $dateFormat, appearance: $appearance) {
  728. responseResult {
  729. succeeded
  730. errorCode
  731. slug
  732. message
  733. }
  734. jwt
  735. }
  736. }
  737. }
  738. `,
  739. variables: {
  740. name: this.user.name,
  741. location: this.user.location,
  742. jobTitle: this.user.jobTitle,
  743. timezone: this.user.timezone,
  744. dateFormat: this.user.dateFormat,
  745. appearance: this.user.appearance
  746. }
  747. })
  748. const resp = _.get(respRaw, 'data.users.updateProfile.responseResult', {})
  749. if (resp.succeeded) {
  750. Cookies.set('jwt', _.get(respRaw, 'data.users.updateProfile.jwt', ''), { expires: 365 })
  751. this.$store.set('user/name', this.user.name)
  752. this.$store.commit('showNotification', {
  753. message: this.$t('profile:save.success'),
  754. style: 'success',
  755. icon: 'check'
  756. })
  757. } else {
  758. throw new Error(resp.message)
  759. }
  760. } catch (err) {
  761. this.$store.commit('pushGraphError', err)
  762. }
  763. this.$store.commit(`loadingStop`, 'profile-save')
  764. this.saveLoading = false
  765. },
  766. /**
  767. * Change Password
  768. */
  769. async changePassword () {
  770. const validation = validate({
  771. current: this.currentPass,
  772. password: this.newPass,
  773. verifyPassword: this.verifyPass
  774. }, {
  775. current: {
  776. presence: {
  777. message: this.$t('auth:missingPassword'),
  778. allowEmpty: false
  779. },
  780. length: {
  781. minimum: 6,
  782. tooShort: this.$t('auth:passwordTooShort')
  783. }
  784. },
  785. password: {
  786. presence: {
  787. message: this.$t('auth:missingPassword'),
  788. allowEmpty: false
  789. },
  790. length: {
  791. minimum: 6,
  792. tooShort: this.$t('auth:passwordTooShort')
  793. }
  794. },
  795. verifyPassword: {
  796. equality: {
  797. attribute: 'password',
  798. message: this.$t('auth:passwordNotMatch')
  799. }
  800. }
  801. }, { fullMessages: false })
  802. if (validation) {
  803. if (validation.current) {
  804. this.$store.commit('showNotification', {
  805. style: 'red',
  806. message: validation.current[0],
  807. icon: 'warning'
  808. })
  809. this.$refs.iptCurrentPass.focus()
  810. } else if (validation.password) {
  811. this.$store.commit('showNotification', {
  812. style: 'red',
  813. message: validation.password[0],
  814. icon: 'warning'
  815. })
  816. this.$refs.iptNewPass.focus()
  817. } else if (validation.verifyPassword) {
  818. this.$store.commit('showNotification', {
  819. style: 'red',
  820. message: validation.verifyPassword[0],
  821. icon: 'warning'
  822. })
  823. this.$refs.iptVerifyPass.focus()
  824. }
  825. } else {
  826. this.changePassLoading = true
  827. this.$store.commit(`loadingStart`, 'profile-changepassword')
  828. try {
  829. const respRaw = await this.$apollo.mutate({
  830. mutation: gql`
  831. mutation ($current: String!, $new: String!) {
  832. users {
  833. changePassword(current: $current, new: $new) {
  834. responseResult {
  835. succeeded
  836. errorCode
  837. slug
  838. message
  839. }
  840. jwt
  841. }
  842. }
  843. }
  844. `,
  845. variables: {
  846. current: this.currentPass,
  847. new: this.newPass
  848. }
  849. })
  850. const resp = _.get(respRaw, 'data.users.changePassword.responseResult', {})
  851. if (resp.succeeded) {
  852. this.currentPass = ''
  853. this.newPass = ''
  854. this.verifyPass = ''
  855. Cookies.set('jwt', _.get(respRaw, 'data.users.changePassword.jwt', ''), { expires: 365 })
  856. this.$store.commit('showNotification', {
  857. message: this.$t('profile:auth.changePassSuccess'),
  858. style: 'success',
  859. icon: 'check'
  860. })
  861. } else {
  862. throw new Error(resp.message)
  863. }
  864. } catch (err) {
  865. this.$store.commit('pushGraphError', err)
  866. }
  867. this.$store.commit(`loadingStop`, 'profile-changepassword')
  868. this.changePassLoading = false
  869. }
  870. }
  871. },
  872. apollo: {
  873. user: {
  874. query: gql`
  875. {
  876. users {
  877. profile {
  878. id
  879. name
  880. email
  881. providerKey
  882. providerName
  883. isSystem
  884. isVerified
  885. location
  886. jobTitle
  887. timezone
  888. dateFormat
  889. appearance
  890. createdAt
  891. updatedAt
  892. lastLoginAt
  893. groups
  894. pagesTotal
  895. }
  896. }
  897. }
  898. `,
  899. fetchPolicy: 'network-only',
  900. update: (data) => _.cloneDeep(data.users.profile),
  901. watchLoading (isLoading) {
  902. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'profile-refresh')
  903. }
  904. }
  905. }
  906. }
  907. </script>
  908. <style lang='scss'>
  909. </style>