Files
chatwoot/app/javascript/dashboard/api/reports.js
Shivam Mishra e5134c9ef5 [CW-53] feat: allow downloading heatmap report (#6683)
* feat: add control header slot

* feat: add download API call

* feat: add conversation traffic template

* feat: allow downloading heatmap content

* feat: wire up download

* fix: grid layout for mobile

* chore: revert formatting

* revert: en.yml file

* feat: add conversation traffic text

* feat: disable rule for map block

* test: conversation traffic

* fix: timezone offset

* feat: download report in UTC

* feat: add UTC warning

* chore: revert formatting

* feat: add traffic text

* chore: fix whitespace change
2023-03-20 15:46:29 +05:30

88 lines
1.9 KiB
JavaScript

/* global axios */
import ApiClient from './ApiClient';
const getTimeOffset = () => -new Date().getTimezoneOffset() / 60;
class ReportsAPI extends ApiClient {
constructor() {
super('reports', { accountScoped: true, apiVersion: 'v2' });
}
getReports({
metric,
from,
to,
type = 'account',
id,
group_by,
business_hours,
}) {
return axios.get(`${this.url}`, {
params: {
metric,
since: from,
until: to,
type,
id,
group_by,
business_hours,
timezone_offset: getTimeOffset(),
},
});
}
getSummary(since, until, type = 'account', id, group_by, business_hours) {
return axios.get(`${this.url}/summary`, {
params: {
since,
until,
type,
id,
group_by,
business_hours,
},
});
}
getConversationMetric(type = 'account', page = 1) {
return axios.get(`${this.url}/conversations`, {
params: {
type,
page,
},
});
}
getAgentReports({ from: since, to: until, businessHours }) {
return axios.get(`${this.url}/agents`, {
params: { since, until, business_hours: businessHours },
});
}
getConversationTrafficCSV({ from: since, to: until }) {
return axios.get(`${this.url}/conversation_traffic`, {
params: { since, until },
});
}
getLabelReports({ from: since, to: until, businessHours }) {
return axios.get(`${this.url}/labels`, {
params: { since, until, business_hours: businessHours },
});
}
getInboxReports({ from: since, to: until, businessHours }) {
return axios.get(`${this.url}/inboxes`, {
params: { since, until, business_hours: businessHours },
});
}
getTeamReports({ from: since, to: until, businessHours }) {
return axios.get(`${this.url}/teams`, {
params: { since, until, business_hours: businessHours },
});
}
}
export default new ReportsAPI();