2020-01-29 11:37:25 -08:00
|
|
|
<template>
|
|
|
|
<div class="mk-instance-users">
|
2020-10-17 04:12:00 -07:00
|
|
|
<div class="_section">
|
|
|
|
<div class="_content">
|
2020-12-25 17:47:36 -08:00
|
|
|
<MkButton inline primary @click="addUser()"><Fa :icon="faPlus"/> {{ $ts.addUser }}</MkButton>
|
2020-10-17 04:12:00 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
<div class="_section lookup">
|
2020-12-25 17:47:36 -08:00
|
|
|
<div class="_title"><Fa :icon="faSearch"/> {{ $ts.lookup }}</div>
|
2020-01-29 11:37:25 -08:00
|
|
|
<div class="_content">
|
2020-10-17 04:12:00 -07:00
|
|
|
<MkInput class="target" v-model:value="target" type="text" @enter="showUser()">
|
2020-12-25 17:47:36 -08:00
|
|
|
<span>{{ $ts.usernameOrUserId }}</span>
|
2020-10-17 04:12:00 -07:00
|
|
|
</MkInput>
|
2020-12-25 17:47:36 -08:00
|
|
|
<MkButton @click="showUser()" primary><Fa :icon="faSearch"/> {{ $ts.lookup }}</MkButton>
|
2020-01-29 11:37:25 -08:00
|
|
|
</div>
|
2020-10-17 04:12:00 -07:00
|
|
|
</div>
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
<div class="_section users">
|
2020-12-25 17:47:36 -08:00
|
|
|
<div class="_title"><Fa :icon="faUsers"/> {{ $ts.users }}</div>
|
2020-04-13 07:27:12 -07:00
|
|
|
<div class="_content">
|
|
|
|
<div class="inputs" style="display: flex;">
|
2020-10-17 04:12:00 -07:00
|
|
|
<MkSelect v-model:value="sort" style="margin: 0; flex: 1;">
|
2020-12-25 17:47:36 -08: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>
|
2020-10-17 04:12:00 -07:00
|
|
|
</MkSelect>
|
|
|
|
<MkSelect v-model:value="state" style="margin: 0; flex: 1;">
|
2020-12-25 17:47:36 -08: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>
|
2020-10-17 04:12:00 -07:00
|
|
|
</MkSelect>
|
|
|
|
<MkSelect v-model:value="origin" style="margin: 0; flex: 1;">
|
2020-12-25 17:47:36 -08:00
|
|
|
<template #label>{{ $ts.instance }}</template>
|
|
|
|
<option value="combined">{{ $ts.all }}</option>
|
|
|
|
<option value="local">{{ $ts.local }}</option>
|
|
|
|
<option value="remote">{{ $ts.remote }}</option>
|
2020-10-17 04:12:00 -07:00
|
|
|
</MkSelect>
|
2020-04-13 07:27:12 -07:00
|
|
|
</div>
|
|
|
|
<div class="inputs" style="display: flex; padding-top: 1.2em;">
|
2020-10-17 04:12:00 -07:00
|
|
|
<MkInput v-model:value="searchUsername" style="margin: 0; flex: 1;" type="text" spellcheck="false" @update:value="$refs.users.reload()">
|
2020-12-25 17:47:36 -08:00
|
|
|
<span>{{ $ts.username }}</span>
|
2020-10-17 04:12:00 -07:00
|
|
|
</MkInput>
|
|
|
|
<MkInput v-model:value="searchHost" style="margin: 0; flex: 1;" type="text" spellcheck="false" @update:value="$refs.users.reload()" :disabled="pagination.params().origin === 'local'">
|
2020-12-25 17:47:36 -08:00
|
|
|
<span>{{ $ts.host }}</span>
|
2020-10-17 04:12:00 -07:00
|
|
|
</MkInput>
|
2020-04-13 07:27:12 -07:00
|
|
|
</div>
|
2020-10-17 04:12:00 -07:00
|
|
|
|
2020-11-07 18:25:28 -08:00
|
|
|
<MkPagination :pagination="pagination" #default="{items}" class="users" ref="users">
|
2021-04-10 02:17:42 -07:00
|
|
|
<button class="user _panel _button _gap" v-for="user in items" :key="user.id" @click="show(user)">
|
2020-10-17 04:12:00 -07:00
|
|
|
<MkAvatar class="avatar" :user="user" :disable-link="true"/>
|
2020-01-29 11:37:25 -08:00
|
|
|
<div class="body">
|
2020-04-13 07:27:12 -07:00
|
|
|
<header>
|
2020-10-17 04:12:00 -07:00
|
|
|
<MkUserName class="name" :user="user"/>
|
|
|
|
<span class="acct">@{{ acct(user) }}</span>
|
|
|
|
<span class="staff" v-if="user.isAdmin"><Fa :icon="faBookmark"/></span>
|
|
|
|
<span class="staff" v-if="user.isModerator"><Fa :icon="farBookmark"/></span>
|
|
|
|
<span class="punished" v-if="user.isSilenced"><Fa :icon="faMicrophoneSlash"/></span>
|
|
|
|
<span class="punished" v-if="user.isSuspended"><Fa :icon="faSnowflake"/></span>
|
2020-04-13 07:27:12 -07:00
|
|
|
</header>
|
|
|
|
<div>
|
2020-12-25 17:47:36 -08:00
|
|
|
<span>{{ $ts.lastUsed }}: <MkTime v-if="user.updatedAt" :time="user.updatedAt" mode="detail"/></span>
|
2020-04-13 07:27:12 -07:00
|
|
|
</div>
|
|
|
|
<div>
|
2020-12-25 17:47:36 -08:00
|
|
|
<span>{{ $ts.registeredDate }}: <MkTime :time="user.createdAt" mode="detail"/></span>
|
2020-04-13 07:27:12 -07:00
|
|
|
</div>
|
2020-01-29 11:37:25 -08:00
|
|
|
</div>
|
|
|
|
</button>
|
2020-10-17 04:12:00 -07:00
|
|
|
</MkPagination>
|
2020-01-29 11:37:25 -08:00
|
|
|
</div>
|
2020-10-17 04:12:00 -07:00
|
|
|
</div>
|
2020-01-29 11:37:25 -08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 04:12:00 -07:00
|
|
|
import { defineComponent } from 'vue';
|
2020-04-13 07:27:12 -07:00
|
|
|
import { faPlus, faUsers, faSearch, faBookmark, faMicrophoneSlash } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { faSnowflake, faBookmark as farBookmark } from '@fortawesome/free-regular-svg-icons';
|
2021-03-23 01:43:07 -07:00
|
|
|
import parseAcct from '@/misc/acct/parse';
|
2021-03-23 01:30:14 -07:00
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
|
|
|
import MkInput from '@client/components/ui/input.vue';
|
|
|
|
import MkSelect from '@client/components/ui/select.vue';
|
|
|
|
import MkPagination from '@client/components/ui/pagination.vue';
|
2020-10-17 04:12:00 -07:00
|
|
|
import { acct } from '../../filters/user';
|
2021-03-23 01:30:14 -07:00
|
|
|
import * as os from '@client/os';
|
2021-04-09 20:54:12 -07:00
|
|
|
import * as symbols from '@client/symbols';
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
export default defineComponent({
|
2020-01-29 11:37:25 -08:00
|
|
|
components: {
|
|
|
|
MkButton,
|
|
|
|
MkInput,
|
2020-04-13 07:27:12 -07:00
|
|
|
MkSelect,
|
2020-01-29 11:37:25 -08:00
|
|
|
MkPagination,
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-09 20:54:12 -07:00
|
|
|
[symbols.PAGE_INFO]: {
|
2020-12-25 17:47:36 -08:00
|
|
|
title: this.$ts.users,
|
2020-11-03 03:36:12 -08:00
|
|
|
icon: faUsers,
|
2020-10-17 04:12:00 -07:00
|
|
|
action: {
|
|
|
|
icon: faSearch,
|
|
|
|
handler: this.searchUser
|
|
|
|
}
|
|
|
|
},
|
2020-04-13 07:27:12 -07:00
|
|
|
target: '',
|
|
|
|
sort: '+createdAt',
|
|
|
|
state: 'all',
|
|
|
|
origin: 'local',
|
|
|
|
searchUsername: '',
|
|
|
|
searchHost: '',
|
2020-01-29 11:37:25 -08:00
|
|
|
pagination: {
|
|
|
|
endpoint: 'admin/show-users',
|
|
|
|
limit: 10,
|
2020-03-24 23:57:35 -07:00
|
|
|
params: () => ({
|
2020-04-13 07:27:12 -07:00
|
|
|
sort: this.sort,
|
|
|
|
state: this.state,
|
|
|
|
origin: this.origin,
|
|
|
|
username: this.searchUsername,
|
|
|
|
hostname: this.searchHost,
|
2020-03-24 23:57:35 -07:00
|
|
|
}),
|
2020-01-29 11:37:25 -08:00
|
|
|
offsetMode: true
|
|
|
|
},
|
2020-04-13 07:27:12 -07:00
|
|
|
faPlus, faUsers, faSearch, faBookmark, farBookmark, faMicrophoneSlash, faSnowflake
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-04-13 07:27:12 -07:00
|
|
|
watch: {
|
|
|
|
sort() {
|
|
|
|
this.$refs.users.reload();
|
|
|
|
},
|
|
|
|
state() {
|
|
|
|
this.$refs.users.reload();
|
|
|
|
},
|
|
|
|
origin() {
|
|
|
|
this.$refs.users.reload();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-01-29 11:37:25 -08:00
|
|
|
methods: {
|
|
|
|
/** テキストエリアのユーザーを解決する */
|
|
|
|
fetchUser() {
|
|
|
|
return new Promise((res) => {
|
2020-10-17 04:12:00 -07:00
|
|
|
const usernamePromise = os.api('users/show', parseAcct(this.target));
|
|
|
|
const idPromise = os.api('users/show', { userId: this.target });
|
2020-01-29 11:37:25 -08:00
|
|
|
let _notFound = false;
|
|
|
|
const notFound = () => {
|
|
|
|
if (_notFound) {
|
2020-10-17 04:12:00 -07:00
|
|
|
os.dialog({
|
2020-01-29 11:37:25 -08:00
|
|
|
type: 'error',
|
2020-12-25 17:47:36 -08:00
|
|
|
text: this.$ts.noSuchUser
|
2020-01-29 11:37:25 -08:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
_notFound = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
usernamePromise.then(res).catch(e => {
|
|
|
|
if (e.code === 'NO_SUCH_USER') {
|
|
|
|
notFound();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
idPromise.then(res).catch(e => {
|
|
|
|
notFound();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
/** テキストエリアから処理対象ユーザーを設定する */
|
|
|
|
async showUser() {
|
|
|
|
const user = await this.fetchUser();
|
2020-04-13 07:27:12 -07:00
|
|
|
this.show(user);
|
2020-01-29 11:37:25 -08:00
|
|
|
this.target = '';
|
|
|
|
},
|
|
|
|
|
2020-04-13 07:27:12 -07:00
|
|
|
searchUser() {
|
2020-10-17 04:12:00 -07:00
|
|
|
os.selectUser().then(user => {
|
2020-04-13 07:27:12 -07:00
|
|
|
this.show(user);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-01-29 11:37:25 -08:00
|
|
|
async addUser() {
|
2020-10-17 04:12:00 -07:00
|
|
|
const { canceled: canceled1, result: username } = await os.dialog({
|
2020-12-25 17:47:36 -08:00
|
|
|
title: this.$ts.username,
|
2020-01-29 11:37:25 -08:00
|
|
|
input: true
|
|
|
|
});
|
|
|
|
if (canceled1) return;
|
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
const { canceled: canceled2, result: password } = await os.dialog({
|
2020-12-25 17:47:36 -08:00
|
|
|
title: this.$ts.password,
|
2020-01-29 11:37:25 -08:00
|
|
|
input: { type: 'password' }
|
|
|
|
});
|
|
|
|
if (canceled2) return;
|
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
os.apiWithDialog('admin/accounts/create', {
|
2020-01-29 11:37:25 -08:00
|
|
|
username: username,
|
|
|
|
password: password,
|
|
|
|
}).then(res => {
|
|
|
|
this.$refs.users.reload();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-11-02 22:22:55 -08:00
|
|
|
show(user) {
|
|
|
|
os.popup(import('./user-dialog.vue'), {
|
2020-10-17 04:12:00 -07:00
|
|
|
userId: user.id
|
|
|
|
}, {}, 'closed');
|
|
|
|
},
|
|
|
|
|
|
|
|
acct
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.mk-instance-users {
|
|
|
|
> .users {
|
|
|
|
> ._content {
|
|
|
|
> .users {
|
2020-10-17 04:12:00 -07:00
|
|
|
margin-top: var(--margin);
|
|
|
|
|
2020-01-29 11:37:25 -08:00
|
|
|
> .user {
|
|
|
|
display: flex;
|
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
|
|
|
text-align: left;
|
|
|
|
align-items: center;
|
2020-10-17 04:12:00 -07:00
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
2020-01-29 11:37:25 -08:00
|
|
|
|
|
|
|
> .avatar {
|
2020-10-17 04:12:00 -07:00
|
|
|
width: 60px;
|
|
|
|
height: 60px;
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
> .body {
|
2020-04-13 07:27:12 -07:00
|
|
|
margin-left: 0.3em;
|
2020-10-17 04:12:00 -07:00
|
|
|
padding: 0 8px;
|
2020-04-13 07:27:12 -07:00
|
|
|
flex: 1;
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
@media (max-width: 500px) {
|
2020-04-13 07:27:12 -07:00
|
|
|
font-size: 14px;
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
|
2020-04-13 07:27:12 -07:00
|
|
|
> header {
|
|
|
|
> .name {
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .acct {
|
|
|
|
margin-left: 8px;
|
|
|
|
opacity: 0.7;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .staff {
|
|
|
|
margin-left: 0.5em;
|
|
|
|
color: var(--badge);
|
|
|
|
}
|
|
|
|
|
|
|
|
> .punished {
|
|
|
|
margin-left: 0.5em;
|
|
|
|
color: #4dabf7;
|
|
|
|
}
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|