2018-03-03 06:32:58 +00:00
|
|
|
<template lang='pug'>
|
2018-09-30 03:30:20 +00:00
|
|
|
v-container(fluid, grid-list-lg)
|
|
|
|
v-layout(row, wrap)
|
|
|
|
v-flex(xs12)
|
|
|
|
.admin-header
|
2020-05-15 21:05:11 +00:00
|
|
|
img.animated.fadeInUp(src='/_assets/svg/icon-customer.svg', alt='Users', style='width: 80px;')
|
2018-09-30 03:30:20 +00:00
|
|
|
.admin-header-title
|
2019-04-07 16:37:33 +00:00
|
|
|
.headline.blue--text.text--darken-2.animated.fadeInLeft Users
|
2019-08-03 04:48:55 +00:00
|
|
|
.subtitle-1.grey--text.animated.fadeInLeft.wait-p2s Manage users
|
2018-09-30 03:30:20 +00:00
|
|
|
v-spacer
|
2020-05-23 03:29:42 +00:00
|
|
|
v-btn.animated.fadeInDown.wait-p2s.mr-3(outlined, color='grey', icon, @click='refresh')
|
2019-07-29 04:50:03 +00:00
|
|
|
v-icon mdi-refresh
|
|
|
|
v-btn.animated.fadeInDown(color='primary', large, depressed, @click='createUser')
|
|
|
|
v-icon(left) mdi-plus
|
2019-01-01 22:03:30 +00:00
|
|
|
span New User
|
2020-05-23 03:29:42 +00:00
|
|
|
v-card.mt-3.animated.fadeInUp
|
|
|
|
.pa-2.d-flex.align-center(:class='$vuetify.theme.dark ? `grey darken-3-d5` : `grey lighten-3`')
|
2019-04-29 00:25:19 +00:00
|
|
|
v-text-field(
|
2020-05-23 03:29:42 +00:00
|
|
|
solo
|
|
|
|
flat
|
2019-04-29 00:25:19 +00:00
|
|
|
v-model='search'
|
2019-07-29 04:50:03 +00:00
|
|
|
prepend-inner-icon='mdi-account-search-outline'
|
2019-04-29 00:25:19 +00:00
|
|
|
label='Search Users...'
|
|
|
|
hide-details
|
2020-05-23 03:29:42 +00:00
|
|
|
style='max-width: 400px;'
|
|
|
|
dense
|
2019-04-29 00:25:19 +00:00
|
|
|
)
|
2020-05-23 03:29:42 +00:00
|
|
|
v-spacer
|
|
|
|
v-select(
|
|
|
|
solo
|
|
|
|
flat
|
2019-04-29 00:25:19 +00:00
|
|
|
hide-details
|
|
|
|
label='Identity Provider'
|
|
|
|
:items='strategies'
|
|
|
|
v-model='filterStrategy'
|
2020-07-03 23:36:33 +00:00
|
|
|
item-text='displayName'
|
2019-04-29 00:25:19 +00:00
|
|
|
item-value='key'
|
2020-05-23 03:29:42 +00:00
|
|
|
style='max-width: 300px;'
|
|
|
|
dense
|
2019-04-29 00:25:19 +00:00
|
|
|
)
|
|
|
|
v-divider
|
2018-09-30 03:30:20 +00:00
|
|
|
v-data-table(
|
|
|
|
v-model='selected'
|
2019-04-29 00:25:19 +00:00
|
|
|
:items='usersFiltered',
|
2018-09-30 03:30:20 +00:00
|
|
|
:headers='headers',
|
|
|
|
:search='search',
|
2019-08-11 02:14:53 +00:00
|
|
|
:page.sync='pagination'
|
|
|
|
:items-per-page='15'
|
2019-04-29 00:25:19 +00:00
|
|
|
:loading='loading'
|
2019-08-11 02:14:53 +00:00
|
|
|
@page-count='pageCount = $event'
|
|
|
|
hide-default-footer
|
|
|
|
)
|
|
|
|
template(slot='item', slot-scope='props')
|
2018-10-19 22:18:55 +00:00
|
|
|
tr.is-clickable(:active='props.selected', @click='$router.push("/users/" + props.item.id)')
|
2018-10-14 03:22:42 +00:00
|
|
|
//- td
|
2018-09-30 03:30:20 +00:00
|
|
|
v-checkbox(hide-details, :input-value='props.selected', color='blue darken-2', @click='props.selected = !props.selected')
|
2019-08-11 02:14:53 +00:00
|
|
|
td {{ props.item.id }}
|
2018-10-14 03:22:42 +00:00
|
|
|
td: strong {{ props.item.name }}
|
2018-09-30 03:30:20 +00:00
|
|
|
td {{ props.item.email }}
|
2018-10-14 03:22:42 +00:00
|
|
|
td {{ props.item.providerKey }}
|
|
|
|
td {{ props.item.createdAt | moment('from') }}
|
|
|
|
td
|
2020-05-15 21:05:11 +00:00
|
|
|
span(v-if='props.item.lastLoginAt') {{ props.item.lastLoginAt | moment('from') }}
|
|
|
|
em.grey--text(v-else) Never
|
|
|
|
td.text-right
|
|
|
|
v-icon.mr-3(v-if='props.item.isSystem') mdi-lock-outline
|
|
|
|
status-indicator(positive, pulse, v-if='props.item.isActive')
|
|
|
|
status-indicator(negative, pulse, v-else)
|
2018-09-30 03:30:20 +00:00
|
|
|
template(slot='no-data')
|
2018-10-14 03:22:42 +00:00
|
|
|
.pa-3
|
2019-08-11 02:14:53 +00:00
|
|
|
v-alert.text-left(icon='mdi-alert', outlined, color='grey')
|
|
|
|
em.body-2 No users to display!
|
|
|
|
v-card-chin(v-if='pageCount > 1')
|
2018-12-15 22:15:13 +00:00
|
|
|
v-spacer
|
2019-08-11 02:14:53 +00:00
|
|
|
v-pagination(v-model='pagination', :length='pageCount')
|
2018-12-15 22:15:13 +00:00
|
|
|
v-spacer
|
2018-10-14 03:22:42 +00:00
|
|
|
|
2019-08-11 02:14:53 +00:00
|
|
|
user-create(v-model='isCreateDialogShown', @refresh='refresh(false)')
|
2018-03-03 06:32:58 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-04-29 00:25:19 +00:00
|
|
|
import _ from 'lodash'
|
2020-05-15 21:05:11 +00:00
|
|
|
import gql from 'graphql-tag'
|
2019-04-29 00:25:19 +00:00
|
|
|
|
2020-05-15 21:05:11 +00:00
|
|
|
import { StatusIndicator } from 'vue-status-indicator'
|
2018-10-14 03:22:42 +00:00
|
|
|
import UserCreate from './admin-users-create.vue'
|
|
|
|
|
2018-03-03 06:32:58 +00:00
|
|
|
export default {
|
2018-10-14 03:22:42 +00:00
|
|
|
components: {
|
2020-05-15 21:05:11 +00:00
|
|
|
StatusIndicator,
|
2018-10-14 03:22:42 +00:00
|
|
|
UserCreate
|
|
|
|
},
|
2018-03-03 06:32:58 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
selected: [],
|
2019-08-11 02:14:53 +00:00
|
|
|
pagination: 1,
|
|
|
|
pageCount: 0,
|
2018-10-14 03:22:42 +00:00
|
|
|
users: [],
|
2018-03-03 06:32:58 +00:00
|
|
|
headers: [
|
2018-10-14 03:22:42 +00:00
|
|
|
{ text: 'ID', value: 'id', width: 80, sortable: true },
|
|
|
|
{ text: 'Name', value: 'name', sortable: true },
|
|
|
|
{ text: 'Email', value: 'email', sortable: true },
|
|
|
|
{ text: 'Provider', value: 'provider', sortable: true },
|
|
|
|
{ text: 'Created', value: 'createdAt', sortable: true },
|
2020-05-15 21:05:11 +00:00
|
|
|
{ text: 'Last Login', value: 'lastLoginAt', sortable: true },
|
|
|
|
{ text: '', value: 'actions', sortable: false, width: 80 }
|
2018-03-03 06:32:58 +00:00
|
|
|
],
|
2019-04-29 00:25:19 +00:00
|
|
|
strategies: [],
|
|
|
|
filterStrategy: 'all',
|
2018-10-14 03:22:42 +00:00
|
|
|
search: '',
|
2019-04-29 00:25:19 +00:00
|
|
|
loading: false,
|
2018-10-14 03:22:42 +00:00
|
|
|
isCreateDialogShown: false
|
2018-03-03 06:32:58 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2019-04-29 00:25:19 +00:00
|
|
|
usersFiltered () {
|
|
|
|
const all = this.filterStrategy === 'all' || this.filterStrategy === ''
|
|
|
|
return _.filter(this.users, u => all || u.providerKey === this.filterStrategy)
|
2018-03-03 06:32:58 +00:00
|
|
|
}
|
2018-03-04 02:48:28 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2018-10-14 03:22:42 +00:00
|
|
|
createUser() {
|
|
|
|
this.isCreateDialogShown = true
|
|
|
|
},
|
2019-08-11 02:14:53 +00:00
|
|
|
async refresh(notify = true) {
|
2018-10-14 03:22:42 +00:00
|
|
|
await this.$apollo.queries.users.refetch()
|
2019-08-11 02:14:53 +00:00
|
|
|
if (notify) {
|
|
|
|
this.$store.commit('showNotification', {
|
|
|
|
message: 'Users list has been refreshed.',
|
|
|
|
style: 'success',
|
|
|
|
icon: 'cached'
|
|
|
|
})
|
2018-03-04 02:48:28 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-14 03:22:42 +00:00
|
|
|
},
|
|
|
|
apollo: {
|
|
|
|
users: {
|
2020-05-15 21:05:11 +00:00
|
|
|
query: gql`
|
|
|
|
query {
|
|
|
|
users {
|
|
|
|
list {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
email
|
|
|
|
providerKey
|
|
|
|
isSystem
|
|
|
|
isActive
|
|
|
|
createdAt
|
|
|
|
lastLoginAt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2018-10-14 03:22:42 +00:00
|
|
|
fetchPolicy: 'network-only',
|
|
|
|
update: (data) => data.users.list,
|
|
|
|
watchLoading (isLoading) {
|
2019-04-29 00:25:19 +00:00
|
|
|
this.loading = isLoading
|
2018-10-14 03:22:42 +00:00
|
|
|
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-users-refresh')
|
|
|
|
}
|
2019-04-29 00:25:19 +00:00
|
|
|
},
|
|
|
|
strategies: {
|
2020-05-15 21:05:11 +00:00
|
|
|
query: gql`
|
|
|
|
query {
|
|
|
|
authentication {
|
2020-07-03 23:36:33 +00:00
|
|
|
activeStrategies {
|
2020-05-15 21:05:11 +00:00
|
|
|
key
|
2020-07-03 23:36:33 +00:00
|
|
|
displayName
|
2020-05-15 21:05:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2019-04-29 00:25:19 +00:00
|
|
|
fetchPolicy: 'network-only',
|
|
|
|
update: (data) => {
|
|
|
|
return _.concat({
|
|
|
|
key: 'all',
|
2020-07-03 23:36:33 +00:00
|
|
|
displayName: 'All Providers'
|
|
|
|
}, data.authentication.activeStrategies)
|
2019-04-29 00:25:19 +00:00
|
|
|
},
|
|
|
|
watchLoading (isLoading) {
|
|
|
|
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-users-strategies-refresh')
|
|
|
|
}
|
2018-10-14 03:22:42 +00:00
|
|
|
}
|
2018-03-03 06:32:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang='scss'>
|
|
|
|
|
|
|
|
</style>
|