1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

feature #2761: Add SSH key from the settings dialog

(cherry picked from commit d39b315e6b7125d5c846d054be4fecfc5392d63c)

Conflicts:
	src/sunstone/public/css/app.css
This commit is contained in:
Daniel Molina 2014-12-12 17:06:29 +01:00
parent da31aeb674
commit 9f66b79f19
2 changed files with 59 additions and 7 deletions

View File

@ -138,6 +138,20 @@ var config_tab_content =
</tbody>\
</table>\
</div>\
<div class="large-5 columns">' +
'<table class="dataTable extended_table" cellpadding="0" cellspacing="0" border="0">\
<thead>\
<tr>\
<th>' + tr("Public SSH Key") + '</th>\
<th>\
<a class="config_ssh_public_key_edit right" href="#"><i class="fa fa-pencil-square-o"></i></a>\
</th>\
</tr>\
</thead>\
</table>\
<textarea rows="6" type="text" id="config_ssh_public_key_textarea" name="ssh_public_key" class="hidden"/>\
<p id="config_ssh_public_key_text" name="ssh_public_key"></p>\
</div>\
</div>\
<div class="row">\
<div id="setting_user_template" class="large-12 columns">'+
@ -303,6 +317,38 @@ function setupConfigDialog() {
dialog.addClass("reveal-modal large max-height").attr("data-reveal", "");
$(".config_ssh_public_key_edit", '#config_dialog').on("click", function(){
$("#config_ssh_public_key_text", '#config_dialog').hide();
$("#config_ssh_public_key_textarea", '#config_dialog').show().focus();
});
$("#config_ssh_public_key_textarea", '#config_dialog').on("change", function(){
var user_id = getSelectedNodes(dataTable_users)[0];
OpenNebula.User.show({
data : {
id: -1
},
success: function(request,user_json){
var template = user_json.USER.TEMPLATE;
template["SSH_PUBLIC_KEY"] = $("#config_ssh_public_key_textarea", '#config_dialog').val();
template_str = "";
$.each(template,function(key,value){
template_str += (key + '=' + '"' + value + '"\n');
});
Sunstone.runAction("UserSettings.update_template", -1, template_str);
}
})
});
$("#config_ssh_public_key_textarea", '#config_dialog').on("focusout", function(){
$("#config_ssh_public_key_text", '#config_dialog').show();
$("#config_ssh_public_key_textarea", '#config_dialog').hide();
});
setupTips(dialog);
if (config['user_config']["vnc_wss"] == "yes"){
@ -415,11 +461,22 @@ function updateUserConfigInfo(request,user_json) {
<td class="value_td" colspan="2"><button id="update_password" type="button" class="button tiny radius" >' + tr("Update password") + '</button></td>\
</tr>')
var ssh_key;
if (info.TEMPLATE.SSH_PUBLIC_KEY) {
ssh_key = info.TEMPLATE.SSH_PUBLIC_KEY;
delete info.TEMPLATE.SSH_PUBLIC_KEY;
$("#config_ssh_public_key_text", "#config_dialog").text(ssh_key);
$("#config_ssh_public_key_textarea", "#config_dialog").val(ssh_key);
} else {
$("#config_ssh_public_key_text", "#config_dialog").text(tr("You can provide a SSH Key for this User clicking on the edit button"))
};
$("#setting_user_template").html(
insert_extended_template_table(info.TEMPLATE,
"UserSettings",
"-1",
tr("Custom Attributes"))
tr("Custom Attributes"),
{SSH_PUBLIC_KEY: ssh_key})
)
$("#div_edit_chg_group_link").die();

View File

@ -594,7 +594,7 @@ function updateUserInfo(request,user){
</thead>\
</table>\
<textarea rows="6" type="text" id="user_ssh_public_key_textarea" name="ssh_public_key" class="hidden"/>\
<p id="user_ssh_public_key_text" name="ssh_public_key" style="font-size: 0.875rem; color: #777; padding: 0px 10px; overflow-x:hidden; text-overflow: ellipsis; height: 120px;">'+tr("You can provide a SSH Key for this User clicking on the edit button")+'</p>\
<p id="user_ssh_public_key_text" name="ssh_public_key">'+tr("You can provide a SSH Key for this User clicking on the edit button")+'</p>\
</div>\
</div>\
<div class="row">\
@ -657,11 +657,6 @@ function updateUserInfo(request,user){
Config.isTabActionEnabled("users-tab", "User.quotas_dialog"),
"User");
if (ssh_key) {
$("#user_ssh_public_key_text", "#user_info_panel").text(ssh_key);
$("#user_ssh_public_key_textarea", "#user_info_panel").val(ssh_key);
}
$(".user_ssh_public_key_edit", "#user_info_panel").on("click", function(){
$("#user_ssh_public_key_text", "#user_info_panel").hide();
$("#user_ssh_public_key_textarea", "#user_info_panel").show().focus();