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
|
|
|
|
v-icon(size='80', color='grey lighten-2') perm_identity
|
|
|
|
.admin-header-title
|
|
|
|
.headline.blue--text.text--darken-2 Users
|
|
|
|
.subheading.grey--text Manage users
|
|
|
|
v-spacer
|
2018-10-14 03:22:42 +00:00
|
|
|
v-btn(outline, color='grey', large, @click='refresh')
|
2018-09-30 03:30:20 +00:00
|
|
|
v-icon refresh
|
2018-10-14 03:22:42 +00:00
|
|
|
v-btn(color='primary', large, depressed, @click='authorizeUser')
|
2018-09-30 03:30:20 +00:00
|
|
|
v-icon(left) lock_outline
|
2018-10-14 03:22:42 +00:00
|
|
|
span Authorize Social User
|
|
|
|
v-btn(color='primary', large, depressed, @click='createUser')
|
2018-09-30 03:30:20 +00:00
|
|
|
v-icon(left) add
|
2018-10-14 03:22:42 +00:00
|
|
|
span New Local User
|
2018-09-30 03:30:20 +00:00
|
|
|
v-card.mt-3
|
|
|
|
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
|
|
|
|
v-menu(bottom, right, min-width='200')
|
|
|
|
v-btn(icon, slot='activator'): v-icon.grey--text.text--darken-1 more_horiz
|
|
|
|
v-list
|
|
|
|
v-list-tile(@click='')
|
|
|
|
v-list-tile-action
|
|
|
|
v-icon(color='primary') edit
|
|
|
|
v-list-tile-content
|
|
|
|
v-list-tile-title Edit
|
|
|
|
v-list-tile(@click='')
|
|
|
|
v-list-tile-action
|
|
|
|
v-icon(color='red') block
|
|
|
|
v-list-tile-content
|
|
|
|
v-list-tile-title Block
|
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!
|
2018-09-30 03:30:20 +00:00
|
|
|
.text-xs-center.py-2
|
|
|
|
v-pagination(v-model='pagination.page', :length='pages')
|
2018-10-14 03:22:42 +00:00
|
|
|
|
|
|
|
user-authorize(v-model='isAuthorizeDialogShown')
|
|
|
|
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 UserAuthorize from './admin-users-authorize.vue'
|
|
|
|
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: {
|
|
|
|
UserAuthorize,
|
|
|
|
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: '',
|
|
|
|
isAuthorizeDialogShown: false,
|
|
|
|
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
|
|
|
authorizeUser() {
|
|
|
|
this.isAuthorizeDialogShown = true
|
|
|
|
},
|
|
|
|
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>
|