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.

139 lines
3.3 KiB

  1. <template lang="pug">
  2. v-dialog(v-model='isShown', max-width='650', persistent)
  3. v-card.wiki-form
  4. .dialog-header.is-short
  5. span New User
  6. v-card-text
  7. v-select(
  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(
  17. outline
  18. prepend-icon='email'
  19. v-model='email'
  20. label='Email Address'
  21. ref='emailInput'
  22. )
  23. v-text-field(
  24. v-if='provider === `local`'
  25. outline
  26. prepend-icon='lock'
  27. append-icon='casino'
  28. v-model='password'
  29. :label='mustChangePwd ? `Temporary Password` : `Password`'
  30. counter='255'
  31. @click:append='generatePwd'
  32. )
  33. v-text-field(
  34. outline
  35. prepend-icon='person'
  36. v-model='name'
  37. label='Name'
  38. )
  39. v-select(
  40. :items='groups'
  41. item-text='name'
  42. item-value='key'
  43. outline
  44. prepend-icon='people'
  45. v-model='group'
  46. label='Assign to Group(s)...'
  47. clearable
  48. multiple
  49. )
  50. v-divider
  51. v-checkbox(
  52. color='primary'
  53. label='Require password change on first login'
  54. v-if='provider === `local`'
  55. v-model='mustChangePwd'
  56. hide-details
  57. )
  58. v-checkbox(
  59. color='primary'
  60. label='Send a welcome email'
  61. hide-details
  62. v-model='sendWelcomeEmail'
  63. )
  64. v-card-chin
  65. v-spacer
  66. v-btn(flat, @click='isShown = false') Cancel
  67. v-btn(color='primary', @click='newUser') Create
  68. v-btn(color='primary', @click='newUser') Create and Close
  69. </template>
  70. <script>
  71. import uuidv4 from 'uuid/v4'
  72. import providersQuery from 'gql/admin/users/users-query-strategies.gql'
  73. import groupsQuery from 'gql/admin/auth/auth-query-groups.gql'
  74. export default {
  75. props: {
  76. value: {
  77. type: Boolean,
  78. default: false
  79. }
  80. },
  81. data() {
  82. return {
  83. providers: [],
  84. provider: 'local',
  85. email: '',
  86. password: '',
  87. name: '',
  88. groups: [],
  89. group: '',
  90. mustChangePwd: false,
  91. sendWelcomeEmail: false
  92. }
  93. },
  94. computed: {
  95. isShown: {
  96. get() { return this.value },
  97. set(val) { this.$emit('input', val) }
  98. }
  99. },
  100. watch: {
  101. value(newValue, oldValue) {
  102. if (newValue) {
  103. this.$nextTick(() => {
  104. this.$refs.emailInput.focus()
  105. })
  106. }
  107. }
  108. },
  109. methods: {
  110. async newUser() {
  111. },
  112. generatePwd() {
  113. this.password = uuidv4().slice(-12)
  114. }
  115. },
  116. apollo: {
  117. providers: {
  118. query: providersQuery,
  119. fetchPolicy: 'network-only',
  120. update: (data) => data.authentication.strategies,
  121. watchLoading (isLoading) {
  122. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-users-strategies-refresh')
  123. }
  124. },
  125. groups: {
  126. query: groupsQuery,
  127. fetchPolicy: 'network-only',
  128. update: (data) => data.groups.list,
  129. watchLoading (isLoading) {
  130. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-auth-groups-refresh')
  131. }
  132. }
  133. }
  134. }
  135. </script>