From 1038d1500ea2ea4738c03849b9699b77f7b03666 Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Tue, 9 Apr 2024 05:44:36 +0530 Subject: [PATCH] feat: SLA reports view (#9189) * feat: SLA report table * feat: Add SLA popover card * feat: Update popover position * feat: Add loader * Update SLACardLabel.vue * feat: Update column order * chore: fix conditions * Update SLATable.vue * chore: enable reports in ui * chore: Revamp report SLA apis * chore: revert download method * chore: improve the code * Update enterprise/app/views/api/v1/accounts/applied_slas/download.csv.erb Co-authored-by: Vishnu Narayanan * chore: style fixes * chore: fix specs * feat: Add number of conversations * chore: review comments * fix: translation * Update app/javascript/dashboard/i18n/locale/en/report.json Co-authored-by: Vishnu Narayanan * Update app/javascript/dashboard/i18n/locale/en/report.json Co-authored-by: Vishnu Narayanan * Update app/javascript/dashboard/i18n/locale/en/report.json Co-authored-by: Vishnu Narayanan * Update SLAReportItem.vue * Update report.json * Update package.json * chore: review comments * chore: remove unused translation * feat: Add TableHeaderCell component * chore: more review fixes * Update app/javascript/dashboard/components/widgets/TableHeaderCell.vue Co-authored-by: Shivam Mishra * Update TableHeaderCell.vue --------- Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: Vishnu Narayanan Co-authored-by: Shivam Mishra --- .../layout/config/sidebarItems/reports.js | 9 ++ .../components/widgets/TableHeaderCell.vue | 39 ++++++ .../conversationCardComponents/CardLabels.vue | 5 + .../dashboard/i18n/locale/en/report.json | 20 +++- .../dashboard/i18n/locale/en/settings.json | 1 + .../mixins/conversation/labelMixin.js | 4 + .../dashboard/settings/reports/SLAReports.vue | 78 ++++++++++++ .../reports/components/FilterSelector.vue | 4 +- .../reports/components/SLA/SLAMetrics.vue | 17 ++- .../components/SLA/SLAReportFilters.vue | 91 ++++++++++++++ .../reports/components/SLA/SLAReportItem.vue | 59 +++++++++ .../reports/components/SLA/SLATable.vue | 112 ++++++++++++++++++ .../reports/components/SLA/SLAViewDetails.vue | 55 +++++++++ .../settings/reports/reports.routes.js | 18 +++ .../dashboard/store/modules/SLAReports.js | 19 +-- .../modules/specs/slaReports/getters.spec.js | 29 +++++ .../specs/slaReports/mutations.spec.js | 8 +- .../v1/accounts/applied_slas_controller.rb | 46 ++++--- enterprise/app/models/applied_sla.rb | 2 +- .../v1/accounts/applied_slas/download.csv.erb | 6 +- .../accounts/applied_slas/index.json.jbuilder | 32 +++-- .../applied_slas/metrics.json.jbuilder | 2 +- package.json | 2 +- .../accounts/applied_slas_controller_spec.rb | 49 ++++---- 24 files changed, 623 insertions(+), 84 deletions(-) create mode 100644 app/javascript/dashboard/components/widgets/TableHeaderCell.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/reports/SLAReports.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/reports/components/SLA/SLAReportFilters.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/reports/components/SLA/SLAReportItem.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/reports/components/SLA/SLATable.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/reports/components/SLA/SLAViewDetails.vue diff --git a/app/javascript/dashboard/components/layout/config/sidebarItems/reports.js b/app/javascript/dashboard/components/layout/config/sidebarItems/reports.js index 551256c74..e7e4997fd 100644 --- a/app/javascript/dashboard/components/layout/config/sidebarItems/reports.js +++ b/app/javascript/dashboard/components/layout/config/sidebarItems/reports.js @@ -12,6 +12,7 @@ const reports = accountId => ({ 'label_reports', 'inbox_reports', 'team_reports', + 'sla_reports', ], menuItems: [ { @@ -71,6 +72,14 @@ const reports = accountId => ({ toState: frontendURL(`accounts/${accountId}/reports/teams`), toStateName: 'team_reports', }, + { + icon: 'document-list-clock', + label: 'REPORTS_SLA', + hasSubMenu: false, + featureFlag: FEATURE_FLAGS.SLA, + toState: frontendURL(`accounts/${accountId}/reports/sla`), + toStateName: 'sla_reports', + }, ], }); diff --git a/app/javascript/dashboard/components/widgets/TableHeaderCell.vue b/app/javascript/dashboard/components/widgets/TableHeaderCell.vue new file mode 100644 index 000000000..8e2cd6326 --- /dev/null +++ b/app/javascript/dashboard/components/widgets/TableHeaderCell.vue @@ -0,0 +1,39 @@ + + diff --git a/app/javascript/dashboard/components/widgets/conversation/conversationCardComponents/CardLabels.vue b/app/javascript/dashboard/components/widgets/conversation/conversationCardComponents/CardLabels.vue index c94e5389b..079d1c7bf 100644 --- a/app/javascript/dashboard/components/widgets/conversation/conversationCardComponents/CardLabels.vue +++ b/app/javascript/dashboard/components/widgets/conversation/conversationCardComponents/CardLabels.vue @@ -46,6 +46,11 @@ export default { type: Number, required: true, }, + conversationLabels: { + type: String, + required: false, + default: '', + }, }, data() { return { diff --git a/app/javascript/dashboard/i18n/locale/en/report.json b/app/javascript/dashboard/i18n/locale/en/report.json index c41e8b8a1..27beaa9ef 100644 --- a/app/javascript/dashboard/i18n/locale/en/report.json +++ b/app/javascript/dashboard/i18n/locale/en/report.json @@ -508,15 +508,29 @@ }, "SLA_REPORTS": { "HEADER": "SLA Reports", + "NO_RECORDS": "SLA applied conversations are not available.", + "LOADING": "Loading SLA data...", "METRICS": { "HIT_RATE": { "LABEL": "Hit Rate", "TOOLTIP": "Percentage of SLAs created were completed successfully" }, - "NO_OF_BREACHES": { - "LABEL": "Number of Breaches", - "TOOLTIP": "The total SLA breaches in a certain period." + "NO_OF_MISSES": { + "LABEL": "Number of Misses", + "TOOLTIP": "Total SLA misses in a certain period" + }, + "NO_OF_CONVERSATIONS": { + "LABEL": "Number of Conversations", + "TOOLTIP": "Total number of conversations with SLA" } + }, + "TABLE": { + "HEADER": { + "POLICY": "Policy", + "CONVERSATION": "Conversation", + "AGENT": "Agent" + }, + "VIEW_DETAILS": "View Details" } } } diff --git a/app/javascript/dashboard/i18n/locale/en/settings.json b/app/javascript/dashboard/i18n/locale/en/settings.json index d9834c545..e9ac56f2a 100644 --- a/app/javascript/dashboard/i18n/locale/en/settings.json +++ b/app/javascript/dashboard/i18n/locale/en/settings.json @@ -240,6 +240,7 @@ "CAMPAIGNS": "Campaigns", "ONGOING": "Ongoing", "ONE_OFF": "One off", + "REPORTS_SLA": "SLA", "REPORTS_BOT": "Bot", "REPORTS_AGENT": "Agents", "REPORTS_LABEL": "Labels", diff --git a/app/javascript/dashboard/mixins/conversation/labelMixin.js b/app/javascript/dashboard/mixins/conversation/labelMixin.js index 5d0e17507..6c9e954b6 100644 --- a/app/javascript/dashboard/mixins/conversation/labelMixin.js +++ b/app/javascript/dashboard/mixins/conversation/labelMixin.js @@ -4,6 +4,10 @@ export default { computed: { ...mapGetters({ accountLabels: 'labels/getLabels' }), savedLabels() { + // If conversationLabels is passed as prop, use it + if (this.conversationLabels) + return this.conversationLabels.split(',').map(item => item.trim()); + // Otherwise, get labels from store return this.$store.getters['conversationLabels/getConversationLabels']( this.conversationId ); diff --git a/app/javascript/dashboard/routes/dashboard/settings/reports/SLAReports.vue b/app/javascript/dashboard/routes/dashboard/settings/reports/SLAReports.vue new file mode 100644 index 000000000..3c1f3775f --- /dev/null +++ b/app/javascript/dashboard/routes/dashboard/settings/reports/SLAReports.vue @@ -0,0 +1,78 @@ + + diff --git a/app/javascript/dashboard/routes/dashboard/settings/reports/components/FilterSelector.vue b/app/javascript/dashboard/routes/dashboard/settings/reports/components/FilterSelector.vue index 84bae6198..0116f54d6 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/reports/components/FilterSelector.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/reports/components/FilterSelector.vue @@ -1,6 +1,8 @@