diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2014-03-05 18:16:25 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2014-03-05 18:16:31 +0100 |
commit | 50aca35f98ddaf325772979e73a8e25ec7aa262b (patch) | |
tree | 485b912cae8cd66340838fbba6e68d67958b398d /sonar-server/src/main/webapp/javascripts/quality-gate | |
parent | 292c533649df419f3dd97036dc799624c48d3075 (diff) | |
download | sonarqube-50aca35f98ddaf325772979e73a8e25ec7aa262b.tar.gz sonarqube-50aca35f98ddaf325772979e73a8e25ec7aa262b.zip |
SONAR-5114 Modify client side application to support App WS
Also add translation module
Diffstat (limited to 'sonar-server/src/main/webapp/javascripts/quality-gate')
10 files changed, 42 insertions, 30 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 346636af8a7..6c119104c12 100644 --- a/sonar-server/src/main/webapp/javascripts/quality-gate/app.coffee +++ b/sonar-server/src/main/webapp/javascripts/quality-gate/app.coffee @@ -125,13 +125,18 @@ requirejs [ App.openFirstQualityGate() if initial - # Load metrics and the list of quality gates before start the application + # Call app, Load metrics and the list of quality gates before start the application + appXHR = jQuery.ajax + url: "#{baseUrl}/api/qualitygates/app" + .done (r) => + App.canEdit = r.edit + App.periods = r.periods + window.messages = r.messages + qualityGatesXHR = App.qualityGates.fetch() - jQuery.when(App.metrics.fetch(), qualityGatesXHR) - .done -> - # Set permissions - App.canEdit = qualityGatesXHR.responseJSON.edit + jQuery.when(App.metrics.fetch(), 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 de8c167eb71..b72dfa17020 100644 --- a/sonar-server/src/main/webapp/javascripts/quality-gate/app.js +++ b/sonar-server/src/main/webapp/javascripts/quality-gate/app.js @@ -31,7 +31,8 @@ }); 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) { - var App, qualityGatesXHR; + var App, appXHR, qualityGatesXHR, + _this = this; jQuery.ajaxSetup({ error: function(jqXHR) { var errorBox, text, _ref; @@ -109,9 +110,15 @@ return App.openFirstQualityGate(); } }); + appXHR = jQuery.ajax({ + url: "" + baseUrl + "/api/qualitygates/app" + }).done(function(r) { + App.canEdit = r.edit; + App.periods = r.periods; + return window.messages = r.messages; + }); qualityGatesXHR = App.qualityGates.fetch(); - return jQuery.when(App.metrics.fetch(), qualityGatesXHR).done(function() { - App.canEdit = qualityGatesXHR.responseJSON.edit; + return jQuery.when(App.metrics.fetch(), qualityGatesXHR, appXHR).done(function() { jQuery('.quality-gate-page-loader').remove(); return App.start(); }); 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 f60bd4439a1..bae22f95073 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 @@ -89,7 +89,7 @@ define [ deleteCondition: -> - if confirm window.SS.phrases.areYouSure + if confirm t('are_you_sure') @showSpinner() @model.delete().done => @options.collectionView.updateConditions() @@ -105,8 +105,8 @@ define [ serializeData: -> - period = _.findWhere(window.SS.metricPeriods, key: '' + this.model.get('period')) + period = _.findWhere(@options.app.periods, key: '' + this.model.get('period')) _.extend super, canEdit: @options.app.canEdit - periods: window.SS.metricPeriods + periods: @options.app.periods periodText: period?.text 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 6e29ecc2db1..ddd499d7f64 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 @@ -107,7 +107,7 @@ QualityGateDetailConditionView.prototype.deleteCondition = function() { var _this = this; - if (confirm(window.SS.phrases.areYouSure)) { + if (confirm(t('are_you_sure'))) { this.showSpinner(); return this.model["delete"]().done(function() { _this.options.collectionView.updateConditions(); @@ -126,12 +126,12 @@ QualityGateDetailConditionView.prototype.serializeData = function() { var period; - period = _.findWhere(window.SS.metricPeriods, { + period = _.findWhere(this.options.app.periods, { key: '' + this.model.get('period') }); return _.extend(QualityGateDetailConditionView.__super__.serializeData.apply(this, arguments), { canEdit: this.options.app.canEdit, - periods: window.SS.metricPeriods, + periods: this.options.app.periods, periodText: period != null ? period.text : void 0 }); }; 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 9e88a74ee9f..8fc8054abcd 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 @@ -49,7 +49,7 @@ define [ @ui.metricSelect.select2 allowClear: false, width: '250px', - placeholder: window.SS.phrases.alerts.select_metric + placeholder: t('alerts.select_metric') groupedMetrics: -> 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 a6a26c583fc..7a145e44594 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 @@ -55,7 +55,7 @@ return this.ui.metricSelect.select2({ allowClear: false, width: '250px', - placeholder: window.SS.phrases.alerts.select_metric + placeholder: t('alerts.select_metric') }); }; diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-header-view.coffee b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-header-view.coffee index b5be79800a1..932de7a1e33 100644 --- a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-header-view.coffee +++ b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-header-view.coffee @@ -39,7 +39,7 @@ define [ deleteQualityGate: -> - if confirm window.SS.phrases.areYouSure + if confirm t('are_you_sure') @showSpinner() jQuery.ajax type: 'POST' diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-header-view.js b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-header-view.js index d3dcdd93591..1ec05e1ea63 100644 --- a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-header-view.js +++ b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-header-view.js @@ -45,7 +45,7 @@ QualityGateDetailHeaderView.prototype.deleteQualityGate = function() { var _this = this; - if (confirm(window.SS.phrases.areYouSure)) { + if (confirm(t('are_you_sure'))) { this.showSpinner(); return jQuery.ajax({ type: 'POST', diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.coffee b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.coffee index 0d02f0bf298..70fbe8f261e 100644 --- a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.coffee +++ b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.coffee @@ -26,10 +26,10 @@ define [ selectParameter: 'projectId' selectParameterValue: 'id' labels: - selected: window.SS.phrases.projects.with - deselected: window.SS.phrases.projects.without - all: window.SS.phrases.projects.all - noResults: window.SS.phrases.projects.noResults + selected: t('quality_gates.projects.with') + deselected: t('quality_gates.projects.without') + all: t('quality_gates.projects.all') + noResults: t('quality_gates.projects.noResults') tooltips: - select: window.SS.phrases.projects.select_hint - deselect: window.SS.phrases.projects.deselect_hint + select: t('quality_gates.projects.select_hint') + deselect: t('quality_gates.projects.deselect_hint') diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.js b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.js index 2da6868f81e..3c647112f03 100644 --- a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.js +++ b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.js @@ -33,14 +33,14 @@ selectParameter: 'projectId', selectParameterValue: 'id', labels: { - selected: window.SS.phrases.projects["with"], - deselected: window.SS.phrases.projects.without, - all: window.SS.phrases.projects.all, - noResults: window.SS.phrases.projects.noResults + selected: t('quality_gates.projects.with'), + deselected: t('quality_gates.projects.without'), + all: t('quality_gates.projects.all'), + noResults: t('quality_gates.projects.noResults') }, tooltips: { - select: window.SS.phrases.projects.select_hint, - deselect: window.SS.phrases.projects.deselect_hint + select: t('quality_gates.projects.select_hint'), + deselect: t('quality_gates.projects.deselect_hint') } }); } |