feature #3748: Remove deprecated sunstone files

This commit is contained in:
Daniel Molina committed 2015-06-23 18:25:52 +02:00
1 parent 3f74314808
commit 3bb0b67e55
29 files changed
-47592

No files matched your search

-17
View File
@@ -1,17 +0,0 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
-101
View File
@@ -1,101 +0,0 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
function auth_success(req, response){
window.location.href = ".";
}
function auth_error(req, error){
var status = error.error.http_status;
switch (status){
case 401:
$("#error_message").text("Invalid username or password");
break;
case 500:
$("#error_message").text("OpenNebula is not running or there was a server exception. Please check the server logs.");
break;
case 0:
$("#error_message").text("No answer from server. Is it running?");
break;
default:
$("#error_message").text("Unexpected error. Status "+status+". Check the server logs.");
};
$("#error_box").fadeIn("slow");
$("#login_spinner").hide();
}
function authenticate(){
var username = $("#username").val();
var password = $("#password").val();
var remember = $("#check_remember").is(":checked");
$("#error_box").fadeOut("slow");
$("#login_spinner").show();
OpenNebula.Auth.login({ data: {username: username
, password: password}
, remember: remember
, success: auth_success
, error: auth_error
});
}
function getInternetExplorerVersion(){
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}
function checkVersion(){
var ver = getInternetExplorerVersion();
if ( ver > -1 ){
msg = ver <= 7.0 ? "You are using an old version of IE. \
Please upgrade or use Firefox or Chrome for full compatibility." :
"OpenNebula Sunstone is best seen with Chrome or Firefox";
$("#error_box").text(msg);
$("#error_box").fadeIn('slow');
}
}
$(document).ready(function(){
$("#login_form").submit(function (){
authenticate();
return false;
});
//compact login elements according to screen height
if (screen.height <= 600){
$('div#logo_sunstone').css("top","15px");
$('div#login').css("top","10px");
$('.error_message').css("top","10px");
};
$("input#username.box").focus();
$("#login_spinner").hide();
checkVersion();
});
File diff suppressed because it is too large. Load diff
-737
View File
@@ -1,737 +0,0 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
/*ACLs tab plugin*/
var dataTable_acls;
var $create_acl_dialog;
var create_acl_tmpl =
'<div class="row">\
<div class="large-12 columns">\
<h3 id="create_vnet_header" class="subheader">'+tr("Create ACL")+'</h3>\
</div>\
</div>\
<form id="create_acl_form" action="">\
<div class="row">\
<div class="large-6 columns">\
<fieldset>\
<legend>'+tr("This rule applies to")+'</legend>\
<div class="row">\
<div class="large-4 columns">\
<input type="radio" class="applies" name="applies_select" value="*" id="applies_all"><label class="applies" for="applies_all">'+tr("All")+'</label>\
</div>\
<div class="large-4 columns">\
<input type="radio" class="applies" name="applies_select" value="applies_to_user" id="applies_id"><label class="applies" for="applies_id">'+tr("User")+'</label>\
</div>\
<div class="large-4 columns">\
<input type="radio" class="applies" name="applies_select" value="applies_to_group" id="applies_group"><label class="applies" for="applies_group">'+tr("Group")+'</label>\
</div>\
</div>\
<div class="row">\
<div class="large-12 columns">\
<div class="applies_to_user">\
<label for="applies_to_user">'+tr("User")+':</label>\
<div name="applies_to_user" id="applies_to_user">\
</div>\
</div>\
<div class="applies_to_group">\
<label for="applies_to_group">'+tr("Group")+':</label>\
<div name="applies_to_group" id="applies_to_group">\
</div>\
</div>\
</div>\
</div>\
</fieldset>\
</div>\
<div class="large-6 columns">\
<label for="zones_applies">'+tr("Zones where the rule applies")+'</label>\
<div name="zones_applies" id="zones_applies">\
</div>\
</div>\
</div>\
<fieldset>\
<legend>'+tr("Affected resources")+'</legend>\
<div class="row">\
<div class="large-3 columns">\
<input type="checkbox" id="res_host" name="res_host" class="resource_cb" value="HOST"><label for="res_host">'+tr("Hosts")+'</label>\
</div>\
<div class="large-3 columns">\
<input type="checkbox" id="res_cluster" name="res_cluster" class="resource_cb" value="CLUSTER"><label for="res_cluster">'+tr("Clusters")+'</label>\
</div>\
<div class="large-3 columns">\
<input type="checkbox" id="res_datastore" name="res_datastore" class="resource_cb" value="DATASTORE"><label for="res_datastore">'+tr("Datastores")+'</label>\
</div>\
<div class="large-3 columns">\
<input type="checkbox" id="res_vm" name="res_vm" class="resource_cb" value="VM"><label for="res_vm">'+tr("Virtual Machines")+'</label>\
</div>\
</div>\
<div class="row">\
<div class="large-3 columns">\
<input type="checkbox" id="res_net" name="res_net" class="resource_cb" value="NET"><label for="res_net">'+tr("Virtual Networks")+'</label>\
</div>\
<div class="large-3 columns">\
<input type="checkbox" id="res_image" name="res_image" class="resource_cb" value="IMAGE"><label for="res_image">'+tr("Images")+'</label>\
</div>\
<div class="large-3 columns">\
<input type="checkbox" id="res_template" name="res_template" class="resource_cb" value="TEMPLATE"><label for="res_template">'+tr("Templates")+'</label>\
</div>\
<div class="large-3 columns">\
<input type="checkbox" id="res_user" name="res_user" class="resource_cb" value="USER"><label for="res_user">'+tr("Users")+'</label>\
</div>\
</div>\
<div class="row">\
<div class="large-3 columns">\
<input type="checkbox" id="res_group" name="res_group" class="resource_cb" value="GROUP"><label for="res_group">'+tr("Groups")+'</label>\
</div>\
<div class="large-3 columns">\
<input type="checkbox" id="res_document" name="res_document" class="resource_cb" value="DOCUMENT"><label for="res_document">'+tr("Documents")+'</label>\
</div>\
<div class="large-3 columns">\
<input type="checkbox" id="res_zone" name="res_zone" class="resource_cb" value="ZONE"><label for="res_zone">'+tr("Zones")+'</label>\
</div>\
<div class="large-3 columns">\
<input type="checkbox" id="res_secgroup" name="res_secgroup" class="resource_cb" value="SECGROUP"><label for="res_secgroup">'+tr("Security Groups")+'</label>\
</div>\
</div>\
<div class="row">\
<div class="large-3 columns">\
<input type="checkbox" id="res_vdc" name="res_vdc" class="resource_cb" value="VDC"><label for="res_vdc">'+tr("VDCs")+'</label>\
</div>\
</div>\
</fieldset>\
<fieldset>\
<legend>'+tr("Resource subset")+'</legend>\
<div class="row">\
<div class="large-3 columns">\
<input type="radio" class="res_subgroup" name="mode_select" value="*" id="res_subgroup_all"><label class="res_subgroup" for="res_subgroup_all">'+tr("All")+'</label>\
</div>\
<div class="large-3 columns">\
<input type="radio" class="res_subgroup" name="mode_select" value="res_id" id="res_subgroup_id"><label class="res_subgroup" for="res_subgroup_id">'+tr("ID")+'</label>\
</div>\
<div class="large-3 columns">\
<input type="radio" class="res_subgroup" name="mode_select" value="belonging_to" id="res_subgroup_group"><label class="res_subgroup" for="res_subgroup_group">'+tr("Group")+'</label>\
</div>\
<div class="large-3 columns">\
<input type="radio" class="res_subgroup" name="mode_select" value="in_cluster" id="res_subgroup_cluster"><label class="res_subgroup" for="res_subgroup_cluster">'+tr("Cluster")+'</label>\
</div>\
</div>\
<div class="row">\
<div class="large-6 columns">\
<div class="res_id">\
<label for="res_id">'+tr("Resource ID")+':</label>\
<input type="text" name="res_id" id="res_id"></input>\
</div>\
<div class="belonging_to">\
<label for="belonging_to">'+tr("Group")+':</label>\
<div name="belonging_to" id="belonging_to">\
</div>\
</div>\
<div class="in_cluster">\
<label for="in_cluster">'+tr("Cluster")+':</label>\
<div name="in_cluster" id="in_cluster">\
</div>\
</div>\
</div>\
</div>\
</fieldset>\
<fieldset>\
<legend>'+tr("Allowed operations")+'</legend>\
<div class="row">\
<div class="large-3 columns">\
<input type="checkbox" id="right_delete" name="right_delete" class="right_cb" value="USE"><label for="right_delete">'+tr("Use")+'</label>\
</div>\
<div class="large-3 columns">\
<input type="checkbox" id="right_use" name="right_use" class="right_cb" value="MANAGE"><label for="right_use">'+ tr("Manage")+'</label>\
</div>\
<div class="large-3 columns">\
<input type="checkbox" id="right_manage" name="right_manage" class="right_cb" value="ADMIN"><label for="right_manage">'+tr("Administrate")+'</label>\
</div>\
<div class="large-3 columns">\
<input type="checkbox" id="right_create" name="right_create" class="right_cb" value="CREATE"><label for="right_create">'+tr("Create")+'</label>\
</div>\
</div>\
</fieldset>\
<br>\
<div class="row">\
<div class="large-12 columns">\
<label for="acl_preview">'+tr("ACL String preview")+':</label>\
<input type="text" name="acl_preview" id="acl_preview"></input>\
</div>\
</div>\
<div class="form_buttons">\
<button class="button radius right success" id="create_acl_submit" type="submit" value="Acl.create">'+tr("Create")+'</button>\
<button class="button secondary radius" type="reset" value="reset">'+tr("Reset")+'</button>\
</div>\
<a class="close-reveal-modal">&#215;</a>\
</form>\
</div>';
var acl_actions = {
"Acl.create" : {
type: "create",
call: OpenNebula.Acl.create,
callback: function(){
$create_acl_dialog.foundation('reveal', 'close');
$create_acl_dialog.empty();
setupCreateAclDialog();
Sunstone.runAction("Acl.list");
},
error: onError,
notify: true
},
"Acl.create_dialog" : {
type: "custom",
call: popUpCreateAclDialog
},
"Acl.list" : {
type: "list",
call: OpenNebula.Acl.list,
callback: updateAclsView,
error: onError
},
"Acl.refresh" : {
type: "custom",
call: function () {
waitingNodes(dataTable_acls);
Sunstone.runAction("Acl.list", {force: true});
}
},
"Acl.delete" : {
type: "multiple",
call: OpenNebula.Acl.del,
callback: deleteAclElement,
elements: aclElements,
error: onError,
notify: true
},
"Acl.help" : {
type: "custom",
call: function() {
hideDialog();
$('div#acls_tab div.legend_div').slideToggle();
}
}
}
var acl_buttons = {
"Acl.refresh" : {
type: "action",
layout: "refresh",
alwaysActive: true
},
// "Sunstone.toggle_top" : {
// type: "custom",
// layout: "top",
// alwaysActive: true
// },
"Acl.create_dialog" : {
type: "create_dialog",
layout: "create"
},
"Acl.delete" : {
type: "confirm",
layout: "del",
text: tr("Delete")
},
//"Acl.help" : {
// type: "action",
// text: '?',
// alwaysActive: true
//}
}
var acls_tab = {
title: tr("ACLs"),
resource: 'Acl',
buttons: acl_buttons,
tabClass: 'subTab',
parentTab: 'system-tab',
search_input: '<input id="acl_search" type="search" placeholder="'+tr("Search")+'" />',
list_header: '<i class="fa fa-key"></i>&emsp;'+tr("Access Control Lists"),
subheader: '<span/><small></small>&emsp;',
table: '<table id="datatable_acls" class="dataTable">\
<thead>\
<tr>\
<th class="check"><input type="checkbox" class="check_all" value=""></input></th>\
<th>'+tr("ID")+'</th>\
<th>'+tr("Applies to")+'</th>\
<th>'+tr("Affected resources")+'</th>\
<th>'+tr("Resource ID / Owned by")+'</th>\
<th>'+tr("Allowed operations")+'</th>\
<th>'+tr("Zone")+'</th>\
<th>'+tr("ACL String")+'</th>\
</tr>\
</thead>\
<tbody id="tbodyaclss">\
</tbody>\
</table>'
}
Sunstone.addActions(acl_actions);
Sunstone.addMainTab('acls-tab',acls_tab);
//Returns selected elements on the acl datatable
function aclElements(){
return getSelectedNodes(dataTable_acls);
}
//Receives a segment of an ACL and translates:
// * -> All
// @1 -> Group 1 (tries to translate "1" into group name)
// #1 -> User 1 (tries to translate "1" into username)
//Translation of usernames and groupnames depends on
//group and user plugins tables.
function parseUserAcl(user){
var user_str="";
if (user[0] == '*'){
user_str = tr("All");
} else {
if (user[0] == '#'){
user_str=tr("User")+" ";
user_str+= getUserName(user.substring(1));
}
else if (user[0] == '@'){
user_str=tr("Group ");
user_str+= getGroupName(user.substring(1));
};
};
return user_str;
}
//Similar to above, but #1 means resource with "ID 1"
function parseResourceAcl(user){
var user_str="";
if (user[0] == '*'){
user_str = tr("All");
} else {
if (user[0] == '#'){
user_str=tr("ID")+" ";
user_str+= user.substring(1);
}
else if (user[0] == '@'){
user_str=tr("Group")+" ";
user_str+= getGroupName(user.substring(1));
}
else if (user[0] == '%'){
user_str=tr("Cluster ID")+" ";
user_str+= user.substring(1);
};
};
return user_str;
}
//Receives a segment of an ACL and translates:
// * -> All
// #1 -> Zone 1 (tries to translate "1" into zone name)
//Translation of zone names depends on
//zone plugins tables.
function parseZoneAcl(zone){
var zone_str = "";
if (zone[0] == '*'){
zone_str = tr("All");
} else if (zone[0] == '#'){
zone_str = getZoneName(zone.substring(1));
}
return zone_str;
}
//Parses a full ACL string, and translates it into
//a legible array
//to be put in the datatable fields.
function parseAclString(string) {
var space_split = string.split(' ');
var user = space_split[0];
var resources = space_split[1];
var rights = space_split[2];
var zone = space_split[3];
//User
var user_str=parseUserAcl(user);
//Resources
var resources_str="";
var resources_array = resources.split('/');
var belonging_to = parseResourceAcl(resources_array[1]);
resources_array = resources_array[0].split('+');
for (var i=0; i<resources_array.length;i++){
switch (resources_array[i]){
case "HOST":
resources_str+=tr("Hosts")+", ";
break;
case "VM":
resources_str+=tr("Virtual Machines")+", ";
break;
case "NET":
resources_str+=tr("Virtual Networks")+", ";
break;
case "IMAGE":
resources_str+=(tr("Images")+", ");
break;
case "TEMPLATE":
resources_str+=tr("VM Templates")+", ";
break;
case "USER":
resources_str+=tr("Users")+", ";
break;
case "GROUP":
resources_str+=tr("Groups")+", ";
break;
case "CLUSTER":
resources_str+=tr("Clusters")+", ";
break;
case "DATASTORE":
resources_str+=tr("Datastores")+", ";
break;
case "DOCUMENT":
resources_str+=tr("Documents")+", ";
break;
case "ZONE":
resources_str+=tr("Zones")+", ";
break;
case "SECGROUP":
resources_str+=tr("Security Groups")+", ";
break;
case "VDC":
resources_str+=tr("VDCs")+", ";
break;
};
};
//remove ", " from end
resources_str = resources_str.substring(0,resources_str.length-2);
//Ops
var ops_str="";
var ops_array = rights.split('+');
for (var i=0; i<ops_array.length;i++){
ops_str += ops_array[i].toLowerCase()+", ";
}
ops_str= ops_str.substring(0,ops_str.length-2);
//Zone
var zone_str = parseZoneAcl(zone);
return [user_str, resources_str, belonging_to, ops_str, zone_str];
}
//forms the array of data to be inserted from
//the raw json
function aclElementArray(acl_json){
var acl = acl_json.ACL;
var acl_string = acl.STRING;
var acl_array = parseAclString(acl_string);
return [
'<input class="check_item" type="checkbox" id="acl_'+acl.ID+'" name="selected_items" value="'+acl.ID+'"/>',
acl.ID,
acl_array[0],
acl_array[1],
acl_array[2],
acl_array[3],
tr(acl_array[4].charAt(0).toUpperCase()+acl_array[4].substring(1)), //capitalize 1st letter for translation
acl.STRING
]
}
// Callback to delete a single element from the dataTable
function deleteAclElement(request){
deleteElement(dataTable_acls,'#acl_'+request.request.data);
}
//update the datatable with new data
function updateAclsView(request,list){
var list_array = [];
$.each(list,function(){
list_array.push(aclElementArray(this));
});
updateView(list_array,dataTable_acls);
}
function setupCreateAclDialog(){
dialogs_context.append('<div id="create_acl_dialog"></div>');
$create_acl_dialog = $('#create_acl_dialog',dialogs_context);
var dialog = $create_acl_dialog;
dialog.html(create_acl_tmpl);
var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window
//Prepare jquery dialog
//dialog.dialog({
// autoOpen: false,
// modal:true,
// width: 650,
// height: height
//});
dialog.addClass("reveal-modal large").attr("data-reveal", "");
//Default selected options
$('#applies_all',dialog).attr('checked','checked');
$('.applies_to_user',dialog).hide();
$('.applies_to_group',dialog).hide();
$('#res_subgroup_all',dialog).attr('checked','checked');
$('.res_id',dialog).hide();
$('.belonging_to',dialog).hide();
$('.in_cluster',dialog).hide();
//$('button',dialog).button();
//Applies to subset radio buttons
$('.applies',dialog).click(function(){
var value = $(this).val();
switch (value) {
case "*":
$('.applies_to_user',dialog).hide();
$('.applies_to_group',dialog).hide();
break;
case "applies_to_user":
$('.applies_to_user',dialog).show();
$('.applies_to_group',dialog).hide();
break;
case "applies_to_group":
$('.applies_to_user',dialog).hide();
$('.applies_to_group',dialog).show();
break;
};
});
//Resource subset radio buttons
$('.res_subgroup',dialog).click(function(){
var value = $(this).val();
switch (value) {
case "*":
$('.res_id',dialog).hide();
$('.belonging_to',dialog).hide();
$('.in_cluster',dialog).hide();
break;
case "res_id":
$('.res_id',dialog).show();
$('.belonging_to').hide();
$('.in_cluster',dialog).hide();
break;
case "belonging_to":
$('.res_id',dialog).hide();
$('.belonging_to',dialog).show();
$('.in_cluster',dialog).hide();
break;
case "in_cluster":
$('.res_id',dialog).hide();
$('.belonging_to',dialog).hide();
$('.in_cluster',dialog).show();
break;
};
});
//trigger ACL string preview on keyup
$('input#res_id',dialog).keyup(function(){
$(this).trigger("change");
});
//update the rule preview every time some field changes
$(dialog).off('change', 'input,select');
$(dialog).on('change', 'input,select', function(){
var context = $('#create_acl_form',$create_acl_dialog);
var user="";
var mode = $('.applies:checked',context).val();
switch (mode) {
case "*":
user="*";
break;
case "applies_to_user":
user="#"+$('div#applies_to_user .resource_list_select',context).val();
break;
case "applies_to_group":
user="@"+$('div#applies_to_group .resource_list_select',context).val();
break;
}
var resources = "";
$('.resource_cb:checked',context).each(function(){
resources+=$(this).val()+'+';
});
if (resources.length) { resources = resources.substring(0,resources.length-1) };
var belonging="";
var mode = $('.res_subgroup:checked',context).val();
switch (mode) {
case "*":
belonging="*";
break;
case "res_id":
belonging="#"+$('#res_id',context).val();
break;
case "belonging_to":
belonging="@"+$('div#belonging_to .resource_list_select',context).val();
break;
case "in_cluster":
belonging="%"+$('#in_cluster .resource_list_select',context).val();
break;
}
var rights = "";
$('.right_cb:checked',context).each(function(){
rights+=$(this).val()+'+';
});
if (rights.length) { rights = rights.substring(0,rights.length-1) };
var zone = $('#zones_applies .resource_list_select',context).val();
if (zone != "*"){
zone = '#'+zone;
}
var acl_string = user + ' ' + resources + '/' + belonging + ' '
+ rights + ' ' + zone;
$('#acl_preview',context).val(acl_string);
});
$('#create_acl_form',dialog).submit(function(){
var mode = $('.applies:checked',this).val();
switch (mode) {
case "applies_to_user":
var l=$('#applies_to_user .resource_list_select',this).val().length;
if (!l){
notifyError("Please select a user to whom the acl applies");
return false;
}
break;
case "applies_to_group":
var l=$('#applies_to_group .resource_list_select',this).val().length;
if (!l){
notifyError("Please select a group to whom the acl applies");
return false;
}
break;
}
var resources = $('.resource_cb:checked',this).length;
if (!resources) {
notifyError(tr("Please select at least one resource"));
return false;
}
var mode = $('.res_subgroup:checked',this).val();
switch (mode) {
case "res_id":
var l=$('#res_id',this).val().length;
if (!l){
notifyError(tr("Please provide a resource ID for the resource(s) in this rule"));
return false;
}
break;
case "belonging_to":
var l=$('#belonging_to .resource_list_select',this).val().length;
if (!l){
notifyError("Please select a group to which the selected resources belong to");
return false;
}
break;
case "in_cluster":
var l=$('#in_cluster .resource_list_select',this).val().length;
if (!l){
notifyError("Please select a cluster to which the selected resources belong to");
return false;
}
break;
}
var rights = $('.right_cb:checked',this).length;
if (!rights) {
notifyError("Please select at least one operation");
return false;
}
var acl_string = $('#acl_preview',this).val();
var acl_json = { "acl" : acl_string };
Sunstone.runAction("Acl.create",acl_json);
return false;
});
}
// Before popping up the dialog, some prepartions are
// required: we have to put the right options in the
// selects.
function popUpCreateAclDialog(){
var dialog = $create_acl_dialog;
insertSelectOptions('div#applies_to_user', dialog, "User", null, true);
insertSelectOptions('div#applies_to_group', dialog, "Group", null, true);
insertSelectOptions('div#belonging_to', dialog, "Group", null, true);
insertSelectOptions('#in_cluster',dialog, "Cluster", null, true);
// Delete cluster -1 option
$('#in_cluster select option[value="-1"]',dialog).remove();
insertSelectOptions('div#zones_applies', dialog, "Zone", "*", false,
'<option value="*">'+tr("All")+'</option>');
dialog.foundation().foundation('reveal', 'open');
}
$(document).ready(function(){
var tab_name = 'acls-tab';
if (Config.isTabEnabled(tab_name)) {
//if we are not oneadmin, our tab will not even be in the DOM.
dataTable_acls = $("#datatable_acls",main_tabs_context).dataTable({
"aoColumnDefs": [
{ "bSortable": false, "aTargets": ["check",2,3,4,5,6,7] },
{ "sWidth": "35px", "aTargets": [0] },
{ "bVisible": true, "aTargets": Config.tabTableColumns(tab_name)},
{ "bVisible": false, "aTargets": ['_all']}
],
"bSortClasses" : false,
"bDeferRender": true
});
$('#acl_search').keyup(function(){
dataTable_acls.fnFilter( $(this).val() );
})
dataTable_acls.on('draw', function(){
recountCheckboxes(dataTable_acls);
})
Sunstone.runAction("Acl.list");
setupCreateAclDialog();
initCheckAllBoxes(dataTable_acls);
tableCheckboxesListener(dataTable_acls);
//shortenedInfoFields('#datatable_acls');
infoListener(dataTable_acls);
$('div#acls_tab div.legend_div').hide();
dataTable_acls.fnSort( [ [1,config['user_config']['table_order']] ] );
}
})
@@ -1,831 +0,0 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
/* ---------------- Cluster tab plugin ---------------- */
/* ------------ Cluster creation dialog ------------ */
var create_cluster_tmpl ='<div class="row">\
<div class="large-12 columns">\
<h3 id="create_cluster_header" class="subheader">'+tr("Create Cluster")+'</h3>\
<h3 id="update_cluster_header" class="subheader">'+tr("Update Cluster")+'</h3>\
</div>\
</div>\
<div class="reveal-body">\
<form id="cluster_create_tabs" class="custom">\
<div class="row">\
<div class="large-6 columns">\
<label for="name">' + tr("Name") + '</label>\
<input type="text" name="name" id="name" />\
</div>\
<div class="large-6 columns">\
<dl class="tabs right-info-tabs text-center right" data-tab>\
<dd class="active"><a href="#tab-hostsTab"><i class="fa fa-hdd-o"></i><br>'+tr("Hosts")+'</a></dd>\
<dd><a href="#tab-vnetsTab"><i class="fa fa-globe"></i><br>'+tr("VNets")+'</a></dd>\
<dd><a href="#tab-datastoresTab"><i class="fa fa-folder-open"></i><br>'+tr("Datastores")+'</a></dd>\
</dl>\
</div>\
</div>\
<div class="tabs-content">\
<div id="tab-hostsTab" class="active content">\
'+generateHostTableSelect("cluster_wizard_hosts")+'\
</div>\
<div id="tab-vnetsTab" class="content">\
'+generateVNetTableSelect("cluster_wizard_vnets")+'\
</div>\
<div id="tab-datastoresTab" class="content">\
'+generateDatastoreTableSelect("cluster_wizard_datastores")+'\
</div>\
</div>\
</form>\
</div>\
<div class="reveal-footer">\
<div class="form_buttons row">\
<button class="button success right radius" type="submit" id="create_cluster_submit" value="OpenNebula.Cluster.create">' + tr("Create") + '</button>\
<button class="button right radius" type="submit" id="update_cluster_submit">' + tr("Update") + '</button>\
</div>\
</div>\
<a class="close-reveal-modal">&#215;</a>';
// Prepares the cluster creation dialog
function setupCreateClusterDialog(){
$("#create_cluster_dialog").remove();
dialogs_context.append('<div id="create_cluster_dialog"></div>');
$create_cluster_dialog = $('div#create_cluster_dialog');
var dialog = $create_cluster_dialog;
dialog.html(create_cluster_tmpl);
var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window
dialog.addClass("reveal-modal large max-height").attr("data-reveal", "");
setupHostTableSelect(dialog, "cluster_wizard_hosts", {multiple_choice: true});
setupVNetTableSelect(dialog, "cluster_wizard_vnets", {multiple_choice: true});
setupDatastoreTableSelect(dialog, "cluster_wizard_datastores", {multiple_choice: true});
// Handle the Create button
$('#create_cluster_submit').click(function(){
if (!($('input#name',dialog).val().length)){
notifyError(tr("Cluster name missing!"));
return false;
}
var selected_hosts_arr = retrieveHostTableSelect(dialog, "cluster_wizard_hosts");
var selected_hosts_list = {};
$.each(selected_hosts_arr, function(i,e){
selected_hosts_list[e] = 1;
});
var selected_vnets_arr = retrieveVNetTableSelect(dialog, "cluster_wizard_vnets");
var selected_vnets_list = {};
$.each(selected_vnets_arr, function(i,e){
selected_vnets_list[e] = 1;
});
var selected_datastores_arr = retrieveDatastoreTableSelect(dialog, "cluster_wizard_datastores");
var selected_datastores_list = {};
$.each(selected_datastores_arr, function(i,e){
selected_datastores_list[e] = 1;
});
var cluster_json = {
"cluster": {
"name": $('#name',dialog).val(),
"hosts": selected_hosts_list,
"vnets": selected_vnets_list,
"datastores": selected_datastores_list
}
};
// Create the OpenNebula.Cluster.
Sunstone.runAction("Cluster.create",cluster_json);
return false;
});
}
// Open creation dialogs
function popUpCreateClusterDialog(){
if (!$create_cluster_dialog || $create_cluster_dialog.html() == "") {
setupCreateClusterDialog();
}
$create_cluster_dialog.die();
// Activate create button
$('#create_cluster_submit',$create_cluster_dialog).show();
$('#update_cluster_submit',$create_cluster_dialog).hide();
$('#create_cluster_header',$create_cluster_dialog).show();
$('#update_cluster_header',$create_cluster_dialog).hide();
refreshHostTableSelect($create_cluster_dialog, "cluster_wizard_hosts");
refreshVNetTableSelect($create_cluster_dialog, "cluster_wizard_vnets");
refreshDatastoreTableSelect($create_cluster_dialog, "cluster_wizard_datastores");
$create_cluster_dialog.foundation().foundation('reveal', 'open');
$("input#name",$create_cluster_dialog).focus();
return false;
}
// Open update dialog
function popUpUpdateClusterDialog(){
var selected_nodes = getSelectedNodes(dataTable_clusters);
if ( selected_nodes.length != 1 )
{
notifyError(tr("Please select one (and just one) cluster to update."));
return false;
}
var dialog = $create_cluster_dialog;
if ($("#create_cluster_dialog")) {
dialog.html("");
}
setupCreateClusterDialog();
// Activate update button
$('#create_cluster_submit',$create_cluster_dialog).hide();
$('#update_cluster_submit',$create_cluster_dialog).show();
$('#create_cluster_header',$create_cluster_dialog).hide();
$('#update_cluster_header',$create_cluster_dialog).show();
Sunstone.runAction("Cluster.show_to_update", selected_nodes[0]);
$create_cluster_dialog.die();
$create_cluster_dialog.live('closed', function () {
$("#create_cluster_dialog").html("");
setupCreateClusterDialog();
});
$create_cluster_dialog.foundation().foundation('reveal', 'open');
return false;
}
// Fill update dialog with loaded properties
function fillPopPup(request,response){
var dialog = $create_cluster_dialog;
// Harvest variables
var name = response.CLUSTER.NAME;
var host_ids = response.CLUSTER.HOSTS.ID;
var vnet_ids = response.CLUSTER.VNETS.ID;
var ds_ids = response.CLUSTER.DATASTORES.ID;
if (typeof host_ids == 'string')
{
host_ids = [host_ids];
}
if (typeof vnet_ids == 'string')
{
vnet_ids = [vnet_ids];
}
if (typeof ds_ids == 'string')
{
ds_ids = [ds_ids];
}
// Fill in the name
$('#name',dialog).val(name);
$('#name',dialog).attr("disabled", "disabled");
var original_hosts_list = [];
// Select hosts belonging to the cluster
if (host_ids)
{
original_hosts_list = host_ids;
var opts = {
ids : host_ids
}
selectHostTableSelect(dialog, "cluster_wizard_hosts", opts);
}
var original_vnets_list = [];
// Select vnets belonging to the cluster
if (vnet_ids)
{
original_vnets_list = vnet_ids;
var opts = {
ids : vnet_ids
}
selectVNetTableSelect(dialog, "cluster_wizard_vnets", opts);
}
var original_datastores_list = [];
// Select datastores belonging to the cluster
if (ds_ids)
{
original_datastores_list = ds_ids;
var opts = {
ids : ds_ids
}
selectDatastoreTableSelect(dialog, "cluster_wizard_datastores", opts);
}
// Clone already existing resources (to keep track)
cluster_to_update_id = response.CLUSTER.ID;
refreshHostTableSelect(dialog, "cluster_wizard_hosts");
refreshVNetTableSelect(dialog, "cluster_wizard_vnets");
refreshDatastoreTableSelect(dialog, "cluster_wizard_datastores");
// Define update button
$('#update_cluster_submit').click(function(){
// find out which ones are in and out
var selected_hosts_list = retrieveHostTableSelect(dialog, "cluster_wizard_hosts");
$.each(selected_hosts_list, function(i,host_id){
if (original_hosts_list.indexOf(host_id) == -1)
{
Sunstone.runAction("Cluster.addhost",cluster_to_update_id,host_id);
}
});
$.each(original_hosts_list, function(i,host_id){
if (selected_hosts_list.indexOf(host_id) == -1)
{
Sunstone.runAction("Cluster.delhost",cluster_to_update_id,host_id);
}
});
var selected_vnets_list = retrieveVNetTableSelect(dialog, "cluster_wizard_vnets");
$.each(selected_vnets_list, function(i,vnet_id){
if (original_vnets_list.indexOf(vnet_id) == -1)
{
Sunstone.runAction("Cluster.addvnet",cluster_to_update_id,vnet_id);
}
});
$.each(original_vnets_list, function(i,vnet_id){
if (selected_vnets_list.indexOf(vnet_id) == -1)
{
Sunstone.runAction("Cluster.delvnet",cluster_to_update_id,vnet_id);
}
});
var selected_datastores_list = retrieveDatastoreTableSelect(dialog, "cluster_wizard_datastores");
$.each(selected_datastores_list, function(i,datastore_id){
if (original_datastores_list.indexOf(datastore_id) == -1)
{
Sunstone.runAction("Cluster.adddatastore",cluster_to_update_id,datastore_id);
}
});
$.each(original_datastores_list, function(i,datastore_id){
if (selected_datastores_list.indexOf(datastore_id) == -1)
{
Sunstone.runAction("Cluster.deldatastore",cluster_to_update_id,datastore_id);
}
});
$create_cluster_dialog.foundation('reveal', 'close')
Sunstone.runAction('Cluster.list');
return false;
});
}
var dataTable_clusters;
var $create_cluster_dialog;
//Setup actions
var cluster_actions = {
"Cluster.create" : {
type: "create",
call: OpenNebula.Cluster.create,
callback: function(request, response){
// Reset the create wizard
$create_cluster_dialog.foundation('reveal', 'close');
$create_cluster_dialog.empty();
setupCreateClusterDialog();
addClusterElement(request, response);
// Sunstone.runAction('Cluster.list');
for (var host in request.request.data[0].cluster.hosts)
if (request.request.data[0].cluster.hosts[host])
Sunstone.runAction("Cluster.addhost",response.CLUSTER.ID,host);
for (var vnet in request.request.data[0].cluster.vnets)
if (request.request.data[0].cluster.vnets[vnet])
Sunstone.runAction("Cluster.addvnet",response.CLUSTER.ID,vnet);
for (var datastore in request.request.data[0].cluster.datastores)
if (request.request.data[0].cluster.datastores[datastore])
Sunstone.runAction("Cluster.adddatastore",response.CLUSTER.ID,datastore);
//Sunstone.runAction('Cluster.list');
// Sunstone.runAction('Cluster.show',response.CLUSTER.ID);
notifyCustom(tr("Cluster created"), " ID: " + response.CLUSTER.ID, false);
},
error: onError
},
"Cluster.create_dialog" : {
type: "custom",
call: popUpCreateClusterDialog
},
"Cluster.list" : {
type: "list",
call: OpenNebula.Cluster.list,
callback: updateClustersView,
error: onError
},
"Cluster.show" : {
type: "single",
call: OpenNebula.Cluster.show,
callback: function(request, response) {
updateClusterElement(request, response);
if (Sunstone.rightInfoVisible($("#clusters-tab"))) {
updateClusterInfo(request, response);
}
},
error: onError
},
"Cluster.show_to_update" : {
type: "single",
call: OpenNebula.Cluster.show,
callback: fillPopPup,
error: onError
},
"Cluster.refresh" : {
type: "custom",
call: function(){
var tab = dataTable_clusters.parents(".tab");
if (Sunstone.rightInfoVisible(tab)) {
Sunstone.runAction("Cluster.show", Sunstone.rightInfoResourceId(tab))
} else {
waitingNodes(dataTable_clusters);
Sunstone.runAction("Cluster.list", {force: true});
}
},
error: onError
},
"Cluster.addhost" : {
type: "single",
call : OpenNebula.Cluster.addhost,
callback : function (req) {
OpenNebula.Helper.clear_cache("HOST");
Sunstone.runAction('Cluster.show',req.request.data[0][0]);
},
error : onError
},
"Cluster.delhost" : {
type: "single",
call : OpenNebula.Cluster.delhost,
callback : function (req) {
OpenNebula.Helper.clear_cache("HOST");
Sunstone.runAction('Cluster.show',req.request.data[0][0]);
},
error : onError
},
"Cluster.adddatastore" : {
type: "single",
call : OpenNebula.Cluster.adddatastore,
callback : function (req) {
OpenNebula.Helper.clear_cache("DATASTORE");
Sunstone.runAction('Cluster.show',req.request.data[0][0]);
},
error : onError
},
"Cluster.deldatastore" : {
type: "single",
call : OpenNebula.Cluster.deldatastore,
callback : function (req) {
OpenNebula.Helper.clear_cache("DATASTORE");
Sunstone.runAction('Cluster.show',req.request.data[0][0]);
},
error : onError
},
"Cluster.addvnet" : {
type: "single",
call : OpenNebula.Cluster.addvnet,
callback : function (req) {
OpenNebula.Helper.clear_cache("VNET");
Sunstone.runAction('Cluster.show',req.request.data[0][0]);
},
error : onError
},
"Cluster.delvnet" : {
type: "single",
call : OpenNebula.Cluster.delvnet,
callback : function (req) {
OpenNebula.Helper.clear_cache("VNET");
Sunstone.runAction('Cluster.show',req.request.data[0][0]);
},
error : onError
},
"Cluster.delete" : {
type: "multiple",
call : OpenNebula.Cluster.del,
callback : deleteClusterElement,
elements: clusterElements,
error : onError
},
"Cluster.update_template" : { // Update template
type: "single",
call: OpenNebula.Cluster.update,
callback: function(request,response){
Sunstone.runAction('Cluster.show',request.request.data[0][0]);
},
error: onError
},
"Cluster.fetch_template" : {
type: "single",
call: OpenNebula.Cluster.fetch_template,
callback: function(request,response){
$('#template_update_dialog #template_update_textarea').val(response.template);
},
error: onError
},
"Cluster.update_dialog" : {
type: "single",
call: popUpUpdateClusterDialog
},
"Cluster.rename" : {
type: "single",
call: OpenNebula.Cluster.rename,
callback: function(request) {
Sunstone.runAction('Cluster.show',request.request.data[0]);
},
error: onError
}
};
var cluster_buttons = {
"Cluster.refresh" : {
type: "action",
layout: "refresh",
alwaysActive: true
},
// "Sunstone.toggle_top" : {
// type: "custom",
// layout: "top",
// alwaysActive: true
// },
"Cluster.create_dialog" : {
type: "create_dialog",
layout: "create"
},
"Cluster.update_dialog" : {
type : "action",
layout: "main",
text : tr("Update")
},
"Cluster.delete" : {
type: "confirm",
layout: "del",
text: tr("Delete")
}
};
var clusters_tab = {
title: tr("Clusters"),
resource: 'Cluster',
buttons: cluster_buttons,
showOnTopMenu: false,
tabClass: "subTab",
parentTab: "infra-tab",
search_input: '<input id="cluster_search" type="search" placeholder="'+tr("Search")+'" />',
list_header: '<i class="fa fa-fw fa-th"></i>&emsp;'+tr("Clusters"),
info_header: '<i class="fa fa-fw fa-th"></i>&emsp;'+tr("Cluster"),
subheader: '<span/> <small></small>&emsp;',
table: '<table id="datatable_clusters" class="datatable twelve">\
<thead>\
<tr>\
<th class="check"><input type="checkbox" class="check_all" value=""></input></th>\
<th>' + tr("ID") + '</th>\
<th>' + tr("Name") + '</th>\
<th>' + tr("Hosts") + '</th>\
<th>' + tr("VNets") + '</th>\
<th>' + tr("Datastores") + '</th>\
</tr>\
</thead>\
<tbody id="tbodyclusters">\
</tbody>\
</table>'
};
var cluster_info_panel = {
"cluster_info_tab" : {
title: tr("Cluster information"),
content:""
},
"cluster_host_tab" : {
title: tr("Cluster Hosts"),
content: ""
},
"cluster_vnet_tab" : {
title: tr("Cluster Virtual Networks"),
content: ""
},
"cluster_datastore_tab" : {
title: tr("Cluster Datastores"),
content: ""
}
};
Sunstone.addActions(cluster_actions);
Sunstone.addMainTab('clusters-tab',clusters_tab);
Sunstone.addInfoPanel("cluster_info_panel",cluster_info_panel);
//return lists of selected elements in cluster list
function clusterElements(){
return getSelectedNodes(dataTable_clusters);
}
function clusterElementArray(element_json){
var element = element_json.CLUSTER;
var hosts = 0;
if ($.isArray(element.HOSTS.ID))
hosts = element.HOSTS.ID.length;
else if (!$.isEmptyObject(element.HOSTS.ID))
hosts = 1;
var vnets = 0;
if ($.isArray(element.VNETS.ID))
vnets = element.VNETS.ID.length;
else if (!$.isEmptyObject(element.VNETS.ID))
vnets = 1;
var dss = 0;
if ($.isArray(element.DATASTORES.ID))
dss = element.DATASTORES.ID.length;
else if (!$.isEmptyObject(element.DATASTORES.ID))
dss = 1;
return [
'<input class="check_item" type="checkbox" id="cluster_'+element.ID+'" name="selected_items" value="'+element.ID+'"/>',
element.ID,
element.NAME,
hosts,
vnets,
dss
];
}
//callback for an action affecting a cluster element
function updateClusterElement(request, element_json){
var id = element_json.CLUSTER.ID;
var element = clusterElementArray(element_json);
updateSingleElement(element,dataTable_clusters,'#cluster_'+id);
}
//callback for actions deleting a cluster element
function deleteClusterElement(req){
deleteElement(dataTable_clusters,'#cluster_'+req.request.data);
$('div#cluster_tab_'+req.request.data,main_tabs_context).remove();
}
//call back for actions creating a cluster element
function addClusterElement(request,element_json){
var id = element_json.CLUSTER.ID;
var element = clusterElementArray(element_json);
addElement(element,dataTable_clusters);
}
//callback to update the list of clusters.
function updateClustersView (request,list){
var list_array = [];
$.each(list,function(){
//Grab table data from the list
list_array.push(clusterElementArray(this));
});
updateView(list_array,dataTable_clusters);
};
// Updates the cluster info panel tab content and pops it up
function updateClusterInfo(request,cluster){
cluster_info = cluster.CLUSTER;
cluster_template = cluster_info.TEMPLATE;
$(".resource-info-header", $("#clusters-tab")).html(cluster_info.NAME);
//Information tab
var info_tab = {
title : tr("Info"),
icon: "fa-info-circle",
content :
'<div class="row">\
<div class="large-6 columns">\
<table id="info_cluster_table" class="dataTable extended_table">\
<thead>\
<tr><th colspan="3">' +tr("Information") +'</th></tr>\
</thead>\
<tbody>\
<tr>\
<td class="key_td">' + tr("id") + '</td>\
<td class="value_td" colspan="2">'+cluster_info.ID+'</td>\
</tr>'+
insert_rename_tr(
'clusters-tab',
"Cluster",
cluster_info.ID,
cluster_info.NAME)+
'</tbody>\
</table>\
</div>\
<div class="large-6 columns">' +
'</div>\
</div>\
<div class="row">\
<div class="large-9 columns">'+
insert_extended_template_table(cluster_template,
"Cluster",
cluster_info.ID,
tr("Attributes")) +
'</div>\
</div>'
}
var cluster_host_tab = {
title: tr("Hosts"),
icon: "fa-hdd-o",
content : '<div class="row">\
<div id="datatable_cluster_hosts_info_div" class="large-12 columns">\
'+generateHostTableSelect("cluster_info_hosts")+'\
</div>\
</div>'
}
var cluster_vnet_tab = {
title: tr("VNets"),
icon: "fa-globe",
content : '<div class="row">\
<div id="datatable_cluster_vnets_info_div" class="large-12 columns">\
'+generateVNetTableSelect("cluster_info_vnets")+'\
</div>\
</div>'
}
var cluster_datastore_tab = {
title: tr("Datastores"),
icon: "fa-folder-open",
content : '<div class="row">\
<div id="datatable_cluster_datastores_info_div" class="large-12 columns">\
'+generateDatastoreTableSelect("cluster_info_datastores")+'\
</div>\
</div>'
}
//Sunstone.updateInfoPanelTab(info_panel_name,tab_name, new tab object);
Sunstone.updateInfoPanelTab("cluster_info_panel","cluster_info_tab",info_tab);
Sunstone.updateInfoPanelTab("cluster_info_panel","cluster_host_tab",cluster_host_tab);
Sunstone.updateInfoPanelTab("cluster_info_panel","cluster_vnet_tab",cluster_vnet_tab);
Sunstone.updateInfoPanelTab("cluster_info_panel","cluster_datastore_tab",cluster_datastore_tab);
Sunstone.popUpInfoPanel("cluster_info_panel", "clusters-tab");
// Hosts datatable
var host_ids = cluster_info.HOSTS.ID;
if (typeof host_ids == 'string'){
host_ids = [host_ids];
} else if (host_ids == undefined){
host_ids = [];
}
var opts = {
read_only: true,
fixed_ids: host_ids
}
setupHostTableSelect($("#cluster_info_panel"), "cluster_info_hosts", opts);
refreshHostTableSelect($("#cluster_info_panel"), "cluster_info_hosts");
// Virtual networks datatable
var vnet_ids = cluster_info.VNETS.ID;
if (typeof vnet_ids == 'string'){
vnet_ids = [vnet_ids];
} else if (vnet_ids == undefined){
vnet_ids = [];
}
var opts = {
read_only: true,
fixed_ids: vnet_ids
}
setupVNetTableSelect($("#cluster_info_panel"), "cluster_info_vnets", opts);
refreshVNetTableSelect($("#cluster_info_panel"), "cluster_info_vnets");
// Datastores datatable
var datastore_ids = cluster_info.DATASTORES.ID;
if (typeof datastore_ids == 'string'){
datastore_ids = [datastore_ids];
} else if (datastore_ids == undefined){
datastore_ids = [];
}
var opts = {
read_only: true,
fixed_ids: datastore_ids
}
setupDatastoreTableSelect($("#cluster_info_panel"), "cluster_info_datastores", opts);
refreshDatastoreTableSelect($("#cluster_info_panel"), "cluster_info_datastores");
}
//This is executed after the sunstone.js ready() is run.
//Here we can basicly init the host datatable, preload it
//and add specific listeners
$(document).ready(function(){
var tab_name = "clusters-tab"
if (Config.isTabEnabled(tab_name)) {
//prepare clusters datatable
dataTable_clusters = $("#datatable_clusters",main_tabs_context).dataTable({
"aoColumnDefs": [
{ "bSortable": false, "aTargets": ["check"] },
{ "sWidth": "35px", "aTargets": [0] },
{ "bVisible": true, "aTargets": Config.tabTableColumns(tab_name)},
{ "bVisible": false, "aTargets": ['_all']}
],
"bSortClasses" : false,
"bDeferRender": true
});
$('#cluster_search').keyup(function(){
dataTable_clusters.fnFilter( $(this).val() );
})
dataTable_clusters.on('draw', function(){
recountCheckboxes(dataTable_clusters);
})
Sunstone.runAction("Cluster.list");
setupCreateClusterDialog();
initCheckAllBoxes(dataTable_clusters);
tableCheckboxesListener(dataTable_clusters);
infoListener(dataTable_clusters, "Cluster.show");
dataTable_clusters.fnSort( [ [1,config['user_config']['table_order']] ] );
}
});
@@ -1,607 +0,0 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
var user_cookie = cookie["one-user"];
setInterval(function(){
if (whichUI() == "sunstone") {
var user_cookie = cookie["one-user"];
readCookie();
if ((cookie["one-user"] == null) || (cookie["one-user"] !== user_cookie)) {
window.location.href='/';
}
}
},5000);
Config = {
"isTabEnabled": function(tab_name){
var enabled = config['view']['enabled_tabs'][tab_name];
return enabled;
},
"isTabActionEnabled": function(tab_name, action_name, panel_name){
var enabled = false;
var config_tab = config['view']['tabs'][tab_name];
if (config_tab != undefined){
if (panel_name) {
enabled = config_tab['panel_tabs_actions'][panel_name][action_name];
} else {
enabled = config_tab['actions'][action_name];
}
}
return enabled;
},
"isTabPanelEnabled": function(tab_name, panel_tab_name){
if (config['view']['tabs'][tab_name]) {
var enabled = config['view']['tabs'][tab_name]['panel_tabs'][panel_tab_name];
return enabled;
} else {
return false;
}
},
"isFeatureEnabled": function(feature_name){
if (config['view']['features'] && config['view']['features'][feature_name]) {
return true;
} else {
return false;
}
},
"tabTableColumns": function(tab_name){
var columns = config['view']['tabs'][tab_name]['table_columns'];
if (columns) {
return columns;
}
else {
return [];
}
},
"isTemplateCreationTabEnabled": function(template_tab_name){
if (config['view']['tabs']['templates-tab']){
var enabled = config['view']['tabs']['templates-tab']['template_creation_tabs'][template_tab_name];
return enabled;
} else {
return false;
}
},
"dashboardWidgets": function(per_row){
var widgets = config['view']['tabs']['dashboard-tab'][per_row];
if (widgets) {
return widgets;
}
else {
return [];
}
},
"tableOrder": function(){
return config['user_config']["table_order"];
},
"provision": {
"dashboard": {
"isEnabled": function(widget) {
if (config['view']['tabs']['provision-tab']){
var enabled = config['view']['tabs']['provision-tab']['dashboard'][widget];
return enabled;
} else {
return false;
}
}
},
"create_vm": {
"isEnabled": function(widget) {
if (config['view']['tabs']['provision-tab'] && config['view']['tabs']['provision-tab']["create_vm"]){
return config['view']['tabs']['provision-tab']['create_vm'][widget];
} else {
return false;
}
}
},
"logo": (config['view']["provision_logo"] || "images/one_small_logo.png")
}
}
var config_response = {};
var config_tab_content =
'<div class="row">\
<div class="large-4 columns">\
<h3 id="configuration_dialog" class="subheader">'+tr("Configuration")+'</h3>\
</div>\
<div class="large-8 columns">\
<dl class="tabs right-info-tabs text-center right" data-tab>\
<dd class="active"><a href="#info_configuration"><i class="fa fa-info-circle"></i><br>'+tr("Info")+'</a></dd>\
<dd><a href="#conf_configuration"><i class="fa fa-cog"></i><br>'+tr("Conf")+'</a></dd>\
<dd><a href="#quotas_configuration"><i class="fa fa-align-left"></i><br>'+tr("Quotas")+'</a></dd>\
<dd><a href="#acct_configuration"><i class="fa fa-bar-chart-o"></i><br>'+tr("Accounting")+'</a></dd>'+
( Config.isFeatureEnabled("showback") ?
'<dd><a href="#showback_configuration"><i class="fa fa-money"></i><br>'+tr("Showback")+'</a></dd>' : '')+
'</dl>\
</div>\
</div>\
<div class="reveal-body">\
<form id="config_form" class="tabs-content">\
<div class="tabs-content">\
<div id="info_configuration" class="content active">\
<div class="row">\
<div class="large-7 columns">\
<table id="user_information" class="dataTable extended_table">\
<thead>\
<tr><th colspan="3">' + tr("User information") +'</th></tr>\
</thead>\
<tbody>\
</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">'+
'<div class="text-center">'+
'<span class="fa-stack fa-5x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-spinner fa-spin fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<br>'+
'<span style="font-size: 18px; color: #999">'+
'</span>'+
'</div>'+
'</div>\
</div>\
</div>\
<div id="conf_configuration" class="row content">\
<div class="large-5 columns">\
<div class="row">\
<label for="lang_sel" >' + tr("Language") + ':\
<select id="lang_sel">'+
language_options +
'</select>\
</label>\
</div>\
<div class="row">\
<label for="view_sel" >' + tr("Views") + ':\
<select id="view_sel">\
</select>\
</label>\
</div>\
<div class="row">\
<label for="table_order" >' + tr("Default Table order") + ':\
<select id="table_order">\
<option value="asc">ascending</option>\
<option value="desc">descending</option>\
</select>\
</label>\
</div>\
</div>\
<div class="reveal-footer">\
<div class="form_buttons">\
<button class="button radius right success" id="config_submit" type="button" value="">'+tr("Update config")+'</button>\
</div>\
</div>\
</div>\
<div id="quotas_configuration" class="row content">\
<div class="large-12 columns">\
<dl class="tabs" data-tab>\
<dd class="active"><a href="#user_quotas">User Quotas</a></dd>\
<dd><a href="#group_quotas">Group Quotas</a></dd>\
</dl>\
<div class="tabs-content">\
<div class="content active" id="user_quotas">\
</div>\
<div id="group_quotas" class="content">\
<div class="row">\
<div class="large-6 columns">\
<label>' + tr("Select group") + ':\
<select id="quota_group_sel">\
</select>\
</label>\
</div>\
</div>\
<div id="group_quotasTabBody" class="row">\
</div>\
</div>\
</div>\
</div>\
</div>\
<div id="acct_configuration" class="row content">\
</div>\
<div id="showback_configuration" class="row content">\
</div>\
</div>\
</form>\
</div>\
<a class="close-reveal-modal">&#215;</a>';
var settings_update_password = '<div class="row">\
<div class="large-12 columns">\
<h3 id="create_vnet_header" class="subheader">'+tr("Update Password")+'</h3>\
</div>\
</div>\
<form id="settings_update_password_form" action="">\
<div class="row ">\
<div class="large-12 columns">\
<label for="new_password">'+tr("New password")+'</label>\
<input type="password" name="new_password" id="new_password" />\
</div>\
</div>\
<div class="row centered">\
<div class="large-12 columns">\
<label for="confirm_password">'+tr("Confirm Password")+'</label>\
<input type="password" name="confirm_password" id="confirm_password" />\
</div>\
</div>\
<div class="form_buttons">\
<button class="button radius right success" id="update_pw_submit" type="submit" value="User.update">'+tr("Change")+'</button>\
</div>\
<a class="close-reveal-modal">&#215;</a>\
</form>';
Sunstone.addActions({
"UserSettings.update_template" : {
type: "single",
call: OpenNebula.User.update,
callback: function(request) {
fillUserInfo();
},
error: onError
},
"UserSettings.passwd" : {
type: "multiple",
call: OpenNebula.User.passwd,
callback: function(req,res){
},
error: onError
}
});
function setupUpdatePassword() {
dialogs_context.append('<div title="'+tr("Change password")+'" id="settings_update_password"></div>');
var dialog = $('#settings_update_password',dialogs_context);
dialog.html(settings_update_password);
dialog.addClass("reveal-modal").attr("data-reveal", "");
$('#update_password').live('click', function(){
$('#settings_update_password',dialogs_context).foundation().foundation('reveal', 'open');
return false;
});
$('#settings_update_password_form',dialog).submit(function(){
var pw=$('#new_password',this).val();
var confirm_password=$('#confirm_password',this).val();
if (!pw.length){
notifyError(tr("Fill in a new password"));
return false;
}
if (pw !== confirm_password){
notifyError(tr("Passwords do not match"));
return false;
}
Sunstone.runAction("UserSettings.passwd",[-1],pw);
dialog.foundation('reveal', 'close');
return false;
});
}
function setupConfigDialog() {
dialogs_context.append('<div id="config_dialog"></div>');
//Insert HTML in place
$config_dialog = $('#config_dialog')
var dialog = $config_dialog;
dialog.html(config_tab_content);
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(){
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"){
$('input#wss_checkbox').attr('checked','checked');
};
$('#table_order option[value="'+config['user_config']["table_order"]+'"]', dialog).attr('selected','selected');
$('#lang_sel option[value="'+config['user_config']["lang"]+'"]', dialog).attr('selected','selected');
$.each( config['available_views'], function(id, view) {
$('select#view_sel', $config_dialog).append('<option value="'+view+'">'+view+'</option>')
});
$('#view_sel option[value="'+config['user_config']["default_view"]+'"]', dialog).attr('selected','selected');
$('#config_submit', dialog).live('click',function(){
var lang = $('#lang_sel', dialog).val();
var vnc_wss = $('input#wss_checkbox', dialog).is(':checked') ? "yes" : "no";
var table_order = $('#table_order', dialog).val();
var default_view = $('#view_sel', dialog).val();
OpenNebula.User.show({
data : {
id: "-1"
},
success: function(request,user_json){
var template = user_json.USER.TEMPLATE;
template["LANG"] = lang;
template['VNC_WSS'] = vnc_wss;
template['TABLE_ORDER'] = table_order;
template["DEFAULT_VIEW"] = default_view;
template_str = "";
$.each(template,function(key,value){
template_str += (key + '=' + '"' + value + '"\n');
});
var data = OpenNebula.Helper.action('update', {"template_raw" : template_str });
$.ajax({
url: 'config',
type: "POST",
dataType: "json",
data: JSON.stringify(data),
success: function(){
window.location.href = ".";
},
error: function(response){
}
});
}
})
});
$("#quota_group_sel", dialog).die();
$("#quota_group_sel", dialog).live("change", function() {
var value_str = $('select#quota_group_sel').val();
if(value_str!="")
{
fillGroupQuotas(value_str)
}
});
}
function updateUserConfigInfo(request,user_json) {
var info = user_json.USER;
var default_user_quotas = Quotas.default_quotas(info.DEFAULT_USER_QUOTAS);
var quotas_tab_html = initQuotasPanel(info, default_user_quotas,
"#user_quotas", false);
$("#user_quotas").html(quotas_tab_html);
setupQuotasPanel(info,
"#user_quotas",
false,
"User");
$("#user_information tbody").html('<tr>\
<td class="key_td">' + tr("ID") + '</td>\
<td class="value_td" colspan="2">'+info.ID+'</td>\
</tr>\
<tr>\
<td class="key_td">' + tr("Name") + '</td>\
<td class="value_td" colspan="2">'+info.NAME+'</td>\
</tr>\
<tr>\
<td class="key_td">' + tr("Group ID") + '</td>\
<td class="value_td" colspan="2">'+info.GID+'</td>\
</tr>\
<tr>\
<td class="key_td">' + tr("Group") + '</td>\
<td class="value_td_group">'+ info.GNAME +'</td>\
<td>\
<div id="div_edit_chg_group">\
<a id="div_edit_chg_group_link" class="edit_e" href="#"><i class="fa fa-pencil-square-o right"/></a>\
</div>\
</td>\
</tr>\
<tr>\
<td class="key_td">' + tr("Secondary groups") + '</td>\
<td class="value_td" colspan="2">'+(typeof info.GROUPS.ID == "object" ? info.GROUPS.ID.join(",") : "-")+'</td>\
</tr>\
<tr>\
<td class="key_td">' + tr("Password") + '</td>\
<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"),
{SSH_PUBLIC_KEY: ssh_key})
)
$("#div_edit_chg_group_link").die();
$("#group_confirm_select").die();
// Listener for key,value pair edit action
$("#div_edit_chg_group_link").live("click", function() {
// TODO: do not call group.list again, use the callback from
// $("span.user-login a.configuration").click
OpenNebula.Group.list(
{
success: function(request, group_list) {
var value_str = $(".value_td_group").text();
var select_str='<select style="margin: 10px 0;" id="group_confirm_select">';
$.each(group_list,function(){
select_str +='<option elem_id="'+this.GROUP.ID
+'" value="'+this.GROUP.ID+'">'
+this.GROUP.NAME+' (id:'+this.GROUP.ID+')</option>';
});
select_str+="</select>";
$(".value_td_group").html(select_str);
$("select#group_confirm_select").val(info.GID);
},
error: onError
})
});
$("#group_confirm_select").live("change", function() {
var value_str = $('select#group_confirm_select').val();
if(value_str!="")
{
// Let OpenNebula know
var resource_struct = new Array();
resource_struct[0] = info.ID;
Sunstone.runAction("User.chgrp",resource_struct,value_str);
fillUserInfo();
}
});
accountingGraphs(
$("#acct_configuration", "#config_dialog"),
{ fixed_user: info.ID,
init_group_by: "vm" });
if (Config.isFeatureEnabled("showback")) {
showbackGraphs(
$("#showback_configuration","#config_dialog"),
{ fixed_user: info.ID });
}
}
function fillGroupQuotas(group_id){
OpenNebula.Group.show({
data : {
id: group_id
},
success: function(request,group_json){
var info = group_json.GROUP;
var default_group_quotas = Quotas.default_quotas(info.DEFAULT_GROUP_QUOTAS);
var quotas_tab_html = initQuotasPanel(info, default_group_quotas,
"#group_quotasTabBody", false);
$("#group_quotasTabBody").html(quotas_tab_html);
setupQuotasPanel(info,
"#group_quotasTabBody",
false,
"Group");
$("select#quota_group_sel").val(info.ID);
}
});
}
function fillUserInfo(){
OpenNebula.User.show({
data : {
id: '-1'
},
success: updateUserConfigInfo
});
}
$(document).ready(function(){
setupConfigDialog();
setupUpdatePassword();
$(".user-zone-info a.configuration").click(function(){
$(document).foundation('dropdown', 'closeall');
fillUserInfo();
OpenNebula.Group.list(
{
success: function(request, group_list) {
var group_dropdown_options = "";
$.each(group_list,function(){
group_dropdown_options +=
'<option elem_id="'+this.GROUP.ID
+'" value="'+this.GROUP.ID+'">'
+this.GROUP.NAME+' (id:'+this.GROUP.ID+')</option>';
});
$('select#quota_group_sel', $config_dialog).html(group_dropdown_options);
fillGroupQuotas('-1');
}
});
$config_dialog.foundation().foundation('reveal', 'open');
});
});
@@ -1,558 +0,0 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
var empty_graph_placeholder =
'<span class="fa-stack fa-2x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
//'<i class="fa fa-info-circle fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<span style="color: #cfcfcf">'+
tr("There is no information available")+
'</span>';
var dashboard_tab_content =
'<div>\
<div id="one_per_row">\
</div>\
<div id="three_per_row" class="row">\
</div>\
<div id="two_per_row" class="row">\
</div>\
<div id="one_footer">\
</div>\
</div>';
var widgets = {
"storage" : '<h5 class="subheader"><i class="fa fa-fw fa-lg fa-upload"></i> '+tr("Storage")+'</h5>\
<div class="row totals-info dashboard-widget-footer">\
<div class="small-6 large-6 columns text-right">\
<h4 class="subheader">\
<span class="total_images subheader"></span><br>\
<span class="size_images subheader"></span>\
</h4>\
</div>\
<div class="small-6 large-6 columns text-left">\
<h4 class="subheader">\
<small>'+tr("IMAGES")+'</small><br>\
<small>'+tr("USED")+'</small>\
</h4>\
</div>\
</div>',
"users" : '<h5 class="subheader"><i class="fa fa-fw fa-lg fa-user"></i> '+tr("Users")+'</h5>\
<div class="row totals-info">\
<div class="large-3 small-3 columns">\
<div class="small-6 large-6 columns text-right">\
<h4 class="subheader">\
<span class="subheader total_users">-</span><br>\
<span class="subheader total_groups">-</span>\
</h4>\
</div>\
<div class="small-6 large-6 columns text-left">\
<h4 class="subheader">\
<small>'+tr("USERS")+'</small><br>\
<small>'+tr("GROUPS")+'</small>\
</h4>\
</div>'+
'</div>'+
'<div class="large-9 small-9 columns" id="dashboard_vdc_user_accounting">'+
'<input style="display:none;" value="user" id="acct_group_by"/>'+
'<div class="small-6 large-6 columns">'+
'<h3 class="subheader"><small>'+tr("CPU hours")+'</small></h3>'+
'<div class="large-12 columns centered graph text-center" id="acct_cpu_graph" style="height: 100px;">'+
empty_graph_placeholder +
'</div>'+
'</div>'+
'<div class="small-6 large-6 columns">'+
'<h3 class="subheader"><small>'+tr("Memory GB hours")+'</small></h3>'+
'<div class="large-12 columns centered graph text-center" id="acct_mem_graph" style="height: 100px;">'+
empty_graph_placeholder +
'</div>'+
'</div>'+
'</div>'+
'</div>\
<div class="row dashboard-widget-footer">\
<div class="small-3 large-3 columns text-center">\
</div>\
<div class="small-9 large-9 columns text-center">\
<br>\
<a class="button secondary radius large-3 small show_users_tab"><i class="fa fa-lg fa-list fa-fw"></i> ' + tr("Users") + '</a>\
<a class="button secondary radius large-3 small show_create_user"><i class="fa fa-lg fa-plus fa-fw"></i> ' + tr("Create") + '</a>\
</div>\
</div>',
"network" : '<h5 class="subheader"><i class="fa fa-fw fa-lg fa-sitemap"></i> '+tr("Network")+'</h5>\
<div class="row totals-info dashboard-widget-footer">\
<div class="small-6 large-6 columns text-right">\
<h4 class="subheader">\
<span class="total_vnets subheader"></span><br>\
<span class="addresses_vnets subheader"></span>\
</h4>\
</div>\
<div class="small-6 large-6 columns text-left">\
<h4 class="subheader">\
<small>'+tr("VNETS")+'</small><br>\
<small>'+tr("USED IPs")+'</small>\
</h4>\
</div>\
</div>',
"hosts" : '<h5 class="subheader"><i class="fa fa-fw fa-lg fa-hdd-o"></i> '+tr("Hosts")+'</h5>\
<div class="row totals-info">\
<div class="small-3 large-3 columns centered">\
<div class="small-6 large-6 columns text-right">\
<h4 class="subheader">\
<span class="total_hosts subheader"/><br>\
<span class="on_hosts subheader success-color"/><br>\
<span class="off_hosts subheader"/><br>\
<span class="error_hosts subheader alert-color"/><br>\
</h4>\
</div>\
<div class="small-6 large-6 columns text-left">\
<h4 class="subheader">\
<small>'+tr("TOTAL")+'</small><br>\
<small class="success-color">'+tr("ON")+'</small><br>\
<small>'+tr("OFF")+'</small><br>\
<small class="alert-color">'+tr("ERROR")+'</small><br>\
</h4>\
</div>\
</div>\
<div class="small-9 large-9 columns">\
<div class="row">\
<div class="small-6 large-6 columns">\
<div id="dashboard_host_allocated_cpu" style="padding: 0px 40px">\
</div>\
<br>\
<div id="dashboard_host_real_cpu" style="padding: 0px 40px">\
</div>\
</div>\
<div class="small-6 large-6 columns">\
<div id="dashboard_host_allocated_mem" style="padding: 0px 40px">\
</div>\
<br>\
<div id="dashboard_host_real_mem" style="padding: 0px 40px">\
</div>\
</div>\
</div>\
</div>\
</div>\
<div class="row dashboard-widget-footer">\
<div class="small-3 large-3 columns text-center">\
</div>\
<div class="small-9 large-9 columns text-center">\
<br>\
<a class="button secondary radius large-3 small show_hosts_tab"><i class="fa fa-lg fa-list fa-fw"></i> ' + tr("Hosts") + '</a>\
<a class="button secondary radius large-3 small show_create_host"><i class="fa fa-lg fa-plus fa-fw"></i> ' + tr("Create") + '</a>\
</div>\
</div>',
"vms" : '<h5 class="subheader"><i class="fa fa-fw fa-lg fa-th"></i> '+tr("Virtual Machines")+'</h5>\
<div class="row totals-info">\
<div class="small-3 large-3 columns">\
<div class="small-6 large-6 columns text-right">\
<h4 class="subheader">\
<span class="subheader total_vms"></span><br>\
<span class="subheader active_vms success-color"></span><br>\
<span class="subheader pending_vms"></span><br>\
<span class="subheader failed_vms alert-color"></span>\
</h4>\
</div>\
<div class="small-6 large-6 columns text-left">\
<h4 class="subheader">\
<small>'+tr("TOTAL")+'</small><br>\
<small class="success-color">'+tr("ACTIVE")+'</small><br>\
<small>'+tr("PENDING")+'</small><br>\
<small class="alert-color">'+tr("FAILED")+'</small>\
</h4>\
</div>\
</div>'+
'<div class="large-9 small-9 columns" id="dashboard_vm_accounting">'+
'<input style="display:none;" value="vm" id="acct_group_by"/>'+
'<div class="small-6 large-6 columns">'+
'<h3 class="subheader"><small>'+tr("CPU hours")+'</small></h3>'+
'<div class="large-12 columns centered graph text-center" id="acct_cpu_graph" style="height: 100px;">'+
empty_graph_placeholder +
'</div>'+
'</div>'+
'<div class="small-6 large-6 columns">'+
'<h3 class="subheader"><small>'+tr("Memory GB hours")+'</small></h3>'+
'<div class="large-12 columns centered graph text-center" id="acct_mem_graph" style="height: 100px;">'+
empty_graph_placeholder +
'</div>'+
'</div>'+
'</div>'+
'</div>'+
'<div class="row dashboard-widget-footer">\
<div class="small-3 large-3 columns text-center">\
</div>\
<div class="small-9 large-9 columns text-center">\
<br>\
<a class="button secondary radius large-3 small show_vms_tab"><i class="fa fa-lg fa-list fa-fw"></i> ' + tr("VMs") + '</a>\
<a class="button secondary radius large-3 small show_create_vm"><i class="fa fa-lg fa-plus fa-fw"></i> ' + tr("Create") + '</a>\
</div>\
</div>',
"user_quotas" : '<h5 class="subheader"><i class="fa fa-fw fa-lg fa-align-left"></i> '+tr("User Quotas")+'</h5>\
<div class="row totals-info dashboard-widget-footer" id="quotas_tab_user">\
<div class="large-12 small-12 columns">'+
'<div class="row">'+
'<div class="large-8 large-centered columns">'+
'<div class="text-center">'+
'<span class="fa-stack fa-5x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-align-left fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<p style="font-size: 18px; color: #999">'+
tr("There are no quotas defined")+
'</p>'+
'</div>'+
'</div>'+
'</div>'+
'</div>\
</div>',
"group_quotas" : '<h5 class="subheader"><i class="fa fa-fw fa-lg fa-align-left"></i> '+tr("Group Quotas")+'</h5>\
<div id="quotas_tab_group_TabBody" class="row">\
<div class="large-12 columns">'+
'<div class="row">'+
'<div class="large-8 large-centered columns">'+
'<div class="text-center">'+
'<span class="fa-stack fa-5x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-align-left fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<p style="font-size: 18px; color: #999">'+
tr("There are no quotas defined")+
'</p>'+
'</div>'+
'</div>'+
'</div>'+
'</div>\
</div>\
<div class="row dashboard-widget-footer">\
<div class="large-12 columns">\
<label>' + tr("Select group") + ':\
<div id="quotas_tab_group_sel">\
</div>\
</label>\
</div>\
</div>',
"accounting" : '<h5 class="subheader"><i class="fa fa-fw fa-lg fa-bar-chart-o"></i> '+tr("Accounting")+'</h5>\
<div class="row dashboard-widget-footer">\
<div id="user_dashboard_info_acct_div" class="large-12 columns columns">\
</div>\
</div>'
}
var widget_refresh = {
"storage" : function(){
Sunstone.runAction("Datastore.list");
},
"users" : function(){
Sunstone.runAction("User.list");
var start_time = Math.floor(new Date().getTime() / 1000);
// ms to s
// 604800 = 7 days = 7*24*60*60
start_time = start_time - 604800;
// today
var end_time = -1;
var options = {
"start_time": start_time,
"end_time": end_time
}
var no_table = true;
OpenNebula.VM.accounting({
success: function(req, response){
fillAccounting($("#dashboard_vdc_user_accounting"), req, response, no_table);
},
error: onError,
data: options
});
},
"network" : function(){
Sunstone.runAction("Network.list");
},
"hosts" : function(){
Sunstone.runAction("Host.list");
},
"vms" : function(){
Sunstone.runAction("VM.list");
var start_time = Math.floor(new Date().getTime() / 1000);
// ms to s
// 604800 = 7 days = 7*24*60*60
start_time = start_time - 604800;
// today
var end_time = -1;
var options = {
"start_time": start_time,
"end_time": end_time
}
var no_table = true;
OpenNebula.VM.accounting({
success: function(req, response){
fillAccounting($("#dashboard_vm_accounting"), req, response, no_table);
},
error: onError,
data: options
});
},
"accounting" : function(){
},
"user_quotas" : refreshDashboardUserQuotas,
"group_quotas" : refreshDashboardGroupQuotas
}
var dashboard_tab_actions = {
"Dashboard.refresh" : {
type: "custom",
call: refreshDashboard
},
"dashboard-tab.refresh" : {
type: "custom",
call: refreshDashboard
},
}
var quotas_tab_buttons = {
"Dashboard.refresh" : {
type: "action",
layout: "refresh",
alwaysActive: true
},
"Sunstone.toggle_top" : {
type: "custom",
layout: "top",
alwaysActive: true
}
}
var dashboard_tab = {
title: '<i class="fa fa-lg fa-fw fa-tachometer"></i>&emsp;'+tr("Dashboard"),
buttons: quotas_tab_buttons,
content: dashboard_tab_content,
showOnTopMenu: false,
list_header: '<i class="fa fa-fw fa-tachometer"></i>&emsp;'+tr("Dashboard")
}
Sunstone.addActions(dashboard_tab_actions);
Sunstone.addMainTab('dashboard-tab',dashboard_tab);
var $dashboard;
// Quotas calls
function fillUserQuotasInfo(){
OpenNebula.User.show({
data : {
id: '-1'
},
success: updateUserQuotasInfo
});
}
var dashboard_current_gid = "-1";
function updateUserQuotasInfo(request,user_json) {
var info = user_json.USER;
dashboard_current_gid = user_json.USER.GID;
var default_user_quotas = Quotas.default_quotas(info.DEFAULT_USER_QUOTAS)
var quotas_tab_html = Quotas.vms(info, default_user_quotas);
quotas_tab_html += Quotas.cpu(info, default_user_quotas);
quotas_tab_html += Quotas.memory(info, default_user_quotas);
quotas_tab_html += Quotas.volatile_size(info, default_user_quotas);
quotas_tab_html += Quotas.image(info, default_user_quotas);
quotas_tab_html += Quotas.network(info, default_user_quotas);
quotas_tab_html += Quotas.datastore(info, default_user_quotas);
if (emptyQuotas(info)) {
quotas_tab_html = '<div class="row">'+
'<div class="large-8 large-centered columns">'+
'<div class="text-center">'+
'<span class="fa-stack fa-5x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-align-left fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<p style="font-size: 18px; color: #999">'+
tr("There are no quotas defined")+
'</p>'+
'</div>'+
'</div>'+
'</div>'
}
$("#quotas_tab_user", $dashboard).html(quotas_tab_html);
}
function fillGroupQuotasInfo(group_id){
OpenNebula.Group.show({
data : {
id: group_id
},
success: updateGroupQuotasInfo
});
}
function updateGroupQuotasInfo(request,group_json){
var info = group_json.GROUP;
var default_group_quotas = Quotas.default_quotas(info.DEFAULT_GROUP_QUOTAS);
var quotas_tab_html = Quotas.vms(info, default_group_quotas);
quotas_tab_html += Quotas.cpu(info, default_group_quotas);
quotas_tab_html += Quotas.memory(info, default_group_quotas);
quotas_tab_html += Quotas.volatile_size(info, default_group_quotas);
quotas_tab_html += Quotas.image(info, default_group_quotas);
quotas_tab_html += Quotas.network(info, default_group_quotas);
quotas_tab_html += Quotas.datastore(info, default_group_quotas);
if (emptyQuotas(info)) {
quotas_tab_html = '<div class="row">'+
'<div class="large-8 large-centered columns">'+
'<div class="text-center">'+
'<span class="fa-stack fa-5x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-align-left fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<p style="font-size: 18px; color: #999">'+
tr("There are no quotas defined")+
'</p>'+
'</div>'+
'</div>'+
'</div>'
}
$("#quotas_tab_group_TabBody", $dashboard).html(quotas_tab_html);
}
function refreshDashboardUserQuotas(){
fillUserQuotasInfo();
}
function refreshDashboardGroupQuotas(){
gid = $("#quotas_tab_group_sel .resource_list_select", $dashboard).val();
if (gid == "" || gid == undefined){
gid = dashboard_current_gid;
}
fillGroupQuotasInfo(gid);
insertSelectOptions('div#quotas_tab_group_sel', $dashboard, "Group", gid, false);
}
function refreshDashboard(){
widget_types = ['widgets_three_per_row', 'widgets_two_per_row',
'widgets_one_per_row', 'widgets_one_footer'];
$.each(widget_types, function(index, widget_type){
$.each(Config.dashboardWidgets(widget_type), function(id, widget){
widget_refresh[widget]();
})
});
}
$(document).ready(function(){
var tab_name = 'dashboard-tab';
if (Config.isTabEnabled(tab_name)) {
$dashboard = $('#dashboard-tab', main_tabs_context);
$.each(Config.dashboardWidgets('widgets_three_per_row'), function(id, widget){
var html = '<div class="small-4 large-4 columns">'+widgets[widget]+'</div>';
$('#three_per_row', $dashboard).append(html);
})
$.each(Config.dashboardWidgets('widgets_two_per_row'), function(id, widget){
var html = '<div class="small-6 large-6 columns">'+widgets[widget]+'</div>';
$('#two_per_row', $dashboard).append(html);
})
$.each(Config.dashboardWidgets('widgets_one_per_row'), function(id, widget){
var html = '<div class="row"><div class="large-12 columns">'+widgets[widget]+'</div></div>';
$('#one_per_row', $dashboard).append(html);
})
$.each(Config.dashboardWidgets('widgets_one_footer'), function(id, widget){
var html = '<div class="row"><div class="large-12 columns">'+widgets[widget]+'</div></div>';
$('#one_footer', $dashboard).append(html);
});
$dashboard.off("change", "#quotas_tab_group_sel .resource_list_select");
$dashboard.on("change", "#quotas_tab_group_sel .resource_list_select", function() {
var value_str = $(this).val();
if(value_str!="")
{
fillGroupQuotasInfo(value_str);
}
});
$(".show_vms_tab").on("click", function(){
showTab('vms-tab');
return false;
})
$(".show_hosts_tab").on("click", function(){
showTab('hosts-tab');
return false;
})
$(".show_users_tab").on("click", function(){
showTab('users-tab');
return false;
})
$(".show_create_vm").on("click", function(){
window.scrollTo(0, 0);
popUpCreateVMDialog();
return false;
})
$(".show_create_host").on("click", function(){
window.scrollTo(0, 0);
popUpCreateHostDialog();
return false;
})
$(".show_create_user").on("click", function(){
window.scrollTo(0, 0);
popUpCreateUserDialog();
return false;
})
accountingGraphs(
$("#user_dashboard_info_acct_div"),
{ fixed_user: config["user_id"],
fixed_group_by: "vm"
}
);
$(document).foundation();
}
});
File diff suppressed because it is too large. Load diff
-852
View File
@@ -1,852 +0,0 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
var create_file_tmpl ='<div class="row">\
<div class="large-5 columns">\
<h3 class="subheader">'+tr("Create File")+'</h3>'+
'</div>'+
'<div class="large-7 columns">'+
'<dl class="tabs right" data-tab>\
<dd class="active"><a href="#file_easyTab">'+tr("Wizard")+'</a></dd>\
<dd><a href="#file_manualTab">'+tr("Advanced mode")+'</a></dd>\
</dl>\
</div>\
</div>\
<form id="create_file_form_easy" action="" class="custom creation">\
<div class="tabs-content">\
<div id="file_easyTab" class="content active">\
<div class="row vm_param">\
<div class="large-6 columns">\
<div class="row">\
<div class="large-12 columns">\
<label for="file_name">'+tr("Name")+
'<span class="tip">'+tr("Name that the File will get. Every file must have a unique name.")+'</span>\
</label>\
<input type="text" name="file_name" id="file_name" />\
</div>\
</div>\
<div class="row">\
<div class="large-12 columns">\
<label for="file_desc">'+tr("Description")+
'<span class="tip">'+tr("Human readable description of the file for other users.")+'</span>\
</label>\
<textarea name="file_desc" id="file_desc" rows="4"></textarea>\
</div>\
</div>\
</div>\
<div class="large-6 columns">\
<div class="row">\
<div class="large-12 columns">\
<label for="file_type">'+tr("Type")+
'<span class="tip">'+tr("Type of the file.")+'<br/><br/>'
+ tr(" KERNEL & RAMDISK files can be used in the OS Booting section of the Template wizard.")+'<br/><br/>'
+ tr(" CONTEXT files can be included in the context CD-ROM, from the Context/Files section of the Template wizard.")+
'</span>'+
'</label>\
<select name="file_type" id="file_type">\
<option value="CONTEXT">'+tr("Context")+'</option>\
<option value="KERNEL">'+tr("Kernel")+'</option>\
<option value="RAMDISK">'+tr("Ramdisk")+'</option>\
</select>\
</div>\
</div>\
<div class="row">\
<div class="large-12 columns">\
<label for="file_datastore">'+tr("Datastore")+
'<span class="tip">'+tr("Select the datastore for this file")+'</span>'+
'</label>\
<div id="file_datastore" name="file_datastore">\
</div>\
</div>\
</div>\
</div>\
</div>\
<fieldset>\
<legend>'+tr("Image location")+':</legend>\
<div class="row" id="src_path_select">\
<div class="large-12 columns text-center">\
<input type="radio" name="src_path" id="path_file" value="path"><label for="path_file">'+ tr("Provide a path")+'</label> \
<input type="radio" name="src_path" id="upload_file" value="upload"> <label for="upload_file">'+tr("Upload")+'</label> \
</div>\
</div>\
<br>\
<div class="file_param row">\
<div class="large-12 columns">\
<label for="file_path">'+tr("Path")+
'<span class="tip">'+tr("Path to the original file that will be copied to the file repository.")+'</span>'+
'</label>\
<input type="text" name="file_path" id="file_path" />\
</div>\
</div>\
<div class="row">\
<div id="files_file-uploader" class="large-12 columns text-center">\
<label id="files_file-uploader-label" for="files_file-uploader-input"></label>\
<input id="files_file-uploader-input" type="file"/>\
</div>\
</div>\
</fieldset>\
<div class="form_buttons">\
<button class="button success radius right" id="create_file_submit" type="submit" value="file/create">'+tr("Create")+'</button>\
<button id="wizard_file_reset_button" class="button secondary radius" type="reset" value="reset">'+tr("Reset")+'</button>\
</div>\
</div>\
<div id="file_manualTab" class="content">\
<div class="row">\
<div class="columns large-12">\
<label for="file_datastores_raw">'+tr("Datastore")+':</label>\
<div id="file_datastore_raw" name="file_datastore_raw">\
</div>\
</div>\
</div>\
<div class="row">\
<div class="columns large-12">\
<textarea id="template" rows="15" style="height:180px !important; width:100%;"></textarea>\
</div>\
</div>\
<div class="form_buttons">\
<button class="button success radius right" id="create_file_submit_manual" value="file/create">'+tr("Create")+'</button>\
<button id="advanced_file_reset_button" class="button secondary radius" type="reset" value="reset">'+tr("Reset")+'</button>\
</div>\
</div>\
</div>\
<a class="close-reveal-modal">&#215;</a>\
</form>\
</div>';
var dataTable_files;
var $create_file_dialog;
var size_files = 0;
var file_actions = {
"File.create" : {
type: "create",
call: OpenNebula.Image.create,
callback: function(request, response) {
// Reset the create wizard
$create_file_dialog.foundation('reveal', 'close');
$create_file_dialog.empty();
setupCreateFileDialog();
addFileElement(request, response);
notifyCustom(tr("File created"), " ID: " + response.IMAGE.ID, false);
},
error: onError
},
"File.create_dialog" : {
type: "custom",
call: popUpCreateFileDialog
},
"File.list" : {
type: "list",
call: OpenNebula.Image.list,
callback: updateFilesView,
error: onError
},
"File.show" : {
type : "single",
call: OpenNebula.Image.show,
callback: function(request, response){
var tab = dataTable_files.parents(".tab");
if (Sunstone.rightInfoVisible(tab)) {
// individual view
updateFileInfo(request, response);
}
// datatable row
updateFileElement(request, response);
},
error: onError
},
"File.refresh" : {
type: "custom",
call: function () {
var tab = dataTable_files.parents(".tab");
if (Sunstone.rightInfoVisible(tab)) {
Sunstone.runAction("File.show", Sunstone.rightInfoResourceId(tab))
} else {
waitingNodes(dataTable_files);
Sunstone.runAction("File.list", {force: true});
}
}
},
"File.update_template" : {
type: "single",
call: OpenNebula.Image.update,
callback: function(request) {
notifyMessage("Template updated correctly");
Sunstone.runAction('File.show',request.request.data[0][0]);
},
error: onError
},
"File.enable" : {
type: "multiple",
call: OpenNebula.Image.enable,
callback: function (req) {
Sunstone.runAction("File.show",req.request.data[0]);
},
elements: fileElements,
error: onError,
notify: true
},
"File.disable" : {
type: "multiple",
call: OpenNebula.Image.disable,
callback: function (req) {
Sunstone.runAction("File.show",req.request.data[0]);
},
elements: fileElements,
error: onError,
notify: true
},
"File.delete" : {
type: "multiple",
call: OpenNebula.Image.del,
callback: deleteFileElement,
elements: fileElements,
error: onError,
notify: true
},
"File.chown" : {
type: "multiple",
call: OpenNebula.Image.chown,
callback: function (req) {
Sunstone.runAction("File.show",req.request.data[0][0]);
},
elements: fileElements,
error: onError,
notify: true
},
"File.chgrp" : {
type: "multiple",
call: OpenNebula.Image.chgrp,
callback: function (req) {
Sunstone.runAction("File.show",req.request.data[0][0]);
},
elements: fileElements,
error: onError,
notify: true
},
"File.chmod" : {
type: "single",
call: OpenNebula.Image.chmod,
// callback
error: onError,
notify: true
},
"File.chtype" : {
type: "single",
call: OpenNebula.Image.chtype,
callback: function (req) {
Sunstone.runAction("File.show",req.request.data[0][0]);
},
elements: fileElements,
error: onError,
notify: true
},
"File.help" : {
type: "custom",
call: function() {
hideDialog();
$('div#files_tab div.legend_div').slideToggle();
}
},
"File.rename" : {
type: "single",
call: OpenNebula.Image.rename,
callback: function(request) {
notifyMessage(tr("File renamed correctly"));
Sunstone.runAction('File.show',request.request.data[0]);
},
error: onError,
notify: true
},
};
var file_buttons = {
"File.refresh" : {
type: "action",
layout: "refresh",
alwaysActive: true
},
// "Sunstone.toggle_top" : {
// type: "custom",
// layout: "top",
// alwaysActive: true
// },
"File.create_dialog" : {
type: "create_dialog",
layout: "create"
},
"File.chown" : {
type: "confirm_with_select",
text: tr("Change owner"),
layout: "user_select",
select: "User",
tip: tr("Select the new owner")+":",
condition: mustBeAdmin
},
"File.chgrp" : {
type: "confirm_with_select",
text: tr("Change group"),
layout: "user_select",
select: "Group",
tip: tr("Select the new group")+":",
condition: mustBeAdmin
},
"File.enable" : {
type: "action",
layout: "more_select",
text: tr("Enable")
},
"File.disable" : {
type: "action",
layout: "more_select",
text: tr("Disable")
},
"File.delete" : {
type: "confirm",
layout: "del",
text: tr("Delete")
}
}
var file_info_panel = {
"file_info_tab" : {
title: tr("Information"),
content: ""
}
}
var files_tab = {
title: tr("Files & Kernels"),
resource: 'File',
buttons: file_buttons,
tabClass: 'subTab',
parentTab: 'vresources-tab',
content: '<div class="large-12 columns">\
<div id="files_upload_progress_bars"></div>\
</div>',
search_input: '<input id="file_search" type="search" placeholder="'+tr("Search")+'" />',
list_header: '<i class="fa fa-fw fa-folder-open"></i>&emsp;'+tr("Files & Kernels"),
info_header: '<i class="fa fa-fw fa-folder-open"></i>&emsp;'+tr("File"),
subheader: '<span class="total_files"/> <small>'+tr("TOTAL")+'</small>&emsp;\
<span class="size_files"/> <small>'+tr("SIZE")+'</small>',
table: '<table id="datatable_files" class="datatable twelve">\
<thead>\
<tr>\
<th class="check"><input type="checkbox" class="check_all" value=""></input></th>\
<th>'+tr("ID")+'</th>\
<th>'+tr("Owner")+'</th>\
<th>'+tr("Group")+'</th>\
<th>'+tr("Name")+'</th>\
<th>'+tr("Datastore")+'</th>\
<th>'+tr("Size")+'</th>\
<th>'+tr("Type")+'</th>\
<th>'+tr("Registration time")+'</th>\
<th>'+tr("Persistent")+'</th>\
<th>'+tr("Status")+'</th>\
<th>'+tr("#VMS")+'</th>\
<th>'+tr("Target")+'</th>\
</tr>\
</thead>\
<tbody id="tbodyfiles">\
</tbody>\
</table>'
}
Sunstone.addActions(file_actions);
Sunstone.addMainTab('files-tab',files_tab);
Sunstone.addInfoPanel('file_info_panel',file_info_panel);
function fileElements() {
return getSelectedNodes(dataTable_files);
}
// Returns an array containing the values of the file_json and ready
// to be inserted in the dataTable
function fileElementArray(file_json){
//Changing this? It may affect to the is_persistent() functions.
var file = file_json.IMAGE;
// OS || CDROM || DATABLOCK
if (file.TYPE == "0" || file.TYPE == "1" || file.TYPE == "2") {
return false;
}
size_files = size_files + parseInt(file.SIZE);
//add also persistent/non-persistent selects, type select.
return [
'<input class="check_item" type="checkbox" id="file_'+file.ID+'" name="selected_items" value="'+file.ID+'"/>',
file.ID,
file.UNAME,
file.GNAME,
file.NAME,
file.DATASTORE,
file.SIZE,
OpenNebula.Helper.image_type(file.TYPE),
pretty_time(file.REGTIME),
parseInt(file.PERSISTENT) ? "yes" : "no",
OpenNebula.Helper.resource_state("image",file.STATE),
file.RUNNING_VMS,
file.TEMPLATE.TARGET ? file.TEMPLATE.TARGET : '--'
];
}
// Callback to update an element in the dataTable
function updateFileElement(request, file_json){
var id = file_json.IMAGE.ID;
var element = fileElementArray(file_json);
updateSingleElement(element,dataTable_files,'#file_'+id);
}
// Callback to remove an element from the dataTable
function deleteFileElement(req){
deleteElement(dataTable_files,'#file_'+req.request.data);
}
// Callback to add an file element
function addFileElement(request, file_json){
var element = fileElementArray(file_json);
addElement(element,dataTable_files);
}
// Callback to refresh the list of files
function updateFilesView(request, files_list){
var file_list_array = [];
size_files = 0;
$.each(files_list,function(){
var file = fileElementArray(this);
if (file)
file_list_array.push(file);
});
updateView(file_list_array,dataTable_files);
var size = humanize_size_from_mb(size_files)
$(".total_files").text(file_list_array.length);
$(".size_files").text(size);
}
// Callback to update the information panel tabs and pop it up
function updateFileInfo(request,file){
var file_info = file.IMAGE;
$(".resource-info-header", $("#files-tab")).html(file_info.NAME);
var info_tab = {
title : tr("Info"),
icon: "fa-info-circle",
content:
'<div class="row">\
<div class="large-6 columns">\
<table id="info_file_table" class="dataTable extended_table">\
<thead>\
<tr><th colspan="3">'+tr("File")+' - '+file_info.NAME+'</th></tr>\
</thead>\
<tr>\
<td class="key_td">'+tr("ID")+'</td>\
<td class="value_td">'+file_info.ID+'</td>\
<td></td>\
</tr>'+
insert_rename_tr(
'files-tab',
"File",
file_info.ID,
file_info.NAME)+
'<tr>\
<td class="key_td">'+tr("Datastore")+'</td>\
<td class="value_td">'+file_info.DATASTORE+'</td>\
<td></td>\
</tr>\
<tr>\
<td class="key_td">'+tr("Type")+'</td>\
<td class="value_td_type_files">'+OpenNebula.Helper.image_type(file_info.TYPE)+'</td>\
<td><div id="div_edit_chg_type_files">\
<a id="div_edit_chg_type_files_link" class="edit_e" href="#"><i class="fa fa-pencil-square-o right"/></a>\
</div>\
</td>\
</tr>\
<tr>\
<td class="key_td">'+tr("Register time")+'</td>\
<td class="value_td">'+pretty_time(file_info.REGTIME)+'</td>\
<td></td>\
</tr>\
<tr>\
<td class="key_td">'+tr("Filesystem type")+'</td>\
<td class="value_td">'+(typeof file_info.FSTYPE === "string" ? file_info.FSTYPE : "--")+'</td>\
<td></td>\
</tr>\
<tr>\
<td class="key_td">'+tr("Size")+'</td>\
<td class="value_td">'+humanize_size_from_mb(file_info.SIZE)+'</td>\
<td></td>\
</tr>\
<tr>\
<td class="key_td">'+tr("State")+'</td>\
<td class="value_td">'+OpenNebula.Helper.resource_state("file",file_info.STATE)+'</td>\
<td></td>\
</tr>\
<tr>\
<td class="key_td">'+tr("Running VMS")+'</td>\
<td class="value_td">'+file_info.RUNNING_VMS+'</td>\
<td></td>\
</tr>\
</table>\
</div>\
<div class="large-6 columns">' +
insert_permissions_table('files-tab',
"File",
file_info.ID,
file_info.UNAME,
file_info.GNAME,
file_info.UID,
file_info.GID) +
'</div>\
</div>\
<div class="row">\
<div class="large-9 columns">'+
insert_extended_template_table(file_info.TEMPLATE,
"File",
file_info.ID,
tr("Attributes")) +
'</div>\
</div>'
}
$("#div_edit_chg_type_files_link").die();
$("#chg_type_select_files").die();
$("#div_edit_persistency_files").die();
$("#persistency_select_files").die();
// Listener for edit link for type change
$("#div_edit_chg_type_files_link").live("click", function() {
$(".value_td_type_files").html(
'<select id="chg_type_select_files">\
<option value="KERNEL">KERNEL</option>\
<option value="RAMDISK">RAMDISK</option>\
<option value="CONTEXT">CONTEXT</option>\
</select>');
$('#chg_type_select_files').val(OpenNebula.Helper.image_type(file_info.TYPE));
});
$("#chg_type_select_files").live("change", function() {
var new_value = $(this).val();
Sunstone.runAction("File.chtype", file_info.ID, new_value);
});
Sunstone.updateInfoPanelTab("file_info_panel","file_info_tab",info_tab);
Sunstone.popUpInfoPanel("file_info_panel", "files-tab");
setPermissionsTable(file_info,'');
}
function enable_all_datastores()
{
$('select#disk_type').children('option').each(function() {
$(this).removeAttr('disabled');
});
}
// Prepare the file creation dialog
function setupCreateFileDialog(){
dialogs_context.append('<div id="create_file_dialog"></div>');
$create_file_dialog = $('#create_file_dialog',dialogs_context);
var dialog = $create_file_dialog;
dialog.html(create_file_tmpl);
dialog.addClass("reveal-modal medium").attr("data-reveal", "");
$('#files_file-uploader',dialog).closest('.row').hide();
$("input[name='src_path']", dialog).change(function(){
var context = $create_file_dialog;
var value = $(this).val();
switch (value){
case "path":
$('#files_file-uploader',context).closest('.row').hide();
$('#file_path',context).closest('.row').show();
break;
case "upload":
$('#file_path',context).closest('.row').hide();
$('#files_file-uploader',context).closest('.row').show();
break;
};
});
$('#path_file',dialog).click();
$('#upload-progress',dialog).css({
border: "1px solid #AAAAAA",
position: "relative",
// bottom: "29px",
width: "258px",
// left: "133px",
height: "15px",
display: "inline-block"
});
$('#upload-progress div',dialog).css("border","1px solid #AAAAAA");
var file_obj;
if (getInternetExplorerVersion() > -1) {
$("#file_uploader").attr("disabled", "disabled");
} else {
var file_uploader = new Resumable({
target: 'upload_chunk',
chunkSize: 10*1024*1024,
maxFiles: 1,
testChunks: false,
query: {
csrftoken: csrftoken
}
});
file_uploader.assignBrowse($('#files_file-uploader-input',dialog)[0]);
var fileName = '';
var file_input = false;
file_uploader.on('fileAdded', function(file){
fileName = file.fileName;
file_input = fileName;
$('#files_file-uploader-input',dialog).hide()
$("#files_file-uploader-label", dialog).html(file.fileName);
});
file_uploader.on('uploadStart', function() {
$('#files_upload_progress_bars').append('<div id="files-'+fileName+'-progressBar" class="row" style="margin-bottom:10px">\
<div id="files-'+fileName+'-info" class="large-2 columns dataTables_info">\
'+tr("Uploading...")+'\
</div>\
<div class="large-10 columns">\
<div id="upload_progress_container" class="progress nine radius" style="height:25px !important">\
<span class="meter" style="width:0%"></span>\
</div>\
<div class="progress-text" style="margin-left:15px">'+fileName+'</div>\
</div>\
</div>');
});
file_uploader.on('progress', function() {
$('span.meter', $('div[id="files-'+fileName+'-progressBar"]')).css('width', file_uploader.progress()*100.0+'%')
});
file_uploader.on('fileSuccess', function(file) {
$('div[id="files-'+fileName+'-info"]').text(tr('Registering in OpenNebula'));
$.ajax({
url: 'upload',
type: "POST",
data: {
csrftoken: csrftoken,
img : JSON.stringify(file_obj),
file: fileName,
tempfile: file.uniqueIdentifier
},
success: function(){
notifyMessage("File uploaded correctly");
$('div[id="files-'+fileName+'-progressBar"]').remove();
Sunstone.runAction("File.refresh");
},
error: function(response){
onError({}, OpenNebula.Error(response));
$('div[id="files-'+fileName+'-progressBar"]').remove();
}
});
});
}
$('#create_file_form_easy',dialog).submit(function(){
var upload = false;
var ds_id = $('#file_datastore .resource_list_select',dialog).val();
if (!ds_id){
notifyError(tr("Please select a datastore for this file"));
return false;
};
var file_json = {};
var name = $('#file_name',dialog).val();
file_json["NAME"] = name;
var desc = $('#file_desc',dialog).val();
if (desc.length){
file_json["DESCRIPTION"] = desc;
}
var type = $('#file_type',dialog).val();
file_json["TYPE"]= type;
switch ($('#src_path_select input:checked',dialog).val()){
case "path":
path = $('#file_path',dialog).val();
if (path) file_json["PATH"] = path;
break;
case "upload":
upload=true;
break;
}
file_obj = { "image" : file_json,
"ds_id" : ds_id};
//we this is an file upload we trigger FileUploader
//to start the upload
if (upload){
$create_file_dialog.foundation('reveal', 'close');
$create_file_dialog.empty();
setupCreateFileDialog();
file_uploader.upload();
} else {
Sunstone.runAction("File.create", file_obj);
};
return false;
});
$('#create_file_submit_manual',dialog).click(function(){
var template=$('#template',dialog).val();
var ds_id = $('#file_datastore_raw .resource_list_select',dialog).val();
if (!ds_id){
notifyError(tr("Please select a datastore for this file"));
return false;
};
var file_obj = {
"image" : {
"image_raw" : template
},
"ds_id" : ds_id
};
Sunstone.runAction("File.create",file_obj);
return false;
});
setupTips(dialog);
$('#wizard_file_reset_button', dialog).click(function(){
$('#create_file_dialog').html("");
setupCreateFileDialog();
popUpCreateFileDialog();
});
$('#advanced_file_reset_button', dialog).click(function(){
$('#create_file_dialog').html("");
setupCreateFileDialog();
popUpCreateFileDialog();
$("a[href='#file_manual']").click();
});
}
function popUpCreateFileDialog(){
$('#files_file-uploader input',$create_file_dialog).removeAttr("style");
$('#files_file-uploader input',$create_file_dialog).attr('style','margin:0;width:256px!important');
var ds_id = $("div#file_datastore .resource_list_select",
$create_file_dialog).val();
var ds_id_raw = $("div#file_datastore_raw .resource_list_select",
$create_file_dialog).val();
// Filter out DS with type image (0) or system (1)
var filter_att = ["TYPE", "TYPE"];
var filter_val = ["0", "1"];
insertSelectOptions('div#file_datastore', $create_file_dialog, "Datastore",
ds_id, false, null, filter_att, filter_val);
insertSelectOptions('div#file_datastore_raw', $create_file_dialog, "Datastore",
ds_id_raw, false, null, filter_att, filter_val);
$create_file_dialog.foundation().foundation('reveal', 'open');
$("input#file_name",$create_file_dialog).focus();
}
function is_persistent_file(id){
var data = getElementData(id,"#file",dataTable_files)[8];
return $(data).is(':checked');
};
//The DOM is ready at this point
$(document).ready(function(){
var tab_name = 'files-tab';
if (Config.isTabEnabled(tab_name)) {
dataTable_files = $("#datatable_files",main_tabs_context).dataTable({
"aoColumnDefs": [
{ "bSortable": false, "aTargets": ["check"] },
{ "sWidth": "35px", "aTargets": [0] },
{ "bVisible": true, "aTargets": Config.tabTableColumns(tab_name)},
{ "bVisible": false, "aTargets": ['_all']}
],
"bSortClasses" : false,
"bDeferRender": true,
});
$('#file_search').keyup(function(){
dataTable_files.fnFilter( $(this).val() );
})
dataTable_files.on('draw', function(){
recountCheckboxes(dataTable_files);
})
Sunstone.runAction("File.list");
setupCreateFileDialog();
initCheckAllBoxes(dataTable_files);
tableCheckboxesListener(dataTable_files);
infoListener(dataTable_files,'File.show');
$('div#files_tab div.legend_div').hide();
dataTable_files.fnSort( [ [1,config['user_config']['table_order']] ] );
}
});
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -1,24 +0,0 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
var infra_tab = {
title: '<i class="fa fa-lg fa-fw fa-sitemap"></i>&emsp;'+tr("Infrastructure"),
no_content: true
}
Sunstone.addMainTab('infra-tab',infra_tab);
$(document).ready(function(){});
@@ -1,617 +0,0 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2010-2015, C12G Labs S.L */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
/* Marketpplace tab plugin */
var dataTable_marketplace;
var $marketplace_import_dialog;
var market_actions = {
"Marketplace.list" : {
type: "list",
call: OpenNebula.Marketplace.list,
callback: function(req,res){
updateView(res.appliances,dataTable_marketplace);
}
},
"Marketplace.refresh" : {
type: "custom",
call: function () {
var tab = dataTable_marketplace.parents(".tab");
if (Sunstone.rightInfoVisible(tab)) {
Sunstone.runAction("Marketplace.show", Sunstone.rightInfoResourceId(tab))
} else {
waitingNodes(dataTable_marketplace);
Sunstone.runAction("Marketplace.list");
}
}
},
"Marketplace.import" : {
//fetches images information and fills in the image creation
//dialog with it.
type: "multiple",
elements: marketplaceElements,
call: OpenNebula.Marketplace.show,
callback: function(request,appliance){
if (appliance['status'] && appliance['status'] != 'ready') {
notifyError(tr("The appliance is not ready"));
return;
}
if ($('#market_import_dialog',dialogs_context) != undefined) {
$('#market_import_dialog',dialogs_context).remove();
}
dialogs_context.append(marketplace_import_dialog);
$marketplace_import_dialog = $('#market_import_dialog',dialogs_context);
$marketplace_import_dialog.addClass("reveal-modal medium").attr("data-reveal", "");
//var tab_id = 1;
$('<div class="row">'+
'<div class="large-12 columns">'+
'<p style="font-size:14px">'+
tr("The following images will be created in OpenNebula.")+ ' '+
tr("If you want to edit parameters of the image you can do it later in the images tab")+ ' '+
'</p>'+
'</div>'+
'</div>').appendTo($("#market_import_dialog_content"));
$('<div class="row">'+
'<div class="large-10 large-centered columns">'+
'<div class="large-10 columns">'+
'<label for="market_img_datastore">'+tr("Select the datastore for the images")+
'</label>'+
'<div id="market_img_datastore" name="market_img_datastore">'+
'</div>'+
'</div>'+
'<div class="large-2 columns">'+
'</div>'+
'</div>'+
'</div>').appendTo($("#market_import_dialog_content"));
// Filter out DS with type system (1) or file (2)
var filter_att = ["TYPE", "TYPE"];
var filter_val = ["1", "2"];
insertSelectOptions('div#market_img_datastore', $marketplace_import_dialog, "Datastore",
null, false, null, filter_att, filter_val);
$.each(appliance['files'], function(index, value){
$('<div class="row" id="market_import_file_'+index+'">'+
'<div class="large-10 large-centered columns">'+
'<div class="large-10 columns">'+
'<label>'+
'<i class="fa fa-fw fa-download"/>&emsp;'+
index+' - '+tr("Image Name")+
'<span class="right">'+
humanize_size(value['size'], true)+
'</span>'+
'</label>'+
'<input type="text" class="name" value="' + (value['name']||appliance['name']) +'" />'+
'</div>'+
'<div class="large-2 columns market_image_result">'+
'</div>'+
'</div>'+
'<div class="large-10 columns market_image_response">'+
'</div>'+
'</div>').appendTo($("#market_import_dialog_content"));
})
if (appliance['opennebula_template'] && appliance['opennebula_template'] !== "CPU=1") {
$('<br>'+
'<div class="row">'+
'<div class="large-12 columns">'+
'<p style="font-size:14px">'+
tr("The following template will be created in OpenNebula and the previous images will be referenced in the disks")+ ' '+
tr("If you want to edit parameters of the template you can do it later in the templates tab")+ ' '+
'</p>'+
'</div>'+
'</div>').appendTo($("#market_import_dialog_content"));
$('<div class="row" id="market_import_file_template">'+
'<div class="large-10 large-centered columns">'+
'<div class="large-10 columns">'+
'<label>'+
'<i class="fa fa-fw fa-file-text-o"/>&emsp;'+
tr("Template Name")+
'</label>'+
'<input type="text" class="name" value="' + (appliance['opennebula_template']['NAME']||appliance['name']) +'" />'+
'</div>'+
'<div class="large-2 columns market_template_result">'+
'</div>'+
'</div>'+
'<div class="large-10 columns market_template_response">'+
'</div>'+
'</div>').appendTo($("#market_import_dialog_content"));
}
$marketplace_import_dialog.foundation().foundation('reveal', 'open');
var images_information = [];
$("#market_import_form").submit(function(){
function try_to_create_template(){
var images_created = $(".market_image_result.success", $marketplace_import_dialog).length;
if ((images_created == number_of_files) && !template_created) {
template_created = true;
if (appliance['opennebula_template'] && appliance['opennebula_template'] !== "CPU=1") {
var vm_template
try {
vm_template = JSON.parse(appliance['opennebula_template'])
} catch (error) {
$(".market_template_result", template_context).html('<span class="fa-stack fa-2x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-warning fa-stack-1x fa-inverse"></i>'+
'</span>');
$(".market_template_response", template_context).html('<p style="font-size:12px" class="error-color">'+
(error.message || tr("Cannot contact server: is it running and reachable?"))+
'</p>');
$("input", template_context).removeAttr("disabled");
$("button", $marketplace_import_dialog).removeAttr("disabled");
template_created = false;
return;
}
if ($.isEmptyObject(vm_template.DISK))
vm_template.DISK = []
else if (!$.isArray(vm_template.DISK))
vm_template.DISK = [vm_template.DISK]
vm_template.NAME = $("input", template_context).val();
if (!vm_template.CPU)
vm_template.CPU = "1"
if (!vm_template.MEMORY)
vm_template.MEMORY = "1024"
$.each(images_information, function(image_index, image_info){
if (!vm_template.DISK[image_index]) {
vm_template.DISK[image_index] = {}
}
vm_template.DISK[image_index].IMAGE = image_info.IMAGE.NAME;
vm_template.DISK[image_index].IMAGE_UNAME = image_info.IMAGE.UNAME;
})
vm_template.FROM_APP = appliance['_id']["$oid"];
vm_template.FROM_APP_NAME = appliance['name'];
OpenNebula.Template.create({
timeout: true,
data: {vmtemplate: vm_template},
success: function (request, response){
$(".market_template_result", template_context).addClass("success").html('<span class="fa-stack fa-2x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-check fa-stack-1x fa-inverse"></i>'+
'</span>');
$(".market_template_response", template_context).html('<p style="font-size:12px" class="running-color">'+
tr("Template created successfully")+' ID:'+response.VMTEMPLATE.ID+
'</p>');
$("button", $marketplace_import_dialog).hide();
},
error: function (request, error_json){
$(".market_template_result", template_context).html('<span class="fa-stack fa-2x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-warning fa-stack-1x fa-inverse"></i>'+
'</span>');
$(".market_template_response", template_context).html('<p style="font-size:12px" class="error-color">'+
(error_json.error.message || tr("Cannot contact server: is it running and reachable?"))+
'</p>');
$("input", template_context).removeAttr("disabled");
$("button", $marketplace_import_dialog).removeAttr("disabled");
template_created = false;
}
});
} else {
$("button", $marketplace_import_dialog).hide();
}
};
}
var number_of_files = appliance['files'].length;
var template_created = false;
$("input, button", $marketplace_import_dialog).attr("disabled", "disabled");
$(".market_image_result:not(.success)", $marketplace_import_dialog).html('<span class="fa-stack fa-2x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-spinner fa-spin fa-stack-1x fa-inverse"></i>'+
'</span>');
$(".market_template_result", $marketplace_import_dialog).html('<span class="fa-stack fa-2x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-spinner fa-spin fa-stack-1x fa-inverse"></i>'+
'</span>');
var template_context = $("#market_import_file_template", $marketplace_import_dialog);
$.each(appliance['files'], function(index, value){
var context = $("#market_import_file_"+index, $marketplace_import_dialog);
if ($(".market_image_result:not(.success)", context).length > 0) {
img_obj = {
"image" : {
"NAME": $("input.name",context).val(),
"PATH": appliance['links']['download']['href']+'/'+index,
"TYPE": value['type'],
"MD5": value['md5'],
"SHA1": value['sha1'],
"TYPE": value['type'],
"DRIVER": value['driver'],
"DEV_PREFIX": value['dev_prefix'],
"FROM_APP": appliance['_id']["$oid"],
"FROM_APP_NAME": appliance['name'],
"FROM_APP_FILE": index
},
"ds_id" : $("#market_img_datastore select", $marketplace_import_dialog).val()
};
OpenNebula.Image.create({
timeout: true,
data: img_obj,
success: function (file_index, file_context){
return function(request, response) {
$(".market_image_result", file_context).addClass("success").html('<span class="fa-stack fa-2x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-check fa-stack-1x fa-inverse"></i>'+
'</span>');
$(".market_image_response", file_context).html('<p style="font-size:12px" class="running-color">'+
tr("Image created successfully")+' ID:'+response.IMAGE.ID+
'</p>');
images_information[file_index] = response;
try_to_create_template();
};
}(index, context),
error: function (request, error_json){
$(".market_template_result", template_context).html('');
$(".market_image_result", context).html('<span class="fa-stack fa-2x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-warning fa-stack-1x fa-inverse"></i>'+
'</span>');
$(".market_image_response", context).html('<p style="font-size:12px" class="error-color">'+
(error_json.error.message || tr("Cannot contact server: is it running and reachable?"))+
'</p>');
$("input", template_context).removeAttr("disabled");
$("input", context).removeAttr("disabled");
$("button", $marketplace_import_dialog).removeAttr("disabled");
}
});
}
});
try_to_create_template();
return false;
})
},
error: onError
},
"Marketplace.show" : {
type: "single",
call: OpenNebula.Marketplace.show,
callback: function(request, response) {
// updateMarketElement(request, response);
if (Sunstone.rightInfoVisible($("#marketplace-tab"))) {
updateMarketInfo(request, response);
}
},
error: onError
}
}
var market_buttons = {
"Marketplace.refresh" : {
type: "action",
layout: "refresh",
text: '<i class="fa fa-refresh fa fa-lg">',
alwaysActive: true
},
"Marketplace.import" : {
type: "action",
layout: "main",
text: tr('Import')
}
};
var marketplace_import_dialog =
'<div id="market_import_dialog">'+
'<div class="row">'+
'<div class="large-12">'+
'<h3 class="subheader">'+tr("Import Appliance")+'</h3>'+
'</div>'+
'</div>'+
'<form id="market_import_form">'+
'<div id="market_import_dialog_content">'+
'</div>'+
'<div class="form_buttons">'+
'<button class="button radius right success" id="market_import_button" type="submit">'+tr("Import")+'</button>'+
'</div>'+
'</form>'+
'<a class="close-reveal-modal">&#215;</a>'+
'</div>';
var marketplace_tab = {
title: '<i class="fa fa-lg fa-fw fa-shopping-cart"></i>&emsp;' + tr("Marketplace"),
buttons: market_buttons,
search_input: '<input id="marketplace_search" type="search" placeholder="'+tr("Search")+'" />',
list_header: '<i class="fa fa-fw fa-shopping-cart"></i>&emsp;'+tr("OpenNebula Marketplace"),
info_header: '<i class="fa fa-fw fa-shopping-cart"></i>&emsp;'+tr("Appliance"),
subheader: '<span/> <small></small>&emsp;',
content: '<div class="row marketplace_error_message" hidden>\
<div class="small-6 columns small-centered text-center">\
<div class="alert-box alert radius">'+tr("Cannot connect to OpenNebula Marketplace")+'</div>\
</div>\
</div>',
table: '<table id="datatable_marketplace" class="datatable twelve">\
<thead>\
<tr>\
<th class="check"></th>\
<th>'+tr("ID")+'</th>\
<th>'+tr("Name")+'</th>\
<th>'+tr("Publisher")+'</th>\
<th>'+tr("Hypervisor")+'</th>\
<th>'+tr("Arch")+'</th>\
<th>'+tr("Format")+'</th>\
<th>'+tr("Tags")+'</th>\
</tr>\
</thead>\
<tbody id="tbodymarketplace">\
</tbody>\
</table>'
};
Sunstone.addMainTab('marketplace-tab', marketplace_tab);
Sunstone.addActions(market_actions);
/*
* INFO PANEL
*/
var marketplace_info_panel = {
"marketplace_info_tab" : {
title: tr("Appliance information"),
content:""
}
};
Sunstone.addInfoPanel("marketplace_info_panel", marketplace_info_panel);
function marketplaceElements(){
return getSelectedNodes(dataTable_marketplace);
}
function updateMarketInfo(request,app){
var url = app.links.download.href;
url = url.replace(/\/download$/, '');
$(".resource-info-header", $("#marketplace-tab")).html(app.name);
var files_table = '<table id="info_marketplace_table2" class="dataTable">\
<thead>\
<tr><th colspan="2">'+tr("Images")+'</th></tr>\
</thead>\
<tbody>';
if (app['files']) {
$.each(app['files'], function(index, value){
files_table += '<tr>\
<td class="value_td">'+value['name']+'</td>\
<td class="value_td">'+humanize_size(value['size'], true)+'</td>\
</tr>'
});
} else {
files_table += '<tr>\
<td colspan="2" class="value_td">'+tr("No Images defined")+'</td>\
</tr>'
}
files_table += '</tbody>\
</table>';
var info_tab = {
title : tr("Info"),
icon: "fa-info-circle",
content: '<div class="row">\
<div class="large-6 columns">\
<table id="info_marketplace_table" class="dataTable">\
<thead>\
<tr><th colspan="2">'+tr("Information")+'</th></tr>\
</thead>\
<tbody>\
<tr>\
<td class="key_td">' + tr("ID") + '</td>\
<td class="value_td">'+app['_id']["$oid"]+'</td>\
</tr>\
<tr>\
<td class="key_td">' + tr("Name") + '</td>\
<td class="value_td">'+app['name']+'</td>\
</tr>\
<tr>\
<td class="key_td">' + tr("URL") + '</td>\
<td class="value_td"><a href="'+url+'" target="_blank">'+tr("link")+'</a></td>\
</tr>\
<tr>\
<td class="key_td">' + tr("Publisher") + '</td>\
<td class="value_td">'+app['publisher']+'</td>\
</tr>\
<tr>\
<td class="key_td">' + tr("Downloads") + '</td>\
<td class="value_td">'+app['downloads']+'</td>'+
(app['status'] ? '<tr>\
<td class="key_td">' + tr("Status") + '</td>\
<td class="value_td">'+app['status']+'</td>\
</tr>' : '') +
(app['tags'] ? '<tr>\
<td class="key_td">' + tr("Tags") + '</td>\
<td class="value_td">'+app['tags'].join(' ')+'</td>\
</tr>' : '') +
(app['catalog'] ? '<tr>\
<td class="key_td">' + tr("Catalog") + '</td>\
<td class="value_td">'+app['catalog']+'</td>\
</tr>' : '') +
'<tr>\
<td class="key_td">' + tr("OS") + '</td>\
<td class="value_td">'+app['os-id']+' '+app['os-release']+'</td>\
</tr>\
<tr>\
<td class="key_td">' + tr("Arch") + '</td>\
<td class="value_td">'+app['os-arch']+'</td>\
</tr>' +
(app['files'] ? '<tr>\
<td class="key_td">' + tr("Size") + '</td>\
<td class="value_td">'+humanize_size(app['files'][0]['size'],true)+'</td>\
</tr>' : '') +
'<tr>\
<td class="key_td">' + tr("Hypervisor") + '</td>\
<td class="value_td">'+app['hypervisor']+'</td>\
</tr>\
<tr>\
<td class="key_td">' + tr("Format") + '</td>\
<td class="value_td">'+app['format']+'</td>\
</tr>' +
'</tbody>\
</table>\
</div>\
<div class="large-6 columns">'+
(app['short_description'] ? '<table class="dataTable">\
<thead>\
<tr><th colspan="2">'+tr("Short Description")+'</th></tr>\
</thead>\
<tbody>\
<tr>\
<td class="value_td">'+app['short_description'].replace(/\n/g, "<br />")+'</td>\
</tr>\
</tbody>\
</table>' : '') +
'<table id="info_marketplace_table2" class="dataTable">\
<thead>\
<tr><th colspan="2">'+tr("Description")+'</th></tr>\
</thead>\
<tbody>\
<tr>\
<td class="value_td">'+app['description'].replace(/\n/g, "<br />")+'</td>\
</tr>\
</tbody>\
</table>'+
files_table+
(app['opennebula_template'] ? '<table class="dataTable">\
<thead>\
<tr><th colspan="2">'+tr("OpenNebula Template")+'</th></tr>\
</thead>\
<tbody>\
<tr>\
<td class="value_td">'+app['opennebula_template'].replace(/\n/g, "<br />")+'</td>\
</tr>\
</tbody>\
</table>' : '') +
'</div>\
</div>'
};
Sunstone.updateInfoPanelTab("marketplace_info_panel", "marketplace_info_tab", info_tab);
Sunstone.popUpInfoPanel("marketplace_info_panel", "marketplace-tab");
};
function infoListenerMarket(dataTable){
$('tbody tr',dataTable).live("click",function(e){
if ($(e.target).is('input') ||
$(e.target).is('select') ||
$(e.target).is('option')) return true;
var aData = dataTable.fnGetData(this);
var id =aData["_id"]["$oid"];
if (!id) return true;
if (e.ctrlKey || e.metaKey || $(e.target).is('input')) {
$('.check_item',this).trigger('click');
} else {
var context = $(this).parents(".tab");
popDialogLoading($("#marketplace-tab"));
Sunstone.runAction("Marketplace.show",id);
$(".resource-id", context).html(id);
$('.top_button, .list_button', context).attr('disabled', false);
}
return false;
});
}
/*
* Document
*/
$(document).ready(function(){
var tab_name = 'marketplace-tab';
if (Config.isTabEnabled(tab_name)) {
dataTable_marketplace = $("#datatable_marketplace", main_tabs_context).dataTable({
"bSortClasses" : false,
"bDeferRender": true,
"aoColumns": [
{ "bSortable": false,
"mData": function ( o, val, data ) {
//we render 1st column as a checkbox directly
return '<input class="check_item" type="checkbox" id="marketplace_'+
o['_id']['$oid']+
'" name="selected_items" value="'+
o['_id']['$oid']+'"/>'
},
"sWidth" : "60px"
},
{ "mDataProp": "_id.$oid", "sWidth" : "200px" },
{ "mDataProp": "name" },
{ "mDataProp": "publisher" },
{ "mDataProp": "files.0.hypervisor", "sWidth" : "100px", "sDefaultContent" : "-" },
{ "mDataProp": "files.0.os-arch", "sWidth" : "100px", "sDefaultContent" : "-" },
{ "mDataProp": "files.0.format", "sWidth" : "100px", "sDefaultContent" : "-" },
{ "mDataProp": "tags"}
],
"aoColumnDefs": [
{ "bVisible": true, "aTargets": Config.tabTableColumns(tab_name)},
{ "bVisible": false, "aTargets": ['_all']}
]
});
$('#marketplace_search').keyup(function(){
dataTable_marketplace.fnFilter( $(this).val() );
})
dataTable_marketplace.on('draw', function(){
recountCheckboxes(dataTable_marketplace);
})
tableCheckboxesListener(dataTable_marketplace);
onlyOneCheckboxListener(dataTable_marketplace);
infoListenerMarket(dataTable_marketplace);
Sunstone.runAction('Marketplace.list');
}
});
@@ -1,23 +0,0 @@
// ------------------------------------------------------------------------ //
// Copyright 2010-2015, C12G Labs S.L. //
// //
// Licensed under the Apache License, Version 2.0 (the "License"); you may //
// not use this file except in compliance with the License. You may obtain //
// a copy of the License at //
// //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
// Unless required by applicable law or agreed to in writing, software //
// distributed under the License is distributed on an "AS IS" BASIS, //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and //
// limitations under the License. //
//------------------------------------------------------------------------- //
var oneflow_dashboard_tab = {
title: '<i class="fa fa-lg fa-fw fa-cubes"></i>&emsp;OneFlow',
no_content: true
}
Sunstone.addMainTab('oneflow-dashboard',oneflow_dashboard_tab);
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -1,1000 +0,0 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
/* ---------------- SecurityGroup tab plugin ---------------- */
//Prepares the dialog to create
function initialize_create_security_group_dialog(dialog){
setupTips(dialog);
dialog.on("change", '.security_group_rule_protocol', function(){
$('.range_row', dialog).hide();
$('.range_row input', dialog).removeAttr('required');
$('.icmp_type_wrapper', dialog).hide();
switch ($(this).val()) {
case "TCP":
case "UDP":
$('.range_row', dialog).show();
$(".range_row select", dialog).trigger("change");
break;
case "ICMP":
$('.icmp_type_wrapper', dialog).show();
break;
case "IPSEC":
case "ALL":
break;
}
});
dialog.on("change", '.security_group_rule_network_sel', function(){
$('.security_group_rule_network',dialog).hide();
$('div.security_group_rule_network input',dialog).removeAttr('required');
$("input#selected_resource_id_"+"new_sg_rule", dialog).removeAttr("required");
$('.vnet_select',dialog).hide();
switch ($(this).val()) {
case "ANY":
break;
case "NETWORK":
$('.security_group_rule_network',dialog).show();
$('div.security_group_rule_network input',dialog).attr('required', '');
break;
case "VNET":
$('.vnet_select',dialog).show();
$("input#selected_resource_id_"+"new_sg_rule", dialog).attr("required", "");
refreshVNetTableSelect(dialog, "new_sg_rule");
break;
};
});
dialog.on("change", '.security_group_rule_range_sel', function(){
switch ($(this).val()) {
case "ALL":
$('.security_group_rule_range', dialog).hide();
$(".security_group_rule_range input", dialog).removeAttr('required');
break;
case "RANGE":
$('.security_group_rule_range', dialog).show();
$(".security_group_rule_range input", dialog).attr('required', '');
break;
};
});
$('#rules_form_wizard',dialog).on('invalid', function () {
// notifyError(tr("One or more required fields are missing or malformed."));
}).on('valid', function() {
var rule = {};
rule["PROTOCOL"] = $(".security_group_rule_protocol", dialog).val();
rule["RULE_TYPE"] = $(".security_group_rule_type", dialog).val();
switch ($('.security_group_rule_range_sel', dialog).val()) {
case "ALL":
break;
case "RANGE":
rule["RANGE"] = $(".security_group_rule_range input", dialog).val();
break;
}
switch ($('.security_group_rule_network_sel', dialog).val()) {
case "ANY":
break;
case "NETWORK":
rule["IP"] = $('#security_group_rule_first_ip', dialog).val();
rule["SIZE"] = $('#security_group_rule_size', dialog).val();
break;
case "VNET":
rule["NETWORK_ID"] = retrieveVNetTableSelect(dialog, "new_sg_rule");
break;
}
if (rule["PROTOCOL"] == "ICMP" ){
var icmp_type_val = $(".security_group_rule_icmp_type", dialog).val();
if (icmp_type_val != ""){
rule["ICMP_TYPE"] = icmp_type_val;
}
}
var text = sg_rule_to_st(rule);
$(".security_group_rules tbody", dialog).append(
'<tr>\
<td>'+text.PROTOCOL+'</td>\
<td>'+text.RULE_TYPE+'</td>\
<td>'+text.RANGE+'</td>\
<td>'+text.NETWORK+'</td>\
<td>'+text.ICMP_TYPE+'</td>\
<td>\
<a href="#"><i class="fa fa-times-circle remove-tab"></i></a>\
</td>\
</tr>');
// Add data to tr element
$(".security_group_rules tbody", dialog).children("tr").last().data("rule", rule);
// Reset new rule fields
$('#new_rule_wizard select option', dialog).prop('selected', function() {
return this.defaultSelected;
});
$('#new_rule_wizard select', dialog).trigger("change");
$('#new_rule_wizard input', dialog).val("");
resetResourceTableSelect(dialog, "new_sg_rule");
});
dialog.on("click", ".security_group_rules i.remove-tab", function(){
var tr = $(this).closest('tr');
tr.remove();
});
setupVNetTableSelect(dialog, "new_sg_rule");
dialog.foundation();
$('#new_rule_wizard select', dialog).trigger("change");
$('#create_security_group_form_wizard',dialog).on('invalid', function () {
notifyError(tr("One or more required fields are missing or malformed."));
popFormDialog("create_security_group_form", $("#secgroups-tab"));
}).on('valid', function() {
security_group_json = generate_json_security_group_from_form(this);
if ($('#create_security_group_form_wizard',dialog).attr("action") == "create") {
var security_group_json = {
"security_group" : security_group_json
};
Sunstone.runAction("SecurityGroup.create",security_group_json);
return false;
} else if ($('#create_security_group_form_wizard',dialog).attr("action") == "update") {
delete security_group_json["NAME"];
Sunstone.runAction(
"SecurityGroup.update",
sg_to_update_id,
convert_template_to_string(security_group_json));
return false;
}
});
$('#create_security_group_form_advanced',dialog).on('invalid.fndtn.abide', function(e) {
// Fix for valid event firing twice
if(e.namespace != 'abide.fndtn') {
return;
}
notifyError(tr("One or more required fields are missing or malformed."));
popFormDialog("create_security_group_form", $("#secgroups-tab"));
}).on('valid.fndtn.abide', function(e) {
// Fix for valid event firing twice
if(e.namespace != 'abide.fndtn') {
return;
}
if ($('#create_security_group_form_advanced',dialog).attr("action") == "create") {
var template = $('textarea#template',dialog).val();
var security_group_json = {security_group: {security_group_raw: template}};
Sunstone.runAction("SecurityGroup.create",security_group_json);
return false;
} else if ($('#create_security_group_form_advanced',dialog).attr("action") == "update") {
var template_raw = $('textarea#template',dialog).val();
Sunstone.runAction("SecurityGroup.update",sg_to_update_id,template_raw);
return false;
}
});
}
function generate_json_security_group_from_form(dialog) {
var name = $('#security_group_name', dialog).val();
var description = $('#security_group_description', dialog).val();
var rules = [];
$(".security_group_rules tbody tr").each(function(){
rules.push($(this).data("rule"));
});
var security_group_json = {
"NAME" : name,
"DESCRIPTION": description,
"RULE" : rules
};
return security_group_json;
}
function fillSecurityGroupUpdateFormPanel(sg, dialog){
// Populates the Avanced mode Tab
$('#template',dialog).val(convert_template_to_string(sg.TEMPLATE).replace(/^[\r\n]+$/g, ""));
$('#security_group_name',dialog).val(
escapeDoubleQuotes(htmlDecode( sg.NAME ))).
prop("disabled", true);
$('#security_group_description', dialog).val(
escapeDoubleQuotes(htmlDecode( sg.TEMPLATE.DESCRIPTION ))
);
var rules = sg.TEMPLATE.RULE;
if (!rules) //empty
{
rules = [];
}
else if (rules.constructor != Array) //>1 rule
{
rules = [rules];
}
$.each(rules, function(){
var text = sg_rule_to_st(this);
$(".security_group_rules tbody", dialog).append(
'<tr>\
<td>'+text.PROTOCOL+'</td>\
<td>'+text.RULE_TYPE+'</td>\
<td>'+text.RANGE+'</td>\
<td>'+text.NETWORK+'</td>\
<td>'+text.ICMP_TYPE+'</td>\
<td>\
<a href="#"><i class="fa fa-times-circle remove-tab"></i></a>\
</td>\
</tr>');
$(".security_group_rules tbody", dialog).children("tr").last().data("rule", this);
});
}
// Security Group clone dialog
function setupSecurityGroupCloneDialog(){
//Append to DOM
dialogs_context.append('<div id="security_group_clone_dialog""></div>');
var dialog = $('#security_group_clone_dialog',dialogs_context);
//Put HTML in place
var html = '<div class="row">\
<h3 class="subheader">'+tr("Clone Security Group")+'</h3>\
</div>\
<form>\
<div class="row">\
<div class="large-12 columns">\
<div class="clone_one"></div>\
<div class="clone_several">'+tr("Several security groups are selected, please choose a prefix to name the new copies")+'<br></div>\
</div>\
</div>\
<div class="row">\
<div class="large-12 columns">\
<label class="clone_one">'+tr("Name")+'</label>\
<label class="clone_several">'+tr("Prefix")+'</label>\
<input type="text" name="name"></input>\
</div>\
</div>\
<div class="form_buttons row">\
<button class="button radius right" id="security_group_clone_button" value="SecurityGroup.clone">\
'+tr("Clone")+'\
</button>\
</div>\
<a class="close-reveal-modal">&#215;</a>\
</form>\
';
dialog.html(html);
dialog.addClass("reveal-modal").attr("data-reveal", "");
$('form',dialog).submit(function(){
var name = $('input', this).val();
var sel_elems = securityGroupElements();
if (!name || !sel_elems.length)
notifyError('A name or prefix is needed!');
if (sel_elems.length > 1){
for (var i=0; i< sel_elems.length; i++)
//use name as prefix if several items selected
Sunstone.runAction('SecurityGroup.clone',
sel_elems[i],
name+getSecurityGroupName(sel_elems[i]));
} else {
Sunstone.runAction('SecurityGroup.clone',sel_elems[0],name)
};
$(this).parents('#security_group_clone_dialog').foundation('reveal', 'close')
setTimeout(function(){
Sunstone.runAction('SecurityGroup.refresh');
}, 1500);
return false;
});
}
function popUpSecurityGroupCloneDialog(){
var dialog = $('#security_group_clone_dialog');
var sel_elems = securityGroupElements();
//show different text depending on how many elements are selected
if (sel_elems.length > 1){
$('.clone_one',dialog).hide();
$('.clone_several',dialog).show();
$('input',dialog).val('Copy of ');
}
else {
$('.clone_one',dialog).show();
$('.clone_several',dialog).hide();
$('input',dialog).val('Copy of '+getSecurityGroupName(sel_elems[0]));
};
$(dialog).foundation().foundation('reveal', 'open');
$("input[name='name']",dialog).focus();
}
var create_security_group_wizard_html =
'<div id="create_security_group_form_wrapper">\
<form data-abide="ajax" id="create_security_group_form_wizard" action="">\
<div class="row">\
<div class="medium-4 columns">\
<label for="security_group_name">'+tr("Security Group Name")+':</label>\
<input required type="text" name="security_group_name" id="security_group_name"/>\
</div>\
<div class="medium-8 columns">\
<label for="security_group_description">'+tr("Description")+'\
<span class="tip">'+tr("Description for the Security Group")+'</span>\
</label>\
<textarea type="text" id="security_group_description" name="security_group_description" style="height: 70px;"/>\
</div>\
</div>\
<hr/>\
</form>\
<form data-abide="ajax" id="rules_form_wizard" action="">\
<div class="row collapse" id="new_rule_wizard">\
<div class="row">\
<div class="medium-4 columns">\
<label>'+tr("Type")+'\
<span class="tip">'+tr("Defines the direction of the rule.")+'</span>\
</label>\
<select class="security_group_rule_type">\
<option value="inbound" selected="selected">'+tr("Inbound")+'</option>\
<option value="outbound">'+tr("Outbound")+'</option>\
</select>\
</div>\
<div class="medium-4 columns">\
<label>'+tr("Protocol")+'\
<span class="tip">'+tr("Defines the protocol of the rule.")+'</span>\
</label>\
<select class="security_group_rule_protocol">\
<option value="TCP" selected="selected">'+tr("TCP")+'</option>\
<option value="UDP">'+tr("UDP")+'</option>\
<option value="ICMP">'+tr("ICMP")+'</option>\
<option value="IPSEC">'+tr("IPsec")+'</option>\
<option value="ALL">'+tr("All")+'</option>\
</select>\
</div>\
<div class="medium-4 columns icmp_type_wrapper">\
<label>'+tr("ICMP Type")+'\
<span class="tip">'+tr("Specific ICMP type of the rule. If a type has multiple codes, it includes all the codes within.")+'</span>\
</label>\
<select class="security_group_rule_icmp_type">\
<option value="" selected="selected">'+tr("All")+'</option>\
<option value = "0">'+"0/0: Echo Reply (pong)"+'</option>\
<option value = "3">'+"3: Destination Unreachable"+'</option>\
<option value = "4">'+"4/0: Source Quench"+'</option>\
<option value = "5">'+"5: Redirect"+'</option>\
<option value = "8">'+"8/0: Echo Request (ping)"+'</option>\
<option value = "9">'+"9/0: Router Advertisement"+'</option>\
<option value = "10">'+"10/0: Router Solicitation"+'</option>\
<option value = "11">'+"11: Time Exceeded"+'</option>\
<option value = "12">'+"12: Parameter Problem"+'</option>\
<option value = "13">'+"13/0: Timestamp Request"+'</option>\
<option value = "14">'+"14/0: Timestamp Reply"+'</option>\
<option value = "17">'+"17/0: Address Mask Request"+'</option>\
<option value = "18">'+"18/0: Address Mask Reply"+'</option>\
</select>\
</div>\
</div>\
<div class="row range_row">\
<div class="medium-4 columns">\
<label>'+tr("Port range")+'\
<span class="tip">'+tr("Selects whether to apply this TCP or UDP rule to all the ports or just a specific set.")+'</span>\
</label>\
<select class="security_group_rule_range_sel">\
<option value="ALL" selected="selected">'+tr("All")+'</option>\
<option value="RANGE">'+tr("Port range")+'</option>\
</select>\
</div>\
<div class="medium-4 columns end security_group_rule_range">\
<label>'+tr("Iptables range")+'\
<span class="tip">'+tr("A Port Range to filter specific ports. Uses the iptables port syntax: port[,port|,port:port]...")+'</span>\
</label>\
<input type="text" placeholder="22,53,80:90,110,1024:65535"/>\
</div>\
</div>\
<div class="row">\
<div class="medium-4 columns">\
<label>'+tr("Network")+'\
<span class="tip">'+tr("Any: apply this rule to any connection regardless of its source or destination. Network: Apply this rule only to a custom defined network range. Virtual Network: Apply this rule only to connections with origin or destination in one of the already defined VNETs.")+'</span>\
</label>\
<select class="security_group_rule_network_sel">\
<option value="ANY" selected="selected">'+tr("Any")+'</option>\
<option value="NETWORK">'+tr("Network")+'</option>\
<option value="VNET">'+tr("Virtual Network")+'</option>\
</select>\
</div>\
<div class="medium-4 columns security_group_rule_network">\
<label for="security_group_rule_first_ip">'+tr("IP Start")+':\
<span class="tip">'+tr("First IP address")+'</span>\
</label>\
<input id="security_group_rule_first_ip" type="text" placeholder="192.168.10.1"/>\
</div>\
<div class="medium-4 columns security_group_rule_network">\
<label for="security_group_rule_size">'+tr("Size")+':\
<span class="tip">'+tr("Number of addresses in the range")+'</span>\
</label>\
<input id="security_group_rule_size" type="text" placeholder="254"/>\
</div>\
</div>\
<div class="row">\
<div class="small-12 columns vnet_select">\
'+generateVNetTableSelect("new_sg_rule")+'\
</br>\
</div>\
</div>\
</div>\
<div class="row">\
<div class="medium-8 small-centered columns">\
<button type="submit" class="add_security_group_rule button small small-12 radius"><i class="fa fa-angle-double-down"></i> '+tr("Add Rule")+'</button>\
</div>\
</div>\
<div class="row">\
<div class="large-12 columns">\
<table class="security_group_rules policies_table dataTable">\
<thead>\
<tr>\
<th>'+tr("Protocol")+'</th>\
<th>'+tr("Type")+'</th>\
<th>'+tr("Port Range")+'</th>\
<th>'+tr("Network")+'</th>\
<th>'+tr("ICMP Type")+'</th>\
<th style="width:3%"></th>\
</tr>\
</thead>\
<tbody>\
</tbody>\
</table>\
</div>\
</div>\
</form>\
</div>';
var create_security_group_advanced_html =
'<form data-abide="ajax" id="create_security_group_form_advanced" class="custom creation">' +
'<div class="row">' +
'<div class="large-12 columns">' +
'<p>'+tr("Write the Security Group template here")+'</p>' +
'</div>' +
'</div>' +
'<div class="row">' +
'<div class="large-12 columns">' +
'<textarea id="template" rows="15" required></textarea>' +
'</div>' +
'</div>' +
'</form>';
var dataTable_security_groups;
var $create_security_group_dialog;
//Setup actions
var security_group_actions = {
"SecurityGroup.create" : {
type: "create",
call: OpenNebula.SecurityGroup.create,
callback: function(request, response){
$("a[href=back]", $("#secgroups-tab")).trigger("click");
popFormDialog("create_security_group_form", $("#secgroups-tab"));
addSecurityGroupElement(request, response);
notifyCustom(tr("Security Group created"), " ID: " + response.SECURITY_GROUP.ID, false);
},
error: function(request, response){
popFormDialog("create_security_group_form", $("#secgroups-tab"));
onError(request, response);
}
},
"SecurityGroup.create_dialog" : {
type: "custom",
call: function(){
Sunstone.popUpFormPanel("create_security_group_form", "secgroups-tab", "create", true);
}
},
"SecurityGroup.list" : {
type: "list",
call: OpenNebula.SecurityGroup.list,
callback: updateSecurityGroupsView,
error: onError
},
"SecurityGroup.show" : {
type: "single",
call: OpenNebula.SecurityGroup.show,
callback: function(request, response){
var tab = dataTable_security_groups.parents(".tab");
if (Sunstone.rightInfoVisible(tab)) {
// individual view
updateSecurityGroupInfo(request, response);
}
// datatable row
updateSecurityGroupElement(request, response);
},
error: onError
},
"SecurityGroup.refresh" : {
type: "custom",
call: function(){
var tab = dataTable_security_groups.parents(".tab");
if (Sunstone.rightInfoVisible(tab)) {
Sunstone.runAction("SecurityGroup.show", Sunstone.rightInfoResourceId(tab))
} else {
waitingNodes(dataTable_security_groups);
Sunstone.runAction("SecurityGroup.list", {force: true});
}
},
error: onError
},
"SecurityGroup.delete" : {
type: "multiple",
call : OpenNebula.SecurityGroup.del,
callback : deleteSecurityGroupElement,
elements: securityGroupElements,
error : onError,
notify:true
},
"SecurityGroup.update_dialog" : {
type: "custom",
call: function(){
var selected_nodes = securityGroupElements();
if ( selected_nodes.length != 1 ) {
notifyMessage("Please select one (and just one) Security Group to update.");
return false;
}
var resource_id = ""+selected_nodes[0];
Sunstone.runAction("SecurityGroup.show_to_update", resource_id);
}
},
"SecurityGroup.show_to_update" : {
type: "single",
call: OpenNebula.SecurityGroup.show,
callback: function(request, response) {
// TODO: global var, better use jquery .data
sg_to_update_id = response.SECURITY_GROUP.ID;
Sunstone.popUpFormPanel("create_security_group_form", "secgroups-tab", "create", true);
Sunstone.popUpFormPanel("create_security_group_form", "secgroups-tab", "update", true, function(context){
fillSecurityGroupUpdateFormPanel(response.SECURITY_GROUP, context);
});
},
error: onError
},
"SecurityGroup.update" : {
type: "single",
call: OpenNebula.SecurityGroup.update,
callback: function(request, response){
$("a[href=back]", $("#secgroups-tab")).trigger("click");
popFormDialog("create_security_group_form", $("#secgroups-tab"));
notifyMessage(tr("Security Group updated correctly"));
},
error: function(request, response){
popFormDialog("create_security_group_form", $("#secgroups-tab"));
onError(request, response);
}
},
"SecurityGroup.update_template" : { // Update template
type: "single",
call: OpenNebula.SecurityGroup.update,
callback: function(request,response){
Sunstone.runAction('SecurityGroup.show',request.request.data[0][0]);
},
error: onError
},
"SecurityGroup.chown" : {
type: "multiple",
call: OpenNebula.SecurityGroup.chown,
callback: function(req) {
Sunstone.runAction("SecurityGroup.show",req.request.data[0]);
},
elements: securityGroupElements,
error:onError
},
"SecurityGroup.chgrp" : {
type: "multiple",
call: OpenNebula.SecurityGroup.chgrp,
callback: function(req) {
Sunstone.runAction("SecurityGroup.show",req.request.data[0]);
},
elements: securityGroupElements,
error:onError
},
"SecurityGroup.chmod" : {
type: "single",
call: OpenNebula.SecurityGroup.chmod,
callback: function(req) {
Sunstone.runAction("SecurityGroup.show",req.request.data[0][0]);
},
error: onError
},
"SecurityGroup.clone_dialog" : {
type: "custom",
call: popUpSecurityGroupCloneDialog
},
"SecurityGroup.clone" : {
type: "single",
call: OpenNebula.SecurityGroup.clone,
error: onError,
notify: true
},
"SecurityGroup.rename" : {
type: "single",
call: OpenNebula.SecurityGroup.rename,
callback: function(request) {
notifyMessage(tr("Security Group renamed correctly"));
Sunstone.runAction('SecurityGroup.show',request.request.data[0][0]);
},
error: onError,
notify: true
}
};
var security_group_buttons = {
"SecurityGroup.refresh" : {
type: "action",
layout: "refresh",
alwaysActive: true
},
"SecurityGroup.create_dialog" : {
type: "create_dialog",
layout: "create"
},
"SecurityGroup.update_dialog" : {
type: "action",
layout: "main",
text: tr("Update")
},
"SecurityGroup.chown" : {
type: "confirm_with_select",
text: tr("Change owner"),
layout: "user_select",
select: "User",
tip: tr("Select the new owner")+":",
condition: mustBeAdmin
},
"SecurityGroup.chgrp" : {
type: "confirm_with_select",
text: tr("Change group"),
layout: "user_select",
select: "Group",
tip: tr("Select the new group")+":",
condition: mustBeAdmin
},
"SecurityGroup.clone_dialog" : {
type: "action",
layout: "main",
text: tr("Clone")
},
"SecurityGroup.delete" : {
type: "confirm",
layout: "del",
text: tr("Delete")
}
};
var security_groups_tab = {
title: tr("Security Groups"),
resource: 'SecurityGroup',
buttons: security_group_buttons,
tabClass: "subTab",
parentTab: "infra-tab",
search_input: '<input id="security_group_search" type="search" placeholder="'+tr("Search")+'" />',
list_header: '<i class="fa fa-fw fa-shield"></i>&emsp;'+tr("Security Groups"),
info_header: '<i class="fa fa-fw fa-shield"></i>&emsp;'+tr("Security Group"),
subheader: '<span/> <small></small>&emsp;',
table: '<table id="datatable_security_groups" class="datatable twelve">\
<thead>\
<tr>\
<th class="check"><input type="checkbox" class="check_all" value=""></input></th>\
<th>' + tr("ID") + '</th>\
<th>' + tr("Owner")+ '</th>\
<th>' + tr("Group")+ '</th>\
<th>' + tr("Name") + '</th>\
</tr>\
</thead>\
<tbody id="tbodysecurity_groups">\
</tbody>\
</table>',
forms: {
"create_security_group_form": {
actions: {
create: {
title: tr("Create Security Group"),
submit_text: tr("Create")
},
update: {
title: tr("Update Security Group"),
submit_text: tr("Update"),
reset_button: false
}
},
wizard_html: create_security_group_wizard_html,
advanced_html: create_security_group_advanced_html,
setup: initialize_create_security_group_dialog
}
}
};
var security_group_info_panel = {
"security_group_info_tab" : {
title: tr("Security Group information"),
content:""
}
};
Sunstone.addActions(security_group_actions);
Sunstone.addMainTab('secgroups-tab',security_groups_tab);
Sunstone.addInfoPanel("security_group_info_panel",security_group_info_panel);
//return lists of selected elements in security_group list
function securityGroupElements(){
return getSelectedNodes(dataTable_security_groups);
}
function securityGroupElementArray(element_json){
var element = element_json.SECURITY_GROUP;
return [
'<input class="check_item" type="checkbox" id="security_group_'+element.ID+'" name="selected_items" value="'+element.ID+'"/>',
element.ID,
element.UNAME,
element.GNAME,
element.NAME
];
}
//callback for an action affecting a security_group element
function updateSecurityGroupElement(request, element_json){
var id = element_json.SECURITY_GROUP.ID;
var element = securityGroupElementArray(element_json);
updateSingleElement(element,dataTable_security_groups,'#security_group_'+id);
}
//callback for actions deleting a security_group element
function deleteSecurityGroupElement(req){
deleteElement(dataTable_security_groups,'#security_group_'+req.request.data);
$('div#security_group_tab_'+req.request.data,main_tabs_context).remove();
}
//call back for actions creating a security_group element
function addSecurityGroupElement(request,element_json){
var id = element_json.SECURITY_GROUP.ID;
var element = securityGroupElementArray(element_json);
addElement(element,dataTable_security_groups);
}
//callback to update the list of security_groups.
function updateSecurityGroupsView (request,list){
var list_array = [];
$.each(list,function(){
//Grab table data from the list
list_array.push(securityGroupElementArray(this));
});
updateView(list_array,dataTable_security_groups);
};
// Updates the security_group info panel tab content and pops it up
function updateSecurityGroupInfo(request,security_group){
security_group_info = security_group.SECURITY_GROUP;
security_group_template = security_group_info.TEMPLATE;
$(".resource-info-header", $("#secgroups-tab")).html(security_group_info.NAME);
stripped_security_group_template = $.extend({}, security_group_info.TEMPLATE);
delete stripped_security_group_template["RULE"];
var hidden_values = {RULE: security_group_info.TEMPLATE.RULE};
//Information tab
var info_tab = {
title : tr("Info"),
icon: "fa-info-circle",
content :
'<div class="row">\
<div class="large-6 columns">\
<table id="info_security_group_table" class="dataTable extended_table">\
<thead>\
<tr><th colspan="3">' + tr("Information") +'</th></tr>\
</thead>\
<tbody>\
<tr>\
<td class="key_td">' + tr("ID") + '</td>\
<td class="value_td" colspan="2">'+security_group_info.ID+'</td>\
</tr>'+
insert_rename_tr(
'secgroups-tab',
"SecurityGroup",
security_group_info.ID,
security_group_info.NAME)+
'</tbody>\
</table>\
</div>\
<div class="large-6 columns">' +
insert_permissions_table('secgroups-tab',
"SecurityGroup",
security_group_info.ID,
security_group_info.UNAME,
security_group_info.GNAME,
security_group_info.UID,
security_group_info.GID) +
'</div>\
</div>\
<div class="row">\
<div class="large-9 columns">\
<table class="dataTable extended_table">\
<thead>\
<tr>\
<th>'+tr("Rules")+'</th>\
</tr>\
</thead>\
</table>'
+ insert_sg_rules_table(security_group_info) +
'</div>\
<div class="row">\
<div class="large-9 columns">'
+ insert_extended_template_table(stripped_security_group_template,
"SecurityGroup",
security_group_info.ID,
tr("Attributes"),
hidden_values) +
'</div>\
</div>'
}
//Sunstone.updateInfoPanelTab(info_panel_name,tab_name, new tab object);
Sunstone.updateInfoPanelTab("security_group_info_panel","security_group_info_tab",info_tab);
Sunstone.popUpInfoPanel("security_group_info_panel", "secgroups-tab");
setPermissionsTable(security_group_info,'');
}
function insert_sg_rules_table(sg){
var html =
'<table class="policies_table dataTable">\
<thead>\
<tr>\
<th>'+tr("Protocol")+'</th>\
<th>'+tr("Type")+'</th>\
<th>'+tr("Port Range")+'</th>\
<th>'+tr("Network")+'</th>\
<th>'+tr("ICMP Type")+'</th>\
</tr>\
</thead>\
<tbody>';
var rules = sg.TEMPLATE.RULE;
if (!rules) //empty
{
rules = [];
}
else if (rules.constructor != Array) //>1 rule
{
rules = [rules];
}
$.each(rules, function(){
var text = sg_rule_to_st(this);
html +=
'<tr>\
<td>'+text.PROTOCOL+'</td>\
<td>'+text.RULE_TYPE+'</td>\
<td>'+text.RANGE+'</td>\
<td>'+text.NETWORK+'</td>\
<td>'+text.ICMP_TYPE+'</td>\
</tr>'
});
html +=
'</tbody>\
</table>';
return html;
}
//This is executed after the sunstone.js ready() is run.
//Here we can basicly init the security_group datatable, preload it
//and add specific listeners
$(document).ready(function(){
var tab_name = "secgroups-tab"
if (Config.isTabEnabled(tab_name)) {
//prepare security_group datatable
dataTable_security_groups = $("#datatable_security_groups",main_tabs_context).dataTable({
"bSortClasses": false,
"bDeferRender": true,
"aoColumnDefs": [
{ "bSortable": false, "aTargets": ["check"] },
{ "sWidth": "35px", "aTargets": [0] },
{ "bVisible": true, "aTargets": Config.tabTableColumns(tab_name)},
{ "bVisible": false, "aTargets": ['_all']}
]
});
$('#security_group_search').keyup(function(){
dataTable_security_groups.fnFilter( $(this).val() );
})
dataTable_security_groups.on('draw', function(){
recountCheckboxes(dataTable_security_groups);
})
Sunstone.runAction("SecurityGroup.list");
setupSecurityGroupCloneDialog();
dialogs_context.append('<div id="create_security_group_dialog"></div>');
initCheckAllBoxes(dataTable_security_groups);
tableCheckboxesListener(dataTable_security_groups);
infoListener(dataTable_security_groups, "SecurityGroup.show");
dataTable_security_groups.fnSort( [ [1,config['user_config']['table_order']] ] );
}
});
@@ -1,727 +0,0 @@
// ------------------------------------------------------------------------ //
// Copyright 2010-2015, C12G Labs S.L. //
// //
// Licensed under the Apache License, Version 2.0 (the "License"); you may //
// not use this file except in compliance with the License. You may obtain //
// a copy of the License at //
// //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
// Unless required by applicable law or agreed to in writing, software //
// distributed under the License is distributed on an "AS IS" BASIS, //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and //
// limitations under the License. //
//------------------------------------------------------------------------- //
var support_interval_function;
var $upload_support_file;
var create_support_request_wizard_html =
'<form data-abide="ajax" id="create_support_request_form_wizard" class="custom creation">' +
'<div class="row">' +
'<div class="large-6 columns">' +
'<label for="subject">Subject</label>' +
'<input id="subject" type="text" required></input>' +
'</div>' +
'<div class="large-6 columns">' +
'<label for="opennebula_version">OpenNebula Version</label>' +
'<input id="opennebula_version" type="text" required></input>' +
'</div>' +
'</div>' +
'<div class="row">' +
'<div class="large-12 columns">' +
'<label for="description">Description</label>' +
'<textarea id="description" rows="5" placeholder="Please enter the details of your request. A member of our support staff will respond as soon as possible." required></textarea>' +
'</div>' +
'</div>' +
'<div class="row">' +
'<div class="large-12 columns">' +
'<label for="severity">Subject</label>' +
'<select id="severity" name="severity">'+
'<option value="severity_1">Severity 1. Product Error: Catastrophic problem in running production systems</option>'+
'<option value="severity_2">Severity 2. Product Error: High-impact problem in running production systems</option>'+
'<option value="severity_3">Severity 3. Product Error: Low impact problem on a running production system </option>'+
'<option value="severity_4" selected>Severity 4. Usage, Design, Configuration, or Integration Question</option>'+
'</select>'+
'</div>' +
'</div>' +
'</form>';
function show_support_connect() {
$(".support_info").hide();
$("#dataTable_support_wrapper").hide();
$(".support_connect").show();
$(".actions_row", "#support-tab").hide();
}
function show_support_list() {
$(".support_info").show();
$(".support_connect").hide();
$(".actions_row", "#support-tab").show();
$("#dataTable_support_wrapper").show();
}
var support_actions = {
"Support.list" : {
type: "list",
call: OpenNebula.Support.list,
callback: function(req, list, res){
show_support_list();
$(".support_open_value").text(res.open_requests);
$(".support_pending_value").text(res.pending_requests);
updateView(list, dataTable_support);
},
error: function(request, error_json) {
if (error_json.error.http_status=="401") {
clearInterval(support_interval_function);
}
show_support_connect();
}
},
"Support.refresh" : {
type: "custom",
call: function () {
var tab = dataTable_support.parents(".tab");
if (Sunstone.rightInfoVisible(tab)) {
Sunstone.runAction("Support.show", Sunstone.rightInfoResourceId(tab))
} else {
waitingNodes(dataTable_support);
Sunstone.runAction("Support.list");
}
},
error: function(request, error_json) {
show_support_connect();
}
},
"Support.show" : {
type: "single",
call: OpenNebula.Support.show,
callback: function(request, response) {
// updateMarketElement(request, response);
if (Sunstone.rightInfoVisible($("#support-tab"))) {
updateSupportInfo(request, response);
}
},
error: function(request, error_json) {
show_support_connect();
}
},
"Support.create" : {
type: "create",
call: OpenNebula.Support.create,
callback: function(request, response){
$("a[href=back]", $("#support-tab")).trigger("click");
popFormDialog("create_support_request_form", $("#support-tab"));
$("a.refresh", $("#support-tab")).trigger("click");
//addTemplateElement(request, response);
//notifyCustom(tr("Request created"), " ID: " + response.VMTEMPLATE.ID, false)
},
error: function(request, error_json){
popFormDialog("create_support_request_form", $("#support-tab"));
if (error_json.error.http_status=="403") {
notifyError(error_json.error.message);
} else {
$("a[href=back]", $("#support-tab")).trigger("click");
show_support_connect();
}
}
},
"Support.create_dialog" : {
type: "custom",
call: function(){
Sunstone.popUpFormPanel(
"create_support_request_form",
"support-tab",
"create",
false,
function(context){});
}
},
"Support.update" : {
type: "single",
call: OpenNebula.Support.update,
callback: function(request, response){
$("a.refresh", $("#support-tab")).trigger("click");
notifyMessage(tr("Comment added correctly"));
},
error: function(request, response){
popFormDialog("create_template_form", $("#templates-tab"));
show_support_connect();
}
},
"Support.signout" : {
type: "single",
call: function() {
$.ajax({
url: 'support/credentials',
type: "DELETE",
dataType: "json",
success: function(){
show_support_connect();
$("#support-tabrefresh_buttons > a").trigger("click");
},
error: function(response){
if (response.status=="401") {
notifyError("Support credentials are incorrect")
} else {
notifyError(response.responseText)
}
}
});
}
},
"Support.upload" : {
type: "single",
call: function() {
$upload_support_file.foundation("reveal", "open");
}
}
}
var support_buttons = {
"Support.refresh" : {
type: "action",
layout: "refresh",
text: '<i class="fa fa-refresh fa fa-lg">',
alwaysActive: true
},
"Support.upload" : {
type: "action",
layout: "main",
text: '<i class="fa fa-cloud-upload" style="color: rgb(111, 111, 111)"/> '+tr("Upload a file"),
custom_classes: "only-right-info"
},
"Support.signout" : {
type: "action",
layout: "main",
text: '<i class="fa fa-sign-out fa fa-lg">',
tip: "Sign out of Commercial Support",
alwaysActive: true
},
"Support.create_dialog" : {
type: "create_dialog",
layout: "create",
text: "Submit a Request"
}
};
var support_tab = {
//title: '<i class="fa fa-lg fa-fw fa-support"></i>&emsp;Support"),
title:
'<span class="support_title"><i class="fa fa-lg fa-fw fa-support"></i> Support</span>' +
'<br>'+
'<div class="support_info" style="display: none;">'+
'<span class="support_open">Open</span><span class="label secondary right support_open_value">-</span>'+
'<br>'+
'<span class="support_pending">Pending</span><span class="label right support_pending_value">-</span>'+
'<br>'+
'<button class="button tiny success radius support_button">Submit a Request</button>'+
'</div>'+
'<div class="support_connect" style="display: none;">'+
'<span class="">Not connected</span>'+
'<br>'+
'<button class="button tiny success radius support_connect_button">Sign in</button>'+
'</div>',
table: '<table id="dataTable_support" class="datatable twelve support_info">\
<thead>\
<tr>\
<th class="check"></th>\
<th>ID</th>\
<th>Subject</th>\
<th>Requested</th>\
<th>Status</th>\
</tr>\
</thead>\
<tbody id="tbodysupport">\
</tbody>\
</table>',
buttons: support_buttons,
search_input: '<input id="support_search" type="search" placeholder="Search" />',
list_header: '<i class="fa fa-fw fa-support"></i> Commercial Support Requests',
info_header: '<i class="fa fa-fw fa-support"></i> Commercial Support Request',
subheader: '<div class="row text-left support_connect">'+
'<div class="large-6 columns" style="font-">'+
'<p>The Support Subscription provides expert integration and production support on supported platforms and include:</p>'+
'<ul class="fa-ul" style="font-size: 14px;">'+
'<li><i class="fa-li fa fa-check"></i>Problem diagnosis, resolution and bug fixing</li>'+
'<li><i class="fa-li fa fa-check"></i>Solving unexpected problems when using, installing or configuring the software</li>'+
'<li><i class="fa-li fa fa-check"></i>Guidance about tuning for optimal and scalable performance in your environment</li>'+
'<li><i class="fa-li fa fa-check"></i>Answering “how to” questions related to standard and intended product usage</li>'+
'<li><i class="fa-li fa fa-check"></i>Offering hints about how to go around missing features</li>'+
'<li><i class="fa-li fa fa-check"></i>Answering questions about product adaptation and integration</li>'+
'</ul>'+
'<p>For more info on support subcriptions, <a href="http://opennebula.systems/support/" target="_blank">click here</a></p>' +
'</div>'+
'<div class="large-6 columns" style="padding: 0px 50px;">'+
'<fieldset>'+
'<legend>Commercial Support</legend>'+
'<form id="support_credentials_form">'+
'<div class="large-12 columns">'+
'<label for="support_email">Email</label>' +
'<input id="support_email" type="text"></input>' +
'</div>'+
'<div class="large-12 columns">'+
'<label for="support_password">Password</label>' +
'<input id="support_password" type="password"></input>' +
'</div>'+
'<div class="large-12 columns">'+
'<button class="button right radius success submit_support_credentials_button" type="submit">Sign in</button>' +
'</div>'+
'<div class="large-12 columns text-center">'+
'<p>or</p>' +
'</div>'+
'<div class="large-12 columns">'+
'<a href="http://opennebula.systems/buy/" target="_blank" class="button large-12 radius" style="color: #fff !important">Get an account</a>' +
'</div>'+
'</form>'+
'</fieldset>'+
'</div>'+
'</div>'+
'<div class="row">'+
'<div class="large-12 columns text-left">'+
'<h3 class="subheader"><i class="fa fa-fw fa-info-circle"></i> Additional Help Resources</h3>'+
'</div>'+
'</div>'+
'<br>'+
'<div class="row">'+
'<div class="large-6 columns">'+
'<a href="http://docs.opennebula.org/4.12/" target="_blank">'+
'<span class="fa-stack fa-2x" style="color: #cfcfcf;">'+
'<i class="fa fa-circle fa-stack-2x"></i>'+
'<i class="fa fa-book fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
"Documentation"+
'</a>'+
'</div>'+
'<div class="large-6 columns">'+
'<a href="http://opennebula.org/support/community/" target="_blank">'+
'<span class="fa-stack fa-2x" style="color: #cfcfcf;">'+
'<i class="fa fa-circle fa-stack-2x"></i>'+
'<i class="fa fa-comments fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
"Community"+
'</a>'+
'</div>'+
'</div>'+
'<br>'+
'<p class="text-center" style="font-size: 14px; color: #999;">This tab can be disabled in the sunstone views configuration files</p>',
forms: {
"create_support_request_form": {
actions: {
create: {
title: "Submit a Request",
submit_text: "Submit"
}
},
wizard_html: create_support_request_wizard_html,
setup: initialize_create_support_request_dialog
}
}
}
function setup_upload_support_file_dialog() {
dialogs_context.append('<div id="upload_support_file"></div>');
$upload_support_file = $('#upload_support_file',dialogs_context);
var dialog = $upload_support_file;
dialog.html('\
<div class="row">\
<div class="large-12 columns">\
<h3 class="subheader">'+tr("Upload File")+'</h3>\
</div>\
</div>\
<form id="upload_support_file_form">\
<div class="row">\
<div id="support_file-uploader" class="large-12 columns text-center">\
<input id="support_file-uploader-input" type="file"/>\
</div>\
</div>\
<div class="row">\
<div class="large-12 columns">\
<button class="button right radius success upload_support_file_form_button" type="submit" disabled>Upload</button>\
</div>\
</div>\
</form>\
<a class="close-reveal-modal">&#215;</a>\
');
dialog.addClass("reveal-modal").attr("data-reveal", "");
$vnc_dialog.foundation();
if (getInternetExplorerVersion() > -1) {
$(".upload_support_file_form_button").text("Uploading files through IE is not supported");
$(".upload_support_file_form_button").attr("disabled", "disabled");
} else {
var uploader = new Resumable({
target: 'upload_chunk',
chunkSize: 10*1024*1024,
maxFiles: 1,
testChunks: false,
query: {
csrftoken: csrftoken
}
});
uploader.assignBrowse($('#support_file-uploader-input'));
var fileName = '';
var file_input = false;
uploader.on('fileAdded', function(file){
$(".upload_support_file_form_button").removeAttr("disabled");
fileName = file.fileName;
file_input = fileName;
});
uploader.on('uploadStart', function() {
$(".upload_support_file_form_button").attr("disabled", "disabled");
$('.support_upload_progress_bars').append('<div id="'+fileName+'progressBar" class="row" style="margin-bottom:10px">\
<div id="'+fileName+'-info" class="large-2 columns dataTables_info">\
'+tr("Uploading...")+'\
</div>\
<div class="large-10 columns">\
<div id="upload_progress_container" class="progress nine radius" style="height:25px !important">\
<span class="meter" style="width:0%"></span>\
</div>\
<div class="progress-text" style="margin-left:15px">'+fileName+'</div>\
</div>\
</div>');
});
uploader.on('progress', function() {
$('span.meter', $('div[id="'+fileName+'progressBar"]')).css('width', uploader.progress()*100.0+'%')
});
uploader.on('fileSuccess', function(file) {
$('div[id="'+fileName+'-info"]').text(tr('Registering in OpenNebula'));
$.ajax({
url: 'support/request/' + $("#submit_support_comment").data("request_id") + '/upload',
type: "POST",
data: {
csrftoken: csrftoken,
file: fileName,
tempfile: file.uniqueIdentifier
},
success: function(){
notifyMessage("File uploaded correctly");
$('div[id="'+fileName+'progressBar"]').remove();
Sunstone.runAction("Support.refresh");
$upload_support_file.foundation('reveal', 'close');
},
error: function(response){
onError({}, OpenNebula.Error(response));
$('div[id="'+fileName+'progressBar"]').remove();
}
});
});
$("#upload_support_file_form").on("submit", function(){
uploader.upload();
$upload_support_file.foundation("reveal", "close")
return false;
})
}
}
function initialize_create_support_request_dialog() {
$('#create_support_request_form_wizard').foundation();
$('#create_support_request_form_wizard').on('invalid.fndtn.abide', function(e) {
// Fix for valid event firing twice
if(e.namespace != 'abide.fndtn') {
return;
}
notifyError(tr("One or more required fields are missing or malformed."));
popFormDialog("create_support_request_form", $("#support-tab"));
}).on('valid.fndtn.abide', function(e) {
// Fix for valid event firing twice
if(e.namespace != 'abide.fndtn') {
return;
}
var template = {
"subject" : $('#subject', this).val(),
"description" : $('#description', this).val(),
"opennebula_version" : $('#opennebula_version', this).val(),
"severity" : $('#severity', this).val(),
}
Sunstone.runAction("Support.create", template);
return false;
});
}
//var doc_tab = {
// title: tr("Documentation"),
// tabClass: 'subTab',
// parentTab: 'support-tab',
// no_content: true
//}
//
//var community_tab = {
// title: tr("Community"),
// tabClass: 'subTab',
// parentTab: 'support-tab',
// no_content: true
//}
//
//var enterprise_tab = {
// title: tr("Enterprise"),
// tabClass: 'subTab',
// parentTab: 'support-tab',
// no_content: true
//}
Sunstone.addActions(support_actions);
Sunstone.addMainTab('support-tab',support_tab);
var support_info_panel = {
"support_info_tab" : {
title: tr("Request Information"),
content:""
}
};
Sunstone.addInfoPanel("support_info_panel", support_info_panel);
//Sunstone.addMainTab('doc-tab',doc_tab);
//Sunstone.addMainTab('community-tab',community_tab);
//Sunstone.addMainTab('enterprise-tab',enterprise_tab);
//
//$(document).on("click", "#li_doc-tab a", function(){
// window.open("http://docs.opennebula.org/4.12/");
// return false;
//})
//
//$(document).on("click", "#li_community-tab a", function(){
// window.open("http://opennebula.org/support/community/");
// return false;
//})
//
//$(document).on("click", "#li_enterprise-tab a", function(){
// window.open("http://opennebula.systems/support/");
// return false;
//})
function updateSupportInfo(request, response){
var message;
if (response["REQUEST"]["status"] == "open") {
message = tr("This request is currently being processed by our staff")
} else if (response["REQUEST"]["status"] == "pending") {
message = tr("This request is awaiting your response")
}
var html = '<div class="row">\
<div class="large-6 columns">\
<h5>'+response["REQUEST"]['subject']+'</h5>\
<p class="subheader" style="font-size: 14px;">'+$("<div/>").html(response["REQUEST"]["html_description"]).text()+'</p>\
</div>\
<div class="large-6 columns">\
<table id="info_marketplace_table" class="dataTable">\
<thead>\
<tr><th colspan="2">Information</th></tr>\
</thead>\
<tbody>\
<tr>\
<td class="key_td">Requested</td>\
<td class="value_td">'+response["REQUEST"]['created_at']+'</td>\
</tr>\
<tr>\
<td class="key_td">Status</td>\
<td class="value_td">'+response["REQUEST"]['status']+'</td>\
</tr>\
<tr>\
<td colspan="2"><span class="large-12 label secondary radius">' + message + '</span></td>\
</tr>\
</tbody>\
</table>\
</div>\
</div><br>'
if (response["REQUEST"]["comments"]) {
$.each(response["REQUEST"]["comments"], function(index, comment){
html += generateAdvancedSection({
title: '<span style="width: 100%;">' + (comment["author_id"] == 21231023 ? "OpenNebula Support Team" : 'Me') + ' <span style="color: #999;"> - '+ comment["created_at"] + '</span></span>',
html_id: 'advanced_comment_' + response["REQUEST"]["id"] + index,
content: '<div class="row">\
<div class="large-12 columns comment" style="font-size: 14px !important;">'+$("<div/>").html(comment["html_body"]).text()+'</div>\
</div>'
});
})
}
html += '<div class="row">\
<div class="large-12 columns support_upload_progress_bars">\
</div>\
</div>';
html += '<form id="submit_support_comment">\
<div class="row">\
<div class="large-12 columns">\
<textarea class="comment" placeholder="Add a comment to this request" rows="4"></textarea>\
</div>\
</div>\
<div class="row">\
<div class="large-12 columns">\
<input id="solved" type="checkbox"><label for="solved">Please consider this request resolved</label>\
<button class="button right radius success" type="submit">Submit</button>\
</div>\
</div>\
</form>';
var info_tab = {
title : tr("Info"),
icon: "fa-info-circle",
content: html
};
Sunstone.updateInfoPanelTab("support_info_panel", "support_info_tab", info_tab);
Sunstone.popUpInfoPanel("support_info_panel", "support-tab");
$("#submit_support_comment").data("request_id", response["REQUEST"]["id"]);
$("#submit_support_comment").on("submit", function(){
var request_id = $(this).data("request_id");
var request_json = {
"comment" : {
"value" : $(".comment", this).val()
},
"solved" : $("#solved:checked", this).length > 0 ? true : false
}
Sunstone.runAction("Support.update", request_id, request_json);
return false;
})
$(".accordion_advanced > a", "#support_info_tab").trigger("click");
$("dl.right-info-tabs", "#support_info_panel").hide();
};
function infoListenerSupport(dataTable){
$('tbody tr',dataTable).live("click",function(e){
if ($(e.target).is('input') ||
$(e.target).is('select') ||
$(e.target).is('option')) return true;
var aData = dataTable.fnGetData(this);
var id =aData["REQUEST"]["id"];
if (!id) return true;
if (e.ctrlKey || e.metaKey || $(e.target).is('input')) {
$('.check_item',this).trigger('click');
} else {
var context = $(this).parents(".tab");
popDialogLoading($("#support-tab"));
Sunstone.runAction("Support.show",id);
$(".resource-id", context).html(id);
$('.top_button, .list_button', context).attr('disabled', false);
}
return false;
});
}
$(document).ready(function(){
var tab_name = 'support-tab';
if (Config.isTabEnabled(tab_name)) {
setup_upload_support_file_dialog();
dataTable_support = $("#dataTable_support", main_tabs_context).dataTable({
"bSortClasses" : false,
"bDeferRender": true,
"aoColumns": [
{ "bSortable": false,
"mData": function ( o, val, data ) {
//we render 1st column as a checkbox directly
return '<input class="check_item" type="checkbox" id="marketplace_'+
o['REQUEST']['id']+
'" name="selected_items" value="'+
o['REQUEST']['id']+'"/>'
}
},
{ "mDataProp": "REQUEST.id" },
{ "mDataProp": "REQUEST.subject" },
{ "mDataProp": "REQUEST.created_at" },
{ "mDataProp": "REQUEST.status"}
],
"aoColumnDefs": [
{ "bVisible": true, "aTargets": Config.tabTableColumns(tab_name)},
{ "bVisible": false, "aTargets": ['_all']}
]
});
$('#support_search').keyup(function(){
dataTable_support.fnFilter( $(this).val() );
})
tableCheckboxesListener(dataTable_support);
onlyOneCheckboxListener(dataTable_support);
infoListenerSupport(dataTable_support);
show_support_connect();
Sunstone.runAction('Support.list');
support_interval_function = setInterval(function(){
Sunstone.runAction('Support.list');
}, top_interval);
$(".support_button").on("click", function(){
$("#li_support-tab > a").trigger("click");
$(".create_dialog_button", "#support-tab").trigger("click");
return false;
})
$("#support_credentials_form").on("submit", function(){
$(".submit_support_credentials_button").attr("disabled", "disabled");
$(".submit_support_credentials_button").html('<i class="fa fa-spinner fa-spin"></i>');
var data = {
email : $("#support_email", this).val(),
password : $("#support_password", this).val()
}
$.ajax({
url: 'support/credentials',
type: "POST",
dataType: "json",
data: JSON.stringify(data),
success: function(){
$(".submit_support_credentials_button").removeAttr("disabled");
$(".submit_support_credentials_button").html('Sign in');
$("#support-tabrefresh_buttons > a").trigger("click");
support_interval_function = setInterval(function(){
Sunstone.runAction('Support.list');
}, top_interval);
show_support_list();
},
error: function(response){
if (response.status=="401") {
notifyError("Support credentials are incorrect")
} else {
notifyError(response.responseText)
}
$(".submit_support_credentials_button").removeAttr("disabled");
$(".submit_support_credentials_button").html('Sign in');
}
});
return false;
})
}
});
@@ -1,26 +0,0 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
var system_tab = {
title: '<i class="fa fa-lg fa-fw fa-cogs"></i>&emsp;'+tr("System"),
no_content: true
}
Sunstone.addMainTab('system-tab',system_tab);
$(document).ready(function(){
});
File diff suppressed because it is too large. Load diff
-905
View File
@@ -1,905 +0,0 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
/*Users tab plugin*/
var dataTable_users;
var $create_user_dialog;
var $user_quotas_dialog;
var $update_pw_dialog;
var $change_auth_dialog;
var user_acct_graphs = [
{ title : tr("CPU"),
monitor_resources : "CPU",
humanize_figures : false
},
{ title : tr("Memory"),
monitor_resources : "MEMORY",
humanize_figures : true
},
{ title : tr("Net TX"),
monitor_resources : "NETTX",
humanize_figures : true
},
{ title : tr("Net RX"),
monitor_resources : "NETRX",
humanize_figures : true
}
];
var auth_drivers_div =
'<select name="driver" id="driver">\
<option value="core" selected="selected">'+tr("Core")+'</option>\
<option value="ssh">'+tr("SSH")+'</option>\
<option value="x509">'+tr("x509")+'</option>\
<option value="ldap">'+tr("LDAP")+'</option>\
<option value="public">'+tr("Public")+'</option>\
<option value="custom">'+tr("Custom")+'</option>\
</select>\
<div>\
<input type="text" id="custom_auth" name="custom_auth" />\
</div>';
// Used also from groups-tabs.js
var user_creation_div =
'<div class="row">\
<div class="large-12 columns">\
<label for="username">'+tr("Username")+'</label>\
<input type="text" name="username" id="username" />\
</div>\
</div>\
<div class="row">\
<div class="large-12 columns">\
<label for="pass">'+tr("Password")+'</label>\
<input type="password" name="pass" id="pass" />\
</div>\
</div>\
<div class="row">\
<div class="large-12 columns">\
<label for="driver">'+tr("Authentication")+'</label>\
'+auth_drivers_div+'\
</div>\
</div>';
var create_user_tmpl =
'<div class="row">\
<div class="large-12 columns">\
<h3 class="subheader" id="create_user_header">'+tr("Create User")+'</h3>\
</div>\
</div>\
<form id="create_user_form" action="">'+
user_creation_div +
'<div class="form_buttons row">\
<button class="button radius right success" id="create_user_submit" value="user/create">'+tr("Create")+'</button>\
</div>\
<a class="close-reveal-modal">&#215;</a>\
</form>';
var update_pw_tmpl = '<div class="row">\
<div class="large-12 columns">\
<h3 id="create_vnet_header" class="subheader">'+tr("Update Password")+'</h3>\
</div>\
</div>\
<form id="update_user_pw_form" action="">\
<div class="row">\
<div class="large-12 columns">\
<label for="new_password">'+tr("New password")+':\
<input type="password" name="new_password" id="new_password" />\
</label>\
</div>\
</div>\
<div class="row">\
<div class="large-12 columns">\
<label for="confirm_password">'+tr("Confirm Password")+':\
<input type="password" name="confirm_password" id="confirm_password" />\
</label>\
</div>\
</div>\
<div class="form_buttons">\
<button class="button radius right success" id="update_pw_submit" type="submit" value="User.update">'+tr("Change")+'</button>\
</div>\
<a class="close-reveal-modal">&#215;</a>\
</form>';
var change_password_tmpl = '<div class="row">\
<div class="large-12 columns">\
<h3 id="change_password_header" class="subheader">'+tr("Change authentication")+'</h3>\
</div>\
</div>\
<form id="change_password_form" action="">\
<div class="row">\
<div class="large-12 columns">\
<label for="driver">'+tr("Authentication")+':\
'+auth_drivers_div+'\
</label>\
</div>\
</div>\
<div class="form_buttons">\
<button class="button radius right success" id="change_password_submit" type="submit" value="User.change_authentication">'+tr("Change")+'</button>\
</div>\
<a class="close-reveal-modal">&#215;</a>\
</form>';
function user_quotas_tmpl(){
return '<div class="row">\
<div class="large-12 columns">\
<h3 class="subheader">'+tr("Update Quota")+'</h3>\
</div>\
</div>\
<div class="reveal-body">\
<form id="user_quotas_form" action="">'+
quotas_tmpl() +
'<div class="reveal-footer">\
<div class="form_buttons">\
<button class="button radius right success" id="create_user_submit" \
type="submit" value="User.set_quota">'+tr("Apply changes")+'</button>\
</div>\
</div>\
<a class="close-reveal-modal">&#215;</a>\
</form>\
</div>';
}
var user_actions = {
"User.create" : {
type: "create",
call: OpenNebula.User.create,
callback: function(request, response) {
$create_user_dialog.foundation('reveal', 'close');
$create_user_dialog.empty();
setupCreateUserDialog();
addUserElement(request, response);
notifyCustom(tr("User created"), " ID: " + response.USER.ID, false);
},
error: onError
},
"User.create_dialog" : {
type: "custom",
call: popUpCreateUserDialog
},
"User.list" : {
type: "list",
call: OpenNebula.User.list,
callback: updateUsersView,
error: onError
},
"User.refresh" : {
type: "custom",
call: function () {
var tab = dataTable_users.parents(".tab");
if (Sunstone.rightInfoVisible(tab)) {
Sunstone.runAction("User.show", Sunstone.rightInfoResourceId(tab))
} else {
waitingNodes(dataTable_users);
Sunstone.runAction("User.list", {force: true});
}
}
},
"User.update_password" : {
type: "custom",
call: popUpUpdatePasswordDialog
},
"User.passwd" : {
type: "multiple",
call: OpenNebula.User.passwd,
elements: userElements,
error: onError
},
"User.chgrp" : {
type: "multiple",
call: OpenNebula.User.chgrp,
callback : function(req){
Sunstone.runAction("User.show",req.request.data[0][0]);
},
elements : userElements,
error: onError
},
"User.addgroup" : {
type: "multiple",
call: OpenNebula.User.addgroup,
callback : function(req){
Sunstone.runAction("User.show",req.request.data[0][0]);
},
elements : userElements,
error: onError
},
"User.delgroup" : {
type: "multiple",
call: OpenNebula.User.delgroup,
callback : function(req){
Sunstone.runAction("User.show",req.request.data[0][0]);
},
elements : userElements,
error: onError
},
"User.change_authentication" : {
type: "custom",
call: popUpChangeAuthenticationDialog
},
"User.chauth" : {
type: "multiple",
call: OpenNebula.User.chauth,
callback : function(req){
Sunstone.runAction("User.show",req.request.data[0][0]);
},
elements: userElements,
error: onError
},
"User.show" : {
type: "single",
call: OpenNebula.User.show,
callback: function(request, response) {
updateUserElement(request, response);
if (Sunstone.rightInfoVisible($("#users-tab"))) {
updateUserInfo(request, response);
}
},
error: onError
},
"User.delete" : {
type: "multiple",
call: OpenNebula.User.del,
callback: deleteUserElement,
elements: userElements,
error: onError
},
"User.update_template" : {
type: "single",
call: OpenNebula.User.update,
callback: function(request) {
Sunstone.runAction('User.show',request.request.data[0][0]);
},
error: onError
},
"User.fetch_quotas" : {
type: "single",
call: OpenNebula.User.show,
callback: function (request,response) {
populateQuotasDialog(
response.USER,
default_user_quotas,
"#user_quotas_dialog",
$user_quotas_dialog);
},
error: onError
},
"User.quotas_dialog" : {
type: "custom",
call: popUpUserQuotasDialog
},
"User.set_quota" : {
type: "multiple",
call: OpenNebula.User.set_quota,
elements: userElements,
callback: function(request) {
Sunstone.runAction('User.show',request.request.data[0]);
},
error: onError
},
"User.accounting" : {
type: "monitor",
call: OpenNebula.User.accounting,
callback: function(req,response) {
var info = req.request.data[0].monitor;
plot_graph(response,'#user_acct_tab','user_acct_', info);
},
error: onError
}
}
var user_buttons = {
"User.refresh" : {
type: "action",
layout: "refresh",
alwaysActive: true
},
// "Sunstone.toggle_top" : {
// type: "custom",
// layout: "top",
// alwaysActive: true
// },
"User.create_dialog" : {
type: "create_dialog",
layout: "create",
condition: mustBeAdmin
},
"User.update_password" : {
type : "action",
layout: "main_buttons",
text : tr("Password")
},
"User.change_authentication" : {
type : "action",
layout: "main_buttons",
text : tr("Auth")
},
"User.quotas_dialog" : {
type : "action",
layout: "main_buttons",
text : tr("Quotas"),
condition: mustBeAdmin
},
"User.chgrp" : {
type: "confirm_with_select",
text: tr("Change group"),
layout: "user_select",
select: "Group",
tip: tr("This will change the main group of the selected users. Select the new group")+":",
condition: mustBeAdmin
},
"User.addgroup" : {
type: "confirm_with_select",
text: tr("Add to group"),
layout: "user_select",
select: "Group",
tip: tr("This will add the user to a secondary group. Select the new group")+":",
condition: mustBeAdmin
},
"User.delgroup" : {
type: "confirm_with_select",
text: tr("Remove from group"),
layout: "user_select",
select: "Group",
tip: tr("This will remove the user from a secondary group. Select the group")+":",
condition: mustBeAdmin
},
"User.delete" : {
type: "confirm",
text: tr("Delete"),
layout: "del",
condition: mustBeAdmin
},
};
var user_info_panel = {
"user_info_tab" : {
title: tr("Information"),
content:""
},
"user_quotas_tab" : {
title: tr("Quotas"),
content:""
},
//"user_acct_tab" : {
// title: tr("Historical usages"),
// content: ""
//}
};
var users_tab = {
title: tr("Users"),
resource: 'User',
buttons: user_buttons,
tabClass: 'subTab',
parentTab: 'system-tab',
search_input: ' <input id="user_search" type="search" placeholder="'+tr("Search")+'" />',
list_header: '<i class="fa fa-fw fa-user"></i>&emsp;'+tr("Users"),
info_header: '<i class="fa fa-fw fa-user"></i>&emsp;'+tr("User"),
subheader: '<span>\
<span class="total_users"/> <small>'+tr("TOTAL")+'</small>\
</span>',
table: '<table id="datatable_users" cellpadding="0" cellspacing="0" border="0" class="tdisplay">\
<thead>\
<tr>\
<th class="check"><input type="checkbox" class="check_all" value=""></input></th>\
<th>'+tr("ID")+'</th>\
<th>'+tr("Name")+'</th>\
<th>'+tr("Group")+'</th>\
<th>'+tr("Auth driver")+'</th>\
<th>'+tr("VMs")+'</th>\
<th>'+tr("Memory")+'</th>\
<th>'+tr("CPU")+'</th>\
<th>'+tr("Group ID")+'</th>\
<th>'+tr("Hidden User Data")+'</th>\
</tr>\
</thead>\
<tbody id="tbodyusers">\
</tbody>\
</table>'
};
Sunstone.addActions(user_actions);
Sunstone.addMainTab('users-tab',users_tab);
Sunstone.addInfoPanel("user_info_panel",user_info_panel);
function userElements(){
return getSelectedNodes(dataTable_users);
}
// Returns an array with the values from the user_json ready to be
// added to the dataTable
function userElementArray(user_json){
var user = user_json.USER;
var vms = '<span class="progress-text right" style="font-size: 12px">-</span>';
var memory = '<span class="progress-text right" style="font-size: 12px">-</span>';
var cpu = '<span class="progress-text right" style="font-size: 12px">-</span>';
initEmptyQuotas(user);
if (!$.isEmptyObject(user.VM_QUOTA)){
vms = quotaBar(
user.VM_QUOTA.VM.VMS_USED,
user.VM_QUOTA.VM.VMS,
default_user_quotas.VM_QUOTA.VM.VMS);
memory = quotaBarMB(
user.VM_QUOTA.VM.MEMORY_USED,
user.VM_QUOTA.VM.MEMORY,
default_user_quotas.VM_QUOTA.VM.MEMORY);
cpu = quotaBarFloat(
user.VM_QUOTA.VM.CPU_USED,
user.VM_QUOTA.VM.CPU,
default_user_quotas.VM_QUOTA.VM.CPU);
}
// Build hidden user template
var hidden_template = convert_template_to_string(user);
return [
'<input class="check_item" type="checkbox" id="user_'+user.ID+'" name="selected_items" value="'+user.ID+'"/>',
user.ID,
user.NAME,
user.GNAME,
user.AUTH_DRIVER,
vms,
memory,
cpu,
user.GID,
hidden_template
]
};
// Callback to refresh a single element from the dataTable
function updateUserElement(request, user_json){
var id = user_json.USER.ID;
var element = userElementArray(user_json);
updateSingleElement(element,dataTable_users,'#user_'+id);
}
// Callback to delete a single element from the dataTable
function deleteUserElement(req){
deleteElement(dataTable_users,'#user_'+req.request.data);
}
// Callback to add a single user element
function addUserElement(request,user_json){
var element = userElementArray(user_json);
addElement(element,dataTable_users);
}
// Callback to update the list of users
function updateUsersView(request,users_list,quotas_list){
var user_list_array = [];
$.each(users_list,function(){
// Inject the VM user quota. This info is returned separately in the
// pool info call, but the userElementArray expects it inside the USER,
// as it is returned by the individual info call
var q = quotas_list[this.USER.ID];
if (q != undefined) {
this.USER.VM_QUOTA = q.QUOTAS.VM_QUOTA;
}
user_list_array.push(userElementArray(this));
});
updateView(user_list_array,dataTable_users);
$(".total_users").text(users_list.length);
};
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 = {
title : tr("Info"),
icon: "fa-info-circle",
content :
'<div class="row">\
<div class="large-6 columns">\
<table id="info_user_table" class="dataTable extended_table" cellpadding="0" cellspacing="0" border="0">\
<thead>\
<tr><th colspan="2">' + tr("Information") + '</th><th></th></tr>\
</thead>\
<tbody>\
<tr>\
<td class="key_td">' + tr("ID") + '</td>\
<td class="value_td">'+info.ID+'</td>\
<td></td>\
</tr>\
<tr>\
<td class="key_td">' + tr("Name") + '</td>\
<td class="value_td">'+info.NAME+'</td>\
<td></td>\
</tr>\
<tr>' +
insert_group_dropdown("User",info.ID,info.GNAME,info.GID,"#info_user_table") +
'</tr>\
<tr>\
<td class="key_td">' + tr("Secondary groups") + '</td>\
<td class="value_td">'+(typeof info.GROUPS.ID == "object" ? info.GROUPS.ID.join(",") : "-")+'</td>\
<td></td>\
</tr>\
<tr>\
<td class="key_td">' + tr("Authentication driver") + '</td>\
<td class="value_td">'+info.AUTH_DRIVER+'</td>\
<td></td>\
</tr>\
</tbody>\
</table>\
</div>\
<div class="large-6 columns">' +
'<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">'+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"),
{SSH_PUBLIC_KEY: ssh_key}) +
'</div>\
</div>'
};
var default_user_quotas = Quotas.default_quotas(info.DEFAULT_USER_QUOTAS);
var quotas_html = initQuotasPanel(info, default_user_quotas,
"#user_info_panel",
Config.isTabActionEnabled("users-tab", "User.quotas_dialog"));
var quotas_tab = {
title : tr("Quotas"),
icon: "fa-align-left",
content : quotas_html
};
var accounting_tab = {
title: tr("Accounting"),
icon: "fa-bar-chart-o",
content: '<div id="user_accounting"></div>'
};
Sunstone.updateInfoPanelTab("user_info_panel","user_info_tab",info_tab);
Sunstone.updateInfoPanelTab("user_info_panel","user_quotas_tab",quotas_tab);
Sunstone.updateInfoPanelTab("user_info_panel","user_accounting_tab",accounting_tab);
if (Config.isFeatureEnabled("showback")) {
var showback_tab = {
title: tr("Showback"),
icon: "fa-money",
content: '<div id="user_showback"></div>'
};
Sunstone.updateInfoPanelTab("user_info_panel","user_showback_tab",showback_tab);
}
//Sunstone.updateInfoPanelTab("user_info_panel","user_acct_tab",acct_tab);
Sunstone.popUpInfoPanel("user_info_panel", 'users-tab');
if (Config.isFeatureEnabled("showback")) {
showbackGraphs(
$("#user_showback","#user_info_panel"),
{ fixed_user: info.ID, fixed_group: "" });
}
accountingGraphs(
$("#user_accounting","#user_info_panel"),
{ fixed_user: info.ID,
init_group_by: "vm" });
setupQuotasPanel(info,
"#user_info_panel",
Config.isTabActionEnabled("users-tab", "User.quotas_dialog"),
"User");
$(".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();
});
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);
}
};
// Used also from groups-tabs.js
function setupCustomAuthDialog(dialog){
$('input[name="custom_auth"]',dialog).parent().hide();
$('select#driver',dialog).change(function(){
if ($(this).val() == "custom")
$('input[name="custom_auth"]',dialog).parent().show();
else
$('input[name="custom_auth"]',dialog).parent().hide();
});
};
function buildUserJSON(dialog){
var user_name = $('#username',dialog).val();
var user_password = $('#pass',dialog).val();
var driver = $('#driver', dialog).val();
if (driver == 'custom'){
driver = $('input[name="custom_auth"]', dialog).val();
} else if (driver == "ldap") {
user_password = "-"
}
var user_json = { "user" :
{ "name" : user_name,
"password" : user_password,
"auth_driver" : driver
}
};
return user_json;
};
// Prepare the user creation dialog
function setupCreateUserDialog(){
dialogs_context.append('<div id="create_user_dialog" class="reveal-modal tiny" data-reveal></div>');
$create_user_dialog = $('#create_user_dialog',dialogs_context);
var dialog = $create_user_dialog;
dialog.html(create_user_tmpl);
$(document).foundation();
//dialog.addClass("reveal-modal").attr("data-reveal", "");
//$('button',dialog).button();
$('#driver', dialog).change(function(){
if ($(this).val() == "ldap"){
$('#pass',dialog).hide();
$('label[for="pass"]',dialog).hide();
} else {
$('#pass',dialog).show();
$('label[for="pass"]',dialog).show();
};
});
setupCustomAuthDialog(dialog);
$('#create_user_form',dialog).submit(function(){
var user_json = buildUserJSON(this);
if (!user_json) {
notifyError(tr("User name and password must be filled in"));
return false;
}
Sunstone.runAction("User.create",user_json);
return false;
});
}
function setupUpdatePasswordDialog(){
dialogs_context.append('<div title="'+tr("Change password")+'" id="update_user_pw_dialog"></div>');
$update_pw_dialog = $('#update_user_pw_dialog',dialogs_context);
var dialog = $update_pw_dialog;
dialog.html(update_pw_tmpl);
dialog.addClass("reveal-modal").attr("data-reveal", "");
$('#update_user_pw_form',dialog).submit(function(){
var pw=$('#new_password',this).val();
var confirm_password=$('#confirm_password',this).val();
if (!pw.length){
notifyError(tr("Fill in a new password"));
return false;
}
if (pw !== confirm_password){
notifyError(tr("Passwords do not match"));
return false;
}
Sunstone.runAction("User.passwd",getSelectedNodes(dataTable_users),pw);
$update_pw_dialog.foundation('reveal', 'close');
return false;
});
};
function setupChangeAuthenticationDialog(){
dialogs_context.append('<div title="'+tr("Change authentication")+'" id="change_user_auth_dialog"></div>');
$change_auth_dialog = $('#change_user_auth_dialog',dialogs_context);
var dialog = $change_auth_dialog;
dialog.html(change_password_tmpl);
dialog.addClass("reveal-modal").attr("data-reveal", "");
$('input[name="custom_auth"]',dialog).parent().hide();
$('select#driver', dialog).change(function(){
if ($(this).val() == "custom")
$('input[name="custom_auth"]',dialog).parent().show();
else
$('input[name="custom_auth"]',dialog).parent().hide();
});
$('#change_password_form',dialog).submit(function(){
var driver = $('#driver', this).val();
if (driver == 'custom')
driver = $('input[name="custom_auth"]', this).val();
if (!driver.length){
notifyError(tr("Fill in a new auth driver"));
return false;
}
Sunstone.runAction("User.chauth",getSelectedNodes(dataTable_users), driver);
$change_auth_dialog.foundation('reveal', 'close');
return false;
});
};
//add a setup quota dialog and call the sunstone-util.js initialization
function setupUserQuotasDialog(){
dialogs_context.append('<div id="user_quotas_dialog"></div>');
$user_quotas_dialog = $('#user_quotas_dialog',dialogs_context);
var dialog = $user_quotas_dialog;
dialog.html(user_quotas_tmpl());
$(document).foundation();
setupQuotasDialog(dialog);
}
function popUpUserQuotasDialog(){
var tab = dataTable_users.parents(".tab");
if (Sunstone.rightInfoVisible(tab)) {
$('a[href="#user_quotas_tab"]', tab).click();
$('#edit_quotas_button', tab).click();
} else {
popUpQuotasDialog(
$user_quotas_dialog,
'User',
userElements(),
default_user_quotas,
"#user_quotas_dialog");
}
}
function popUpCreateUserDialog(){
$create_user_dialog.foundation().foundation('reveal', 'open');;
$("input#username",$create_user_dialog).focus();
}
function popUpUpdatePasswordDialog(){
$('#new_password',$update_pw_dialog).val("");
$update_pw_dialog.foundation().foundation('reveal', 'open');;
$("input#new_password",$update_pw_dialog).focus();
}
function popUpChangeAuthenticationDialog(){
$('#driver',$change_auth_dialog).val("");
$change_auth_dialog.foundation().foundation('reveal', 'open');;
}
$(document).ready(function(){
var tab_name = 'users-tab';
if (Config.isTabEnabled(tab_name)) {
//if we are not oneadmin, our tab will not even be in the DOM.
dataTable_users = $("#datatable_users",main_tabs_context).dataTable({
"bSortClasses": false,
"bAutoWidth": false,
"bDeferRender": true,
"aoColumnDefs": [
{ "bSortable": false, "aTargets": ["check",5,6,7] },
{ "sWidth": "35px", "aTargets": [0] },
{ "sWidth": "150px", "aTargets": [5,6,7] },
{ "bVisible": true, "aTargets": Config.tabTableColumns(tab_name)},
{ "bVisible": false, "aTargets": ['_all']}
]
});
$('#user_search').keyup(function(){
dataTable_users.fnFilter( $(this).val(), null, true, false );
})
dataTable_users.on('draw', function(){
recountCheckboxes(dataTable_users);
})
Sunstone.runAction("User.list");
setupCreateUserDialog();
setupUpdatePasswordDialog();
setupChangeAuthenticationDialog();
setupUserQuotasDialog();
//Setup quota icons
//Also for group tab
setupQuotaIcons();
initCheckAllBoxes(dataTable_users);
tableCheckboxesListener(dataTable_users);
infoListener(dataTable_users,'User.show');
$('div#users_tab div.legend_div').hide();
$('div#users_tab_non_admin div.legend_div').hide();
dataTable_users.fnSort( [ [1,config['user_config']['table_order']] ] );
}
});
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -1,26 +0,0 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
var vres_tab = {
title: '<i class="fa fa-lg fa-fw fa-cloud"></i>&emsp;'+tr("Virtual Resources"),
no_content: true
}
Sunstone.addMainTab('vresources-tab',vres_tab);
$(document).ready(function(){
});
-389
View File
@@ -1,389 +0,0 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
/* ---------------- Zone tab plugin ---------------- */
//Prepares the dialog to create
function setupCreateZoneDialog(){
if ($('#create_zone_dialog').length == 0) {
dialogs_context.append('<div title=\"'+tr("Create zone")+'\" id="create_zone_dialog"></div>');
}
$create_zone_dialog = $('#create_zone_dialog',dialogs_context);
var dialog = $create_zone_dialog;
dialog.html(create_zone_tmpl);
dialog.addClass("reveal-modal").attr("data-reveal", "");
$('#create_zone_form',dialog).submit(function(){
var name=$('#zonename',this).val();
var endpoint=$("#endpoint",this).val();
var zone_json = { "zone" : { "name" : name, "endpoint" : endpoint}};
Sunstone.runAction("Zone.create",zone_json);
return false;
});
}
function popUpCreateZoneDialog(){
$create_zone_dialog.foundation().foundation('reveal', 'open');
$("input#name",$create_zone_dialog).focus();
return false;
}
// Open update dialog
//function popUpUpdateZoneDialog(){
// TODO
//}
var create_zone_tmpl =
'<div class="row">\
<div class="large-12 columns">\
<h3 id="create_zone_header" class="subheader">'+tr("Create Zone")+'</h3>\
</div>\
</div>\
<form id="create_zone_form" action="">\
<div class="row">\
<div class="large-12 columns">\
<label for="zonename">'+tr("Zone Name")+':</label>\
<input type="text" name="zonename" id="zonename" />\
</div>\
</div>\
<div class="row centered">\
<div class="large-12 columns">\
<label for="endpoint">'+tr("Endpoint")+':</label>\
<input type="text" name="endpoint" id="endpoint" />\
</div>\
</div>\
<div class="form_buttons">\
<button class="button radius right success" id="create_zone_submit" value="zone/create">'+tr("Create")+'</button>\
</div>\
<a class="close-reveal-modal">&#215;</a>\
</form>';
var dataTable_zones;
var $create_zone_dialog;
//Setup actions
var zone_actions = {
"Zone.create" : {
type: "create",
call: OpenNebula.Zone.create,
callback: function(request, response){
$create_zone_dialog.foundation('reveal', 'close');
$("form", $create_zone_dialog)[0].reset();
Sunstone.runAction('Zone.list');
},
error: onError,
notify: true
},
"Zone.create_dialog" : {
type: "custom",
call: popUpCreateZoneDialog
},
"Zone.list" : {
type: "list",
call: OpenNebula.Zone.list,
callback: updateZonesView,
error: onError
},
"Zone.show" : {
type: "single",
call: OpenNebula.Zone.show,
callback: function(request, response){
var tab = dataTable_zones.parents(".tab");
if (Sunstone.rightInfoVisible(tab)) {
// individual view
updateZoneInfo(request, response);
}
// datatable row
updateZoneElement(request, response);
},
error: onError
},
"Zone.show_to_update" : {
type: "single",
call: OpenNebula.Zone.show,
callback: fillPopPup,
error: onError
},
"Zone.refresh" : {
type: "custom",
call: function(){
var tab = dataTable_zones.parents(".tab");
if (Sunstone.rightInfoVisible(tab)) {
Sunstone.runAction("Zone.show", Sunstone.rightInfoResourceId(tab))
} else {
waitingNodes(dataTable_zones);
Sunstone.runAction("Zone.list", {force: true});
}
},
error: onError
},
"Zone.delete" : {
type: "multiple",
call : OpenNebula.Zone.del,
callback : deleteZoneElement,
elements: zoneElements,
error : onError,
notify:true
},
"Zone.update_template" : { // Update template
type: "single",
call: OpenNebula.Zone.update,
callback: function(request,response){
notifyMessage(tr("Zone updated correctly"));
Sunstone.runAction('Zone.show',request.request.data[0][0]);
},
error: onError
},
"Zone.fetch_template" : {
type: "single",
call: OpenNebula.Zone.fetch_template,
callback: function(request,response){
$('#template_update_dialog #template_update_textarea').val(response.template);
},
error: onError
},
"Zone.rename" : {
type: "single",
call: OpenNebula.Zone.rename,
callback: function(request) {
notifyMessage(tr("Zone renamed correctly"));
Sunstone.runAction('Zone.show',request.request.data[0][0]);
},
error: onError,
notify: true
}
};
var zone_buttons = {
"Zone.refresh" : {
type: "action",
layout: "refresh",
alwaysActive: true
},
// "Sunstone.toggle_top" : {
// type: "custom",
// layout: "top",
// alwaysActive: true
// },
"Zone.create_dialog" : {
type: "create_dialog",
layout: "create"
},
// "Zone.update_dialog" : {
// type : "action",
// layout: "main",
// text : tr("Update"),
// alwaysActive: true
// },
"Zone.delete" : {
type: "confirm",
layout: "del",
text: tr("Delete")
}
};
var zones_tab = {
title: tr("Zones"),
resource: 'Zone',
buttons: zone_buttons,
tabClass: "subTab",
parentTab: "infra-tab",
search_input: '<input id="zone_search" type="search" placeholder="'+tr("Search")+'" />',
list_header: '<i class="fa fa-fw fa-files-o"></i>&emsp;'+tr("Zones"),
info_header: '<i class="fa fa-fw fa-files-o"></i>&emsp;'+tr("Zone"),
subheader: '<span/> <small></small>&emsp;',
table: '<table id="datatable_zones" class="datatable twelve">\
<thead>\
<tr>\
<th class="check"><input type="checkbox" class="check_all" value=""></input></th>\
<th>' + tr("ID") + '</th>\
<th>' + tr("Name") + '</th>\
<th>' + tr("Endpoint") + '</th>\
</tr>\
</thead>\
<tbody id="tbodyzones">\
</tbody>\
</table>'
};
var zone_info_panel = {
"zone_info_tab" : {
title: tr("Zone information"),
content:""
}
};
Sunstone.addActions(zone_actions);
Sunstone.addMainTab('zones-tab',zones_tab);
Sunstone.addInfoPanel("zone_info_panel",zone_info_panel);
//return lists of selected elements in zone list
function zoneElements(){
return getSelectedNodes(dataTable_zones);
}
function zoneElementArray(element_json){
var element = element_json.ZONE;
return [
'<input class="check_item" type="checkbox" id="zone_'+element.ID+'" name="selected_items" value="'+element.ID+'"/>',
element.ID,
element.NAME,
element.TEMPLATE.ENDPOINT
];
}
//callback for an action affecting a zone element
function updateZoneElement(request, element_json){
var id = element_json.ZONE.ID;
var element = zoneElementArray(element_json);
updateSingleElement(element,dataTable_zones,'#zone_'+id);
}
//callback for actions deleting a zone element
function deleteZoneElement(req){
deleteElement(dataTable_zones,'#zone_'+req.request.data);
$('div#zone_tab_'+req.request.data,main_tabs_context).remove();
}
//call back for actions creating a zone element
function addZoneElement(request,element_json){
var id = element_json.ZONE.ID;
var element = zoneElementArray(element_json);
addElement(element,dataTable_zones);
}
//callback to update the list of zones.
function updateZonesView (request,list){
var list_array = [];
$.each(list,function(){
//Grab table data from the list
list_array.push(zoneElementArray(this));
});
updateView(list_array,dataTable_zones);
};
// Updates the zone info panel tab content and pops it up
function updateZoneInfo(request,zone){
zone_info = zone.ZONE;
zone_template = zone_info.TEMPLATE;
$(".resource-info-header", $("#zones-tab")).html(zone_info.NAME);
//Information tab
var info_tab = {
title : tr("Info"),
icon: "fa-info-circle",
content :
'<div class="row">\
<div class="large-6 columns">\
<table id="info_zone_table" class="dataTable extended_table">\
<thead>\
<tr><th colspan="3">' + tr("Information") +'</th></tr>\
</thead>\
<tbody>\
<tr>\
<td class="key_td">' + tr("ID") + '</td>\
<td class="value_td" colspan="2">'+zone_info.ID+'</td>\
</tr>'+
insert_rename_tr(
'zones-tab',
"Zone",
zone_info.ID,
zone_info.NAME)+
'</tbody>\
</table>\
</div>\
<div class="large-6 columns">\
</div>\
</div>\
<div class="row">\
<div class="large-9 columns">'
+ insert_extended_template_table(zone_template,
"Zone",
zone_info.ID,
tr("Attributes")) +
'</div>\
</div>'
}
//Sunstone.updateInfoPanelTab(info_panel_name,tab_name, new tab object);
Sunstone.updateInfoPanelTab("zone_info_panel","zone_info_tab",info_tab);
Sunstone.popUpInfoPanel("zone_info_panel", "zones-tab");
}
//This is executed after the sunstone.js ready() is run.
//Here we can basicly init the zone datatable, preload it
//and add specific listeners
$(document).ready(function(){
var tab_name = "zones-tab"
if (Config.isTabEnabled(tab_name)) {
//prepare zone datatable
dataTable_zones = $("#datatable_zones",main_tabs_context).dataTable({
"bSortClasses": false,
"bDeferRender": true,
"aoColumnDefs": [
{ "bSortable": false, "aTargets": ["check"] },
{ "sWidth": "35px", "aTargets": [0] },
{ "bVisible": true, "aTargets": Config.tabTableColumns(tab_name)},
{ "bVisible": false, "aTargets": ['_all']}
]
});
$('#zone_search').keyup(function(){
dataTable_zones.fnFilter( $(this).val() );
})
dataTable_zones.on('draw', function(){
recountCheckboxes(dataTable_zones);
})
Sunstone.runAction("Zone.list");
setupCreateZoneDialog();
dialogs_context.append('<div title=\"'+tr("Create zone")+'\" id="create_zone_dialog"></div>');
initCheckAllBoxes(dataTable_zones);
tableCheckboxesListener(dataTable_zones);
infoListener(dataTable_zones, "Zone.show");
dataTable_zones.fnSort( [ [1,config['user_config']['table_order']] ] );
}
});
File diff suppressed because it is too large. Load diff