iceshrimp/src/client/app/admin/views/users.vue

139 lines
3.6 KiB
Vue
Raw Normal View History

2018-11-02 23:05:53 +09:00
<template>
<div class="ucnffhbtogqgscfmqcymwmmupoknpfsw">
2018-11-02 23:05:53 +09:00
<ui-card>
<div slot="title">{{ $t('verify-user') }}</div>
2018-11-02 23:05:53 +09:00
<section class="fit-top">
<ui-input v-model="verifyUsername" type="text">
<span slot="prefix">@</span>
</ui-input>
<ui-button @click="verifyUser" :disabled="verifying">{{ $t('verify') }}</ui-button>
2018-11-02 23:05:53 +09:00
</section>
</ui-card>
<ui-card>
<div slot="title">{{ $t('unverify-user') }}</div>
2018-11-02 23:05:53 +09:00
<section class="fit-top">
<ui-input v-model="unverifyUsername" type="text">
<span slot="prefix">@</span>
</ui-input>
<ui-button @click="unverifyUser" :disabled="unverifying">{{ $t('unverify') }}</ui-button>
2018-11-02 23:05:53 +09:00
</section>
</ui-card>
<ui-card>
<div slot="title">{{ $t('suspend-user') }}</div>
2018-11-02 23:05:53 +09:00
<section class="fit-top">
<ui-input v-model="suspendUsername" type="text">
<span slot="prefix">@</span>
</ui-input>
<ui-button @click="suspendUser" :disabled="suspending">{{ $t('suspend') }}</ui-button>
2018-11-02 23:05:53 +09:00
</section>
</ui-card>
<ui-card>
<div slot="title">{{ $t('unsuspend-user') }}</div>
2018-11-02 23:05:53 +09:00
<section class="fit-top">
<ui-input v-model="unsuspendUsername" type="text">
<span slot="prefix">@</span>
</ui-input>
<ui-button @click="unsuspendUser" :disabled="unsuspending">{{ $t('unsuspend') }}</ui-button>
2018-11-02 23:05:53 +09:00
</section>
</ui-card>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import i18n from '../../i18n';
2018-11-02 23:05:53 +09:00
import parseAcct from "../../../../misc/acct/parse";
export default Vue.extend({
i18n: i18n('admin/views/users.vue'),
2018-11-02 23:05:53 +09:00
data() {
return {
verifyUsername: null,
verifying: false,
unverifyUsername: null,
unverifying: false,
suspendUsername: null,
suspending: false,
unsuspendUsername: null,
unsuspending: false
};
},
methods: {
async verifyUser() {
this.verifying = true;
const process = async () => {
2018-11-09 08:13:34 +09:00
const user = await this.$root.os.api('users/show', parseAcct(this.verifyUsername));
await this.$root.os.api('admin/verify-user', { userId: user.id });
//this.$root.os.apis.dialog({ text: this.$t('verified') });
2018-11-02 23:05:53 +09:00
};
await process().catch(e => {
2018-11-09 08:13:34 +09:00
//this.$root.os.apis.dialog({ text: `Failed: ${e}` });
2018-11-02 23:05:53 +09:00
});
this.verifying = false;
},
async unverifyUser() {
this.unverifying = true;
const process = async () => {
2018-11-09 08:13:34 +09:00
const user = await this.$root.os.api('users/show', parseAcct(this.unverifyUsername));
await this.$root.os.api('admin/unverify-user', { userId: user.id });
//this.$root.os.apis.dialog({ text: this.$t('unverified') });
2018-11-02 23:05:53 +09:00
};
await process().catch(e => {
2018-11-09 08:13:34 +09:00
//this.$root.os.apis.dialog({ text: `Failed: ${e}` });
2018-11-02 23:05:53 +09:00
});
this.unverifying = false;
},
async suspendUser() {
this.suspending = true;
const process = async () => {
2018-11-09 08:13:34 +09:00
const user = await this.$root.os.api('users/show', parseAcct(this.suspendUsername));
await this.$root.os.api('admin/suspend-user', { userId: user.id });
//this.$root.os.apis.dialog({ text: this.$t('suspended') });
2018-11-02 23:05:53 +09:00
};
await process().catch(e => {
2018-11-09 08:13:34 +09:00
//this.$root.os.apis.dialog({ text: `Failed: ${e}` });
2018-11-02 23:05:53 +09:00
});
this.suspending = false;
},
async unsuspendUser() {
this.unsuspending = true;
const process = async () => {
2018-11-09 08:13:34 +09:00
const user = await this.$root.os.api('users/show', parseAcct(this.unsuspendUsername));
await this.$root.os.api('admin/unsuspend-user', { userId: user.id });
//this.$root.os.apis.dialog({ text: this.$t('unsuspended') });
2018-11-02 23:05:53 +09:00
};
await process().catch(e => {
2018-11-09 08:13:34 +09:00
//this.$root.os.apis.dialog({ text: `Failed: ${e}` });
2018-11-02 23:05:53 +09:00
});
this.unsuspending = false;
}
}
});
</script>
<style lang="stylus" scoped>
.ucnffhbtogqgscfmqcymwmmupoknpfsw
@media (min-width 500px)
padding 16px
</style>