aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-04-03 11:38:45 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-04-03 11:38:45 +0200
commit83da0fcf581c31768ba322246da4079d23fa20bd (patch)
treeeb04f5088bc81937fa3099a86676305bfec68d4a
parentb6e187780e6057c3cf77b34b9452682e19720c63 (diff)
downloadsonarqube-83da0fcf581c31768ba322246da4079d23fa20bd.tar.gz
sonarqube-83da0fcf581c31768ba322246da4079d23fa20bd.zip
SONAR-6331 prepare for detailed panels
-rw-r--r--server/sonar-web/src/main/hbs/overview/overview-layout.hbs19
-rw-r--r--server/sonar-web/src/main/hbs/overview/overview-main-layout.hbs18
-rw-r--r--server/sonar-web/src/main/js/overview/app.js35
-rw-r--r--server/sonar-web/src/main/js/overview/controller.js55
-rw-r--r--server/sonar-web/src/main/js/overview/layout.js16
-rw-r--r--server/sonar-web/src/main/js/overview/main/coverage-view.js (renamed from server/sonar-web/src/main/js/overview/views/coverage-view.js)0
-rw-r--r--server/sonar-web/src/main/js/overview/main/duplications-view.js (renamed from server/sonar-web/src/main/js/overview/views/duplications-view.js)0
-rw-r--r--server/sonar-web/src/main/js/overview/main/gate-view.js (renamed from server/sonar-web/src/main/js/overview/views/gate-view.js)0
-rw-r--r--server/sonar-web/src/main/js/overview/main/issues-view.js (renamed from server/sonar-web/src/main/js/overview/views/issues-view.js)0
-rw-r--r--server/sonar-web/src/main/js/overview/main/layout.js46
-rw-r--r--server/sonar-web/src/main/js/overview/main/size-view.js (renamed from server/sonar-web/src/main/js/overview/views/size-view.js)0
-rw-r--r--server/sonar-web/src/main/js/overview/router.js37
12 files changed, 175 insertions, 51 deletions
diff --git a/server/sonar-web/src/main/hbs/overview/overview-layout.hbs b/server/sonar-web/src/main/hbs/overview/overview-layout.hbs
index 8ce2a7d4e4f..a0a7d067a0e 100644
--- a/server/sonar-web/src/main/hbs/overview/overview-layout.hbs
+++ b/server/sonar-web/src/main/hbs/overview/overview-layout.hbs
@@ -1,18 +1 @@
-<div class="overview-card overview-gate" id="overview-gate"></div>
-
-<div class="overview-container columns">
- <div class="column-half">
- <div class="overview-card" id="overview-size"></div>
- </div>
- <div class="column-half">
- <div class="overview-card" id="overview-issues"></div>
- </div>
-</div>
-<div class="overview-container columns">
- <div class="column-half">
- <div class="overview-card" id="overview-coverage"></div>
- </div>
- <div class="column-half">
- <div class="overview-card" id="overview-duplications"></div>
- </div>
-</div>
+<div class="js-region"></div>
diff --git a/server/sonar-web/src/main/hbs/overview/overview-main-layout.hbs b/server/sonar-web/src/main/hbs/overview/overview-main-layout.hbs
new file mode 100644
index 00000000000..8ce2a7d4e4f
--- /dev/null
+++ b/server/sonar-web/src/main/hbs/overview/overview-main-layout.hbs
@@ -0,0 +1,18 @@
+<div class="overview-card overview-gate" id="overview-gate"></div>
+
+<div class="overview-container columns">
+ <div class="column-half">
+ <div class="overview-card" id="overview-size"></div>
+ </div>
+ <div class="column-half">
+ <div class="overview-card" id="overview-issues"></div>
+ </div>
+</div>
+<div class="overview-container columns">
+ <div class="column-half">
+ <div class="overview-card" id="overview-coverage"></div>
+ </div>
+ <div class="column-half">
+ <div class="overview-card" id="overview-duplications"></div>
+ </div>
+</div>
diff --git a/server/sonar-web/src/main/js/overview/app.js b/server/sonar-web/src/main/js/overview/app.js
index 9470914d271..4bf5db63969 100644
--- a/server/sonar-web/src/main/js/overview/app.js
+++ b/server/sonar-web/src/main/js/overview/app.js
@@ -19,36 +19,35 @@
*/
requirejs([
'overview/layout',
- 'overview/models/state',
- 'overview/views/gate-view',
- 'overview/views/size-view',
- 'overview/views/issues-view',
- 'overview/views/coverage-view',
- 'overview/views/duplications-view'
+ 'overview/controller',
+ 'overview/router',
+ 'overview/models/state'
], function (Layout,
- State,
- GateView,
- SizeView,
- IssuesView,
- CoverageView,
- DuplicationsView) {
+ Controller,
+ Router,
+ State) {
var $ = jQuery,
App = new Marionette.Application();
App.addInitializer(function () {
$('body').addClass('dashboard-page');
+
+ // add state model
this.state = new State(window.overviewConf);
+
+ // create and render layout
this.layout = new Layout({
el: '.overview',
model: this.state
}).render();
- this.layout.gateRegion.show(new GateView({ model: this.state }));
- this.layout.sizeRegion.show(new SizeView({ model: this.state }));
- this.layout.issuesRegion.show(new IssuesView({ model: this.state }));
- this.layout.coverageRegion.show(new CoverageView({ model: this.state }));
- this.layout.duplicationsRegion.show(new DuplicationsView({ model: this.state }));
- this.state.fetch();
+
+ // create controller
+ this.controller = new Controller({ state: this.state, layout: this.layout });
+
+ // start router
+ this.router = new Router({ controller: this.controller });
+ Backbone.history.start();
});
window.requestMessages().done(function () {
diff --git a/server/sonar-web/src/main/js/overview/controller.js b/server/sonar-web/src/main/js/overview/controller.js
new file mode 100644
index 00000000000..f72b99cefdf
--- /dev/null
+++ b/server/sonar-web/src/main/js/overview/controller.js
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+define([
+ 'overview/main/layout',
+ 'overview/main/gate-view',
+ 'overview/main/size-view',
+ 'overview/main/issues-view',
+ 'overview/main/coverage-view',
+ 'overview/main/duplications-view'
+], function (MainLayout,
+ GateView,
+ SizeView,
+ IssuesView,
+ CoverageView,
+ DuplicationsView) {
+
+ return Marionette.Controller.extend({
+
+ initialize: function (options) {
+ this.state = options.state;
+ this.layout = options.layout;
+ },
+
+ main: function () {
+ var options = { model: this.state },
+ mainLayout = new MainLayout(options);
+ this.layout.mainRegion.show(mainLayout);
+ mainLayout.gateRegion.show(new GateView(options));
+ mainLayout.sizeRegion.show(new SizeView(options));
+ mainLayout.issuesRegion.show(new IssuesView(options));
+ mainLayout.coverageRegion.show(new CoverageView(options));
+ mainLayout.duplicationsRegion.show(new DuplicationsView(options));
+ this.state.fetch();
+ }
+
+ });
+
+});
diff --git a/server/sonar-web/src/main/js/overview/layout.js b/server/sonar-web/src/main/js/overview/layout.js
index ba70f756f62..97cd93d0ca6 100644
--- a/server/sonar-web/src/main/js/overview/layout.js
+++ b/server/sonar-web/src/main/js/overview/layout.js
@@ -25,21 +25,7 @@ define([
template: Templates['overview-layout'],
regions: {
- gateRegion: '#overview-gate',
- sizeRegion: '#overview-size',
- issuesRegion: '#overview-issues',
- coverageRegion: '#overview-coverage',
- duplicationsRegion: '#overview-duplications'
- },
-
- modelEvents: {
- 'change': 'toggleRegions'
- },
-
- toggleRegions: function () {
- var conditions = this.model.get('gateConditions'),
- hasGate = _.isArray(conditions) && conditions.length > 0;
- this.$(this.gateRegion.el).toggle(hasGate);
+ mainRegion: '.js-region'
}
});
diff --git a/server/sonar-web/src/main/js/overview/views/coverage-view.js b/server/sonar-web/src/main/js/overview/main/coverage-view.js
index 8b807e4d6ed..8b807e4d6ed 100644
--- a/server/sonar-web/src/main/js/overview/views/coverage-view.js
+++ b/server/sonar-web/src/main/js/overview/main/coverage-view.js
diff --git a/server/sonar-web/src/main/js/overview/views/duplications-view.js b/server/sonar-web/src/main/js/overview/main/duplications-view.js
index 18e69af549b..18e69af549b 100644
--- a/server/sonar-web/src/main/js/overview/views/duplications-view.js
+++ b/server/sonar-web/src/main/js/overview/main/duplications-view.js
diff --git a/server/sonar-web/src/main/js/overview/views/gate-view.js b/server/sonar-web/src/main/js/overview/main/gate-view.js
index 22b4f1c2a0c..22b4f1c2a0c 100644
--- a/server/sonar-web/src/main/js/overview/views/gate-view.js
+++ b/server/sonar-web/src/main/js/overview/main/gate-view.js
diff --git a/server/sonar-web/src/main/js/overview/views/issues-view.js b/server/sonar-web/src/main/js/overview/main/issues-view.js
index a17a1d9547a..a17a1d9547a 100644
--- a/server/sonar-web/src/main/js/overview/views/issues-view.js
+++ b/server/sonar-web/src/main/js/overview/main/issues-view.js
diff --git a/server/sonar-web/src/main/js/overview/main/layout.js b/server/sonar-web/src/main/js/overview/main/layout.js
new file mode 100644
index 00000000000..8db7c1e088d
--- /dev/null
+++ b/server/sonar-web/src/main/js/overview/main/layout.js
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+define([
+ 'templates/overview'
+], function () {
+
+ return Marionette.Layout.extend({
+ template: Templates['overview-main-layout'],
+
+ regions: {
+ gateRegion: '#overview-gate',
+ sizeRegion: '#overview-size',
+ issuesRegion: '#overview-issues',
+ coverageRegion: '#overview-coverage',
+ duplicationsRegion: '#overview-duplications'
+ },
+
+ modelEvents: {
+ 'change': 'toggleRegions'
+ },
+
+ toggleRegions: function () {
+ var conditions = this.model.get('gateConditions'),
+ hasGate = _.isArray(conditions) && conditions.length > 0;
+ this.$(this.gateRegion.el).toggle(hasGate);
+ }
+ });
+
+});
diff --git a/server/sonar-web/src/main/js/overview/views/size-view.js b/server/sonar-web/src/main/js/overview/main/size-view.js
index db1ab7e41a8..db1ab7e41a8 100644
--- a/server/sonar-web/src/main/js/overview/views/size-view.js
+++ b/server/sonar-web/src/main/js/overview/main/size-view.js
diff --git a/server/sonar-web/src/main/js/overview/router.js b/server/sonar-web/src/main/js/overview/router.js
new file mode 100644
index 00000000000..ace5ffd7e9b
--- /dev/null
+++ b/server/sonar-web/src/main/js/overview/router.js
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+define(function () {
+
+ return Backbone.Router.extend({
+
+ routes: {
+ '': 'main'
+ },
+
+ initialize: function (options) {
+ this.controller = options.controller;
+ },
+
+ main: function () {
+ this.controller.main();
+ }
+ });
+
+});