From: Stas Vilchik Date: Fri, 24 Oct 2014 15:23:43 +0000 (+0200) Subject: SONAR-5627 Feedback applied X-Git-Tag: 5.0-RC1~584 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8c9bc62d2ed2fb3a2cdce61b4592d04addd47c3c;p=sonarqube.git SONAR-5627 Feedback applied --- diff --git a/server/sonar-web/src/main/coffee/analysis-reports/app.coffee b/server/sonar-web/src/main/coffee/analysis-reports/app.coffee index 4a82e4479ca..f0c19a1d9f6 100644 --- a/server/sonar-web/src/main/coffee/analysis-reports/app.coffee +++ b/server/sonar-web/src/main/coffee/analysis-reports/app.coffee @@ -19,6 +19,7 @@ requirejs.config requirejs [ 'backbone', 'backbone.marionette' + 'analysis-reports/router' 'analysis-reports/layout' 'analysis-reports/models/reports' 'analysis-reports/views/reports-view' @@ -28,6 +29,7 @@ requirejs [ 'common/handlebars-extensions' ], ( Backbone, Marionette + Router Layout Reports ReportsView @@ -44,36 +46,47 @@ requirejs [ App.fetchReports = -> + process = window.process.addBackgroundProcess() fetch = if @state.get 'active' then @reports.fetchActive() else @reports.fetchHistory() @layout.showSpinner 'actionsRegion' @layout.resultsRegion.reset() fetch.done => + @state.set page: @reports.paging.page @reportsView = new ReportsView app: @ collection: @reports @layout.resultsRegion.show @reportsView + @reportsView.bindScrollEvents() unless @state.get 'active' @actionsView = new ActionsView app: @ collection: @reports @layout.actionsRegion.show @actionsView + @layout.onResize() + + window.process.finishBackgroundProcess process + + + App.fetchNextPage = -> + process = window.process.addBackgroundProcess() + @reports.fetchHistory + data: + p: @state.get('page') + 1 + remove: false + .done => + @state.set page: @reports.paging.page + window.process.finishBackgroundProcess process + App.addInitializer -> - @state = new Backbone.Model active: true + @state = new Backbone.Model() @state.on 'change:active', => @fetchReports() App.addInitializer -> @layout = new Layout app: @ jQuery('#analysis-reports').empty().append @layout.render().el - @layout.onResize() - - - App.addInitializer -> - @reports = new Reports() - @fetchReports() - setInterval (=> @fetchReports()), 30000 # Once every 30s App.addInitializer -> @@ -81,6 +94,11 @@ requirejs [ @layout.headerRegion.show @headerView + App.addInitializer -> + @reports = new Reports() + @router = new Router app: @ + Backbone.history.start() + l10nXHR = window.requestMessages() jQuery.when(l10nXHR).done -> App.start() diff --git a/server/sonar-web/src/main/coffee/analysis-reports/layout.coffee b/server/sonar-web/src/main/coffee/analysis-reports/layout.coffee index 2ce017d04d7..147522cd7bb 100644 --- a/server/sonar-web/src/main/coffee/analysis-reports/layout.coffee +++ b/server/sonar-web/src/main/coffee/analysis-reports/layout.coffee @@ -31,8 +31,7 @@ define [ footerHeight = footerEl.outerHeight true resultsEl = @ui.results - resultsHeight = jQuery(window).height() - resultsEl.offset().top - - parseInt(resultsEl.css('margin-bottom'), 10) - footerHeight + resultsHeight = jQuery(window).height() - resultsEl.offset().top - footerHeight resultsEl.height resultsHeight diff --git a/server/sonar-web/src/main/coffee/analysis-reports/models/reports.coffee b/server/sonar-web/src/main/coffee/analysis-reports/models/reports.coffee index fd0ef350cfd..cbaeec3df68 100644 --- a/server/sonar-web/src/main/coffee/analysis-reports/models/reports.coffee +++ b/server/sonar-web/src/main/coffee/analysis-reports/models/reports.coffee @@ -12,7 +12,11 @@ define [ parse: (r) -> - @paging = r.paging + @paging = + page: r.p + pageSize: r.ps + total: r.total + maxResultsReached: r.p * r.ps >= r.total r.reports @@ -20,5 +24,7 @@ define [ @fetch { url: "#{baseUrl}/api/analysis_reports/active" }, { reset: true } - fetchHistory: -> - @fetch { url: "#{baseUrl}/api/analysis_reports/history" }, { reset: true } + fetchHistory: (options = { }) -> + _.extend options, + url: "#{baseUrl}/api/analysis_reports/history" + @fetch options, { reset: true } diff --git a/server/sonar-web/src/main/coffee/analysis-reports/router.coffee b/server/sonar-web/src/main/coffee/analysis-reports/router.coffee new file mode 100644 index 00000000000..db11154c188 --- /dev/null +++ b/server/sonar-web/src/main/coffee/analysis-reports/router.coffee @@ -0,0 +1,26 @@ +define [ + 'backbone', +], ( + Backbone, +) -> + + class AppRouter extends Backbone.Router + + routes: + '': 'showCurrent' + 'current': 'showCurrent' + 'past': 'showPast' + + + initialize: (options) -> + @options = options + + + showCurrent: -> + @navigate 'current' + @options.app.state.set active: true + + + showPast: -> + @navigate 'past' + @options.app.state.set active: false diff --git a/server/sonar-web/src/main/coffee/analysis-reports/views/actions-view.coffee b/server/sonar-web/src/main/coffee/analysis-reports/views/actions-view.coffee index 345c8a0728a..237485c18e6 100644 --- a/server/sonar-web/src/main/coffee/analysis-reports/views/actions-view.coffee +++ b/server/sonar-web/src/main/coffee/analysis-reports/views/actions-view.coffee @@ -21,14 +21,14 @@ define [ showPastReports: -> - @options.app.state.set active: false + @options.app.router.navigate 'past', trigger: true showCurrentActivity: -> - @options.app.state.set active: true + @options.app.router.navigate 'current', trigger: true serializeData: -> _.extend super, state: @options.app.state.toJSON() - total: if @collection.paging then @collection.paging.total else @collection.length + total: @collection.paging.total || 0 diff --git a/server/sonar-web/src/main/coffee/analysis-reports/views/report-view.coffee b/server/sonar-web/src/main/coffee/analysis-reports/views/report-view.coffee index 9215879a4f4..25b2680bf29 100644 --- a/server/sonar-web/src/main/coffee/analysis-reports/views/report-view.coffee +++ b/server/sonar-web/src/main/coffee/analysis-reports/views/report-view.coffee @@ -17,3 +17,17 @@ define [ @$el.addClass 'analysis-reports-report-working' if status is 'WORKING' @$el.addClass 'analysis-reports-report-done' if status is 'SUCCESS' @$el.addClass 'analysis-reports-report-failed' if status is 'FAIL' + + + serializeData: -> + duration = null + if @model.has('startedAt') && @model.has('finishedAt') + startedAtMoment = moment @model.get 'startedAt' + finishedAtMoment = moment @model.get 'finishedAt' + duration = finishedAtMoment.diff startedAtMoment + duration = + seconds: Math.floor (duration / 1000) % 60 + minutes: Math.floor (duration / (1000 * 60)) % 60 + hours: Math.floor (duration / (1000 * 60 * 60)) % 24 + _.extend super, + duration: duration diff --git a/server/sonar-web/src/main/coffee/analysis-reports/views/reports-empty-view.coffee b/server/sonar-web/src/main/coffee/analysis-reports/views/reports-empty-view.coffee new file mode 100644 index 00000000000..da789ce358f --- /dev/null +++ b/server/sonar-web/src/main/coffee/analysis-reports/views/reports-empty-view.coffee @@ -0,0 +1,11 @@ +define [ + 'backbone.marionette' + 'templates/analysis-reports' +], ( + Marionette + Templates +) -> + + class extends Marionette.ItemView + tagName: 'li' + template: Templates['analysis-reports-empty'] diff --git a/server/sonar-web/src/main/coffee/analysis-reports/views/reports-view.coffee b/server/sonar-web/src/main/coffee/analysis-reports/views/reports-view.coffee index 5da4e03a34c..adc40931436 100644 --- a/server/sonar-web/src/main/coffee/analysis-reports/views/reports-view.coffee +++ b/server/sonar-web/src/main/coffee/analysis-reports/views/reports-view.coffee @@ -1,16 +1,45 @@ define [ 'backbone.marionette' 'analysis-reports/views/report-view' + 'analysis-reports/views/reports-empty-view' ], ( Marionette ReportView + EmptyView ) -> + $ = jQuery + + class extends Marionette.CollectionView tagName: 'ol' className: 'navigator-results-list' itemView: ReportView + emptyView: EmptyView itemViewOptions: -> listView: @, app: @options.app + + + initialize: -> + @loadMoreThrottled = _.throttle @loadMore, 200 + + + onClose: -> + @unbindScrollEvents() + + + bindScrollEvents: -> + $('.navigator-results').on 'scroll', (=> @loadMoreThrottled()) + + + unbindScrollEvents: -> + $('.navigator-results').off 'scroll' + + + loadMore: -> + if $('.navigator-results').scrollTop() + $('.navigator-results').outerHeight() >= $('.navigator-results-list').outerHeight() - 40 + @unbindScrollEvents() + @options.app.fetchNextPage().done => + @bindScrollEvents() unless @collection.paging.maxResultsReached diff --git a/server/sonar-web/src/main/hbs/analysis-reports/analysis-reports-empty.hbs b/server/sonar-web/src/main/hbs/analysis-reports/analysis-reports-empty.hbs new file mode 100644 index 00000000000..00cb7e82333 --- /dev/null +++ b/server/sonar-web/src/main/hbs/analysis-reports/analysis-reports-empty.hbs @@ -0,0 +1 @@ +
  • No reports to show
  • diff --git a/server/sonar-web/src/main/hbs/analysis-reports/analysis-reports-header.hbs b/server/sonar-web/src/main/hbs/analysis-reports/analysis-reports-header.hbs index 06e2dbf1862..9eec52a18e4 100644 --- a/server/sonar-web/src/main/hbs/analysis-reports/analysis-reports-header.hbs +++ b/server/sonar-web/src/main/hbs/analysis-reports/analysis-reports-header.hbs @@ -1 +1,2 @@

    {{t 'analysis_reports.page'}}

    + diff --git a/server/sonar-web/src/main/hbs/analysis-reports/analysis-reports-report.hbs b/server/sonar-web/src/main/hbs/analysis-reports/analysis-reports-report.hbs index c58a92151d2..fc2cf616177 100644 --- a/server/sonar-web/src/main/hbs/analysis-reports/analysis-reports-report.hbs +++ b/server/sonar-web/src/main/hbs/analysis-reports/analysis-reports-report.hbs @@ -4,23 +4,21 @@ {{projectName}} - {{#if submittedAt}} - - Submitted: {{dt submittedAt}} - - {{/if}} + + {{#if submittedAt}}Submitted: {{dt submittedAt}}
    {{/if}} + {{#if startedAt}}Started: {{dt startedAt}}
    {{/if}} + {{#if finishedAt}}Finished: {{dt finishedAt}}
    {{/if}} +
    - {{#if startedAt}} + {{#if duration}} - Started: {{dt startedAt}} + Duration: + {{#gt duration.hours 0}}{{duration.hours}}h{{/gt}} + {{#gt duration.minutes 0}}{{duration.minutes}}m{{/gt}} + {{duration.seconds}}s {{/if}} - {{#if finishedAt}} - - Finished: {{dt finishedAt}} - - {{/if}}
    {{id}} {{status}}
    diff --git a/server/sonar-web/src/main/less/navigator/base.less b/server/sonar-web/src/main/less/navigator/base.less index 1adb6a0ba17..1613a496c5e 100644 --- a/server/sonar-web/src/main/less/navigator/base.less +++ b/server/sonar-web/src/main/less/navigator/base.less @@ -163,6 +163,7 @@ .navigator-header-description { display: inline-block; vertical-align: middle; + max-width: 70%; margin-left: 16px; font-size: @smallFontSize; font-style: italic;