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
|
2019-04-07 16:37:33 +00:00
|
|
|
img.animated.fadeInUp(src='/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-06-22 03:55:56 +00:00
|
|
|
.subheading.grey--text.animated.fadeInLeft.wait-p2s Manage users #[v-chip(label, color='primary', small).white--text coming soon]
|
2018-09-30 03:30:20 +00:00
|
|
|
v-spacer
|
2019-04-07 16:37:33 +00:00
|
|
|
v-btn.animated.fadeInDown.wait-p2s(outline, color='grey', large, @click='refresh')
|
2018-09-30 03:30:20 +00:00
|
|
|
v-icon refresh
|
2019-06-22 03:55:56 +00:00
|
|
|
v-btn.animated.fadeInDown(color='primary', large, depressed, @click='createUser', disabled)
|
2018-09-30 03:30:20 +00:00
|
|
|
v-icon(left) add
|
2019-01-01 22:03:30 +00:00
|
|
|
span New User
|
2019-04-29 00:25:19 +00:00
|
|
|
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
|
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',
|
|
|
|
:pagination.sync='pagination',
|
|
|
|
:rows-per-page-items='[15]'
|
2019-04-29 00:25:19 +00:00
|
|
|
:loading='loading'
|
2018-09-30 03:30:20 +00:00
|
|
|
hide-actions,
|
|
|
|
disable-initial-sort
|
|
|
|
)
|
|
|
|
template(slot='headers', slot-scope='props')
|
|
|
|
tr
|
|
|
|
th.text-xs-left(
|
|
|
|
v-for='header in props.headers'
|
|
|
|
:key='header.text'
|
|
|
|
:width='header.width'
|
2018-10-14 03:22:42 +00:00
|
|
|
:class='[`column`, header.sortable ? `sortable` : ``, pagination.descending ? `desc` : `asc`, header.value === pagination.sortBy ? `active` : ``]'
|
2018-09-30 03:30:20 +00:00
|
|
|
@click='changeSort(header.value)'
|
|
|
|
)
|
|
|
|
| {{ header.text }}
|
2018-10-14 03:22:42 +00:00
|
|
|
v-icon(small, v-if='header.sortable') arrow_upward
|
2018-09-30 03:30:20 +00:00
|
|
|
template(slot='items', 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')
|
|
|
|
td.text-xs-right {{ 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
|
2018-12-15 22:15:13 +00:00
|
|
|
v-tooltip(left, v-if='props.item.isSystem')
|
|
|
|
v-icon(slot='activator') lock_outline
|
|
|
|
span System User
|
2018-09-30 03:30:20 +00:00
|
|
|
template(slot='no-data')
|
2018-10-14 03:22:42 +00:00
|
|
|
.pa-3
|
|
|
|
v-alert(icon='warning', :value='true', outline) No users to display!
|
2019-04-29 00:25:19 +00:00
|
|
|
v-card-chin(v-if='this.pages > 1')
|
2018-12-15 22:15:13 +00:00
|
|
|
v-spacer
|
2018-09-30 03:30:20 +00:00
|
|
|
v-pagination(v-model='pagination.page', :length='pages')
|
2018-12-15 22:15:13 +00:00
|
|
|
v-spacer
|
2018-10-14 03:22:42 +00:00
|
|
|
|
|
|
|
user-create(v-model='isCreateDialogShown')
|
2018-03-03 06:32:58 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-04-29 00:25:19 +00:00
|
|
|
import _ from 'lodash'
|
|
|
|
|
2018-10-14 03:22:42 +00:00
|
|
|
import usersQuery from 'gql/admin/users/users-query-list.gql'
|
2019-04-29 00:25:19 +00:00
|
|
|
import providersQuery from 'gql/admin/users/users-query-strategies.gql'
|
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: {
|
|
|
|
UserCreate
|
|
|
|
},
|
2018-03-03 06:32:58 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
selected: [],
|
|
|
|
pagination: {},
|
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 },
|
2018-03-04 02:48:28 +00:00
|
|
|
{ text: '', value: 'actions', sortable: false, width: 50 }
|
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
|
|
|
pages () {
|
2019-04-29 00:25:19 +00:00
|
|
|
if (this.pagination.rowsPerPage == null || this.usersFiltered.length < 1) {
|
2018-03-03 06:32:58 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2019-04-29 00:25:19 +00:00
|
|
|
return Math.ceil(this.usersFiltered.length / this.pagination.rowsPerPage)
|
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
|
|
|
|
},
|
|
|
|
async refresh() {
|
|
|
|
await this.$apollo.queries.users.refetch()
|
|
|
|
this.$store.commit('showNotification', {
|
|
|
|
message: 'Users list has been refreshed.',
|
|
|
|
style: 'success',
|
|
|
|
icon: 'cached'
|
|
|
|
})
|
|
|
|
},
|
2018-03-04 02:48:28 +00:00
|
|
|
changeSort (column) {
|
|
|
|
if (this.pagination.sortBy === column) {
|
|
|
|
this.pagination.descending = !this.pagination.descending
|
|
|
|
} else {
|
|
|
|
this.pagination.sortBy = column
|
|
|
|
this.pagination.descending = false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
toggleAll () {
|
|
|
|
if (this.selected.length) {
|
|
|
|
this.selected = []
|
|
|
|
} else {
|
|
|
|
this.selected = this.items.slice()
|
|
|
|
}
|
|
|
|
}
|
2018-10-14 03:22:42 +00:00
|
|
|
},
|
|
|
|
apollo: {
|
|
|
|
users: {
|
|
|
|
query: usersQuery,
|
|
|
|
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: {
|
|
|
|
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')
|
|
|
|
}
|
2018-10-14 03:22:42 +00:00
|
|
|
}
|
2018-03-03 06:32:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang='scss'>
|
|
|
|
|
|
|
|
</style>
|