From 20ee2e87ca0f007265139e71db0d429e1463bdbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denny=20Korsuk=C3=A9witz?= Date: Wed, 4 Sep 2019 11:30:46 +0200 Subject: [PATCH] Fixes #1010 - display only used channels in dashboard --- .../stats/ticket_channel_distribution.coffee | 27 +++++--- .../stats/ticket_channel_distribution.jst.eco | 18 ++--- app/assets/stylesheets/zammad.scss | 43 ++++++++---- lib/stats/ticket_channel_distribution.rb | 68 ++++++++++++++++--- 4 files changed, 113 insertions(+), 43 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_dashboard/stats/ticket_channel_distribution.coffee b/app/assets/javascripts/app/controllers/_dashboard/stats/ticket_channel_distribution.coffee index 8ffceb062..105ba213b 100644 --- a/app/assets/javascripts/app/controllers/_dashboard/stats/ticket_channel_distribution.coffee +++ b/app/assets/javascripts/app/controllers/_dashboard/stats/ticket_channel_distribution.coffee @@ -15,21 +15,26 @@ class Stats extends App.Controller data.StatsTicketChannelDistribution = channels: 1: - inbound: 1 - outbound: 0 - inbound_in_percent: 0 + icon: 'email' + sender: 'email' + inbound: 0 + outbound: 0 + inbound_in_percent: 0 outbound_in_percent: 0 2: - inbound: 0 - outbound: 0 - inbound_in_percent: 0 - outbound_in_percent: 0 - 3: - inbound: 2 - outbound: 0 - inbound_in_percent: 0 + icon: 'phone' + sender: 'phone' + inbound: 0 + outbound: 0 + inbound_in_percent: 0 outbound_in_percent: 0 + totalTickets = _.reduce data.StatsTicketChannelDistribution.channels, ((memo, channel) -> memo + channel.inbound + channel.outbound), 0 + totalChannels = _.size data.StatsTicketChannelDistribution.channels + + for id, channel of data.StatsTicketChannelDistribution.channels + channel.overal_percentage = Math.round((channel.inbound + channel.outbound) / totalTickets * 100) + data.StatsTicketChannelDistribution.description = 'How many of your tickets are coming from email, phone, Twitter, or Facebook? (Shows percentages for both inbound and outbound tickets.)' content = App.view('dashboard/stats/ticket_channel_distribution')(data) diff --git a/app/assets/javascripts/app/views/dashboard/stats/ticket_channel_distribution.jst.eco b/app/assets/javascripts/app/views/dashboard/stats/ticket_channel_distribution.jst.eco index 7567746f6..92efdd2de 100644 --- a/app/assets/javascripts/app/views/dashboard/stats/ticket_channel_distribution.jst.eco +++ b/app/assets/javascripts/app/views/dashboard/stats/ticket_channel_distribution.jst.eco @@ -6,15 +6,17 @@ <%- @Icon('help') %> -
- <% for channel_name, channel of @StatsTicketChannelDistribution.channels: %> -