mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 12:08:01 +00:00
feat: Download SLA reports (#9201)
This commit is contained in:
@@ -510,6 +510,8 @@
|
|||||||
"HEADER": "SLA Reports",
|
"HEADER": "SLA Reports",
|
||||||
"NO_RECORDS": "SLA applied conversations are not available.",
|
"NO_RECORDS": "SLA applied conversations are not available.",
|
||||||
"LOADING": "Loading SLA data...",
|
"LOADING": "Loading SLA data...",
|
||||||
|
"DOWNLOAD_SLA_REPORTS": "Download SLA reports",
|
||||||
|
"DOWNLOAD_FAILED": "Failed to download SLA Reports",
|
||||||
"METRICS": {
|
"METRICS": {
|
||||||
"HIT_RATE": {
|
"HIT_RATE": {
|
||||||
"LABEL": "Hit Rate",
|
"LABEL": "Hit Rate",
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col flex-1 px-4 pt-4 overflow-auto">
|
<div class="flex flex-col flex-1 px-4 pt-4 overflow-auto">
|
||||||
<SLAReportFilters @filter-change="onFilterChange" />
|
<SLAReportFilters @filter-change="onFilterChange" />
|
||||||
|
<woot-button
|
||||||
|
color-scheme="success"
|
||||||
|
class-names="button--fixed-top"
|
||||||
|
icon="arrow-download"
|
||||||
|
@click="downloadReports"
|
||||||
|
>
|
||||||
|
{{ $t('SLA_REPORTS.DOWNLOAD_SLA_REPORTS') }}
|
||||||
|
</woot-button>
|
||||||
<div class="flex flex-col gap-6">
|
<div class="flex flex-col gap-6">
|
||||||
<SLAMetrics
|
<SLAMetrics
|
||||||
:hit-rate="slaMetrics.hitRate"
|
:hit-rate="slaMetrics.hitRate"
|
||||||
@@ -22,8 +30,9 @@
|
|||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
import SLAMetrics from './components/SLA/SLAMetrics.vue';
|
import SLAMetrics from './components/SLA/SLAMetrics.vue';
|
||||||
import SLATable from './components/SLA/SLATable.vue';
|
import SLATable from './components/SLA/SLATable.vue';
|
||||||
|
import alertMixin from 'shared/mixins/alertMixin';
|
||||||
import SLAReportFilters from './components/SLA/SLAReportFilters.vue';
|
import SLAReportFilters from './components/SLA/SLAReportFilters.vue';
|
||||||
|
import { generateFileName } from 'dashboard/helper/downloadHelper';
|
||||||
export default {
|
export default {
|
||||||
name: 'SLAReports',
|
name: 'SLAReports',
|
||||||
components: {
|
components: {
|
||||||
@@ -31,6 +40,7 @@ export default {
|
|||||||
SLATable,
|
SLATable,
|
||||||
SLAReportFilters,
|
SLAReportFilters,
|
||||||
},
|
},
|
||||||
|
mixins: [alertMixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
pageNumber: 1,
|
pageNumber: 1,
|
||||||
@@ -73,6 +83,17 @@ export default {
|
|||||||
this.fetchSLAReports();
|
this.fetchSLAReports();
|
||||||
this.fetchSLAMetrics();
|
this.fetchSLAMetrics();
|
||||||
},
|
},
|
||||||
|
downloadReports() {
|
||||||
|
const type = 'sla';
|
||||||
|
try {
|
||||||
|
this.$store.dispatch('slaReports/download', {
|
||||||
|
fileName: generateFileName({ type, to: this.to }),
|
||||||
|
...this.requestPayload,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
this.showAlert(this.$t('SLA_REPORTS.DOWNLOAD_FAILED'));
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as MutationHelpers from 'shared/helpers/vuex/mutationHelpers';
|
import * as MutationHelpers from 'shared/helpers/vuex/mutationHelpers';
|
||||||
import types from '../mutation-types';
|
import types from '../mutation-types';
|
||||||
import SLAReportsAPI from '../../api/slaReports';
|
import SLAReportsAPI from '../../api/slaReports';
|
||||||
|
import { downloadCsvFile } from 'dashboard/helper/downloadHelper';
|
||||||
export const state = {
|
export const state = {
|
||||||
records: [],
|
records: [],
|
||||||
metrics: {
|
metrics: {
|
||||||
@@ -60,6 +60,11 @@ export const actions = {
|
|||||||
commit(types.SET_SLA_REPORTS_UI_FLAG, { isFetchingMetrics: false });
|
commit(types.SET_SLA_REPORTS_UI_FLAG, { isFetchingMetrics: false });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
download(_, params) {
|
||||||
|
return SLAReportsAPI.download(params).then(response => {
|
||||||
|
downloadCsvFile(params.fileName, response.data);
|
||||||
|
});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
|
|||||||
Reference in New Issue
Block a user