diff --git a/src/sunstone/models/SunstoneViews.rb b/src/sunstone/models/SunstoneViews.rb
index 585b165d46..ddc2489651 100644
--- a/src/sunstone/models/SunstoneViews.rb
+++ b/src/sunstone/models/SunstoneViews.rb
@@ -131,6 +131,17 @@ class SunstoneViews
@views.keys
end
+ def get_all_labels(group_name)
+ labels = []
+ if @views_config['labels_groups'][group_name]
+ @views_config['labels_groups'][group_name].each{|l| labels.push(l)}
+ end
+ if @views_config['labels_groups']['default']
+ @views_config['labels_groups']['default'].each{|l| labels.push(l)}
+ end
+ return labels
+ end
+
def logo
@views_config['logo']
end
diff --git a/src/sunstone/public/app/utils/labels/tree.js b/src/sunstone/public/app/utils/labels/tree.js
index b188dba8ae..6467b3743d 100644
--- a/src/sunstone/public/app/utils/labels/tree.js
+++ b/src/sunstone/public/app/utils/labels/tree.js
@@ -16,6 +16,9 @@
define(function(require) {
var Locale = require('utils/locale');
+ var OpenNebulaUser = require('opennebula/user');
+ var Sunstone = require('sunstone');
+ var TemplateUtils = require('utils/template-utils');
/*
CONSTRUCTOR
@@ -61,6 +64,8 @@ define(function(require) {
html = '
';
} else {
var title = $(tree.htmlStr).attr('title');
+ var persis = $(tree.htmlStr).attr('persis');
+ var yaml = $(tree.htmlStr).attr('yaml');
var color = _labelHue(title);
if (title != undefined && title != "") {
@@ -82,6 +87,8 @@ define(function(require) {
html = '
';
} else {
var title = $(tree.htmlStr).attr('title');
+ var persis = $(tree.htmlStr).attr('persis');
+ var yaml = $(tree.htmlStr).attr('yaml');
var color = _labelHue(title);
if (title != undefined && title != "") {
@@ -89,7 +96,13 @@ define(function(require) {
} else {
html = '
';
}
-
+ if (!yaml) {
+ if (!persis) {
+ html += '';
+ } else {
+ html += '';
+ }
+ }
html += ' ';
}
@@ -131,6 +144,48 @@ define(function(require) {
$('.one-label', this).addClass('active');
}
});
+
+ $(".lock", context).on("click", function(){
+ var type = $(this).attr("type");
+ var title = $(this).attr("title");
+ if (type == "unlock"){
+ $(".fa-unlock", this).attr("class", "left fa fa-fw fa-lock");
+ $(this).attr("type", "lock");
+ } else {
+ $(".fa-lock", this).attr("class", "left fa fa-fw fa-unlock");
+ $(this).attr("type", "unlock");
+ }
+ var that = this;
+ OpenNebulaUser.show({
+ data : {
+ id: config['user_id']
+ },
+ success: function(request, user_json) {
+ var final_template = {};
+ if (user_json["USER"]["TEMPLATE"]) {
+ if (user_json["USER"]["TEMPLATE"]["LABELS"]) {
+ var titles = user_json["USER"]["TEMPLATE"]["LABELS"].split(",");
+ var pos = titles.indexOf(title);
+ if (type == "lock" && pos != -1){ //unlock
+ titles.splice(pos, 1);
+ $(this).removeAttr("locked");
+ } else if (type == "unlock" && pos == -1) { //lock
+ titles.push(title);
+ $(this).attr("locked", "true");
+ }
+ user_json["USER"]["TEMPLATE"]["LABELS"] = titles.join(",");
+ } else {
+ user_json["USER"]["TEMPLATE"]["LABELS"] = title;
+ }
+ if (user_json["USER"]["TEMPLATE"]["LABELS"] == ""){
+ delete user_json["USER"]["TEMPLATE"]["LABELS"];
+ }
+ template_str = TemplateUtils.templateToString(user_json["USER"]["TEMPLATE"]);
+ Sunstone.runAction("User.update_template", config['user_id'], template_str);
+ }
+ }
+ });
+ });
}
// http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
diff --git a/src/sunstone/public/app/utils/labels/utils.js b/src/sunstone/public/app/utils/labels/utils.js
index 4f9354abac..422b48bf1c 100644
--- a/src/sunstone/public/app/utils/labels/utils.js
+++ b/src/sunstone/public/app/utils/labels/utils.js
@@ -23,6 +23,7 @@ define(function(require) {
var Locale = require('utils/locale');
var Notifier = require('utils/notifier');
var TemplateUtils = require('utils/template-utils');
+ var OpenNebulaUser = require('opennebula/user');
var LABELS_ATTR = 'LABELS';
@@ -117,20 +118,59 @@ define(function(require) {
var labelsDropdown = $('#' + tabName + 'LabelsDropdown');
- var labels = _getLabels(dataTable, labelsColumn);
- labelsDropdown.html(
- '