2018-11-14 20:15:42 +01:00
|
|
|
<template>
|
2019-01-19 15:00:15 +01:00
|
|
|
<div>
|
2018-11-14 20:15:42 +01:00
|
|
|
<ui-card>
|
|
|
|
<div slot="title"><fa icon="plus"/> {{ $t('add-moderator.title') }}</div>
|
|
|
|
<section class="fit-top">
|
|
|
|
<ui-input v-model="username" type="text">
|
|
|
|
<span slot="prefix">@</span>
|
|
|
|
</ui-input>
|
2019-02-07 20:40:47 +01:00
|
|
|
<ui-horizon-group>
|
|
|
|
<ui-button @click="add" :disabled="changing">{{ $t('add-moderator.add') }}</ui-button>
|
|
|
|
<ui-button @click="remove" :disabled="changing">{{ $t('add-moderator.remove') }}</ui-button>
|
|
|
|
</ui-horizon-group>
|
2018-11-14 20:15:42 +01:00
|
|
|
</section>
|
|
|
|
</ui-card>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import i18n from '../../i18n';
|
|
|
|
import parseAcct from "../../../../misc/acct/parse";
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
i18n: i18n('admin/views/moderators.vue'),
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
username: '',
|
2019-01-11 00:11:24 +01:00
|
|
|
changing: false
|
2018-11-14 20:15:42 +01:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async add() {
|
2019-01-11 00:11:24 +01:00
|
|
|
this.changing = true;
|
2018-11-14 20:15:42 +01:00
|
|
|
|
|
|
|
const process = async () => {
|
|
|
|
const user = await this.$root.api('users/show', parseAcct(this.username));
|
|
|
|
await this.$root.api('admin/moderators/add', { userId: user.id });
|
2018-12-02 07:28:52 +01:00
|
|
|
this.$root.dialog({
|
2018-11-14 20:15:42 +01:00
|
|
|
type: 'success',
|
|
|
|
text: this.$t('add-moderator.added')
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
await process().catch(e => {
|
2018-12-02 07:28:52 +01:00
|
|
|
this.$root.dialog({
|
2018-11-14 20:15:42 +01:00
|
|
|
type: 'error',
|
2018-11-14 20:24:40 +01:00
|
|
|
text: e.toString()
|
2018-11-14 20:15:42 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-11 00:11:24 +01:00
|
|
|
this.changing = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
async remove() {
|
|
|
|
this.changing = true;
|
|
|
|
|
|
|
|
const process = async () => {
|
|
|
|
const user = await this.$root.api('users/show', parseAcct(this.username));
|
|
|
|
await this.$root.api('admin/moderators/remove', { userId: user.id });
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
|
|
|
text: this.$t('add-moderator.removed')
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
await process().catch(e => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'error',
|
|
|
|
text: e.toString()
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
this.changing = false;
|
2018-11-14 20:15:42 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|