mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
feature #2761: Easily add ssh keys to any user from the admin view
(cherry picked from commit 11ce7f1fad480e170e5c6c81d7011449ff7759fe) Conflicts: src/sunstone/public/css/app.css
This commit is contained in:
parent
6f6ef024bc
commit
da31aeb674
File diff suppressed because one or more lines are too long
@ -537,6 +537,12 @@ function updateUsersView(request,users_list,quotas_list){
|
||||
function updateUserInfo(request,user){
|
||||
var info = user.USER;
|
||||
|
||||
var ssh_key;
|
||||
if (info.TEMPLATE.SSH_PUBLIC_KEY) {
|
||||
ssh_key = info.TEMPLATE.SSH_PUBLIC_KEY;
|
||||
delete info.TEMPLATE.SSH_PUBLIC_KEY;
|
||||
};
|
||||
|
||||
$(".resource-info-header", $("#users-tab")).html(info.NAME);
|
||||
|
||||
var info_tab = {
|
||||
@ -577,14 +583,27 @@ function updateUserInfo(request,user){
|
||||
</table>\
|
||||
</div>\
|
||||
<div class="large-6 columns">' +
|
||||
'</div>\
|
||||
'<table class="dataTable extended_table" cellpadding="0" cellspacing="0" border="0">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th>' + tr("Public SSH Key") + '</th>\
|
||||
<th>\
|
||||
<a class="user_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="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>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="row">\
|
||||
<div class="large-9 columns">'+
|
||||
insert_extended_template_table(info.TEMPLATE,
|
||||
"User",
|
||||
info.ID,
|
||||
tr("Attributes")) +
|
||||
tr("Attributes"),
|
||||
{SSH_PUBLIC_KEY: ssh_key}) +
|
||||
'</div>\
|
||||
</div>'
|
||||
};
|
||||
@ -637,6 +656,43 @@ function updateUserInfo(request,user){
|
||||
"#user_info_panel",
|
||||
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();
|
||||
});
|
||||
|
||||
$("#user_ssh_public_key_textarea", "#user_info_panel").on("change", function(){
|
||||
var user_id = getSelectedNodes(dataTable_users)[0];
|
||||
|
||||
OpenNebula.User.show({
|
||||
data : {
|
||||
id: user_id
|
||||
},
|
||||
success: function(request,user_json){
|
||||
var template = user_json.USER.TEMPLATE;
|
||||
|
||||
template["SSH_PUBLIC_KEY"] = $("#user_ssh_public_key_textarea", "#user_info_panel").val();
|
||||
|
||||
template_str = "";
|
||||
$.each(template,function(key,value){
|
||||
template_str += (key + '=' + '"' + value + '"\n');
|
||||
});
|
||||
|
||||
Sunstone.runAction("User.update_template", user_id, template_str);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
$("#user_ssh_public_key_textarea", "#user_info_panel").on("focusout", function(){
|
||||
$("#user_ssh_public_key_text", "#user_info_panel").show();
|
||||
$("#user_ssh_public_key_textarea", "#user_info_panel").hide();
|
||||
});
|
||||
};
|
||||
|
||||
// Used also from groups-tabs.js
|
||||
|
@ -1124,3 +1124,12 @@ hr {
|
||||
margin-top: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
#user_ssh_public_key_text, #config_ssh_public_key_text {
|
||||
font-size: 0.875rem;
|
||||
color: #777;
|
||||
padding: 0px 10px;
|
||||
overflow-x:hidden;
|
||||
text-overflow:
|
||||
ellipsis; height: 120px;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user