diff --git a/app/javascript/dashboard/i18n/locale/en/report.json b/app/javascript/dashboard/i18n/locale/en/report.json index a14704007..1574b1cca 100644 --- a/app/javascript/dashboard/i18n/locale/en/report.json +++ b/app/javascript/dashboard/i18n/locale/en/report.json @@ -20,12 +20,14 @@ "FIRST_RESPONSE_TIME": { "NAME": "First Response Time", "DESC": "( Avg )", - "INFO_TEXT": "Total number of conversations used for computation:" + "INFO_TEXT": "Total number of conversations used for computation:", + "TOOLTIP_TEXT": "First Response Time is %{metricValue} (based on %{conversationCount} conversations)" }, "RESOLUTION_TIME": { "NAME": "Resolution Time", "DESC": "( Avg )", - "INFO_TEXT": "Total number of conversations used for computation:" + "INFO_TEXT": "Total number of conversations used for computation:", + "TOOLTIP_TEXT": "Resolution Time is %{metricValue} (based on %{conversationCount} conversations)" }, "RESOLUTION_COUNT": { "NAME": "Resolution Count", @@ -103,12 +105,14 @@ "FIRST_RESPONSE_TIME": { "NAME": "First Response Time", "DESC": "( Avg )", - "INFO_TEXT": "Total number of conversations used for computation:" + "INFO_TEXT": "Total number of conversations used for computation:", + "TOOLTIP_TEXT": "First Response Time is %{metricValue} (based on %{conversationCount} conversations)" }, "RESOLUTION_TIME": { "NAME": "Resolution Time", "DESC": "( Avg )", - "INFO_TEXT": "Total number of conversations used for computation:" + "INFO_TEXT": "Total number of conversations used for computation:", + "TOOLTIP_TEXT": "Resolution Time is %{metricValue} (based on %{conversationCount} conversations)" }, "RESOLUTION_COUNT": { "NAME": "Resolution Count", @@ -168,12 +172,14 @@ "FIRST_RESPONSE_TIME": { "NAME": "First Response Time", "DESC": "( Avg )", - "INFO_TEXT": "Total number of conversations used for computation:" + "INFO_TEXT": "Total number of conversations used for computation:", + "TOOLTIP_TEXT": "First Response Time is %{metricValue} (based on %{conversationCount} conversations)" }, "RESOLUTION_TIME": { "NAME": "Resolution Time", "DESC": "( Avg )", - "INFO_TEXT": "Total number of conversations used for computation:" + "INFO_TEXT": "Total number of conversations used for computation:", + "TOOLTIP_TEXT": "Resolution Time is %{metricValue} (based on %{conversationCount} conversations)" }, "RESOLUTION_COUNT": { "NAME": "Resolution Count", @@ -233,12 +239,14 @@ "FIRST_RESPONSE_TIME": { "NAME": "First Response Time", "DESC": "( Avg )", - "INFO_TEXT": "Total number of conversations used for computation:" + "INFO_TEXT": "Total number of conversations used for computation:", + "TOOLTIP_TEXT": "First Response Time is %{metricValue} (based on %{conversationCount} conversations)" }, "RESOLUTION_TIME": { "NAME": "Resolution Time", "DESC": "( Avg )", - "INFO_TEXT": "Total number of conversations used for computation:" + "INFO_TEXT": "Total number of conversations used for computation:", + "TOOLTIP_TEXT": "Resolution Time is %{metricValue} (based on %{conversationCount} conversations)" }, "RESOLUTION_COUNT": { "NAME": "Resolution Count", @@ -298,12 +306,14 @@ "FIRST_RESPONSE_TIME": { "NAME": "First Response Time", "DESC": "( Avg )", - "INFO_TEXT": "Total number of conversations used for computation:" + "INFO_TEXT": "Total number of conversations used for computation:", + "TOOLTIP_TEXT": "First Response Time is %{metricValue} (based on %{conversationCount} conversations)" }, "RESOLUTION_TIME": { "NAME": "Resolution Time", "DESC": "( Avg )", - "INFO_TEXT": "Total number of conversations used for computation:" + "INFO_TEXT": "Total number of conversations used for computation:", + "TOOLTIP_TEXT": "Resolution Time is %{metricValue} (based on %{conversationCount} conversations)" }, "RESOLUTION_COUNT": { "NAME": "Resolution Count", @@ -372,4 +382,4 @@ } } } -} \ No newline at end of file +} diff --git a/app/javascript/dashboard/mixins/specs/reportMixin.spec.js b/app/javascript/dashboard/mixins/specs/reportMixin.spec.js index ca1c45751..aa3c451d9 100644 --- a/app/javascript/dashboard/mixins/specs/reportMixin.spec.js +++ b/app/javascript/dashboard/mixins/specs/reportMixin.spec.js @@ -25,7 +25,7 @@ describe('reportMixin', () => { const wrapper = shallowMount(Component, { store, localVue }); expect(wrapper.vm.displayMetric('conversations_count')).toEqual(5); expect(wrapper.vm.displayMetric('avg_first_response_time')).toEqual( - '3 Min' + '3 Min 18 Sec' ); }); diff --git a/app/javascript/dashboard/routes/dashboard/settings/reports/Index.vue b/app/javascript/dashboard/routes/dashboard/settings/reports/Index.vue index f9a9256f4..bc6ac48de 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/reports/Index.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/reports/Index.vue @@ -57,6 +57,7 @@ import format from 'date-fns/format'; import ReportFilterSelector from './components/FilterSelector'; import { GROUP_BY_FILTER, METRIC_CHART } from './constants'; import reportMixin from '../../../../mixins/reportMixin'; +import { formatTime } from '@chatwoot/utils'; const REPORTS_KEYS = { CONVERSATIONS: 'conversations_count', @@ -145,8 +146,22 @@ export default { }; }, chartOptions() { + let tooltips = {}; + if (this.isAverageMetricType(this.metrics[this.currentSelection].KEY)) { + tooltips.callbacks = { + label: tooltipItem => { + return this.$t(this.metrics[this.currentSelection].TOOLTIP_TEXT, { + metricValue: formatTime(tooltipItem.yLabel), + conversationCount: this.accountReport.data[tooltipItem.index] + .count, + }); + }, + }; + } + return { scales: METRIC_CHART[this.metrics[this.currentSelection].KEY].scales, + tooltips: tooltips, }; }, metrics() { @@ -158,11 +173,18 @@ export default { 'RESOLUTION_TIME', 'RESOLUTION_COUNT', ]; + const infoText = { + FIRST_RESPONSE_TIME: this.$t( + `REPORT.METRICS.FIRST_RESPONSE_TIME.INFO_TEXT` + ), + RESOLUTION_TIME: this.$t(`REPORT.METRICS.RESOLUTION_TIME.INFO_TEXT`), + }; return reportKeys.map(key => ({ NAME: this.$t(`REPORT.METRICS.${key}.NAME`), KEY: REPORTS_KEYS[key], DESC: this.$t(`REPORT.METRICS.${key}.DESC`), - INFO_TEXT: this.$t(`REPORT.METRICS.${key}.INFO_TEXT`), + INFO_TEXT: infoText[key], + TOOLTIP_TEXT: `REPORT.METRICS.${key}.TOOLTIP_TEXT`, })); }, }, diff --git a/app/javascript/dashboard/routes/dashboard/settings/reports/components/ReportFilters.vue b/app/javascript/dashboard/routes/dashboard/settings/reports/components/ReportFilters.vue index 0bfeae8a1..c0b87e19b 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/reports/components/ReportFilters.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/reports/components/ReportFilters.vue @@ -148,9 +148,9 @@