]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5114 Modify client side application to support App WS
authorStas Vilchik <vilchiks@gmail.com>
Thu, 6 Mar 2014 08:28:23 +0000 (09:28 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 6 Mar 2014 08:28:23 +0000 (09:28 +0100)
Use metric from app WS

sonar-server/src/main/webapp/javascripts/quality-gate/app.coffee
sonar-server/src/main/webapp/javascripts/quality-gate/app.js
sonar-server/src/main/webapp/javascripts/quality-gate/collections/metrics.coffee [deleted file]
sonar-server/src/main/webapp/javascripts/quality-gate/collections/metrics.js [deleted file]
sonar-server/src/main/webapp/javascripts/quality-gate/models/metric.coffee [deleted file]
sonar-server/src/main/webapp/javascripts/quality-gate/models/metric.js [deleted file]
sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-condition-view.coffee
sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-condition-view.js
sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-conditions-view.coffee
sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-conditions-view.js

index 6c119104c12a4a774974e735592cf59102047ac7..49f9bdb693bed7799416a3cf3816022f60ea5d18 100644 (file)
@@ -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()
index b72dfa17020346fc8e73101e40d3adadc097f354..dd1301494f56a4e1ca9e0c7b4ecf438cf5059a63 100644 (file)
@@ -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) {
     }).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 (file)
index 73082c0..0000000
+++ /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 (file)
index 9bdc904..0000000
+++ /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 (file)
index 6c1e045..0000000
+++ /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 (file)
index 59a6895..0000000
+++ /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);
index bae22f95073cb20cbbd75257ce33f3caf58b7054..da1b8d46f04d300304e3262dd9931f4c0c679b2f 100644 (file)
@@ -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: ->
index ddd499d7f646cdd8322e60c6649fb1c8ec88204d..0abc1b0532b242fe7fcfe7203eccf0434e6d4bf5 100644 (file)
       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
         });
index 8fc8054abcd7e3f99693a60a23c865274f68255d..9a297344ae7d879284448918b23b5ce0d806ea1a 100644 (file)
@@ -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: ->
index 7a145e44594eae6f001cd023aa7f2ed18058535d..6df80cd776644c39d16bf6423186233f950c7d1e 100644 (file)
 
       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() {