feat: users create (wip)

pull/835/head 2.0.0-beta.115
Nick 6 years ago
parent 849d4f4774
commit 4f23984ac6

@ -1,6 +1,10 @@
<template lang='pug'> <template lang='pug'>
v-app(:dark='darkMode').admin v-app(:dark='darkMode').admin
nav-header nav-header(hide-search)
template(slot='mid')
v-spacer
.subheading.grey--text Administration Area
v-spacer
v-navigation-drawer.pb-0.admin-sidebar(v-model='adminDrawerShown', app, fixed, clipped, left, permanent) v-navigation-drawer.pb-0.admin-sidebar(v-model='adminDrawerShown', app, fixed, clipped, left, permanent)
vue-scroll(:ops='scrollStyle') vue-scroll(:ops='scrollStyle')
v-list(dense) v-list(dense)

@ -130,7 +130,7 @@
persistent-hint persistent-hint
) )
v-switch.ml-3( v-switch.ml-3(
v-if='strategy.useForm' v-if='strategy.key === `local`'
:disabled='!strategy.selfRegistration || true' :disabled='!strategy.selfRegistration || true'
v-model='strategy.recaptcha' v-model='strategy.recaptcha'
label='Use reCAPTCHA by Google' label='Use reCAPTCHA by Google'

@ -45,7 +45,7 @@
:class='isLatestVersion ? "teal lighten-2" : "red lighten-2"' :class='isLatestVersion ? "teal lighten-2" : "red lighten-2"'
dark dark
) )
v-btn(fab, absolute, right, top, small, light, to='system', v-if='hasPermission(`manage:system`)') v-btn.btn-animate-wrench(fab, absolute, right, top, small, light, to='system', v-if='hasPermission(`manage:system`)')
v-icon(:color='isLatestVersion ? `teal` : `red darken-4`') build v-icon(:color='isLatestVersion ? `teal` : `red darken-4`') build
v-card-text v-card-text
v-icon.dashboard-icon blur_on v-icon.dashboard-icon blur_on

@ -10,7 +10,7 @@
v-layout.mt-3(row wrap) v-layout.mt-3(row wrap)
v-flex(lg6 xs12) v-flex(lg6 xs12)
v-card.animated.fadeInUp v-card.animated.fadeInUp
v-btn.animated.fadeInLeft.wait-p2s(fab, absolute, right, top, small, light, @click='refresh'): v-icon refresh v-btn.animated.fadeInLeft.wait-p2s.btn-animate-rotate(fab, absolute, right, top, small, light, @click='refresh'): v-icon refresh
v-list(two-line, dense) v-list(two-line, dense)
v-subheader Wiki.js v-subheader Wiki.js
v-list-tile(avatar) v-list-tile(avatar)

@ -1,10 +1,10 @@
<template lang="pug"> <template lang="pug">
v-dialog(v-model='isShown', max-width='550') v-dialog(v-model='isShown', max-width='650', persistent)
v-card.wiki-form v-card.wiki-form
.dialog-header.is-short .dialog-header.is-short
span New User span New User
v-card-text v-card-text
v-select.md2( v-select(
:items='providers' :items='providers'
item-text='title' item-text='title'
item-value='key' item-value='key'
@ -13,40 +13,66 @@
v-model='provider' v-model='provider'
label='Provider' label='Provider'
) )
v-text-field.md2( v-text-field(
outline outline
prepend-icon='email' prepend-icon='email'
v-model='email' v-model='email'
label='Email Address' label='Email Address'
ref='emailInput' ref='emailInput'
) )
v-text-field.md2( v-text-field(
v-if='provider === `local`' v-if='provider === `local`'
outline outline
prepend-icon='lock' prepend-icon='lock'
append-icon='casino' append-icon='casino'
v-model='password' v-model='password'
label='Password' :label='mustChangePwd ? `Temporary Password` : `Password`'
counter='255' counter='255'
@click:append='generatePwd' @click:append='generatePwd'
) )
v-text-field.md2( v-text-field(
outline outline
prepend-icon='person' prepend-icon='person'
v-model='name' v-model='name'
label='Name' label='Name'
) )
v-select(
:items='groups'
item-text='name'
item-value='key'
outline
prepend-icon='people'
v-model='group'
label='Assign to Group(s)...'
clearable
multiple
)
v-divider
v-checkbox(
color='primary'
label='Require password change on first login'
v-if='provider === `local`'
v-model='mustChangePwd'
hide-details
)
v-checkbox(
color='primary'
label='Send a welcome email'
hide-details
v-model='sendWelcomeEmail'
)
v-card-chin v-card-chin
v-spacer v-spacer
v-btn(flat, @click='isShown = false') Cancel v-btn(flat, @click='isShown = false') Cancel
v-btn(color='primary', @click='newUser') Create v-btn(color='primary', @click='newUser') Create
v-btn(color='primary', @click='newUser') Create and Close
</template> </template>
<script> <script>
import _ from 'lodash'
import uuidv4 from 'uuid/v4' import uuidv4 from 'uuid/v4'
import providersQuery from 'gql/admin/users/users-query-strategies.gql' import providersQuery from 'gql/admin/users/users-query-strategies.gql'
import groupsQuery from 'gql/admin/auth/auth-query-groups.gql'
export default { export default {
props: { props: {
@ -61,7 +87,11 @@ export default {
provider: 'local', provider: 'local',
email: '', email: '',
password: '', password: '',
name: '' name: '',
groups: [],
group: '',
mustChangePwd: false,
sendWelcomeEmail: false
} }
}, },
computed: { computed: {
@ -95,6 +125,14 @@ export default {
watchLoading (isLoading) { watchLoading (isLoading) {
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-users-strategies-refresh') this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-users-strategies-refresh')
} }
},
groups: {
query: groupsQuery,
fetchPolicy: 'network-only',
update: (data) => data.groups.list,
watchLoading (isLoading) {
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-auth-groups-refresh')
}
} }
} }
} }

@ -3,17 +3,17 @@
v-layout(row, wrap) v-layout(row, wrap)
v-flex(xs12) v-flex(xs12)
.admin-header .admin-header
img(src='/svg/icon-male-user.svg', alt='Edit User', style='width: 80px;') img.animated.fadeInUp(src='/svg/icon-male-user.svg', alt='Edit User', style='width: 80px;')
.admin-header-title .admin-header-title
.headline.blue--text.text--darken-2 Edit User .headline.blue--text.text--darken-2.animated.fadeInLeft Edit User
.subheading.grey--text {{user.name}} .subheading.grey--text.animated.fadeInLeft.wait-p2s {{user.name}}
v-spacer v-spacer
.caption.grey--text ID #[strong {{user.id}}] .caption.grey--text.animated.fadeInRight.wait-p5s ID #[strong {{user.id}}]
v-divider.mx-3(vertical) v-divider.animated.fadeInRight.wait-p3s.mx-3(vertical)
v-btn(color='grey', large, outline, to='/users') v-btn.animated.fadeInDown.wait-p2s(color='grey', large, outline, to='/users')
v-icon arrow_back v-icon arrow_back
v-dialog(v-model='deleteUserDialog', max-width='500', v-if='user.id !== currentUserId && !user.isSystem') v-dialog(v-model='deleteUserDialog', max-width='500', v-if='user.id !== currentUserId && !user.isSystem')
v-btn(color='red', large, outline, slot='activator') v-btn.animated.fadeInDown.wait-p1s(color='red', large, outline, slot='activator')
v-icon(color='red') delete v-icon(color='red') delete
v-card v-card
.dialog-header.is-red Delete User? .dialog-header.is-red Delete User?
@ -22,11 +22,11 @@
v-spacer v-spacer
v-btn(flat, @click='deleteUserDialog = false') Cancel v-btn(flat, @click='deleteUserDialog = false') Cancel
v-btn(color='red', dark, @click='deleteUser') Delete v-btn(color='red', dark, @click='deleteUser') Delete
v-btn(color='primary', large, depressed, @click='updateUser') v-btn.animated.fadeInDown(color='primary', large, depressed, @click='updateUser')
v-icon(left) check v-icon(left) check
span Update User span Update User
v-flex(xs5) v-flex(xs5)
v-card v-card.animated.fadeInUp
v-toolbar(color='primary', dense, dark, flat) v-toolbar(color='primary', dense, dark, flat)
v-icon.mr-2 directions_run v-icon.mr-2 directions_run
span Basic Info span Basic Info
@ -50,7 +50,7 @@
v-list-tile-action v-list-tile-action
v-btn(icon, color='grey', flat) v-btn(icon, color='grey', flat)
v-icon edit v-icon edit
v-card.mt-3(v-if='!user.isSystem') v-card.mt-3.animated.fadeInUp.wait-p2s(v-if='!user.isSystem')
v-toolbar(color='primary', dense, dark, flat) v-toolbar(color='primary', dense, dark, flat)
v-icon.mr-2 lock_outline v-icon.mr-2 lock_outline
span Authentication span Authentication
@ -95,7 +95,7 @@
v-list-tile-content v-list-tile-content
v-list-tile-title Provider Id v-list-tile-title Provider Id
v-list-tile-sub-title {{ user.providerId }} v-list-tile-sub-title {{ user.providerId }}
v-card.mt-3 v-card.mt-3.animated.fadeInUp.wait-p4s
v-toolbar(color='primary', dense, dark, flat) v-toolbar(color='primary', dense, dark, flat)
v-icon.mr-2 people v-icon.mr-2 people
span User Groups span User Groups
@ -116,7 +116,7 @@
v-icon(left) how_to_reg v-icon(left) how_to_reg
span Assign to group span Assign to group
v-flex(xs7) v-flex(xs7)
v-card v-card.animated.fadeInUp.wait-p2s
v-toolbar(color='primary', dense, dark, flat) v-toolbar(color='primary', dense, dark, flat)
v-icon.mr-2 directions_walk v-icon.mr-2 directions_walk
span Extended Metadata span Extended Metadata
@ -150,7 +150,7 @@
v-list-tile-action v-list-tile-action
v-btn(icon, color='grey', flat) v-btn(icon, color='grey', flat)
v-icon edit v-icon edit
v-card.mt-3 v-card.mt-3.animated.fadeInUp.wait-p4s
v-toolbar(color='primary', dense, dark, flat) v-toolbar(color='primary', dense, dark, flat)
v-icon.mr-2 insert_drive_file v-icon.mr-2 insert_drive_file
span Content span Content

@ -6,21 +6,42 @@
img.animated.fadeInUp(src='/svg/icon-customer.svg', alt='Users', style='width: 80px;') img.animated.fadeInUp(src='/svg/icon-customer.svg', alt='Users', style='width: 80px;')
.admin-header-title .admin-header-title
.headline.blue--text.text--darken-2.animated.fadeInLeft Users .headline.blue--text.text--darken-2.animated.fadeInLeft Users
.subheading.grey--text.animated.fadeInLeft.wait-p4s Manage users .subheading.grey--text.animated.fadeInLeft.wait-p2s Manage users
v-spacer v-spacer
v-btn.animated.fadeInDown.wait-p2s(outline, color='grey', large, @click='refresh') v-btn.animated.fadeInDown.wait-p2s(outline, color='grey', large, @click='refresh')
v-icon refresh v-icon refresh
v-btn.animated.fadeInDown(color='primary', large, depressed, @click='createUser') v-btn.animated.fadeInDown(color='primary', large, depressed, @click='createUser', disabled)
v-icon(left) add v-icon(left) add
span New User span New User
v-card.mt-3.animated.fadeInUp v-card.wiki-form.mt-3.animated.fadeInUp
v-toolbar(flat, :color='$vuetify.dark ? `grey darken-3-d5` : `grey lighten-5`', height='80')
v-spacer
v-text-field(
outline
v-model='search'
prepend-inner-icon='search'
label='Search Users...'
hide-details
)
v-select.ml-2(
outline
hide-details
label='Identity Provider'
:items='strategies'
v-model='filterStrategy'
item-text='title'
item-value='key'
)
v-spacer
v-divider
v-data-table( v-data-table(
v-model='selected' v-model='selected'
:items='users', :items='usersFiltered',
:headers='headers', :headers='headers',
:search='search', :search='search',
:pagination.sync='pagination', :pagination.sync='pagination',
:rows-per-page-items='[15]' :rows-per-page-items='[15]'
:loading='loading'
hide-actions, hide-actions,
disable-initial-sort disable-initial-sort
) )
@ -51,7 +72,7 @@
template(slot='no-data') template(slot='no-data')
.pa-3 .pa-3
v-alert(icon='warning', :value='true', outline) No users to display! v-alert(icon='warning', :value='true', outline) No users to display!
v-card-chin(v-if='this.pages > 0') v-card-chin(v-if='this.pages > 1')
v-spacer v-spacer
v-pagination(v-model='pagination.page', :length='pages') v-pagination(v-model='pagination.page', :length='pages')
v-spacer v-spacer
@ -60,7 +81,10 @@
</template> </template>
<script> <script>
import _ from 'lodash'
import usersQuery from 'gql/admin/users/users-query-list.gql' import usersQuery from 'gql/admin/users/users-query-list.gql'
import providersQuery from 'gql/admin/users/users-query-strategies.gql'
import UserCreate from './admin-users-create.vue' import UserCreate from './admin-users-create.vue'
@ -81,17 +105,24 @@ export default {
{ text: 'Created', value: 'createdAt', sortable: true }, { text: 'Created', value: 'createdAt', sortable: true },
{ text: '', value: 'actions', sortable: false, width: 50 } { text: '', value: 'actions', sortable: false, width: 50 }
], ],
strategies: [],
filterStrategy: 'all',
search: '', search: '',
loading: false,
isCreateDialogShown: false isCreateDialogShown: false
} }
}, },
computed: { computed: {
usersFiltered () {
const all = this.filterStrategy === 'all' || this.filterStrategy === ''
return _.filter(this.users, u => all || u.providerKey === this.filterStrategy)
},
pages () { pages () {
if (this.pagination.rowsPerPage == null || this.pagination.totalItems == null) { if (this.pagination.rowsPerPage == null || this.usersFiltered.length < 1) {
return 0 return 0
} }
return Math.ceil(this.pagination.totalItems / this.pagination.rowsPerPage) return Math.ceil(this.usersFiltered.length / this.pagination.rowsPerPage)
} }
}, },
methods: { methods: {
@ -128,8 +159,22 @@ export default {
fetchPolicy: 'network-only', fetchPolicy: 'network-only',
update: (data) => data.users.list, update: (data) => data.users.list,
watchLoading (isLoading) { watchLoading (isLoading) {
this.loading = isLoading
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-users-refresh') this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-users-refresh')
} }
},
strategies: {
query: providersQuery,
fetchPolicy: 'network-only',
update: (data) => {
return _.concat({
key: 'all',
title: 'All'
}, data.authentication.strategies)
},
watchLoading (isLoading) {
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-users-strategies-refresh')
}
} }
} }
} }

@ -32,6 +32,16 @@
} }
} }
.btn-animate-wrench {
i {
transition: all .7s cubic-bezier(0.68, -0.55, 0.265, 1.55);
transform: rotate(0deg);
}
&:hover i {
transform: rotate(45deg);
}
}
.btn-animate-app { .btn-animate-app {
i { i {
transition: all .6s ease; transition: all .6s ease;

@ -17,14 +17,15 @@ module.exports = {
resource: conf.resource, resource: conf.resource,
tenant: conf.tenant tenant: conf.tenant
}, (accessToken, refreshToken, params, profile, cb) => { }, (accessToken, refreshToken, params, profile, cb) => {
console.info(params, profile)
let waadProfile = jwt.decode(params.id_token) let waadProfile = jwt.decode(params.id_token)
waadProfile.id = waadProfile.oid waadProfile.id = waadProfile.oid
waadProfile.provider = 'azure' waadProfile.provider = 'azure'
WIKI.models.users.processProfile(waadProfile).then((user) => { // WIKI.models.users.processProfile(waadProfile).then((user) => {
return cb(null, user) || true // return cb(null, user) || true
}).catch((err) => { // }).catch((err) => {
return cb(err, null) || true // return cb(err, null) || true
}) // })
} }
)) ))
} }

@ -5,6 +5,7 @@ author: requarks.io
logo: https://static.requarks.io/logo/azure.svg logo: https://static.requarks.io/logo/azure.svg
color: blue darken-3 color: blue darken-3
website: https://azure.microsoft.com/services/active-directory/ website: https://azure.microsoft.com/services/active-directory/
isAvailable: false
useForm: false useForm: false
props: props:
clientId: String clientId: String

Loading…
Cancel
Save