2019-09-09 09:31:08 +02:00
|
|
|
<template>
|
2019-12-20 13:04:34 +01:00
|
|
|
<section class="container section">
|
2019-09-09 09:31:08 +02:00
|
|
|
<nav class="breadcrumb" aria-label="breadcrumbs">
|
|
|
|
<ul>
|
2019-11-15 18:36:47 +01:00
|
|
|
<li><router-link :to="{ name: RouteName.DASHBOARD }">{{ $t('Dashboard') }}</router-link></li>
|
|
|
|
<li class="is-active"><router-link :to="{ name: RouteName.REPORTS }" aria-current="page">{{ $t('Reports') }}</router-link></li>
|
2019-09-09 09:31:08 +02:00
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
<b-field>
|
|
|
|
<b-radio-button v-model="filterReports"
|
|
|
|
:native-value="ReportStatusEnum.OPEN">
|
2019-12-03 11:29:51 +01:00
|
|
|
{{ $t('Open') }}
|
2019-09-09 09:31:08 +02:00
|
|
|
</b-radio-button>
|
|
|
|
<b-radio-button v-model="filterReports"
|
|
|
|
:native-value="ReportStatusEnum.RESOLVED">
|
2019-12-03 11:29:51 +01:00
|
|
|
{{ $t('Resolved') }}
|
2019-09-09 09:31:08 +02:00
|
|
|
</b-radio-button>
|
|
|
|
<b-radio-button v-model="filterReports"
|
|
|
|
:native-value="ReportStatusEnum.CLOSED">
|
2019-12-03 11:29:51 +01:00
|
|
|
{{ $t('Closed') }}
|
2019-09-09 09:31:08 +02:00
|
|
|
</b-radio-button>
|
|
|
|
</b-field>
|
|
|
|
<ul v-if="reports.length > 0">
|
|
|
|
<li v-for="report in reports">
|
2019-10-03 12:32:20 +02:00
|
|
|
<router-link :to="{ name: RouteName.REPORT, params: { reportId: report.id } }">
|
2019-09-09 09:31:08 +02:00
|
|
|
<report-card :report="report" />
|
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<div v-else>
|
2019-12-03 11:29:51 +01:00
|
|
|
<b-message v-if="filterReports === ReportStatusEnum.OPEN" type="is-info">{{ $t('No open reports yet') }}</b-message>
|
|
|
|
<b-message v-if="filterReports === ReportStatusEnum.RESOLVED" type="is-info">{{ $t('No resolved reports yet') }}</b-message>
|
|
|
|
<b-message v-if="filterReports === ReportStatusEnum.CLOSED" type="is-info">{{ $t('No closed reports yet') }}</b-message>
|
2019-09-09 09:31:08 +02:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
|
|
import { Component, Prop, Vue, Watch } from 'vue-property-decorator';
|
|
|
|
import { IReport, ReportStatusEnum } from '@/types/report.model';
|
|
|
|
import { REPORTS } from '@/graphql/report';
|
|
|
|
import ReportCard from '@/components/Report/ReportCard.vue';
|
2019-10-03 12:32:20 +02:00
|
|
|
import { RouteName } from '@/router';
|
2019-09-09 09:31:08 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
components: {
|
|
|
|
ReportCard,
|
|
|
|
},
|
|
|
|
apollo: {
|
|
|
|
reports: {
|
|
|
|
query: REPORTS,
|
|
|
|
fetchPolicy: 'no-cache',
|
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
status: this.filterReports,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
pollInterval: 120000, // 2 minutes
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
export default class ReportList extends Vue {
|
|
|
|
|
|
|
|
reports?: IReport[] = [];
|
2019-10-03 12:32:20 +02:00
|
|
|
RouteName = RouteName;
|
2019-09-09 09:31:08 +02:00
|
|
|
ReportStatusEnum = ReportStatusEnum;
|
|
|
|
filterReports: ReportStatusEnum = ReportStatusEnum.OPEN;
|
|
|
|
|
|
|
|
@Watch('$route.params.filter', { immediate: true })
|
|
|
|
onRouteFilterChanged (val: string) {
|
|
|
|
if (!val) return;
|
|
|
|
const filter = val.toUpperCase();
|
|
|
|
if (filter in ReportStatusEnum) {
|
|
|
|
this.filterReports = filter as ReportStatusEnum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Watch('filterReports', { immediate: true })
|
|
|
|
async onFilterChanged (val: string) {
|
2019-10-03 12:32:20 +02:00
|
|
|
await this.$router.push({ name: RouteName.REPORTS, params: { filter: val.toLowerCase() } });
|
2019-09-09 09:31:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|