2019-09-09 09:31:08 +02:00
|
|
|
<template>
|
2020-06-25 11:36:35 +02:00
|
|
|
<div>
|
|
|
|
<nav class="breadcrumb" aria-label="breadcrumbs">
|
|
|
|
<ul>
|
|
|
|
<li>
|
2020-11-30 10:24:11 +01:00
|
|
|
<router-link :to="{ name: RouteName.MODERATION }">{{
|
|
|
|
$t("Moderation")
|
|
|
|
}}</router-link>
|
2020-06-25 11:36:35 +02:00
|
|
|
</li>
|
|
|
|
<li class="is-active">
|
2020-11-30 10:24:11 +01:00
|
|
|
<router-link :to="{ name: RouteName.REPORTS }">{{
|
|
|
|
$t("Reports")
|
|
|
|
}}</router-link>
|
2020-06-25 11:36:35 +02:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
<section>
|
|
|
|
<b-field>
|
2020-11-30 10:24:11 +01:00
|
|
|
<b-radio-button
|
2021-05-12 18:10:07 +02:00
|
|
|
v-model="status"
|
2020-11-30 10:24:11 +01:00
|
|
|
:native-value="ReportStatusEnum.OPEN"
|
|
|
|
>{{ $t("Open") }}</b-radio-button
|
|
|
|
>
|
|
|
|
<b-radio-button
|
2021-05-12 18:10:07 +02:00
|
|
|
v-model="status"
|
2020-11-30 10:24:11 +01:00
|
|
|
:native-value="ReportStatusEnum.RESOLVED"
|
|
|
|
>{{ $t("Resolved") }}</b-radio-button
|
|
|
|
>
|
|
|
|
<b-radio-button
|
2021-05-12 18:10:07 +02:00
|
|
|
v-model="status"
|
2020-11-30 10:24:11 +01:00
|
|
|
:native-value="ReportStatusEnum.CLOSED"
|
|
|
|
>{{ $t("Closed") }}</b-radio-button
|
|
|
|
>
|
2020-06-25 11:36:35 +02:00
|
|
|
</b-field>
|
2021-05-12 18:10:07 +02:00
|
|
|
<ul v-if="reports.elements.length > 0">
|
|
|
|
<li v-for="report in reports.elements" :key="report.id">
|
2020-11-30 10:24:11 +01:00
|
|
|
<router-link
|
|
|
|
:to="{ name: RouteName.REPORT, params: { reportId: report.id } }"
|
|
|
|
>
|
2020-06-25 11:36:35 +02:00
|
|
|
<report-card :report="report" />
|
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
</ul>
|
2021-05-12 18:10:07 +02:00
|
|
|
<div v-else class="no-reports">
|
|
|
|
<empty-content
|
|
|
|
icon="chat-alert"
|
|
|
|
inline
|
|
|
|
v-if="status === ReportStatusEnum.OPEN"
|
2020-11-30 10:24:11 +01:00
|
|
|
>
|
2020-06-25 11:36:35 +02:00
|
|
|
{{ $t("No open reports yet") }}
|
2021-05-12 18:10:07 +02:00
|
|
|
</empty-content>
|
|
|
|
<empty-content
|
|
|
|
icon="chat-alert"
|
|
|
|
inline
|
|
|
|
v-if="status === ReportStatusEnum.RESOLVED"
|
2020-11-30 10:24:11 +01:00
|
|
|
>
|
2020-06-25 11:36:35 +02:00
|
|
|
{{ $t("No resolved reports yet") }}
|
2021-05-12 18:10:07 +02:00
|
|
|
</empty-content>
|
|
|
|
<empty-content
|
|
|
|
icon="chat-alert"
|
|
|
|
inline
|
|
|
|
v-if="status === ReportStatusEnum.CLOSED"
|
2020-11-30 10:24:11 +01:00
|
|
|
>
|
2020-06-25 11:36:35 +02:00
|
|
|
{{ $t("No closed reports yet") }}
|
2021-05-12 18:10:07 +02:00
|
|
|
</empty-content>
|
2020-06-25 11:36:35 +02:00
|
|
|
</div>
|
2021-05-12 18:10:07 +02:00
|
|
|
<b-pagination
|
|
|
|
:total="reports.total"
|
|
|
|
v-model="page"
|
|
|
|
:simple="true"
|
|
|
|
:per-page="REPORT_PAGE_LIMIT"
|
|
|
|
:aria-next-label="$t('Next page')"
|
|
|
|
:aria-previous-label="$t('Previous page')"
|
|
|
|
:aria-page-label="$t('Page')"
|
|
|
|
:aria-current-label="$t('Current page')"
|
|
|
|
>
|
|
|
|
</b-pagination>
|
2020-06-25 11:36:35 +02:00
|
|
|
</section>
|
|
|
|
</div>
|
2019-09-09 09:31:08 +02:00
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
2021-05-12 18:10:07 +02:00
|
|
|
import { Component, Vue } from "vue-property-decorator";
|
2020-11-27 19:27:44 +01:00
|
|
|
import { IReport } from "@/types/report.model";
|
2020-02-18 08:57:00 +01:00
|
|
|
import { REPORTS } from "@/graphql/report";
|
|
|
|
import ReportCard from "@/components/Report/ReportCard.vue";
|
2021-05-12 18:10:07 +02:00
|
|
|
import EmptyContent from "@/components/Utils/EmptyContent.vue";
|
2020-11-27 19:27:44 +01:00
|
|
|
import { ReportStatusEnum } from "@/types/enums";
|
2020-02-18 08:57:00 +01:00
|
|
|
import RouteName from "../../router/name";
|
2021-05-12 18:10:07 +02:00
|
|
|
import VueRouter from "vue-router";
|
|
|
|
import { Paginate } from "@/types/paginate";
|
|
|
|
const { isNavigationFailure, NavigationFailureType } = VueRouter;
|
|
|
|
|
|
|
|
const REPORT_PAGE_LIMIT = 1;
|
2019-09-09 09:31:08 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
components: {
|
|
|
|
ReportCard,
|
2021-05-12 18:10:07 +02:00
|
|
|
EmptyContent,
|
2019-09-09 09:31:08 +02:00
|
|
|
},
|
|
|
|
apollo: {
|
|
|
|
reports: {
|
|
|
|
query: REPORTS,
|
|
|
|
variables() {
|
|
|
|
return {
|
2021-05-12 18:10:07 +02:00
|
|
|
page: this.page,
|
|
|
|
status: this.status,
|
|
|
|
limit: REPORT_PAGE_LIMIT,
|
2019-09-09 09:31:08 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
pollInterval: 120000, // 2 minutes
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
export default class ReportList extends Vue {
|
2021-05-12 18:10:07 +02:00
|
|
|
reports?: Paginate<IReport> = { elements: [], total: 0 };
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-10-03 12:32:20 +02:00
|
|
|
RouteName = RouteName;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-09-09 09:31:08 +02:00
|
|
|
ReportStatusEnum = ReportStatusEnum;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-09-09 09:31:08 +02:00
|
|
|
filterReports: ReportStatusEnum = ReportStatusEnum.OPEN;
|
|
|
|
|
2021-05-12 18:10:07 +02:00
|
|
|
REPORT_PAGE_LIMIT = REPORT_PAGE_LIMIT;
|
|
|
|
|
|
|
|
get page(): number {
|
|
|
|
return parseInt((this.$route.query.page as string) || "1", 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
set page(page: number) {
|
|
|
|
this.pushRouter(RouteName.REPORTS, {
|
|
|
|
page: page.toString(),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
get status(): ReportStatusEnum {
|
|
|
|
const filter = this.$route.params.filter?.toUpperCase();
|
2019-09-09 09:31:08 +02:00
|
|
|
if (filter in ReportStatusEnum) {
|
2021-05-12 18:10:07 +02:00
|
|
|
return filter as ReportStatusEnum;
|
2019-09-09 09:31:08 +02:00
|
|
|
}
|
2021-05-12 18:10:07 +02:00
|
|
|
return ReportStatusEnum.OPEN;
|
2019-09-09 09:31:08 +02:00
|
|
|
}
|
|
|
|
|
2021-05-12 18:10:07 +02:00
|
|
|
set status(status: ReportStatusEnum) {
|
|
|
|
this.$router.push({
|
2020-02-18 08:57:00 +01:00
|
|
|
name: RouteName.REPORTS,
|
2021-05-12 18:10:07 +02:00
|
|
|
params: { filter: status.toLowerCase() },
|
2020-02-18 08:57:00 +01:00
|
|
|
});
|
2019-09-09 09:31:08 +02:00
|
|
|
}
|
2021-05-12 18:10:07 +02:00
|
|
|
|
|
|
|
protected async pushRouter(
|
|
|
|
routeName: string,
|
|
|
|
args: Record<string, string>
|
|
|
|
): Promise<void> {
|
|
|
|
try {
|
|
|
|
await this.$router.push({
|
|
|
|
name: routeName,
|
|
|
|
params: this.$route.params,
|
|
|
|
query: { ...this.$route.query, ...args },
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
if (isNavigationFailure(e, NavigationFailureType.redirected)) {
|
|
|
|
throw Error(e.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-09 09:31:08 +02:00
|
|
|
}
|
|
|
|
</script>
|
2020-06-18 16:57:11 +02:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-05-12 18:10:07 +02:00
|
|
|
section {
|
|
|
|
.no-reports {
|
|
|
|
margin-bottom: 2rem;
|
|
|
|
}
|
|
|
|
& > ul li {
|
|
|
|
margin: 0.5rem auto;
|
|
|
|
|
|
|
|
& > a {
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
}
|
2020-06-18 16:57:11 +02:00
|
|
|
}
|
|
|
|
</style>
|