2020-01-29 13:37:25 -06:00
|
|
|
<template>
|
2021-04-22 08:29:33 -05:00
|
|
|
<div class="lknzcolw">
|
2021-10-08 22:33:08 -05:00
|
|
|
<MkHeader :info="header"/>
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2021-04-22 08:29:33 -05:00
|
|
|
<div class="users">
|
2021-10-02 09:11:21 -05:00
|
|
|
<div class="inputs">
|
|
|
|
<MkSelect v-model="sort" style="flex: 1;">
|
2021-04-22 08:29:33 -05:00
|
|
|
<template #label>{{ $ts.sort }}</template>
|
|
|
|
<option value="-createdAt">{{ $ts.registeredDate }} ({{ $ts.ascendingOrder }})</option>
|
|
|
|
<option value="+createdAt">{{ $ts.registeredDate }} ({{ $ts.descendingOrder }})</option>
|
|
|
|
<option value="-updatedAt">{{ $ts.lastUsed }} ({{ $ts.ascendingOrder }})</option>
|
|
|
|
<option value="+updatedAt">{{ $ts.lastUsed }} ({{ $ts.descendingOrder }})</option>
|
|
|
|
</MkSelect>
|
2021-10-02 09:11:21 -05:00
|
|
|
<MkSelect v-model="state" style="flex: 1;">
|
2021-04-22 08:29:33 -05:00
|
|
|
<template #label>{{ $ts.state }}</template>
|
|
|
|
<option value="all">{{ $ts.all }}</option>
|
|
|
|
<option value="available">{{ $ts.normal }}</option>
|
|
|
|
<option value="admin">{{ $ts.administrator }}</option>
|
|
|
|
<option value="moderator">{{ $ts.moderator }}</option>
|
|
|
|
<option value="silenced">{{ $ts.silence }}</option>
|
|
|
|
<option value="suspended">{{ $ts.suspend }}</option>
|
|
|
|
</MkSelect>
|
2021-10-02 09:11:21 -05:00
|
|
|
<MkSelect v-model="origin" style="flex: 1;">
|
2021-04-22 08:29:33 -05:00
|
|
|
<template #label>{{ $ts.instance }}</template>
|
|
|
|
<option value="combined">{{ $ts.all }}</option>
|
|
|
|
<option value="local">{{ $ts.local }}</option>
|
|
|
|
<option value="remote">{{ $ts.remote }}</option>
|
|
|
|
</MkSelect>
|
|
|
|
</div>
|
2021-10-02 09:11:21 -05:00
|
|
|
<div class="inputs">
|
|
|
|
<MkInput v-model="searchUsername" style="flex: 1;" type="text" spellcheck="false" @update:modelValue="$refs.users.reload()">
|
2021-10-10 01:19:16 -05:00
|
|
|
<template #prefix>@</template>
|
2021-08-06 08:29:19 -05:00
|
|
|
<template #label>{{ $ts.username }}</template>
|
2021-04-22 08:29:33 -05:00
|
|
|
</MkInput>
|
2021-10-02 09:11:21 -05:00
|
|
|
<MkInput v-model="searchHost" style="flex: 1;" type="text" spellcheck="false" @update:modelValue="$refs.users.reload()" :disabled="pagination.params().origin === 'local'">
|
2021-10-10 01:19:16 -05:00
|
|
|
<template #prefix>@</template>
|
2021-08-06 08:29:19 -05:00
|
|
|
<template #label>{{ $ts.host }}</template>
|
2020-10-17 06:12:00 -05:00
|
|
|
</MkInput>
|
2020-01-29 13:37:25 -06:00
|
|
|
</div>
|
|
|
|
|
2021-04-22 08:29:33 -05:00
|
|
|
<MkPagination :pagination="pagination" #default="{items}" class="users" ref="users">
|
|
|
|
<button class="user _panel _button _gap" v-for="user in items" :key="user.id" @click="show(user)">
|
|
|
|
<MkAvatar class="avatar" :user="user" :disable-link="true" :show-indicator="true"/>
|
|
|
|
<div class="body">
|
|
|
|
<header>
|
|
|
|
<MkUserName class="name" :user="user"/>
|
|
|
|
<span class="acct">@{{ acct(user) }}</span>
|
|
|
|
<span class="staff" v-if="user.isAdmin"><i class="fas fa-bookmark"></i></span>
|
|
|
|
<span class="staff" v-if="user.isModerator"><i class="far fa-bookmark"></i></span>
|
|
|
|
<span class="punished" v-if="user.isSilenced"><i class="fas fa-microphone-slash"></i></span>
|
|
|
|
<span class="punished" v-if="user.isSuspended"><i class="fas fa-snowflake"></i></span>
|
|
|
|
</header>
|
|
|
|
<div>
|
|
|
|
<span>{{ $ts.lastUsed }}: <MkTime v-if="user.updatedAt" :time="user.updatedAt" mode="detail"/></span>
|
2020-01-29 13:37:25 -06:00
|
|
|
</div>
|
2021-04-22 08:29:33 -05:00
|
|
|
<div>
|
|
|
|
<span>{{ $ts.registeredDate }}: <MkTime :time="user.createdAt" mode="detail"/></span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
</MkPagination>
|
2020-10-17 06:12:00 -05:00
|
|
|
</div>
|
2020-01-29 13:37:25 -06:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 06:12:00 -05:00
|
|
|
import { defineComponent } from 'vue';
|
2021-03-23 03:30:14 -05:00
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
2021-09-29 10:50:45 -05:00
|
|
|
import MkInput from '@client/components/form/input.vue';
|
|
|
|
import MkSelect from '@client/components/form/select.vue';
|
2021-03-23 03:30:14 -05:00
|
|
|
import MkPagination from '@client/components/ui/pagination.vue';
|
2021-08-05 02:34:18 -05:00
|
|
|
import { acct } from '@client/filters/user';
|
2021-03-23 03:30:14 -05:00
|
|
|
import * as os from '@client/os';
|
2021-04-09 22:54:12 -05:00
|
|
|
import * as symbols from '@client/symbols';
|
2021-04-22 08:29:33 -05:00
|
|
|
import { lookupUser } from '@client/scripts/lookup-user';
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
export default defineComponent({
|
2020-01-29 13:37:25 -06:00
|
|
|
components: {
|
|
|
|
MkButton,
|
|
|
|
MkInput,
|
2020-04-13 09:27:12 -05:00
|
|
|
MkSelect,
|
2020-01-29 13:37:25 -06:00
|
|
|
MkPagination,
|
|
|
|
},
|
|
|
|
|
2021-04-22 08:29:33 -05:00
|
|
|
emits: ['info'],
|
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-09 22:54:12 -05:00
|
|
|
[symbols.PAGE_INFO]: {
|
2020-12-25 19:47:36 -06:00
|
|
|
title: this.$ts.users,
|
2021-04-20 09:22:59 -05:00
|
|
|
icon: 'fas fa-users',
|
2021-10-02 09:11:21 -05:00
|
|
|
bg: 'var(--bg)',
|
2021-10-08 22:33:08 -05:00
|
|
|
},
|
|
|
|
header: {
|
|
|
|
title: this.$ts.users,
|
|
|
|
icon: 'fas fa-users',
|
|
|
|
bg: 'var(--bg)',
|
|
|
|
actions: [{
|
2021-04-20 09:22:59 -05:00
|
|
|
icon: 'fas fa-search',
|
2021-10-08 22:33:08 -05:00
|
|
|
text: this.$ts.search,
|
2020-10-17 06:12:00 -05:00
|
|
|
handler: this.searchUser
|
2021-10-08 22:33:08 -05:00
|
|
|
}, {
|
|
|
|
asFullButton: true,
|
|
|
|
icon: 'fas fa-plus',
|
|
|
|
text: this.$ts.addUser,
|
|
|
|
handler: this.addUser
|
|
|
|
}, {
|
|
|
|
asFullButton: true,
|
|
|
|
icon: 'fas fa-search',
|
|
|
|
text: this.$ts.lookup,
|
|
|
|
handler: this.lookupUser
|
|
|
|
}]
|
2020-10-17 06:12:00 -05:00
|
|
|
},
|
2020-04-13 09:27:12 -05:00
|
|
|
sort: '+createdAt',
|
|
|
|
state: 'all',
|
|
|
|
origin: 'local',
|
|
|
|
searchUsername: '',
|
|
|
|
searchHost: '',
|
2020-01-29 13:37:25 -06:00
|
|
|
pagination: {
|
|
|
|
endpoint: 'admin/show-users',
|
|
|
|
limit: 10,
|
2020-03-25 01:57:35 -05:00
|
|
|
params: () => ({
|
2020-04-13 09:27:12 -05:00
|
|
|
sort: this.sort,
|
|
|
|
state: this.state,
|
|
|
|
origin: this.origin,
|
|
|
|
username: this.searchUsername,
|
|
|
|
hostname: this.searchHost,
|
2020-03-25 01:57:35 -05:00
|
|
|
}),
|
2020-01-29 13:37:25 -06:00
|
|
|
offsetMode: true
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-04-13 09:27:12 -05:00
|
|
|
watch: {
|
|
|
|
sort() {
|
|
|
|
this.$refs.users.reload();
|
|
|
|
},
|
|
|
|
state() {
|
|
|
|
this.$refs.users.reload();
|
|
|
|
},
|
|
|
|
origin() {
|
|
|
|
this.$refs.users.reload();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2021-04-22 08:29:33 -05:00
|
|
|
async mounted() {
|
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
|
|
|
},
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2021-04-22 08:29:33 -05:00
|
|
|
methods: {
|
|
|
|
lookupUser,
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2020-04-13 09:27:12 -05:00
|
|
|
searchUser() {
|
2020-10-17 06:12:00 -05:00
|
|
|
os.selectUser().then(user => {
|
2020-04-13 09:27:12 -05:00
|
|
|
this.show(user);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
async addUser() {
|
2020-10-17 06:12:00 -05:00
|
|
|
const { canceled: canceled1, result: username } = await os.dialog({
|
2020-12-25 19:47:36 -06:00
|
|
|
title: this.$ts.username,
|
2020-01-29 13:37:25 -06:00
|
|
|
input: true
|
|
|
|
});
|
|
|
|
if (canceled1) return;
|
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
const { canceled: canceled2, result: password } = await os.dialog({
|
2020-12-25 19:47:36 -06:00
|
|
|
title: this.$ts.password,
|
2020-01-29 13:37:25 -06:00
|
|
|
input: { type: 'password' }
|
|
|
|
});
|
|
|
|
if (canceled2) return;
|
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
os.apiWithDialog('admin/accounts/create', {
|
2020-01-29 13:37:25 -06:00
|
|
|
username: username,
|
|
|
|
password: password,
|
|
|
|
}).then(res => {
|
|
|
|
this.$refs.users.reload();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-11-03 00:22:55 -06:00
|
|
|
show(user) {
|
2021-04-22 22:00:07 -05:00
|
|
|
os.pageWindow(`/user-info/${user.id}`);
|
2020-10-17 06:12:00 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
acct
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-22 08:29:33 -05:00
|
|
|
.lknzcolw {
|
2020-01-29 13:37:25 -06:00
|
|
|
> .users {
|
2021-04-22 08:29:33 -05:00
|
|
|
margin: var(--margin);
|
2021-10-02 09:11:21 -05:00
|
|
|
|
|
|
|
> .inputs {
|
|
|
|
display: flex;
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
|
|
|
> * {
|
|
|
|
margin-right: 16px;
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
margin-right: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-22 08:29:33 -05:00
|
|
|
|
|
|
|
> .users {
|
|
|
|
margin-top: var(--margin);
|
|
|
|
|
|
|
|
> .user {
|
|
|
|
display: flex;
|
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
|
|
|
text-align: left;
|
|
|
|
align-items: center;
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
2020-10-17 06:12:00 -05:00
|
|
|
|
2021-04-22 08:29:33 -05:00
|
|
|
> .avatar {
|
|
|
|
width: 60px;
|
|
|
|
height: 60px;
|
|
|
|
}
|
2020-10-17 06:12:00 -05:00
|
|
|
|
2021-04-22 08:29:33 -05:00
|
|
|
> .body {
|
|
|
|
margin-left: 0.3em;
|
|
|
|
padding: 0 8px;
|
|
|
|
flex: 1;
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2021-04-22 08:29:33 -05:00
|
|
|
@media (max-width: 500px) {
|
|
|
|
font-size: 14px;
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
|
2021-04-22 08:29:33 -05:00
|
|
|
> header {
|
|
|
|
> .name {
|
|
|
|
font-weight: bold;
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
|
2021-04-22 08:29:33 -05:00
|
|
|
> .acct {
|
|
|
|
margin-left: 8px;
|
|
|
|
opacity: 0.7;
|
|
|
|
}
|
2020-04-13 09:27:12 -05:00
|
|
|
|
2021-04-22 08:29:33 -05:00
|
|
|
> .staff {
|
|
|
|
margin-left: 0.5em;
|
|
|
|
color: var(--badge);
|
|
|
|
}
|
2020-04-13 09:27:12 -05:00
|
|
|
|
2021-04-22 08:29:33 -05:00
|
|
|
> .punished {
|
|
|
|
margin-left: 0.5em;
|
|
|
|
color: #4dabf7;
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|