aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2014-03-06 09:28:23 +0100
committerStas Vilchik <vilchiks@gmail.com>2014-03-06 09:28:23 +0100
commite28d0422ad13af951415f1f947ded7a079fb6d7a (patch)
tree4e69932f8e1ab3a72bcec651030f99249958cff2
parent6c7dcb3a2af976d6cfdf7ac7dec2cedbe6013619 (diff)
downloadsonarqube-e28d0422ad13af951415f1f947ded7a079fb6d7a.tar.gz
sonarqube-e28d0422ad13af951415f1f947ded7a079fb6d7a.zip
SONAR-5114 Modify client side application to support App WS
Use metric from app WS
-rw-r--r--sonar-server/src/main/webapp/javascripts/quality-gate/app.coffee6
-rw-r--r--sonar-server/src/main/webapp/javascripts/quality-gate/app.js6
-rw-r--r--sonar-server/src/main/webapp/javascripts/quality-gate/collections/metrics.coffee18
-rw-r--r--sonar-server/src/main/webapp/javascripts/quality-gate/collections/metrics.js29
-rw-r--r--sonar-server/src/main/webapp/javascripts/quality-gate/models/metric.coffee7
-rw-r--r--sonar-server/src/main/webapp/javascripts/quality-gate/models/metric.js21
-rw-r--r--sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-condition-view.coffee4
-rw-r--r--sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-condition-view.js4
-rw-r--r--sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-conditions-view.coffee7
-rw-r--r--sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-conditions-view.js8
10 files changed, 19 insertions, 91 deletions
diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/app.coffee b/sonar-server/src/main/webapp/javascripts/quality-gate/app.coffee
index 6c119104c12..49f9bdb693b 100644
--- a/sonar-server/src/main/webapp/javascripts/quality-gate/app.coffee
+++ b/sonar-server/src/main/webapp/javascripts/quality-gate/app.coffee
@@ -26,7 +26,6 @@ requirejs.config
requirejs [
'backbone', 'backbone.marionette', 'handlebars',
'quality-gate/collections/quality-gates',
- 'quality-gate/collections/metrics',
'quality-gate/views/quality-gate-sidebar-list-view',
'quality-gate/views/quality-gate-actions-view',
'quality-gate/views/quality-gate-edit-view',
@@ -36,7 +35,6 @@ requirejs [
], (
Backbone, Marionette, Handlebars,
QualityGates,
- Metrics,
QualityGateSidebarListItemView,
QualityGateActionsView,
QualityGateEditView,
@@ -65,7 +63,6 @@ requirejs [
App = new Marionette.Application
- App.metrics = new Metrics
App.qualityGates = new QualityGates
@@ -131,11 +128,12 @@ requirejs [
.done (r) =>
App.canEdit = r.edit
App.periods = r.periods
+ App.metrics = r.metrics
window.messages = r.messages
qualityGatesXHR = App.qualityGates.fetch()
- jQuery.when(App.metrics.fetch(), qualityGatesXHR, appXHR)
+ jQuery.when(qualityGatesXHR, appXHR)
.done ->
# Remove the initial spinner
jQuery('.quality-gate-page-loader').remove()
diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/app.js b/sonar-server/src/main/webapp/javascripts/quality-gate/app.js
index b72dfa17020..dd1301494f5 100644
--- a/sonar-server/src/main/webapp/javascripts/quality-gate/app.js
+++ b/sonar-server/src/main/webapp/javascripts/quality-gate/app.js
@@ -30,7 +30,7 @@
}
});
- requirejs(['backbone', 'backbone.marionette', 'handlebars', 'quality-gate/collections/quality-gates', 'quality-gate/collections/metrics', 'quality-gate/views/quality-gate-sidebar-list-view', 'quality-gate/views/quality-gate-actions-view', 'quality-gate/views/quality-gate-edit-view', 'quality-gate/router', 'quality-gate/layout', 'common/handlebars-extensions'], function(Backbone, Marionette, Handlebars, QualityGates, Metrics, QualityGateSidebarListItemView, QualityGateActionsView, QualityGateEditView, QualityGateRouter, QualityGateLayout) {
+ requirejs(['backbone', 'backbone.marionette', 'handlebars', 'quality-gate/collections/quality-gates', 'quality-gate/views/quality-gate-sidebar-list-view', 'quality-gate/views/quality-gate-actions-view', 'quality-gate/views/quality-gate-edit-view', 'quality-gate/router', 'quality-gate/layout', 'common/handlebars-extensions'], function(Backbone, Marionette, Handlebars, QualityGates, QualityGateSidebarListItemView, QualityGateActionsView, QualityGateEditView, QualityGateRouter, QualityGateLayout) {
var App, appXHR, qualityGatesXHR,
_this = this;
jQuery.ajaxSetup({
@@ -50,7 +50,6 @@
});
jQuery('html').addClass('navigator-page quality-gates-page');
App = new Marionette.Application;
- App.metrics = new Metrics;
App.qualityGates = new QualityGates;
App.openFirstQualityGate = function() {
if (this.qualityGates.length > 0) {
@@ -115,10 +114,11 @@
}).done(function(r) {
App.canEdit = r.edit;
App.periods = r.periods;
+ App.metrics = r.metrics;
return window.messages = r.messages;
});
qualityGatesXHR = App.qualityGates.fetch();
- return jQuery.when(App.metrics.fetch(), qualityGatesXHR, appXHR).done(function() {
+ return jQuery.when(qualityGatesXHR, appXHR).done(function() {
jQuery('.quality-gate-page-loader').remove();
return App.start();
});
diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/collections/metrics.coffee b/sonar-server/src/main/webapp/javascripts/quality-gate/collections/metrics.coffee
deleted file mode 100644
index 73082c000ce..00000000000
--- a/sonar-server/src/main/webapp/javascripts/quality-gate/collections/metrics.coffee
+++ /dev/null
@@ -1,18 +0,0 @@
-define [
- 'backbone',
- 'quality-gate/models/metric'
-], (
- Backbone,
- Metric
-) ->
-
- class Metrics extends Backbone.Collection
- model: Metric
-
-
- url:
- "#{baseUrl}/api/qualitygates/metrics"
-
-
- parse: (r) ->
- r.metrics
diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/collections/metrics.js b/sonar-server/src/main/webapp/javascripts/quality-gate/collections/metrics.js
deleted file mode 100644
index 9bdc904fe88..00000000000
--- a/sonar-server/src/main/webapp/javascripts/quality-gate/collections/metrics.js
+++ /dev/null
@@ -1,29 +0,0 @@
-// Generated by CoffeeScript 1.6.3
-(function() {
- var __hasProp = {}.hasOwnProperty,
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
-
- define(['backbone', 'quality-gate/models/metric'], function(Backbone, Metric) {
- var Metrics, _ref;
- return Metrics = (function(_super) {
- __extends(Metrics, _super);
-
- function Metrics() {
- _ref = Metrics.__super__.constructor.apply(this, arguments);
- return _ref;
- }
-
- Metrics.prototype.model = Metric;
-
- Metrics.prototype.url = "" + baseUrl + "/api/qualitygates/metrics";
-
- Metrics.prototype.parse = function(r) {
- return r.metrics;
- };
-
- return Metrics;
-
- })(Backbone.Collection);
- });
-
-}).call(this);
diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/models/metric.coffee b/sonar-server/src/main/webapp/javascripts/quality-gate/models/metric.coffee
deleted file mode 100644
index 6c1e045db8d..00000000000
--- a/sonar-server/src/main/webapp/javascripts/quality-gate/models/metric.coffee
+++ /dev/null
@@ -1,7 +0,0 @@
-define [
- 'backbone'
-], (
- Backbone
-) ->
-
- class Metric extends Backbone.Model
diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/models/metric.js b/sonar-server/src/main/webapp/javascripts/quality-gate/models/metric.js
deleted file mode 100644
index 59a6895c52f..00000000000
--- a/sonar-server/src/main/webapp/javascripts/quality-gate/models/metric.js
+++ /dev/null
@@ -1,21 +0,0 @@
-// Generated by CoffeeScript 1.6.3
-(function() {
- var __hasProp = {}.hasOwnProperty,
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
-
- define(['backbone'], function(Backbone) {
- var Metric, _ref;
- return Metric = (function(_super) {
- __extends(Metric, _super);
-
- function Metric() {
- _ref = Metric.__super__.constructor.apply(this, arguments);
- return _ref;
- }
-
- return Metric;
-
- })(Backbone.Model);
- });
-
-}).call(this);
diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-condition-view.coffee b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-condition-view.coffee
index bae22f95073..da1b8d46f04 100644
--- a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-condition-view.coffee
+++ b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-condition-view.coffee
@@ -40,8 +40,8 @@ define [
populateMetric: ->
metricKey = @model.get('metric')
- metric = @options.app.metrics.findWhere key: metricKey
- @model.set { metric: metric.toJSON() }, { silent: true }
+ metric = _.findWhere @options.app.metrics, key: metricKey
+ @model.set { metric: metric }, { silent: true }
onRender: ->
diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-condition-view.js b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-condition-view.js
index ddd499d7f64..0abc1b0532b 100644
--- a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-condition-view.js
+++ b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-condition-view.js
@@ -48,11 +48,11 @@
QualityGateDetailConditionView.prototype.populateMetric = function() {
var metric, metricKey;
metricKey = this.model.get('metric');
- metric = this.options.app.metrics.findWhere({
+ metric = _.findWhere(this.options.app.metrics, {
key: metricKey
});
return this.model.set({
- metric: metric.toJSON()
+ metric: metric
}, {
silent: true
});
diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-conditions-view.coffee b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-conditions-view.coffee
index 8fc8054abcd..9a297344ae7 100644
--- a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-conditions-view.coffee
+++ b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-conditions-view.coffee
@@ -53,8 +53,11 @@ define [
groupedMetrics: ->
- metrics = @options.app.metrics.toJSON()
- _.sortBy(_.map(_.groupBy(metrics, 'domain'), (metrics, domain) -> return { domain: domain, metrics: _.sortBy(metrics, 'short_name') }), 'domain')
+ metrics = @options.app.metrics
+ metrics = _.groupBy metrics, 'domain'
+ metrics = _.map metrics, (metrics, domain) ->
+ domain: domain, metrics: _.sortBy metrics, 'short_name'
+ _.sortBy metrics, 'domain'
serializeData: ->
diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-conditions-view.js b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-conditions-view.js
index 7a145e44594..6df80cd7766 100644
--- a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-conditions-view.js
+++ b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-conditions-view.js
@@ -61,13 +61,15 @@
QualityGateDetailConditionsView.prototype.groupedMetrics = function() {
var metrics;
- metrics = this.options.app.metrics.toJSON();
- return _.sortBy(_.map(_.groupBy(metrics, 'domain'), function(metrics, domain) {
+ metrics = this.options.app.metrics;
+ metrics = _.groupBy(metrics, 'domain');
+ metrics = _.map(metrics, function(metrics, domain) {
return {
domain: domain,
metrics: _.sortBy(metrics, 'short_name')
};
- }), 'domain');
+ });
+ return _.sortBy(metrics, 'domain');
};
QualityGateDetailConditionsView.prototype.serializeData = function() {