2018-11-14 19:15:42 +00:00
|
|
|
<template>
|
2019-01-19 14:00:15 +00:00
|
|
|
<div>
|
2018-11-14 19:15:42 +00:00
|
|
|
<ui-card>
|
2019-02-18 02:13:56 +00:00
|
|
|
<template #title><fa icon="plus"/> {{ $t('add-moderator.title') }}</template>
|
2018-11-14 19:15:42 +00:00
|
|
|
<section class="fit-top">
|
|
|
|
<ui-input v-model="username" type="text">
|
2019-02-18 02:13:56 +00:00
|
|
|
<template #prefix>@</template>
|
2018-11-14 19:15:42 +00:00
|
|
|
</ui-input>
|
2019-02-07 19:40:47 +00: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 19:15:42 +00:00
|
|
|
</section>
|
|
|
|
</ui-card>
|
2019-07-13 18:18:45 +00:00
|
|
|
|
|
|
|
<ui-card>
|
|
|
|
<template #title>{{ $t('logs.title') }}</template>
|
|
|
|
<section class="fit-top">
|
|
|
|
<sequential-entrance animation="entranceFromTop" delay="25">
|
|
|
|
<div v-for="log in logs" :key="log.id" class="">
|
|
|
|
<ui-horizon-group inputs>
|
|
|
|
<ui-input :value="log.user | acct" type="text" readonly>
|
|
|
|
<span>{{ $t('logs.moderator') }}</span>
|
|
|
|
</ui-input>
|
|
|
|
<ui-input :value="log.type" type="text" readonly>
|
|
|
|
<span>{{ $t('logs.type') }}</span>
|
|
|
|
</ui-input>
|
|
|
|
<ui-input :value="log.createdAt | date" type="text" readonly>
|
|
|
|
<span>{{ $t('logs.at') }}</span>
|
|
|
|
</ui-input>
|
|
|
|
</ui-horizon-group>
|
|
|
|
<ui-textarea :value="JSON.stringify(log.info, null, 4)" readonly>
|
|
|
|
<span>{{ $t('logs.info') }}</span>
|
|
|
|
</ui-textarea>
|
|
|
|
</div>
|
|
|
|
</sequential-entrance>
|
|
|
|
<ui-button v-if="existMoreLogs" @click="fetchLogs">{{ $t('@.load-more') }}</ui-button>
|
|
|
|
</section>
|
|
|
|
</ui-card>
|
2018-11-14 19:15:42 +00:00
|
|
|
</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-07-13 18:18:45 +00:00
|
|
|
changing: false,
|
|
|
|
logs: [],
|
|
|
|
untilLogId: null,
|
|
|
|
existMoreLogs: false
|
2018-11-14 19:15:42 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2019-07-13 18:18:45 +00:00
|
|
|
created() {
|
|
|
|
this.fetchLogs();
|
|
|
|
},
|
|
|
|
|
2018-11-14 19:15:42 +00:00
|
|
|
methods: {
|
|
|
|
async add() {
|
2019-01-10 23:11:24 +00:00
|
|
|
this.changing = true;
|
2018-11-14 19:15:42 +00: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 06:28:52 +00:00
|
|
|
this.$root.dialog({
|
2018-11-14 19:15:42 +00:00
|
|
|
type: 'success',
|
|
|
|
text: this.$t('add-moderator.added')
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
await process().catch(e => {
|
2018-12-02 06:28:52 +00:00
|
|
|
this.$root.dialog({
|
2018-11-14 19:15:42 +00:00
|
|
|
type: 'error',
|
2018-11-14 19:24:40 +00:00
|
|
|
text: e.toString()
|
2018-11-14 19:15:42 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-10 23:11:24 +00: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 19:15:42 +00:00
|
|
|
},
|
2019-07-13 18:18:45 +00:00
|
|
|
|
|
|
|
fetchLogs() {
|
|
|
|
this.$root.api('admin/show-moderation-logs', {
|
|
|
|
untilId: this.untilId,
|
|
|
|
limit: 10 + 1
|
|
|
|
}).then(logs => {
|
|
|
|
if (logs.length == 10 + 1) {
|
|
|
|
logs.pop();
|
|
|
|
this.existMoreLogs = true;
|
|
|
|
} else {
|
|
|
|
this.existMoreLogs = false;
|
|
|
|
}
|
|
|
|
this.logs = this.logs.concat(logs);
|
|
|
|
this.untilLogId = this.logs[this.logs.length - 1].id;
|
|
|
|
});
|
|
|
|
},
|
2018-11-14 19:15:42 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|