mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Implement paginating user view for admins
This commit is contained in:
parent
e6e9b1b7d7
commit
448f350c2e
@ -707,6 +707,13 @@ import Factory from './factories'
|
|||||||
to: 'o3',
|
to: 'o3',
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
[...Array(30).keys()].map(i => {
|
||||||
|
return f.create('User')
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
/* eslint-disable-next-line no-console */
|
/* eslint-disable-next-line no-console */
|
||||||
console.log('Seeded Data...')
|
console.log('Seeded Data...')
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
|
|||||||
@ -188,7 +188,14 @@
|
|||||||
"name": "Organisationen"
|
"name": "Organisationen"
|
||||||
},
|
},
|
||||||
"users": {
|
"users": {
|
||||||
"name": "Benutzer"
|
"name": "Benutzer",
|
||||||
|
"table": {
|
||||||
|
"columns": {
|
||||||
|
"name": "Name",
|
||||||
|
"slug": "Username",
|
||||||
|
"role": "Rolle"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"pages": {
|
"pages": {
|
||||||
"name": "Seiten"
|
"name": "Seiten"
|
||||||
|
|||||||
@ -189,7 +189,14 @@
|
|||||||
"name": "Organizations"
|
"name": "Organizations"
|
||||||
},
|
},
|
||||||
"users": {
|
"users": {
|
||||||
"name": "Users"
|
"name": "Users",
|
||||||
|
"table": {
|
||||||
|
"columns": {
|
||||||
|
"name": "Name",
|
||||||
|
"slug": "Username",
|
||||||
|
"role": "Role"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"pages": {
|
"pages": {
|
||||||
"name": "Pages"
|
"name": "Pages"
|
||||||
|
|||||||
@ -24,11 +24,10 @@ export default {
|
|||||||
name: this.$t('admin.dashboard.name'),
|
name: this.$t('admin.dashboard.name'),
|
||||||
path: `/admin`,
|
path: `/admin`,
|
||||||
},
|
},
|
||||||
// TODO implement
|
{
|
||||||
/* {
|
|
||||||
name: this.$t('admin.users.name'),
|
name: this.$t('admin.users.name'),
|
||||||
path: `/admin/users`
|
path: `/admin/users`,
|
||||||
}, */
|
},
|
||||||
// TODO implement
|
// TODO implement
|
||||||
/* {
|
/* {
|
||||||
name: this.$t('admin.organizations.name'),
|
name: this.$t('admin.organizations.name'),
|
||||||
|
|||||||
@ -1,15 +1,93 @@
|
|||||||
<template>
|
<template>
|
||||||
<ds-card :header="$t('admin.users.name')">
|
<ds-card :header="$t('admin.users.name')">
|
||||||
<hc-empty icon="tasks" message="Coming Soon…" />
|
<ds-table v-if="User && User.length" :data="User" :fields="fields" condensed>
|
||||||
|
<template slot="name" slot-scope="scope">
|
||||||
|
<nuxt-link
|
||||||
|
:to="{
|
||||||
|
name: 'profile-id-slug',
|
||||||
|
params: { id: scope.row.id, slug: scope.row.slug },
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<b>{{ scope.row.name | truncate(50) }}</b>
|
||||||
|
</nuxt-link>
|
||||||
|
</template>
|
||||||
|
</ds-table>
|
||||||
|
<ds-flex direction="row-reverse">
|
||||||
|
<ds-flex-item width="50px">
|
||||||
|
<ds-button @click="next" :disabled="!hasNext" icon="arrow-right" primary />
|
||||||
|
</ds-flex-item>
|
||||||
|
<ds-flex-item width="50px">
|
||||||
|
<ds-button @click="back" :disabled="!hasPrevious" icon="arrow-left" primary />
|
||||||
|
</ds-flex-item>
|
||||||
|
</ds-flex>
|
||||||
</ds-card>
|
</ds-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import HcEmpty from '~/components/Empty.vue'
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
data() {
|
||||||
HcEmpty,
|
const pageSize = 15
|
||||||
|
return {
|
||||||
|
offset: 0,
|
||||||
|
pageSize,
|
||||||
|
first: pageSize,
|
||||||
|
User: [],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
hasNext() {
|
||||||
|
const { countUsers } = this.statistics
|
||||||
|
return this.offset < countUsers - this.pageSize
|
||||||
|
},
|
||||||
|
hasPrevious() {
|
||||||
|
return this.offset > 0
|
||||||
|
},
|
||||||
|
fields() {
|
||||||
|
return {
|
||||||
|
id: 'ID',
|
||||||
|
name: this.$t('admin.users.table.columns.name'),
|
||||||
|
slug: this.$t('admin.users.table.columns.slug'),
|
||||||
|
role: this.$t('admin.users.table.columns.role'),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
apollo: {
|
||||||
|
statistics: {
|
||||||
|
query() {
|
||||||
|
return gql('query { statistics { countUsers } }')
|
||||||
|
},
|
||||||
|
},
|
||||||
|
User: {
|
||||||
|
query() {
|
||||||
|
return gql(`
|
||||||
|
query($filter: _UserFilter, $first: Int, $offset: Int) {
|
||||||
|
User(filter: $filter, first: $first, offset: $offset, orderBy: createdAt_desc) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
slug
|
||||||
|
role
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
},
|
||||||
|
variables() {
|
||||||
|
const { offset, first } = this
|
||||||
|
return { first, offset }
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
back() {
|
||||||
|
this.offset -= this.pageSize
|
||||||
|
this.offset = Math.max(this.offset, 0)
|
||||||
|
},
|
||||||
|
next() {
|
||||||
|
this.offset += this.pageSize
|
||||||
|
const { countUsers } = this.statistics
|
||||||
|
this.offset = Math.min(this.offset, countUsers - this.pageSize)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user