Sharkey/src/client/pages/instance/abuses.vue

170 lines
4.4 KiB
Vue
Raw Normal View History

2020-10-19 13:29:04 +03:00
<template>
<div class="lcixvhis">
2020-10-19 13:29:04 +03:00
<div class="_section reports">
<div class="_content">
<div class="inputs" style="display: flex;">
<MkSelect v-model:value="state" style="margin: 0; flex: 1;">
2020-12-26 03:47:36 +02:00
<template #label>{{ $ts.state }}</template>
<option value="all">{{ $ts.all }}</option>
<option value="unresolved">{{ $ts.unresolved }}</option>
<option value="resolved">{{ $ts.resolved }}</option>
2020-10-19 13:29:04 +03:00
</MkSelect>
<MkSelect v-model:value="targetUserOrigin" style="margin: 0; flex: 1;">
2020-12-26 03:47:36 +02:00
<template #label>{{ $ts.targetUserOrigin }}</template>
<option value="combined">{{ $ts.all }}</option>
<option value="local">{{ $ts.local }}</option>
<option value="remote">{{ $ts.remote }}</option>
2020-10-19 13:29:04 +03:00
</MkSelect>
<MkSelect v-model:value="reporterOrigin" style="margin: 0; flex: 1;">
2020-12-26 03:47:36 +02:00
<template #label>{{ $ts.reporterOrigin }}</template>
<option value="combined">{{ $ts.all }}</option>
<option value="local">{{ $ts.local }}</option>
<option value="remote">{{ $ts.remote }}</option>
2020-10-19 13:29:04 +03:00
</MkSelect>
</div>
<!-- TODO
<div class="inputs" style="display: flex; padding-top: 1.2em;">
<MkInput v-model:value="searchUsername" style="margin: 0; flex: 1;" type="text" spellcheck="false" @update:value="$refs.reports.reload()">
2020-12-26 03:47:36 +02:00
<span>{{ $ts.username }}</span>
2020-10-19 13:29:04 +03:00
</MkInput>
<MkInput v-model:value="searchHost" style="margin: 0; flex: 1;" type="text" spellcheck="false" @update:value="$refs.reports.reload()" :disabled="pagination.params().origin === 'local'">
2020-12-26 03:47:36 +02:00
<span>{{ $ts.host }}</span>
2020-10-19 13:29:04 +03:00
</MkInput>
</div>
-->
2020-11-08 04:25:28 +02:00
<MkPagination :pagination="pagination" #default="{items}" ref="reports" style="margin-top: var(--margin);">
2021-04-10 12:17:42 +03:00
<div class="bcekxzvu _card _gap" v-for="report in items" :key="report.id">
2020-10-19 13:29:04 +03:00
<div class="_content target">
2021-04-17 17:52:54 +03:00
<MkAvatar class="avatar" :user="report.targetUser" :show-indicator="true"/>
2020-10-19 13:29:04 +03:00
<div class="info">
<MkUserName class="name" :user="report.targetUser"/>
<div class="acct">@{{ acct(report.targetUser) }}</div>
</div>
</div>
<div class="_content">
<div>
<Mfm :text="report.comment"/>
</div>
<hr>
<div>Reporter: <MkAcct :user="report.reporter"/></div>
<div><MkTime :time="report.createdAt"/></div>
</div>
<div class="_footer">
<div v-if="report.assignee">Assignee: <MkAcct :user="report.assignee"/></div>
2020-12-26 03:47:36 +02:00
<MkButton @click="resolve(report)" primary v-if="!report.resolved">{{ $ts.abuseMarkAsResolved }}</MkButton>
2020-10-19 13:29:04 +03:00
</div>
</div>
</MkPagination>
</div>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
2021-07-15 14:45:32 +03:00
import { parseAcct } from '@/misc/acct';
2021-03-23 10:30:14 +02: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-19 13:29:04 +03:00
import { acct } from '../../filters/user';
2021-03-23 10:30:14 +02:00
import * as os from '@client/os';
2021-04-10 06:54:12 +03:00
import * as symbols from '@client/symbols';
2020-10-19 13:29:04 +03:00
export default defineComponent({
components: {
MkButton,
MkInput,
MkSelect,
MkPagination,
},
emits: ['info'],
2020-10-19 13:29:04 +03:00
data() {
return {
2021-04-10 06:54:12 +03:00
[symbols.PAGE_INFO]: {
2020-12-26 03:47:36 +02:00
title: this.$ts.abuseReports,
icon: 'fas fa-exclamation-circle'
2020-10-19 13:29:04 +03:00
},
searchUsername: '',
searchHost: '',
state: 'unresolved',
reporterOrigin: 'combined',
targetUserOrigin: 'combined',
pagination: {
endpoint: 'admin/abuse-user-reports',
limit: 10,
params: () => ({
state: this.state,
reporterOrigin: this.reporterOrigin,
targetUserOrigin: this.targetUserOrigin,
}),
},
}
},
watch: {
state() {
this.$refs.reports.reload();
},
reporterOrigin() {
this.$refs.reports.reload();
},
targetUserOrigin() {
this.$refs.reports.reload();
},
},
mounted() {
this.$emit('info', this[symbols.PAGE_INFO]);
},
2020-10-19 13:29:04 +03:00
methods: {
acct,
resolve(report) {
os.apiWithDialog('admin/resolve-abuse-user-report', {
reportId: report.id,
}).then(() => {
this.$refs.reports.removeItem(item => item.id === report.id);
});
},
}
});
</script>
<style lang="scss" scoped>
.lcixvhis {
margin: var(--margin);
}
2020-10-19 13:29:04 +03:00
.bcekxzvu {
> .target {
display: flex;
width: 100%;
box-sizing: border-box;
text-align: left;
align-items: center;
> .avatar {
width: 42px;
height: 42px;
}
> .info {
margin-left: 0.3em;
padding: 0 8px;
flex: 1;
> .name {
font-weight: bold;
}
}
}
}
</style>