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',
], (
Backbone, Marionette, Handlebars,
QualityGates,
- Metrics,
QualityGateSidebarListItemView,
QualityGateActionsView,
QualityGateEditView,
App = new Marionette.Application
- App.metrics = new Metrics
App.qualityGates = new QualityGates
.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()
}
});
- 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({
});
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();
});
+++ /dev/null
-define [
- 'backbone',
- 'quality-gate/models/metric'
-], (
- Backbone,
- Metric
-) ->
-
- class Metrics extends Backbone.Collection
- model: Metric
-
-
- url:
- "#{baseUrl}/api/qualitygates/metrics"
-
-
- parse: (r) ->
- r.metrics
+++ /dev/null
-// 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);
+++ /dev/null
-define [
- 'backbone'
-], (
- Backbone
-) ->
-
- class Metric extends Backbone.Model
+++ /dev/null
-// 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);
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: ->
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
});
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: ->
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() {