'
end
- html += ' >'
html += draw_node_body(node)
if (!node.children.nil? && node.children.size > 0)
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/user.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/user.rb
index c89ae10fef9..ff6bcd6ebbc 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/user.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/user.rb
@@ -27,7 +27,6 @@ class User < ActiveRecord::Base
has_many :user_roles, :dependent => :delete_all
has_many :properties, :foreign_key => 'user_id', :dependent => :delete_all
- has_many :filters, :dependent => :destroy
has_many :active_dashboards, :dependent => :destroy, :order => 'order_index'
has_many :dashboards, :dependent => :destroy
has_many :measure_filters, :class_name => 'MeasureFilter', :dependent => :delete_all, :order => 'name asc'
@@ -99,7 +98,6 @@ class User < ActiveRecord::Base
self.save(false)
self.user_roles.clear
self.properties.clear
- self.filters.clear
self.dashboards.clear
self.active_dashboards.clear
self.measure_filter_favourites.clear
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_treemap.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_treemap.html.erb
index ea8981befaf..561d68e3441 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_treemap.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_treemap.html.erb
@@ -1,4 +1,8 @@
-<% if defined? widget %>
+<%
+ treemap_id = 1
+ if defined? widget
+ treemap_id = widget.id
+%>
+
<%= filter.display.html -%>
+
+
+
<%= image_tag 'help.png', :title => h(message('treemap.click_help')) -%>
+
/
+
+
+
+
<% end %>
\ No newline at end of file
diff --git a/sonar-server/src/main/webapp/javascripts/application.js b/sonar-server/src/main/webapp/javascripts/application.js
index eb635f67831..65d32fb7d03 100644
--- a/sonar-server/src/main/webapp/javascripts/application.js
+++ b/sonar-server/src/main/webapp/javascripts/application.js
@@ -15,33 +15,33 @@ function info(message) {
function autocompleteResources() {
$('searchInput').value = '';
new Ajax.Autocompleter('searchInput', 'searchResourcesResults', baseUrl + '/search', {
- method:'post',
- minChars:3,
- indicator:'searchingResources',
- paramName:'s',
- updateElement:function (item) {
+ method: 'post',
+ minChars: 3,
+ indicator: 'searchingResources',
+ paramName: 's',
+ updateElement: function (item) {
if (item.id) {
window.location = baseUrl + '/dashboard/index/' + item.id;
}
},
- onShow:function (element, update) { /* no update */
+ onShow: function (element, update) { /* no update */
update.show();
}
});
}
var SelectBox = {
- cache:new Object(),
- init:function (id) {
+ cache: new Object(),
+ init: function (id) {
var box = document.getElementById(id);
var node;
SelectBox.cache[id] = new Array();
var cache = SelectBox.cache[id];
for (var i = 0; (node = box.options[i]); i++) {
- cache.push({value:node.value, text:node.text, displayed:1});
+ cache.push({value: node.value, text: node.text, displayed: 1});
}
},
- redisplay:function (id) {
+ redisplay: function (id) {
// Repopulate HTML select box from cache
var box = document.getElementById(id);
box.options.length = 0; // clear all options
@@ -52,7 +52,7 @@ var SelectBox = {
}
}
},
- filter:function (id, text) {
+ filter: function (id, text) {
// Redisplay the HTML select box, displaying only the choices containing ALL
// the words in text. (It's an AND search.)
var tokens = text.toLowerCase().split(/\s+/);
@@ -67,7 +67,7 @@ var SelectBox = {
}
SelectBox.redisplay(id);
},
- delete_from_cache:function (id, value) {
+ delete_from_cache: function (id, value) {
var node, delete_index = null;
for (var i = 0; (node = SelectBox.cache[id][i]); i++) {
if (node.value == value) {
@@ -81,10 +81,10 @@ var SelectBox = {
}
SelectBox.cache[id].length--;
},
- add_to_cache:function (id, option) {
- SelectBox.cache[id].push({value:option.value, text:option.text, displayed:1});
+ add_to_cache: function (id, option) {
+ SelectBox.cache[id].push({value: option.value, text: option.text, displayed: 1});
},
- cache_contains:function (id, value) {
+ cache_contains: function (id, value) {
// Check if an item is contained in the cache
var node;
for (var i = 0; (node = SelectBox.cache[id][i]); i++) {
@@ -94,31 +94,31 @@ var SelectBox = {
}
return false;
},
- move:function (from, to) {
+ move: function (from, to) {
var from_box = document.getElementById(from);
var option;
for (var i = 0; (option = from_box.options[i]); i++) {
if (option.selected && SelectBox.cache_contains(from, option.value)) {
- SelectBox.add_to_cache(to, {value:option.value, text:option.text, displayed:1});
+ SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1});
SelectBox.delete_from_cache(from, option.value);
}
}
SelectBox.redisplay(from);
SelectBox.redisplay(to);
},
- move_all:function (from, to) {
+ move_all: function (from, to) {
var from_box = document.getElementById(from);
var option;
for (var i = 0; (option = from_box.options[i]); i++) {
if (SelectBox.cache_contains(from, option.value)) {
- SelectBox.add_to_cache(to, {value:option.value, text:option.text, displayed:1});
+ SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1});
SelectBox.delete_from_cache(from, option.value);
}
}
SelectBox.redisplay(from);
SelectBox.redisplay(to);
},
- sort:function (id) {
+ sort: function (id) {
SelectBox.cache[id].sort(function (a, b) {
a = a.text.toLowerCase();
b = b.text.toLowerCase();
@@ -132,7 +132,7 @@ var SelectBox = {
return 0;
});
},
- select_all:function (id) {
+ select_all: function (id) {
var box = document.getElementById(id);
for (var i = 0; i < box.options.length; i++) {
box.options[i].selected = 'selected';
@@ -146,9 +146,8 @@ var treemaps = {};
function treemapById(id) {
return treemaps[id];
}
-var TreemapContext = function (type, id, label) {
- this.type = type;
- this.id = id;
+var TreemapContext = function (rid, label) {
+ this.rid = rid;
this.label = label;
};
@@ -158,25 +157,15 @@ var TreemapContext = function (type, id, label) {
* tm-bc-#{id} : required breadcrumb
* tm-loading-#{id} : optional loading icon
*/
-var Treemap = function (id, sizeMetric, colorMetric, heightInPercents) {
+var Treemap = function (id, sizeMetric, colorMetric) {
this.id = id;
this.sizeMetric = sizeMetric;
this.colorMetric = colorMetric;
- this.heightInPercents = heightInPercents;
this.breadcrumb = [];
treemaps[id] = this;
-};
-Treemap.prototype.initResource = function (resourceId) {
- this.breadcrumb.push(new TreemapContext('resource', resourceId, ''));
- return this;
-};
-Treemap.prototype.initFilter = function (filterId) {
- this.breadcrumb.push(new TreemapContext('filter', filterId, ''));
- return this;
-};
-Treemap.prototype.init = function (type, id) {
- this.breadcrumb.push(new TreemapContext(type, id, ''));
- return this;
+ this.rootNode().height(this.rootNode().width() * 0.6);
+ this.initNodes();
+
};
Treemap.prototype.changeSizeMetric = function (metric) {
this.sizeMetric = metric;
@@ -194,74 +183,69 @@ Treemap.prototype.currentContext = function () {
}
return null;
};
-Treemap.prototype.width = function () {
- return $('tm-' + this.id).getWidth();
-};
Treemap.prototype.load = function () {
var context = this.currentContext();
- var width = this.width();
- var height = Math.round(width * Math.abs(this.heightInPercents / 100.0));
-
var output = '';
this.breadcrumb.each(function (ctx) {
output += ctx.label + ' / ';
});
- if ($('tm-bc-' + this.id) != null) {
- $('tm-bc-' + this.id).innerHTML = output;
- }
- var loadingIcon = $('tm-loading-' + this.id);
- if (loadingIcon != null) {
- loadingIcon.show();
- }
-
- new Ajax.Request(
- baseUrl + '/treemap/index?id=' + this.id + '&height=' + height + '&size_metric=' + this.sizeMetric + '&color_metric=' + this.colorMetric + '&' + context.type + '=' + context.id,
- {
- asynchronous:true,
- evalScripts:true
- });
+ $j('#tm-bc-' + this.id).html(output);
+ $j('#tm-loading-' + this.id).show();
+ var self = this;
+ $j.ajax({
+ type: "GET",
+ url: baseUrl + '/treemap/index?html_id=' + this.id + '&size_metric=' + this.sizeMetric + '&color_metric=' + this.colorMetric + '&resource=' + context.rid,
+ dataType: "html",
+ success: function (data) {
+ self.rootNode().html(data);
+ self.initNodes();
+ $j("#tm-loading-" + self.id).hide();
+ }
+ });
};
-Treemap.prototype.htmlNode = function (nodeId) {
- return $('tm-node-' + this.id + '-' + nodeId);
+Treemap.prototype.rootNode = function () {
+ return $j('#tm-' + this.id);
};
-Treemap.prototype.handleClick = function (event) {
- if (Event.isLeftClick(event)) {
- var link = event.findElement('a');
- if (link != null) {
- event.stopPropagation();
- return false;
- }
- var elt = event.findElement('div');
- var rid = elt.readAttribute('rid');
- var leaf = elt.hasAttribute('l');
- if (!leaf) {
- var label = elt.innerText || elt.textContent;
- var context = new TreemapContext('resource', rid, label);
- this.breadcrumb.push(context);
- this.load();
- }
-
- } else if (Event.isRightClick(event)) {
- if (this.breadcrumb.length > 1) {
- this.breadcrumb.pop();
- this.load();
- }
- }
-};
-Treemap.prototype.onLoaded = function (componentsSize) {
- for (var i = 1; i <= componentsSize; i++) {
- var elt = this.htmlNode(i);
- elt.oncontextmenu = function () {
- return false
- };
- elt.observe('mouseup', this.handleClick.bind(this));
- }
+Treemap.prototype.initNodes = function () {
+ var self = this;
+ $j('#tm-' + this.id).find('a').each(function (index) {
+ this.on("mouseup", function (event) {
+ event.stopPropagation()
+ });
+ });
+ $j('#tm-' + this.id).find('[rid]').each(function (index) {
+ this.on("mouseup", function (event) {
+ if (event.which == 1) {
+ var source = $j(this);
+ var rid = source.attr('rid');
+ var has_leaves = !!(source.attr('l'));
+ if (!has_leaves) {
+ var context = new TreemapContext(rid, source.text());
+ self.breadcrumb.push(context);
+ self.load();
+ }
+ }
+ }
+ );
+ this.on("contextmenu", function (event) {
+ event.preventDefault();
+ // right click
+ if (self.breadcrumb.length > 1) {
+ self.breadcrumb.pop();
+ self.load();
+ } else {
+ location.reload();
+ }
+ return false;
+ });
+ }
+ );
};
(function ($j) {
$j.fn.extend({
- modal:function () {
+ modal: function () {
return this.each(function () {
var obj = $j(this);
var $link = obj.bind('click', function () {
@@ -275,13 +259,13 @@ Treemap.prototype.onLoaded = function (componentsSize) {
$dialog.html(html);
$dialog
.dialog({
- width:($link.attr('modal-width') || 540),
- draggable:false,
- autoOpen:false,
- modal:true,
- minHeight:50,
- resizable:false,
- close:function () {
+ width: ($link.attr('modal-width') || 540),
+ draggable: false,
+ autoOpen: false,
+ modal: true,
+ minHeight: 50,
+ resizable: false,
+ close: function () {
$j('#modal').remove();
}
});
@@ -301,19 +285,19 @@ Treemap.prototype.onLoaded = function (componentsSize) {
});
});
},
- modalForm:function (ajax_options) {
+ modalForm: function (ajax_options) {
return this.each(function () {
var obj = $j(this);
obj.submit(function (event) {
$j('input[type=submit]', this).attr('disabled', 'disabled');
$j.ajax($j.extend({
- type:'POST',
- url:obj.attr('action'),
- data:obj.serialize(),
- success:function (data) {
+ type: 'POST',
+ url: obj.attr('action'),
+ data: obj.serialize(),
+ success: function (data) {
window.location.reload();
},
- error:function (xhr, textStatus, errorThrown) {
+ error: function (xhr, textStatus, errorThrown) {
$j("#modal").html(xhr.responseText);
}
}, ajax_options));
diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css
index 4c8a61c9b4b..903bec852fc 100644
--- a/sonar-server/src/main/webapp/stylesheets/style.css
+++ b/sonar-server/src/main/webapp/stylesheets/style.css
@@ -271,10 +271,13 @@ h4, .h4 {
.treemap a {
color: #FFF;
- text-decoration: underline;
+ text-decoration: none;
font-size: 12px;
padding: 1px;
}
+.treemap a:hover {
+ text-decoration: underline;
+}
/* ------------------- MESSAGES ------------------- */
.warning {
--
2.39.5