aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-04-13 17:25:28 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-04-13 17:25:28 +0200
commitc020c6baecfb3549de4b1afa2a0f72a0357f0b9e (patch)
tree17f0d4c4eb1d1e9983506bef5a0e6554158dfb63 /server/sonar-web/src/main
parent8f3021e5490370d14581be78aedb8296fac9e279 (diff)
downloadsonarqube-c020c6baecfb3549de4b1afa2a0f72a0357f0b9e.tar.gz
sonarqube-c020c6baecfb3549de4b1afa2a0f72a0357f0b9e.zip
SONAR-5851 refactor profile fetch
Diffstat (limited to 'server/sonar-web/src/main')
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/controller.js5
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/profile.js48
2 files changed, 49 insertions, 4 deletions
diff --git a/server/sonar-web/src/main/js/quality-profiles/controller.js b/server/sonar-web/src/main/js/quality-profiles/controller.js
index 7a71e1e71e6..a7071cde771 100644
--- a/server/sonar-web/src/main/js/quality-profiles/controller.js
+++ b/server/sonar-web/src/main/js/quality-profiles/controller.js
@@ -83,10 +83,7 @@ define([
},
fetchProfile: function (profile) {
- return $.when(
- this.fetchProfileRules(profile),
- this.fetchInheritance(profile)
- );
+ return profile.fetch();
},
fetchProfileRules: function (profile) {
diff --git a/server/sonar-web/src/main/js/quality-profiles/profile.js b/server/sonar-web/src/main/js/quality-profiles/profile.js
index 6c1d9684946..c88f747cf97 100644
--- a/server/sonar-web/src/main/js/quality-profiles/profile.js
+++ b/server/sonar-web/src/main/js/quality-profiles/profile.js
@@ -19,11 +19,59 @@
*/
define(function () {
+ var $ = jQuery;
+
return Backbone.Model.extend({
idAttribute: 'key',
defaults: {
activeRuleCount: 0
+ },
+
+ fetch: function () {
+ var that = this;
+ this.fetchChanged = {};
+ return $.when(
+ this.fetchProfileRules(),
+ this.fetchInheritance()
+ ).done(function () {
+ that.set(that.fetchChanged);
+ });
+ },
+
+ fetchProfileRules: function () {
+ var that = this,
+ url = baseUrl + '/api/rules/search',
+ key = this.id,
+ options = {
+ ps: 1,
+ facets: 'severities,tags',
+ qprofile: key,
+ activation: 'true'
+ };
+ return $.get(url, options).done(function (r) {
+ var severityFacet = _.findWhere(r.facets, { property: 'severities' });
+ if (severityFacet != null) {
+ var severities = severityFacet.values,
+ severityComparator = function (s) {
+ return window.severityColumnsComparator(s.val);
+ },
+ sortedSeverities = _.sortBy(severities, severityComparator);
+ _.extend(that.fetchChanged, { rulesSeverities: sortedSeverities });
+ }
+ });
+ },
+
+ fetchInheritance: function () {
+ var that = this,
+ url = baseUrl + '/api/qualityprofiles/inheritance',
+ options = { profileKey: this.id };
+ return $.get(url, options).done(function (r) {
+ _.extend(that.fetchChanged, r.profile, {
+ ancestors: r.ancestors,
+ children: r.children
+ });
+ });
}
});