2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
|
|
|
<x-window @closed="() => { $emit('closed'); destroyDom(); }" :avatar="user">
|
|
|
|
<template #header><mk-user-name :user="user"/></template>
|
|
|
|
<div class="vrcsvlkm">
|
2020-01-31 05:15:59 +09:00
|
|
|
<mk-button @click="resetPassword()" primary>{{ $t('resetPassword') }}</mk-button>
|
2020-02-18 17:53:52 +09:00
|
|
|
<mk-switch v-if="$store.state.i.isAdmin && !user.isAdmin" @change="toggleModerator()" v-model="moderator">{{ $t('moderator') }}</mk-switch>
|
2020-01-30 04:37:25 +09:00
|
|
|
<mk-switch @change="toggleSilence()" v-model="silenced">{{ $t('silence') }}</mk-switch>
|
|
|
|
<mk-switch @change="toggleSuspend()" v-model="suspended">{{ $t('suspend') }}</mk-switch>
|
|
|
|
</div>
|
|
|
|
</x-window>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import i18n from '../i18n';
|
|
|
|
import MkButton from './ui/button.vue';
|
|
|
|
import MkSwitch from './ui/switch.vue';
|
|
|
|
import XWindow from './window.vue';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
i18n,
|
|
|
|
|
|
|
|
components: {
|
|
|
|
MkButton,
|
|
|
|
MkSwitch,
|
|
|
|
XWindow,
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
user: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2020-01-30 06:00:43 +09:00
|
|
|
moderator: this.user.isModerator,
|
2020-01-30 04:37:25 +09:00
|
|
|
silenced: this.user.isSilenced,
|
|
|
|
suspended: this.user.isSuspended,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2020-01-31 05:15:59 +09:00
|
|
|
async resetPassword() {
|
2020-01-30 04:37:25 +09:00
|
|
|
const dialog = this.$root.dialog({
|
|
|
|
type: 'waiting',
|
|
|
|
iconOnly: true
|
|
|
|
});
|
2020-02-18 17:53:52 +09:00
|
|
|
|
2020-01-31 05:15:59 +09:00
|
|
|
this.$root.api('admin/reset-password', {
|
2020-01-30 04:37:25 +09:00
|
|
|
userId: this.user.id,
|
2020-01-31 05:15:59 +09:00
|
|
|
}).then(({ password }) => {
|
2020-01-30 04:37:25 +09:00
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
2020-01-31 05:15:59 +09:00
|
|
|
text: this.$t('newPasswordIs', { password })
|
2020-01-30 04:37:25 +09:00
|
|
|
});
|
|
|
|
}).catch(e => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'error',
|
|
|
|
text: e
|
|
|
|
});
|
|
|
|
}).finally(() => {
|
|
|
|
dialog.close();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
async toggleSilence() {
|
|
|
|
const confirm = await this.$root.dialog({
|
|
|
|
type: 'warning',
|
|
|
|
showCancelButton: true,
|
|
|
|
text: this.silenced ? this.$t('silenceConfirm') : this.$t('unsilenceConfirm'),
|
|
|
|
});
|
|
|
|
if (confirm.canceled) {
|
|
|
|
this.silenced = !this.silenced;
|
|
|
|
} else {
|
|
|
|
this.$root.api(this.silenced ? 'admin/silence-user' : 'admin/unsilence-user', { userId: this.user.id });
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
async toggleSuspend() {
|
|
|
|
const confirm = await this.$root.dialog({
|
|
|
|
type: 'warning',
|
|
|
|
showCancelButton: true,
|
|
|
|
text: this.suspended ? this.$t('suspendConfirm') : this.$t('unsuspendConfirm'),
|
|
|
|
});
|
|
|
|
if (confirm.canceled) {
|
|
|
|
this.suspended = !this.suspended;
|
|
|
|
} else {
|
2020-01-30 06:00:43 +09:00
|
|
|
this.$root.api(this.suspended ? 'admin/suspend-user' : 'admin/unsuspend-user', { userId: this.user.id });
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
2020-01-30 06:00:43 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
async toggleModerator() {
|
|
|
|
this.$root.api(this.moderator ? 'admin/moderators/add' : 'admin/moderators/remove', { userId: this.user.id });
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.vrcsvlkm {
|
|
|
|
|
|
|
|
}
|
|
|
|
</style>
|