From f58503171707eb0cbed6fa7361b1a07aba106a8c Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 20 Oct 2015 13:54:29 +0200 Subject: [PATCH 1/4] Fixed initial setups. --- db/seeds.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/db/seeds.rb b/db/seeds.rb index 6bf34ec19..8824661ea 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1487,6 +1487,13 @@ Role.create_if_not_exists( updated_by_id: 1, created_by_id: 1 ) +Role.create_if_not_exists( + id: 4, + name: 'Report', + note: 'Access the report area.', + created_by_id: 1, + updated_by_id: 1, +) Group.create_if_not_exists( id: 1, @@ -1862,6 +1869,14 @@ Channel.create_if_not_exists( active: true, ) +Report::Profile.create_if_not_exists( + name: '-all-', + condition: {}, + active: true, + updated_by_id: 1, + created_by_id: 1, +) + network = Network.create_if_not_exists( id: 1, name: 'base', From ce6f868ba5f7443f453df25c8b6d6e62719183cd Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 20 Oct 2015 13:55:23 +0200 Subject: [PATCH 2/4] Replaced active with is-active class. --- .../app/controllers/report.js.coffee | 34 +++++++++---------- .../app/views/report/download_header.jst.eco | 2 +- .../app/views/report/time_picker.jst.eco | 8 ++--- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/app/assets/javascripts/app/controllers/report.js.coffee b/app/assets/javascripts/app/controllers/report.js.coffee index f6564eec9..3d63b9357 100644 --- a/app/assets/javascripts/app/controllers/report.js.coffee +++ b/app/assets/javascripts/app/controllers/report.js.coffee @@ -212,15 +212,15 @@ class Download extends App.Controller active = false @el.find('.js-dataDownloadBackendSelector').each( (index, element) -> - if $(element).parent().hasClass('active') + if $(element).parent().hasClass('is-active') active = true ) if !active - @el.find('.js-dataDownloadBackendSelector').first().parent().addClass('active') + @el.find('.js-dataDownloadBackendSelector').first().parent().addClass('is-active') # rerender view after backend is selected @el.find('.js-dataDownloadBackendSelector').each( (index, element) => - if $(element).parent().hasClass('active') + if $(element).parent().hasClass('is-active') @profileSelectedId = $(element).data('profile-id') @backendSelected = $(element).data('backend') ) @@ -230,8 +230,8 @@ class Download extends App.Controller tableUpdate: (e) => if e e.preventDefault() - @el.find('.js-dataDownloadBackendSelector').parent().removeClass('active') - $(e.target).parent().addClass('active') + @el.find('.js-dataDownloadBackendSelector').parent().removeClass('is-active') + $(e.target).parent().addClass('is-active') @profileSelectedId = $(e.target).data('profile-id') @backendSelected = $(e.target).data('backend') @@ -297,8 +297,8 @@ class TimeRangePicker extends App.Controller @html App.view('report/time_range_picker')() # select time slot - @el.find('.js-timeRange').removeClass('active') - @el.find('.js-timeRange[data-type="' + @ui.params.timeRange + '"]').addClass('active') + @el.find('.js-timeRange').removeClass('is-active') + @el.find('.js-timeRange[data-type="' + @ui.params.timeRange + '"]').addClass('is-active') select: (e) => console.log('TS click') @@ -336,35 +336,35 @@ class TimePicker extends App.Controller ) # select time slot - @el.find('.time-slot').removeClass('active') - @el.find('.time-slot[data-type="' + @ui.params.timeRange + '"]').addClass('active') + @el.find('.time-slot').removeClass('is-active') + @el.find('.time-slot[data-type="' + @ui.params.timeRange + '"]').addClass('is-active') selectTimeDay: (e) => e.preventDefault() @ui.params.day = $(e.target).data('type') - $(e.target).parent().parent().find('li').removeClass('active') - $(e.target).parent().addClass('active') + $(e.target).parent().parent().find('li').removeClass('is-active') + $(e.target).parent().addClass('is-active') App.Event.trigger( 'ui:report:rerender' ) selectTimeMonth: (e) => e.preventDefault() @ui.params.month = $(e.target).data('type') - $(e.target).parent().parent().find('li').removeClass('active') - $(e.target).parent().addClass('active') + $(e.target).parent().parent().find('li').removeClass('is-active') + $(e.target).parent().addClass('is-active') App.Event.trigger( 'ui:report:rerender' ) selectTimeWeek: (e) => e.preventDefault() @ui.params.week = $(e.target).data('type') - $(e.target).parent().parent().find('li').removeClass('active') - $(e.target).parent().addClass('active') + $(e.target).parent().parent().find('li').removeClass('is-active') + $(e.target).parent().addClass('is-active') App.Event.trigger( 'ui:report:rerender' ) selectTimeYear: (e) => e.preventDefault() @ui.params.year = $(e.target).data('type') - $(e.target).parent().parent().find('li').removeClass('active') - $(e.target).parent().addClass('active') + $(e.target).parent().parent().find('li').removeClass('is-active') + $(e.target).parent().addClass('is-active') App.Event.trigger( 'ui:report:rerender' ) _timeSlotPicker: -> diff --git a/app/assets/javascripts/app/views/report/download_header.jst.eco b/app/assets/javascripts/app/views/report/download_header.jst.eco index 2c06034c9..d772fe768 100644 --- a/app/assets/javascripts/app/views/report/download_header.jst.eco +++ b/app/assets/javascripts/app/views/report/download_header.jst.eco @@ -4,7 +4,7 @@ <% for profile in @profiles: %> <% for backend in @metric.backend: %> <% if backend.dataDownload: %> -
  • <%= @T(backend.display) %>
  • +
  • <%= @T(backend.display) %>
  • <% end %> <% end %> <% end %> diff --git a/app/assets/javascripts/app/views/report/time_picker.jst.eco b/app/assets/javascripts/app/views/report/time_picker.jst.eco index 707fc5220..7e015223a 100644 --- a/app/assets/javascripts/app/views/report/time_picker.jst.eco +++ b/app/assets/javascripts/app/views/report/time_picker.jst.eco @@ -2,7 +2,7 @@ <% if @params.timeRange is 'day': %>
    <% for item in @timeRangeDay: %> - + <% end %>

    @@ -11,7 +11,7 @@ <% if @params.timeRange is 'day' || @params.timeRange is 'month': %>
    <% for item in @timeRangeMonth: %> - + <% end %>

    @@ -20,7 +20,7 @@ <% if @params.timeRange is 'week': %>
    <% for item in @timeRangeWeek: %> - + <% end %>

    @@ -29,7 +29,7 @@ <% if @params.timeRange isnt 'realtime': %>
    <% for item in @timeRangeYear: %> - + <% end %>
    <% end %> From 78fc282051e03a5d049100d807b4e86438cf3e4e Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 20 Oct 2015 13:55:49 +0200 Subject: [PATCH 3/4] Fixed realtime range check. --- app/controllers/reports_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 2ae053ef0..612f991fa 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -117,7 +117,8 @@ class ReportsController < ApplicationController match = false result['aggregations']['time_buckets']['buckets'].each {|item| if interval == 'minute' - start_string = start.iso8601.sub(/:\d\d.+?$/, '') + item['key_as_string'] = item['key_as_string'].sub(/:\d\d.\d\d\dZ$/, '') + start_string = start.iso8601.sub(/:\d\dZ$/, '') else start_string = start.iso8601.sub(/:\d\d:\d\d.+?$/, '') end From 563789135f384186b6601d34edb6d35f669511e7 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 20 Oct 2015 14:58:04 +0200 Subject: [PATCH 4/4] Implemented download list --- .../app/controllers/report.js.coffee | 50 ++++++------------- .../app/views/report/download_header.jst.eco | 2 +- .../app/views/report/download_list.jst.eco | 6 +-- app/controllers/reports_controller.rb | 16 ++++-- app/models/report.rb | 26 +++++----- 5 files changed, 43 insertions(+), 57 deletions(-) diff --git a/app/assets/javascripts/app/controllers/report.js.coffee b/app/assets/javascripts/app/controllers/report.js.coffee index 3d63b9357..e3f3ebfd7 100644 --- a/app/assets/javascripts/app/controllers/report.js.coffee +++ b/app/assets/javascripts/app/controllers/report.js.coffee @@ -188,11 +188,12 @@ class Download extends App.Controller reports = [] # select first backend, if no backend is selected - $('.js-backendSelector:checked').each( (index, element) -> - if $(element).hasClass('download') - value = $(element).val() - reports.push value - ) + @backendSelected = undefined + if @config.metric[@params.metric] + for backend in @config.metric[@params.metric].backend + console.log('bac', backend) + if backend.dataDownload && !@backendSelected + @backendSelected = backend.name # get used profiles profiles = [] @@ -203,26 +204,10 @@ class Download extends App.Controller profiles.push App.ReportProfile.find(key) @html App.view('report/download_header')( - reports: reports - profiles: profiles - metric: @config.metric[@params.metric] - ) - - @backendSelected = '' - - active = false - @el.find('.js-dataDownloadBackendSelector').each( (index, element) -> - if $(element).parent().hasClass('is-active') - active = true - ) - if !active - @el.find('.js-dataDownloadBackendSelector').first().parent().addClass('is-active') - - # rerender view after backend is selected - @el.find('.js-dataDownloadBackendSelector').each( (index, element) => - if $(element).parent().hasClass('is-active') - @profileSelectedId = $(element).data('profile-id') - @backendSelected = $(element).data('backend') + reports: reports + profiles: profiles + backendSelected: @backendSelected + metric: @config.metric[@params.metric] ) @tableUpdate() @@ -240,7 +225,7 @@ class Download extends App.Controller if App.Config.get('import_mode') url = App.Config.get('import_otrs_endpoint') + '/index.pl?Action=AgentTicketZoom;TicketID=' if _.isEmpty(tickets) - @el.find('js-dataDownloadTable').html('') + @el.find('.js-dataDownloadTable').html('') else html = App.view('report/download_list')( tickets: tickets @@ -248,7 +233,7 @@ class Download extends App.Controller url: url download: @apiPath + '/reports/csvforset/' + name ) - @el.find('js-dataDownloadTable').html(html) + @el.find('.js-dataDownloadTable').html(html) @startLoading() @ajax( @@ -267,14 +252,11 @@ class Download extends App.Controller processData: true success: (data) => @stopLoading() - - # load ticket collection / do not save in localStorage - App.Collection.load( type: 'TicketReport', data: data.tickets, localStorage: true ) + App.Collection.loadAssets(data.assets) ticket_collection = [] - - if data.tickets - for record in data.tickets - ticket = App.TicketReport.fullLocal( record.id ) + if data.ticket_ids + for record_id in data.ticket_ids + ticket = App.Ticket.fullLocal( record_id ) ticket_collection.push ticket table(ticket_collection, data.count) diff --git a/app/assets/javascripts/app/views/report/download_header.jst.eco b/app/assets/javascripts/app/views/report/download_header.jst.eco index d772fe768..03e04c277 100644 --- a/app/assets/javascripts/app/views/report/download_header.jst.eco +++ b/app/assets/javascripts/app/views/report/download_header.jst.eco @@ -4,7 +4,7 @@ <% for profile in @profiles: %> <% for backend in @metric.backend: %> <% if backend.dataDownload: %> -
  • <%= @T(backend.display) %>
  • +
  • class="is-active active"<% end %>><%= @T(backend.display) %>
  • <% end %> <% end %> <% end %> diff --git a/app/assets/javascripts/app/views/report/download_list.jst.eco b/app/assets/javascripts/app/views/report/download_list.jst.eco index 8fcbda5c7..ef18cdebc 100644 --- a/app/assets/javascripts/app/views/report/download_list.jst.eco +++ b/app/assets/javascripts/app/views/report/download_list.jst.eco @@ -1,7 +1,5 @@ <%- @T('%s records', @count) %> - - - + <%- @Icon('download') %> @@ -15,7 +13,7 @@ <% for ticket in @tickets: %> - + diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 612f991fa..787361c6b 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -76,12 +76,18 @@ class ReportsController < ApplicationController end # get data - + ticket_ids = [] + assets = {} + Ticket.select('id').all.each {|ticket_part| + ticket = Ticket.lookup(id: ticket_part.id) + assets = ticket.assets(assets) + ticket_ids.push ticket_part.id + } + count = Ticket.count render json: { - data: { - start: start, - stop: stop, - } + ticket_ids: ticket_ids, + assets: assets, + count: count, } end diff --git a/app/models/report.rb b/app/models/report.rb index 22cb72ff2..3f33539a9 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -123,36 +123,36 @@ class Report name: 'first_response_average', display: 'First Response average', selected: true, - dataDownload: true, + dataDownload: false, }, { name: 'first_response_max', display: 'First Response max', - selected: true, + selected: false, dataDownload: true, }, { name: 'first_response_min', display: 'First Response min', - selected: true, + selected: false, dataDownload: true, }, { name: 'solution_time_average', display: 'Solution Time average', selected: true, - dataDownload: true, + dataDownload: false, }, { name: 'solution_time_max', display: 'Solution Time max', - selected: true, + selected: false, dataDownload: true, }, { name: 'solution_time_min', display: 'Solution Time min', - selected: true, + selected: false, dataDownload: true, }, ] @@ -168,43 +168,43 @@ class Report name: 'phone_in', display: 'Phone (in)', selected: true, - dataDownload: true, + dataDownload: false, }, { name: 'phone_out', display: 'Phone (out)', selected: true, - dataDownload: true, + dataDownload: false, }, { name: 'email_in', display: 'Email (in)', selected: true, - dataDownload: true, + dataDownload: false, }, { name: 'email_out', display: 'Email (out)', selected: true, - dataDownload: true, + dataDownload: false, }, { name: 'web_in', display: 'Web (in)', selected: true, - dataDownload: true, + dataDownload: false, }, { name: 'twitter_in', display: 'Twitter (in)', selected: true, - dataDownload: true, + dataDownload: false, }, { name: 'twitter_out', display: 'Twitter (out)', selected: true, - dataDownload: true, + dataDownload: false, }, ] config[:metric][:communication][:backend] = backend
    <%- @P(ticket, 'number') %>target="_blank"<% end %> href="<%= @url %><%= ticket.id %>"><%- @P(ticket, 'number') %> <%- @P(ticket, 'title') %> <%- @P(ticket, 'state') %> <%- @P(ticket, 'group') %>