mirror of
https://akkoma.dev/AkkomaGang/akkoma-fe
synced 2025-04-30 11:09:30 +08:00
Add user list, querying and pagination to moderation
This commit is contained in:
parent
db7395b502
commit
b025b6f10f
5 changed files with 122 additions and 45 deletions
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
.panel-body {
|
.panel-body {
|
||||||
height: inherit;
|
height: inherit;
|
||||||
|
overflow-y: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,9 @@
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<ModModalContent v-if="modalOpenedOnce" />
|
<ModModalContent v-if="modalOpenedOnce" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="panel-footer settings-footer">
|
||||||
|
<span id="navigation" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
import BasicUserCard from 'src/components/basic_user_card/basic_user_card.vue'
|
||||||
|
import ModerationTools from 'src/components/moderation_tools/moderation_tools.vue'
|
||||||
import Popover from 'src/components/popover/popover.vue'
|
import Popover from 'src/components/popover/popover.vue'
|
||||||
|
|
||||||
import { forEach } from 'lodash'
|
import { forEach, every, findKey } from 'lodash'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
@ -16,53 +18,91 @@ library.add(
|
||||||
const UsersTab = {
|
const UsersTab = {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
searchTerm: null,
|
||||||
|
page: 1,
|
||||||
accountType: {
|
accountType: {
|
||||||
local: true,
|
local: true,
|
||||||
external: false,
|
external: false
|
||||||
all: false
|
|
||||||
},
|
},
|
||||||
status: {
|
status: {
|
||||||
active: true,
|
active: true,
|
||||||
deactivated: false,
|
deactivated: false,
|
||||||
pending: false,
|
need_approval: false,
|
||||||
unconfirmed: false,
|
unconfirmed: false
|
||||||
all: false
|
|
||||||
},
|
},
|
||||||
actorType: {
|
actorType: {
|
||||||
person: true,
|
Person: false,
|
||||||
bot: true,
|
Service: false,
|
||||||
application: true,
|
Application: false
|
||||||
all: true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
BasicUserCard,
|
||||||
|
ModerationTools,
|
||||||
Popover
|
Popover
|
||||||
},
|
},
|
||||||
|
created () {
|
||||||
|
this.query()
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
users () { return this.$store.state.users.adminUsers },
|
||||||
|
isActive () {
|
||||||
|
const tabSwitcher = this.$parent
|
||||||
|
console.log(this.users)
|
||||||
|
return tabSwitcher ? tabSwitcher.isActive('users') : false
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setAccountType (type) {
|
all (filter) { return every(filter, _ => !_) },
|
||||||
if (type === 'all') {
|
setAccountType (type = false) {
|
||||||
forEach(this.accountType, (k, v) => { this.accountType[v] = true })
|
forEach(this.accountType, (k, v) => { this.accountType[v] = false })
|
||||||
} else {
|
if (type) {
|
||||||
forEach(this.accountType, (k, v) => { this.accountType[v] = false })
|
|
||||||
this.accountType[type] = true
|
this.accountType[type] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.query()
|
||||||
},
|
},
|
||||||
setStatus (status) {
|
setStatus (status = false) {
|
||||||
if (status === 'all') {
|
forEach(this.status, (k, v) => { this.status[v] = false })
|
||||||
forEach(this.status, (k, v) => { this.status[v] = true })
|
if (status) {
|
||||||
} else {
|
|
||||||
forEach(this.status, (k, v) => { this.status[v] = false })
|
|
||||||
this.status[status] = true
|
this.status[status] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.query()
|
||||||
},
|
},
|
||||||
setActorType (type) {
|
setActorType (type = false) {
|
||||||
if (type === 'all') {
|
forEach(this.actorType, (k, v) => { this.actorType[v] = false })
|
||||||
forEach(this.actorType, (k, v) => { this.actorType[v] = true })
|
if (type) {
|
||||||
} else {
|
|
||||||
forEach(this.actorType, (k, v) => { this.actorType[v] = false })
|
|
||||||
this.actorType[type] = true
|
this.actorType[type] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.query()
|
||||||
|
},
|
||||||
|
prevPage () {
|
||||||
|
this.page--
|
||||||
|
this.query()
|
||||||
|
},
|
||||||
|
nextPage () {
|
||||||
|
this.page++
|
||||||
|
this.query()
|
||||||
|
},
|
||||||
|
query () {
|
||||||
|
const params = {}
|
||||||
|
params.actorTypes = [findKey(this.actorType, _ => _)].filter(Boolean)
|
||||||
|
params.filters = [
|
||||||
|
findKey(this.status, _ => _),
|
||||||
|
findKey(this.accountType, _ => _)
|
||||||
|
].filter(Boolean)
|
||||||
|
|
||||||
|
if (this.searchTerm) {
|
||||||
|
params.name = this.searchTerm
|
||||||
|
}
|
||||||
|
if (this.page > 1) {
|
||||||
|
params.page = this.page
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$store.dispatch('fetchUsers', params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
v-model="searchTerm"
|
v-model="searchTerm"
|
||||||
class="search-input"
|
class="search-input"
|
||||||
:placeholder="$t('nav.search')"
|
:placeholder="$t('nav.search')"
|
||||||
@keyup.enter="newQuery(searchTerm)"
|
@keyup.enter="query()"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Popover
|
<Popover
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="menu-checkbox -radio"
|
class="menu-checkbox -radio"
|
||||||
:class="{ 'menu-checkbox-checked': !accountType.all && accountType.local }"
|
:class="{ 'menu-checkbox-checked': accountType.local }"
|
||||||
/>{{ $t('moderation.users.filter.local') }}
|
/>{{ $t('moderation.users.filter.local') }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
|
@ -46,16 +46,16 @@
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="menu-checkbox -radio"
|
class="menu-checkbox -radio"
|
||||||
:class="{ 'menu-checkbox-checked': !accountType.all && accountType.external }"
|
:class="{ 'menu-checkbox-checked': accountType.external }"
|
||||||
/>{{ $t('moderation.users.filter.external') }}
|
/>{{ $t('moderation.users.filter.external') }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="button-default dropdown-item"
|
class="button-default dropdown-item"
|
||||||
@click="setAccountType('all')"
|
@click="setAccountType()"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="menu-checkbox -radio"
|
class="menu-checkbox -radio"
|
||||||
:class="{ 'menu-checkbox-checked': accountType.all }"
|
:class="{ 'menu-checkbox-checked': all(accountType) }"
|
||||||
/>{{ $t('moderation.users.filter.all') }}
|
/>{{ $t('moderation.users.filter.all') }}
|
||||||
</button>
|
</button>
|
||||||
<div
|
<div
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="menu-checkbox -radio"
|
class="menu-checkbox -radio"
|
||||||
:class="{ 'menu-checkbox-checked': !status.all && status.active }"
|
:class="{ 'menu-checkbox-checked': status.active }"
|
||||||
/>{{ $t('moderation.users.filter.active') }}
|
/>{{ $t('moderation.users.filter.active') }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
|
@ -79,16 +79,16 @@
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="menu-checkbox -radio"
|
class="menu-checkbox -radio"
|
||||||
:class="{ 'menu-checkbox-checked': !status.all && status.deactivated }"
|
:class="{ 'menu-checkbox-checked': status.deactivated }"
|
||||||
/>{{ $t('moderation.users.filter.deactivated') }}
|
/>{{ $t('moderation.users.filter.deactivated') }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="button-default dropdown-item"
|
class="button-default dropdown-item"
|
||||||
@click="setStatus('pending')"
|
@click="setStatus('need_approval')"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="menu-checkbox -radio"
|
class="menu-checkbox -radio"
|
||||||
:class="{ 'menu-checkbox-checked': !status.all && status.pending }"
|
:class="{ 'menu-checkbox-checked': status.need_approval }"
|
||||||
/>{{ $t('moderation.users.filter.pending') }}
|
/>{{ $t('moderation.users.filter.pending') }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
|
@ -97,16 +97,16 @@
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="menu-checkbox -radio"
|
class="menu-checkbox -radio"
|
||||||
:class="{ 'menu-checkbox-checked': !status.all && status.unconfirmed }"
|
:class="{ 'menu-checkbox-checked': status.unconfirmed }"
|
||||||
/>{{ $t('moderation.users.filter.unconfirmed') }}
|
/>{{ $t('moderation.users.filter.unconfirmed') }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="button-default dropdown-item"
|
class="button-default dropdown-item"
|
||||||
@click="setStatus('all')"
|
@click="setStatus()"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="menu-checkbox -radio"
|
class="menu-checkbox -radio"
|
||||||
:class="{ 'menu-checkbox-checked': status.all }"
|
:class="{ 'menu-checkbox-checked': all(status) }"
|
||||||
/>{{ $t('moderation.users.filter.all') }}
|
/>{{ $t('moderation.users.filter.all') }}
|
||||||
</button>
|
</button>
|
||||||
<div
|
<div
|
||||||
|
@ -117,38 +117,38 @@
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<button
|
<button
|
||||||
class="button-default dropdown-item"
|
class="button-default dropdown-item"
|
||||||
@click="setActorType('person')"
|
@click="setActorType('Person')"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="menu-checkbox -radio"
|
class="menu-checkbox -radio"
|
||||||
:class="{ 'menu-checkbox-checked': !actorType.all && actorType.person }"
|
:class="{ 'menu-checkbox-checked': actorType.Person }"
|
||||||
/>{{ $t('moderation.users.filter.person') }}
|
/>{{ $t('moderation.users.filter.person') }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="button-default dropdown-item"
|
class="button-default dropdown-item"
|
||||||
@click="setActorType('bot')"
|
@click="setActorType('Service')"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="menu-checkbox -radio"
|
class="menu-checkbox -radio"
|
||||||
:class="{ 'menu-checkbox-checked': !actorType.all && actorType.bot }"
|
:class="{ 'menu-checkbox-checked': actorType.Service }"
|
||||||
/>{{ $t('moderation.users.filter.bot') }}
|
/>{{ $t('moderation.users.filter.bot') }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="button-default dropdown-item"
|
class="button-default dropdown-item"
|
||||||
@click="setActorType('application')"
|
@click="setActorType('Application')"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="menu-checkbox -radio"
|
class="menu-checkbox -radio"
|
||||||
:class="{ 'menu-checkbox-checked': !actorType.all && actorType.application }"
|
:class="{ 'menu-checkbox-checked': actorType.Application }"
|
||||||
/>{{ $t('moderation.users.filter.application') }}
|
/>{{ $t('moderation.users.filter.application') }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="button-default dropdown-item"
|
class="button-default dropdown-item"
|
||||||
@click="setActorType('all')"
|
@click="setActorType()"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="menu-checkbox -radio"
|
class="menu-checkbox -radio"
|
||||||
:class="{ 'menu-checkbox-checked': actorType.all }"
|
:class="{ 'menu-checkbox-checked': all(actorType) }"
|
||||||
/>{{ $t('moderation.users.filter.all') }}
|
/>{{ $t('moderation.users.filter.all') }}
|
||||||
</button>
|
</button>
|
||||||
<div
|
<div
|
||||||
|
@ -161,8 +161,39 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="users">
|
<div class="users">
|
||||||
|
<div
|
||||||
|
v-for="user in users"
|
||||||
|
:key="user.id"
|
||||||
|
class="user"
|
||||||
|
>
|
||||||
|
<BasicUserCard :user="user">
|
||||||
|
<ModerationTools :user="user" />
|
||||||
|
</BasicUserCard>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<teleport
|
||||||
|
v-if="isActive"
|
||||||
|
to="#navigation"
|
||||||
|
>
|
||||||
|
<div class="apply-container">
|
||||||
|
<button
|
||||||
|
class="btn button-default submit"
|
||||||
|
:disabled="page == 1"
|
||||||
|
@click="prevPage"
|
||||||
|
>
|
||||||
|
{{ $t('moderation.previous') }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="btn button-default"
|
||||||
|
:disabled="users.length < 50"
|
||||||
|
@click="nextPage"
|
||||||
|
>
|
||||||
|
{{ $t('moderation.next') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</teleport>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -294,6 +294,8 @@
|
||||||
"tags": "Set post restrictions"
|
"tags": "Set post restrictions"
|
||||||
},
|
},
|
||||||
"statuses": "Posts",
|
"statuses": "Posts",
|
||||||
|
"next": "Next page",
|
||||||
|
"previous": "Previous page",
|
||||||
"users": {
|
"users": {
|
||||||
"users": "Users",
|
"users": "Users",
|
||||||
"filter": {
|
"filter": {
|
||||||
|
|
Loading…
Reference in a new issue