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
|
|
|
|
.subheading.grey--text.animated.fadeInLeft.wait-p4s Manage users
|
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-04-07 16:37:33 +00:00
|
|
|
v-btn.animated.fadeInDown(color='primary', large, depressed, @click='createUser')
|
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-07 16:37:33 +00:00
|
|
|
v-card.mt-3.animated.fadeInUp
|
2018-09-30 03:30:20 +00:00
|
|
|
v-data-table(
|
|
|
|
v-model='selected'
|
2018-10-14 03:22:42 +00:00
|
|
|
:items='users',
|
2018-09-30 03:30:20 +00:00
|
|
|
:headers='headers',
|
|
|
|
:search='search',
|
|
|
|
:pagination.sync='pagination',
|
|
|
|
:rows-per-page-items='[15]'
|
|
|
|
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-01-01 22:03:30 +00:00
|
|
|
v-card-chin(v-if='this.pages > 0')
|
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>
|
2018-10-14 03:22:42 +00:00
|
|
|
import usersQuery from 'gql/admin/users/users-query-list.gql'
|
|
|
|
|
|
|
|
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
|
|
|
],
|
2018-10-14 03:22:42 +00:00
|
|
|
search: '',
|
|
|
|
isCreateDialogShown: false
|
2018-03-03 06:32:58 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
pages () {
|
|
|
|
if (this.pagination.rowsPerPage == null || this.pagination.totalItems == null) {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
return Math.ceil(this.pagination.totalItems / this.pagination.rowsPerPage)
|
|
|
|
}
|
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) {
|
|
|
|
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-users-refresh')
|
|
|
|
}
|
|
|
|
}
|
2018-03-03 06:32:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang='scss'>
|
|
|
|
|
|
|
|
</style>
|