You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.2 KiB

  1. <template lang="pug">
  2. v-dialog(v-model='isShown', max-width='550')
  3. v-card.wiki-form
  4. .dialog-header.is-short
  5. span New User
  6. v-card-text
  7. v-select.md2(
  8. :items='providers'
  9. item-text='title'
  10. item-value='key'
  11. outline
  12. prepend-icon='business'
  13. v-model='provider'
  14. label='Provider'
  15. )
  16. v-text-field.md2(
  17. outline
  18. prepend-icon='email'
  19. v-model='email'
  20. label='Email Address'
  21. ref='emailInput'
  22. )
  23. v-text-field.md2(
  24. v-if='provider === `local`'
  25. outline
  26. prepend-icon='lock'
  27. append-icon='casino'
  28. v-model='password'
  29. label='Password'
  30. counter='255'
  31. @click:append='generatePwd'
  32. )
  33. v-text-field.md2(
  34. outline
  35. prepend-icon='person'
  36. v-model='name'
  37. label='Name'
  38. )
  39. v-card-chin
  40. v-spacer
  41. v-btn(flat, @click='isShown = false') Cancel
  42. v-btn(color='primary', @click='newUser') Create
  43. </template>
  44. <script>
  45. import _ from 'lodash'
  46. import uuidv4 from 'uuid/v4'
  47. import providersQuery from 'gql/admin/users/users-query-strategies.gql'
  48. export default {
  49. props: {
  50. value: {
  51. type: Boolean,
  52. default: false
  53. }
  54. },
  55. data() {
  56. return {
  57. providers: [],
  58. provider: 'local',
  59. email: '',
  60. password: '',
  61. name: ''
  62. }
  63. },
  64. computed: {
  65. isShown: {
  66. get() { return this.value },
  67. set(val) { this.$emit('input', val) }
  68. }
  69. },
  70. watch: {
  71. value(newValue, oldValue) {
  72. if (newValue) {
  73. this.$nextTick(() => {
  74. this.$refs.emailInput.focus()
  75. })
  76. }
  77. }
  78. },
  79. methods: {
  80. async newUser() {
  81. },
  82. generatePwd() {
  83. this.password = uuidv4().slice(-12)
  84. }
  85. },
  86. apollo: {
  87. providers: {
  88. query: providersQuery,
  89. fetchPolicy: 'network-only',
  90. update: (data) => data.authentication.strategies,
  91. watchLoading (isLoading) {
  92. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-users-strategies-refresh')
  93. }
  94. }
  95. }
  96. }
  97. </script>