diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2014-10-08 16:54:05 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2014-10-08 16:54:05 +0200 |
commit | b0ce29966933102359d5e4c44ff1ce11ec4cb3ed (patch) | |
tree | a0ec07f37fdab0a4ca8ca73569c658d7a4f0caed /server/sonar-web | |
parent | 99fa2be3429f1612edd016d1260c08d97ebc8404 (diff) | |
download | sonarqube-b0ce29966933102359d5e4c44ff1ce11ec4cb3ed.tar.gz sonarqube-b0ce29966933102359d5e4c44ff1ce11ec4cb3ed.zip |
SONAR-5623 Initial step to implement the monitoring page
Diffstat (limited to 'server/sonar-web')
16 files changed, 371 insertions, 0 deletions
diff --git a/server/sonar-web/Gruntfile.coffee b/server/sonar-web/Gruntfile.coffee index a319bf3d0e9..b75d8acf466 100644 --- a/server/sonar-web/Gruntfile.coffee +++ b/server/sonar-web/Gruntfile.coffee @@ -210,6 +210,10 @@ module.exports = (grunt) -> name: 'libraries/app' out: '<%= pkg.assets %>build/js/libraries/app.js' + monitoring: options: + name: 'monitoring/app' + out: '<%= pkg.assets %>build/js/monitoring/app.js' + handlebars: options: @@ -258,6 +262,9 @@ module.exports = (grunt) -> '<%= pkg.assets %>js/templates/dashboard.js': [ '<%= pkg.sources %>hbs/dashboard/**/*.hbs' ] + '<%= pkg.assets %>js/templates/monitoring.js': [ + '<%= pkg.sources %>hbs/monitoring/**/*.hbs' + ] clean: diff --git a/server/sonar-web/src/main/coffee/monitoring/app.coffee b/server/sonar-web/src/main/coffee/monitoring/app.coffee new file mode 100644 index 00000000000..da57c63b4ec --- /dev/null +++ b/server/sonar-web/src/main/coffee/monitoring/app.coffee @@ -0,0 +1,79 @@ +requirejs.config + baseUrl: "#{baseUrl}/js" + + paths: + 'backbone': 'third-party/backbone' + 'backbone.marionette': 'third-party/backbone.marionette' + 'handlebars': 'third-party/handlebars' + + shim: + 'backbone.marionette': + deps: ['backbone'] + exports: 'Marionette' + 'backbone': + exports: 'Backbone' + 'handlebars': + exports: 'Handlebars' + + +requirejs [ + 'backbone', 'backbone.marionette' + + 'monitoring/layout' + 'monitoring/models/reports' + 'monitoring/views/reports-view' + 'monitoring/views/header-view' + + 'common/handlebars-extensions' + 'monitoring/mockjax' +], ( + Backbone, Marionette + MonitoringLayout + Reports + ReportsView + HeaderView +) -> + + # Add html class to mark the page as navigator page + jQuery('html').addClass 'navigator-page' + + + # Create an Application + App = new Marionette.Application + + + # Construct layout + App.addInitializer -> + @layout = new MonitoringLayout app: @ + jQuery('#monitoring').empty().append @layout.render().el + @layout.onResize() + + + App.addInitializer -> + @headerView = new HeaderView app: @ + @layout.headerRegion.show @headerView + + + App.addInitializer -> + @reports = new Reports() + + @reportsView = new ReportsView + app: @ + collection: @reports + @layout.resultsRegion.show @reportsView + + @reports.fetch() + + +# App.addInitializer -> +# @codingRulesActionsView = new CodingRulesActionsView +# app: @ +# collection: @reports +# @layout.actionsRegion.show @codingRulesActionsView + + + # Message bundles + l10nXHR = window.requestMessages() + + + jQuery.when(l10nXHR).done -> App.start() diff --git a/server/sonar-web/src/main/coffee/monitoring/layout.coffee b/server/sonar-web/src/main/coffee/monitoring/layout.coffee new file mode 100644 index 00000000000..88b819319a3 --- /dev/null +++ b/server/sonar-web/src/main/coffee/monitoring/layout.coffee @@ -0,0 +1,40 @@ +define [ + 'backbone.marionette', + 'templates/monitoring' +], ( + Marionette, + Templates +) -> + + class extends Marionette.Layout + className: 'navigator monitoring-navigator' + template: Templates['monitoring-layout'] + + + regions: + headerRegion: '.navigator-header' + resultsRegion: '.navigator-results' + + + ui: + side: '.navigator-side' + results: '.navigator-results' + + + initialize: -> + jQuery(window).on 'resize', => @onResize() + + + onResize: -> + footerEl = jQuery('#footer') + footerHeight = footerEl.outerHeight true + + resultsEl = @ui.results + resultsHeight = jQuery(window).height() - resultsEl.offset().top - + parseInt(resultsEl.css('margin-bottom'), 10) - footerHeight + resultsEl.height resultsHeight + + + showSpinner: (region) -> + @[region].show new Marionette.ItemView + template: _.template('<i class="spinner"></i>') diff --git a/server/sonar-web/src/main/coffee/monitoring/mockjax.coffee b/server/sonar-web/src/main/coffee/monitoring/mockjax.coffee new file mode 100644 index 00000000000..94deb2289b3 --- /dev/null +++ b/server/sonar-web/src/main/coffee/monitoring/mockjax.coffee @@ -0,0 +1,113 @@ +define ['third-party/jquery.mockjax'], -> + + jQuery.mockjaxSettings.contentType = 'text/json'; + jQuery.mockjaxSettings.responseTime = 250; + + # GET /api/codingrules/app + jQuery.mockjax + url: "#{baseUrl}/api/reports/search" + responseText: JSON.stringify + paging: + pageIndex: 1 + pageSize: 5 + total: 206 + pages: 42 + reports: [ + { + id: 84 + project: "org.codehaus.sonar:sonar" + projectName: "SonarQube" + startDate: "2014-07-19T23:11:33+06:00" + status: "PENDING" + } + { + id: 83 + project: "org.codehaus.sonar:sonar" + projectName: "SonarQube" + startDate: "2014-07-19T23:10:33+06:00" + endDate: "2014-07-19T23:12:01+06:00" + status: "DONE" + extra: "Some additional text or stack trace." + } + { + id: 82 + project: "org.codehaus.sonar:sonar" + projectName: "SonarQube" + startDate: "2014-07-19T23:10:33+06:00" + endDate: "2014-07-19T23:12:01+06:00" + status: "DONE" + extra: "Some additional text or stack trace." + } + { + id: 81 + project: "org.codehaus.sonar:sonar" + projectName: "SonarQube" + startDate: "2014-07-19T23:10:33+06:00" + endDate: "2014-07-19T23:12:01+06:00" + status: "DONE" + extra: "Some additional text or stack trace." + } + { + id: 80 + project: "org.codehaus.sonar:sonar" + projectName: "SonarQube" + startDate: "2014-07-19T23:10:33+06:00" + endDate: "2014-07-19T23:12:01+06:00" + status: "DONE" + extra: "Some additional text or stack trace." + } + { + id: 79 + project: "org.codehaus.sonar:sonar" + projectName: "SonarQube" + startDate: "2014-07-19T23:10:33+06:00" + endDate: "2014-07-19T23:12:01+06:00" + status: "DONE" + extra: "Some additional text or stack trace." + } + { + id: 78 + project: "org.codehaus.sonar:sonar" + projectName: "SonarQube" + startDate: "2014-07-19T23:10:33+06:00" + endDate: "2014-07-19T23:12:01+06:00" + status: "DONE" + extra: "Some additional text or stack trace." + } + { + id: 77 + project: "org.codehaus.sonar:sonar" + projectName: "SonarQube" + startDate: "2014-07-19T23:10:33+06:00" + endDate: "2014-07-19T23:12:01+06:00" + status: "DONE" + extra: "Some additional text or stack trace." + } + { + id: 76 + project: "org.codehaus.sonar:sonar" + projectName: "SonarQube" + startDate: "2014-07-19T23:10:33+06:00" + endDate: "2014-07-19T23:12:01+06:00" + status: "DONE" + extra: "Some additional text or stack trace." + } + { + id: 75 + project: "org.codehaus.sonar:sonar" + projectName: "SonarQube" + startDate: "2014-07-19T23:10:33+06:00" + endDate: "2014-07-19T23:12:01+06:00" + status: "DONE" + extra: "Some asdditional text or stack trace." + } + { + id: 74 + project: "org.codehaus.sonar:sonar" + projectName: "SonarQube" + startDate: "2014-07-19T23:10:33+06:00" + endDate: "2014-07-19T23:12:01+06:00" + status: "DONE" + extra: "Some additional text or stack trace." + } + ] diff --git a/server/sonar-web/src/main/coffee/monitoring/models/report.coffee b/server/sonar-web/src/main/coffee/monitoring/models/report.coffee new file mode 100644 index 00000000000..ba69b108ac4 --- /dev/null +++ b/server/sonar-web/src/main/coffee/monitoring/models/report.coffee @@ -0,0 +1,4 @@ +define ['backbone'], (Backbone) -> + + + class extends Backbone.Model diff --git a/server/sonar-web/src/main/coffee/monitoring/models/reports.coffee b/server/sonar-web/src/main/coffee/monitoring/models/reports.coffee new file mode 100644 index 00000000000..c18a8cc8744 --- /dev/null +++ b/server/sonar-web/src/main/coffee/monitoring/models/reports.coffee @@ -0,0 +1,20 @@ +define [ + 'backbone' + 'monitoring/models/report' +], ( + Backbone + Report +) -> + + + class extends Backbone.Collection + model: Report + + + url: -> + "#{baseUrl}/api/reports/search" + + + parse: (r) -> + @paging = r.paging + r.reports diff --git a/server/sonar-web/src/main/coffee/monitoring/views/header-view.coffee b/server/sonar-web/src/main/coffee/monitoring/views/header-view.coffee new file mode 100644 index 00000000000..4decd30ef99 --- /dev/null +++ b/server/sonar-web/src/main/coffee/monitoring/views/header-view.coffee @@ -0,0 +1,10 @@ +define [ + 'backbone.marionette' + 'templates/monitoring' +], ( + Marionette + Templates +) -> + + class extends Marionette.ItemView + template: Templates['monitoring-header'] diff --git a/server/sonar-web/src/main/coffee/monitoring/views/report-view.coffee b/server/sonar-web/src/main/coffee/monitoring/views/report-view.coffee new file mode 100644 index 00000000000..31680d448c2 --- /dev/null +++ b/server/sonar-web/src/main/coffee/monitoring/views/report-view.coffee @@ -0,0 +1,11 @@ +define [ + 'backbone.marionette' + 'templates/monitoring' +], ( + Marionette + Templates +) -> + + class extends Marionette.ItemView + tagName: 'li' + template: Templates['monitoring-report'] diff --git a/server/sonar-web/src/main/coffee/monitoring/views/reports-view.coffee b/server/sonar-web/src/main/coffee/monitoring/views/reports-view.coffee new file mode 100644 index 00000000000..7eb9171713d --- /dev/null +++ b/server/sonar-web/src/main/coffee/monitoring/views/reports-view.coffee @@ -0,0 +1,16 @@ +define [ + 'backbone.marionette' + 'monitoring/views/report-view' +], ( + Marionette + ReportView +) -> + + class extends Marionette.CollectionView + tagName: 'ol' + className: 'navigator-results-list' + itemView: ReportView + + + itemViewOptions: -> + listView: @, app: @options.app diff --git a/server/sonar-web/src/main/hbs/monitoring/monitoring-header.hbs b/server/sonar-web/src/main/hbs/monitoring/monitoring-header.hbs new file mode 100644 index 00000000000..7882d9e99f2 --- /dev/null +++ b/server/sonar-web/src/main/hbs/monitoring/monitoring-header.hbs @@ -0,0 +1,2 @@ +<h1 class="navigator-header-title">{{t 'monitoring.page'}}</h1> + diff --git a/server/sonar-web/src/main/hbs/monitoring/monitoring-layout.hbs b/server/sonar-web/src/main/hbs/monitoring/monitoring-layout.hbs new file mode 100644 index 00000000000..f4bf713e493 --- /dev/null +++ b/server/sonar-web/src/main/hbs/monitoring/monitoring-layout.hbs @@ -0,0 +1,9 @@ +<div class="navigator-header"></div> + +<div class="navigator-content"> + <div class="navigator-side"> + <div> + <div class="navigator-results"></div> + </div> + </div> +</div> diff --git a/server/sonar-web/src/main/hbs/monitoring/monitoring-report.hbs b/server/sonar-web/src/main/hbs/monitoring/monitoring-report.hbs new file mode 100644 index 00000000000..c6bdea3bc36 --- /dev/null +++ b/server/sonar-web/src/main/hbs/monitoring/monitoring-report.hbs @@ -0,0 +1,7 @@ +<div class="line line-small"> + Started: {{dt startTime}} +</div> + +<div class="line"> + <i class="icon-qualifier-trk"></i> {{projectName}} +</div> diff --git a/server/sonar-web/src/main/less/monitoring.less b/server/sonar-web/src/main/less/monitoring.less new file mode 100644 index 00000000000..376b7b1ceb5 --- /dev/null +++ b/server/sonar-web/src/main/less/monitoring.less @@ -0,0 +1,12 @@ +.monitoring-navigator { + margin: -10px; + + .navigator-results { margin-top: 0; } + + .navigator-results-list > li { + cursor: default; + + &:hover { background: transparent; } + } + +} diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/monitoring_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/monitoring_controller.rb new file mode 100644 index 00000000000..2e5ec7f3997 --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/monitoring_controller.rb @@ -0,0 +1,31 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2014 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# SonarQube is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +class MonitoringController < ApplicationController + + before_filter :admin_required + + SECTION=Navigation::SECTION_CONFIGURATION + + def index + + end + +end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb index 85f30bea0c6..c97fcab9c68 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb @@ -164,6 +164,8 @@ <% end %> <li class="<%= 'active' if controller.controller_path=='system' -%>"> <a href="<%= ApplicationController.root_context -%>/system"><%= message('system_info.page') -%></a></li> + <li class="<%= 'active' if controller.controller_path=='monitoring' -%>"> + <a href="<%= ApplicationController.root_context -%>/monitoring"><%= message('monitoring.page') -%></a></li> <% end #of admin part %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/monitoring/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/monitoring/index.html.erb new file mode 100644 index 00000000000..107db4dee1a --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/monitoring/index.html.erb @@ -0,0 +1,8 @@ +<% content_for :script do %> + <script data-main="<%= ApplicationController.root_context -%>/js/monitoring/app" src="<%= ApplicationController.root_context -%>/js/require.js"></script> +<% end %> + + +<div id="monitoring"> + <i class="spinner"></i> +</div> |