mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-21 04:12:37 +09:00
feature #3671: Move Sunstone user settings to a SUNSTONE vector inside the template
This commit is contained in:
1 parent
d0c71ed743
commit
a8d040362d
4 files changed
+69
-51
No files matched your search
@@ -71,6 +71,7 @@ define(function(require) {
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
$(document).foundation('accordion', 'reflow');
|
||||
var ssh_key = this.element.TEMPLATE.SSH_PUBLIC_KEY;
|
||||
if (ssh_key && ssh_key.length) {
|
||||
@@ -126,18 +127,26 @@ define(function(require) {
|
||||
});
|
||||
|
||||
$("#provision_change_view_form").submit(function() {
|
||||
var template_str = 'DEFAULT_VIEW = "'+$('#provision_user_views_select', this).val()+'"';
|
||||
|
||||
Sunstone.runAction("User.append_template_refresh", "-1", template_str);
|
||||
var sunstone_template = {};
|
||||
if (that.element.TEMPLATE.SUNSTONE) {
|
||||
$.extend(sunstone_template, that.element.TEMPLATE.SUNSTONE);
|
||||
}
|
||||
|
||||
sunstone_template.DEFAULT_VIEW = $('#provision_user_views_select', this).val();
|
||||
var template_str = TemplateUtils.templateToString({'SUNSTONE': sunstone_template});
|
||||
Sunstone.runAction("User.append_template_refresh", that.element.ID, template_str);
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#provision_change_language_form").submit(function() {
|
||||
var template_str = 'LANG = "'+$('#provision_new_language', this).val()+'"';
|
||||
|
||||
Sunstone.runAction("User.append_template_refresh", "-1", template_str);
|
||||
var sunstone_template = {};
|
||||
if (that.element.TEMPLATE.SUNSTONE) {
|
||||
$.extend(sunstone_template, that.element.TEMPLATE.SUNSTONE);
|
||||
}
|
||||
|
||||
sunstone_template.LANG = $('#provision_new_language', this).val();
|
||||
var template_str = TemplateUtils.templateToString({'SUNSTONE': sunstone_template});
|
||||
Sunstone.runAction("User.append_template_refresh", that.element.ID, template_str);
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
@@ -83,10 +83,7 @@ define(function(require) {
|
||||
// TODO: simplify interface?
|
||||
var strippedTemplate = $.extend({}, this.element.TEMPLATE);
|
||||
delete strippedTemplate["SSH_PUBLIC_KEY"];
|
||||
delete strippedTemplate["LANG"];
|
||||
delete strippedTemplate["TABLE_ORDER"];
|
||||
delete strippedTemplate["DEFAULT_VIEW"];
|
||||
delete strippedTemplate["TABLE_DEFAULT_PAGE_LENGTH"];
|
||||
delete strippedTemplate["SUNSTONE"];
|
||||
|
||||
var templateTableHTML = TemplateTable.html(strippedTemplate, RESOURCE,
|
||||
Locale.tr("Attributes"));
|
||||
@@ -94,6 +91,7 @@ define(function(require) {
|
||||
|
||||
return TemplateInfo({
|
||||
'element': this.element,
|
||||
'sunstone_template': this.element.TEMPLATE.SUNSTONE||{},
|
||||
'groupTrHTML': groupTrHTML,
|
||||
'secondaryGroups': secondaryGroups,
|
||||
'templateTableHTML': templateTableHTML
|
||||
@@ -107,24 +105,15 @@ define(function(require) {
|
||||
// TODO: simplify interface?
|
||||
var strippedTemplate = $.extend({}, this.element.TEMPLATE);
|
||||
delete strippedTemplate["SSH_PUBLIC_KEY"];
|
||||
delete strippedTemplate["LANG"];
|
||||
delete strippedTemplate["TABLE_ORDER"];
|
||||
delete strippedTemplate["DEFAULT_VIEW"];
|
||||
delete strippedTemplate["TABLE_DEFAULT_PAGE_LENGTH"];
|
||||
delete strippedTemplate["SUNSTONE"];
|
||||
|
||||
var hiddenValues = {};
|
||||
|
||||
if (this.element.TEMPLATE.SSH_PUBLIC_KEY != undefined) {
|
||||
hiddenValues.SSH_PUBLIC_KEY = this.element.TEMPLATE.SSH_PUBLIC_KEY;
|
||||
}
|
||||
if (this.element.TEMPLATE.LANG != undefined) {
|
||||
hiddenValues.LANG = this.element.TEMPLATE.LANG;
|
||||
}
|
||||
if (this.element.TEMPLATE.TABLE_ORDER != undefined) {
|
||||
hiddenValues.TABLE_ORDER = this.element.TEMPLATE.TABLE_ORDER;
|
||||
}
|
||||
if (this.element.TEMPLATE.DEFAULT_VIEW != undefined) {
|
||||
hiddenValues.DEFAULT_VIEW = this.element.TEMPLATE.DEFAULT_VIEW;
|
||||
if (this.element.TEMPLATE.SUNSTONE != undefined) {
|
||||
hiddenValues.SUNSTONE = this.element.TEMPLATE.SUNSTONE;
|
||||
}
|
||||
|
||||
TemplateTable.setup(strippedTemplate, RESOURCE, this.element.ID, context, hiddenValues);
|
||||
@@ -182,15 +171,20 @@ define(function(require) {
|
||||
'<option value="desc">' + Locale.tr("descending") + '</option>' +
|
||||
'</select>');
|
||||
|
||||
if (that.element.TEMPLATE.TABLE_ORDER) {
|
||||
$('#table_order_select', context).val(that.element.TEMPLATE.TABLE_ORDER);
|
||||
if (that.element.TEMPLATE.SUNSTONE && that.element.TEMPLATE.SUNSTONE.TABLE_ORDER) {
|
||||
$('#table_order_select', context).val(that.element.TEMPLATE.SUNSTONE.TABLE_ORDER);
|
||||
}
|
||||
});
|
||||
|
||||
context.off("change", "#table_order_select")
|
||||
context.on("change", "#table_order_select", function() {
|
||||
var template_str = 'TABLE_ORDER = "'+$(this).val()+'"';
|
||||
var sunstone_template = {};
|
||||
if (that.element.TEMPLATE.SUNSTONE) {
|
||||
$.extend(sunstone_template, that.element.TEMPLATE.SUNSTONE);
|
||||
}
|
||||
|
||||
sunstone_template.TABLE_ORDER = $(this).val();
|
||||
var template_str = TemplateUtils.templateToString({'SUNSTONE': sunstone_template});
|
||||
Sunstone.runAction("User.append_template_refresh", that.element.ID, template_str);
|
||||
});
|
||||
|
||||
@@ -201,15 +195,20 @@ define(function(require) {
|
||||
Locale.language_options +
|
||||
'</select>');
|
||||
|
||||
if (that.element.TEMPLATE.LANG) {
|
||||
$('#language_select', context).val(that.element.TEMPLATE.LANG);
|
||||
if (that.element.TEMPLATE.SUNSTONE && that.element.TEMPLATE.SUNSTONE.LANG) {
|
||||
$('#language_select', context).val(that.element.TEMPLATE.SUNSTONE.LANG);
|
||||
}
|
||||
});
|
||||
|
||||
context.off("change", "#language_select")
|
||||
context.on("change", "#language_select", function() {
|
||||
var template_str = 'LANG = "'+$(this).val()+'"';
|
||||
var sunstone_template = {};
|
||||
if (that.element.TEMPLATE.SUNSTONE) {
|
||||
$.extend(sunstone_template, that.element.TEMPLATE.SUNSTONE);
|
||||
}
|
||||
|
||||
sunstone_template.LANG = $(this).val();
|
||||
var template_str = TemplateUtils.templateToString({'SUNSTONE': sunstone_template});
|
||||
Sunstone.runAction("User.append_template_refresh", that.element.ID, template_str);
|
||||
});
|
||||
|
||||
@@ -225,15 +224,20 @@ define(function(require) {
|
||||
options +
|
||||
'</select>');
|
||||
|
||||
if (that.element.TEMPLATE.DEFAULT_VIEW) {
|
||||
$('#view_select', context).val(that.element.TEMPLATE.DEFAULT_VIEW);
|
||||
if (that.element.TEMPLATE.SUNSTONE && that.element.TEMPLATE.SUNSTONE.DEFAULT_VIEW) {
|
||||
$('#view_select', context).val(that.element.TEMPLATE.SUNSTONE.DEFAULT_VIEW);
|
||||
}
|
||||
});
|
||||
|
||||
context.off("change", "#view_select")
|
||||
context.on("change", "#view_select", function() {
|
||||
var template_str = 'DEFAULT_VIEW = "'+$(this).val()+'"';
|
||||
var sunstone_template = {};
|
||||
if (that.element.TEMPLATE.SUNSTONE) {
|
||||
$.extend(sunstone_template, that.element.TEMPLATE.SUNSTONE);
|
||||
}
|
||||
|
||||
sunstone_template.DEFAULT_VIEW = $(this).val();
|
||||
var template_str = TemplateUtils.templateToString({'SUNSTONE': sunstone_template});
|
||||
Sunstone.runAction("User.append_template_refresh", that.element.ID, template_str);
|
||||
});
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Table Order"}}</td>
|
||||
<td class="value_td_table_order">{{valOrDefault element.TEMPLATE.TABLE_ORDER "-"}}</td>
|
||||
<td class="value_td_table_order">{{valOrDefault sunstone_template.TABLE_ORDER "-"}}</td>
|
||||
<td>
|
||||
<div id="div_edit_table_order">
|
||||
<a id="div_edit_table_order_link" class="edit_e" href="#"> <i class="fa fa-pencil-square-o right"/></a>
|
||||
@@ -63,7 +63,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Language"}}</td>
|
||||
<td class="value_td_language">{{valOrDefault element.TEMPLATE.LANG "-"}}</td>
|
||||
<td class="value_td_language">{{valOrDefault sunstone_template.LANG "-"}}</td>
|
||||
<td>
|
||||
<div id="div_edit_language">
|
||||
<a id="div_edit_language_link" class="edit_e" href="#"> <i class="fa fa-pencil-square-o right"/></a>
|
||||
@@ -72,7 +72,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "View"}}</td>
|
||||
<td class="value_td_view">{{valOrDefault element.TEMPLATE.DEFAULT_VIEW "-"}}</td>
|
||||
<td class="value_td_view">{{valOrDefault sunstone_template.DEFAULT_VIEW "-"}}</td>
|
||||
<td>
|
||||
<div id="div_edit_view">
|
||||
<a id="div_edit_view_link" class="edit_e" href="#"> <i class="fa fa-pencil-square-o right"/></a>
|
||||
|
||||
@@ -49,7 +49,12 @@ $: << SUNSTONE_ROOT_DIR+'/models'
|
||||
|
||||
SESSION_EXPIRE_TIME = 60*60
|
||||
|
||||
DISPLAY_NAME_XPATH = 'TEMPLATE/SUNSTONE_DISPLAY_NAME'
|
||||
DISPLAY_NAME_XPATH = 'TEMPLATE/SUNSTONE/DISPLAY_NAME'
|
||||
TABLE_ORDER_XPATH = 'TEMPLATE/SUNSTONE/TABLE_ORDER'
|
||||
DEFAULT_VIEW_XPATH = 'TEMPLATE/SUNSTONE/DEFAULT_VIEW'
|
||||
GROUP_ADMIN_DEFAULT_VIEW_XPATH = 'TEMPLATE/SUNSTONE/GROUP_ADMIN_DEFAULT_VIEW'
|
||||
TABLE_DEFAULT_PAGE_LENGTH_XPATH = 'TEMPLATE/SUNSTONE/TABLE_DEFAULT_PAGE_LENGTH'
|
||||
LANG_XPATH = 'TEMPLATE/SUNSTONE/LANG'
|
||||
|
||||
##############################################################################
|
||||
# Required libraries
|
||||
@@ -225,14 +230,14 @@ helpers do
|
||||
# - WSS CONECTION
|
||||
# - TABLE ORDER
|
||||
|
||||
if user['TEMPLATE/LANG']
|
||||
session[:lang] = user['TEMPLATE/LANG']
|
||||
if user[LANG_XPATH]
|
||||
session[:lang] = user[LANG_XPATH]
|
||||
else
|
||||
session[:lang] = $conf[:lang]
|
||||
end
|
||||
|
||||
if user['TEMPLATE/TABLE_DEFAULT_PAGE_LENGTH']
|
||||
session[:page_length] = user['TEMPLATE/TABLE_DEFAULT_PAGE_LENGTH']
|
||||
if user[TABLE_DEFAULT_PAGE_LENGTH_XPATH]
|
||||
session[:page_length] = user[TABLE_DEFAULT_PAGE_LENGTH_XPATH]
|
||||
else
|
||||
session[:page_length] = DEFAULT_PAGE_LENGTH
|
||||
end
|
||||
@@ -242,18 +247,18 @@ helpers do
|
||||
session[:vnc_wss] = (wss == true || wss == "yes" || wss == "only" ?
|
||||
"yes" : "no")
|
||||
|
||||
if user['TEMPLATE/TABLE_ORDER']
|
||||
session[:table_order] = user['TEMPLATE/TABLE_ORDER']
|
||||
if user[TABLE_ORDER_XPATH]
|
||||
session[:table_order] = user[TABLE_ORDER_XPATH]
|
||||
else
|
||||
session[:table_order] = $conf[:table_order] || DEFAULT_TABLE_ORDER
|
||||
end
|
||||
|
||||
if user['TEMPLATE/DEFAULT_VIEW']
|
||||
session[:default_view] = user['TEMPLATE/DEFAULT_VIEW']
|
||||
elsif group.contains_admin(user.id) && group['TEMPLATE/GROUP_ADMIN_DEFAULT_VIEW']
|
||||
session[:default_view] = group['TEMPLATE/GROUP_ADMIN_DEFAULT_VIEW']
|
||||
elsif group['TEMPLATE/DEFAULT_VIEW']
|
||||
session[:default_view] = group['TEMPLATE/DEFAULT_VIEW']
|
||||
if user[DEFAULT_VIEW_XPATH]
|
||||
session[:default_view] = user[DEFAULT_VIEW_XPATH]
|
||||
elsif group.contains_admin(user.id) && group[GROUP_ADMIN_DEFAULT_VIEW_XPATH]
|
||||
session[:default_view] = group[GROUP_ADMIN_DEFAULT_VIEW_XPATH]
|
||||
elsif group[DEFAULT_VIEW_XPATH]
|
||||
session[:default_view] = group[DEFAULT_VIEW_XPATH]
|
||||
else
|
||||
session[:default_view] = $views_config.available_views(session[:user], session[:user_gname]).first
|
||||
end
|
||||
@@ -458,11 +463,11 @@ post '/config' do
|
||||
error 500, ""
|
||||
end
|
||||
|
||||
session[:lang] = user['TEMPLATE/LANG'] if user['TEMPLATE/LANG']
|
||||
session[:lang] = user[LANG_XPATH] if user[LANG_XPATH]
|
||||
session[:vnc_wss] = user['TEMPLATE/VNC_WSS'] if user['TEMPLATE/VNC_WSS']
|
||||
session[:default_view] = user['TEMPLATE/DEFAULT_VIEW'] if user['TEMPLATE/DEFAULT_VIEW']
|
||||
session[:table_order] = user['TEMPLATE/TABLE_ORDER'] if user['TEMPLATE/TABLE_ORDER']
|
||||
session[:page_length] = user['TEMPLATE/TABLE_DEFAULT_PAGE_LENGTH'] if user['TEMPLATE/TABLE_DEFAULT_PAGE_LENGTH']
|
||||
session[:default_view] = user[DEFAULT_VIEW_XPATH] if user[DEFAULT_VIEW_XPATH]
|
||||
session[:table_order] = user[TABLE_ORDER_XPATH] if user[TABLE_ORDER_XPATH]
|
||||
session[:page_length] = user[TABLE_DEFAULT_PAGE_LENGTH_XPATH] if user[TABLE_DEFAULT_PAGE_LENGTH_XPATH]
|
||||
session[:display_name] = user[DISPLAY_NAME_XPATH] || user['NAME']
|
||||
|
||||
[204, ""]
|
||||
|
||||
Reference in new issue
Block a user