Feature #992: Commit all latest modifications
To this point OpenNebula Self-Service is usable. Files like sunstone.js or sunstone vendors are duplicated in ONE tree to ease manual install (copy ui folder). Some unneeded files have been removed (old sunstone plugins). TO-DO list: * Fix error handling as errors come back in non json format. * Handle sessions (with cookie) * Update install.sh * Put useful function in occi-utils.js * Extract authentication functions from opennebula.js, ozones.js and occi.js and merge on a single file if possible. * fix refresh elements functions (vnShow()) etc. * instance_types should be fetched from server and added to VM creation dialog. * Top panel links should be customizable. * Main dashboard panel * Improve icons
@ -48,6 +48,8 @@ $: << RUBY_LIB_LOCATION+"/cloud" # For the Repository Manager
|
||||
require 'rubygems'
|
||||
require 'sinatra'
|
||||
require 'yaml'
|
||||
require 'erb'
|
||||
require 'tempfile'
|
||||
|
||||
require 'OCCIServer'
|
||||
require 'CloudAuth'
|
||||
@ -73,6 +75,7 @@ CloudServer.print_configuration(conf)
|
||||
##############################################################################
|
||||
use Rack::Session::Pool, :key => 'occi'
|
||||
set :public, Proc.new { File.join(root, "ui/public") }
|
||||
set :views, settings.root + '/ui/views'
|
||||
set :config, conf
|
||||
|
||||
if CloudServer.is_port_open?(settings.config[:server],
|
||||
@ -291,5 +294,16 @@ get '/ui' do
|
||||
if !authorized?
|
||||
return File.read(File.dirname(__FILE__)+'/ui/templates/login.html')
|
||||
end
|
||||
return File.read(File.dirname(__FILE__)+'/ui/templates/index.html')
|
||||
|
||||
erb :index
|
||||
#return File.read(File.dirname(__FILE__)+'/ui/templates/index.html')
|
||||
end
|
||||
|
||||
post '/ui/upload' do
|
||||
file = Tempfile.new('uploaded_image')
|
||||
request.params['file'] = file.path #so we can re-use occi post_storage()
|
||||
file.write(request.env['rack.input'].read)
|
||||
#file.close # this would allow that file is garbage-collected
|
||||
result,rc = @occi_server.post_storage(request)
|
||||
treat_response(result,rc)
|
||||
end
|
||||
|
@ -170,7 +170,7 @@ fieldset div{
|
||||
|
||||
fieldset input,
|
||||
fieldset textarea{
|
||||
width:180px;
|
||||
width:140px;
|
||||
/*border-top:1px solid #555;
|
||||
border-left:1px solid #555;
|
||||
border-bottom:1px solid #ccc;
|
||||
@ -182,7 +182,7 @@ fieldset textarea{
|
||||
}
|
||||
|
||||
fieldset select{
|
||||
width:184px;
|
||||
width:144px;
|
||||
/*border-top:1px solid #555;
|
||||
border-left:1px solid #555;
|
||||
border-bottom:1px solid #ccc;
|
||||
@ -211,7 +211,7 @@ legend{
|
||||
|
||||
label{
|
||||
float: left;
|
||||
width:120px;
|
||||
width:100px;
|
||||
padding:0 1em;
|
||||
text-align:left;
|
||||
}
|
||||
@ -289,8 +289,9 @@ textarea:focus{
|
||||
}
|
||||
|
||||
.form_buttons {
|
||||
margin-top:25px;
|
||||
text-align:right;
|
||||
margin-top:6px;
|
||||
text-align:left;
|
||||
margin-bottom:20px;
|
||||
}
|
||||
|
||||
.add_remove_button {
|
||||
@ -319,11 +320,13 @@ tr.odd td, tr.even td{
|
||||
}
|
||||
|
||||
tr.odd:hover{
|
||||
background-color: #E69138 !important;
|
||||
background-color: #0098C3 !important;
|
||||
color: white;
|
||||
}
|
||||
|
||||
tr.even:hover{
|
||||
background-color: #E69138 !important;
|
||||
color: white;
|
||||
background-color: #0098C3 !important;
|
||||
}
|
||||
|
||||
.show_hide label{
|
||||
@ -367,7 +370,7 @@ tr.even:hover{
|
||||
margin: 20px;
|
||||
text-align: left;
|
||||
display: inline-block;
|
||||
width:43%;
|
||||
width:85%;
|
||||
vertical-align:top;
|
||||
overflow:auto;
|
||||
}
|
||||
@ -551,7 +554,7 @@ ul.action_list li a{
|
||||
|
||||
}
|
||||
ul.action_list li a:hover{
|
||||
color:#E69138;
|
||||
color:#0098C3;
|
||||
|
||||
}
|
||||
|
||||
@ -567,4 +570,19 @@ ul.action_list li a:hover{
|
||||
.ui-layout-resizer-open-hover, /* hover-color to 'resize' */
|
||||
.ui-layout-resizer-dragging {
|
||||
background: #EEE;
|
||||
}
|
||||
|
||||
.dashboard_img {
|
||||
padding-left:10px;
|
||||
border:0;
|
||||
height:40px;
|
||||
}
|
||||
|
||||
.dashboard_p {
|
||||
color: #353735;
|
||||
text-align:justify;
|
||||
}
|
||||
|
||||
.dashboard_p p{
|
||||
padding-top:5px;
|
||||
}
|
@ -93,7 +93,7 @@ body {
|
||||
font-weight: bold;
|
||||
}
|
||||
.sunstone-color {
|
||||
color: #E69138;
|
||||
color: #0098C3;
|
||||
}
|
||||
|
||||
#logo-wrapper {
|
||||
@ -140,12 +140,12 @@ background-image: -moz-linear-gradient(
|
||||
linear,
|
||||
left top,
|
||||
right top,
|
||||
color-stop(0.95, #E69138),
|
||||
color-stop(0.95, #0098C3),
|
||||
color-stop(1, rgb(53,55,53))
|
||||
);
|
||||
background-image: -moz-linear-gradient(
|
||||
left center,
|
||||
#E69138 95%,
|
||||
#0098C3 95%,
|
||||
rgb(53,55,53) 100%
|
||||
);
|
||||
/*
|
||||
|
@ -52,7 +52,7 @@ div#logo_sunstone {
|
||||
top: 80px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
background: url(../images/opennebula-sunstone-big.png) no-repeat center;
|
||||
background: url(../images/opennebula-selfservice-big.png) no-repeat center;
|
||||
vertical-align: center;
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 673 B After Width: | Height: | Size: 673 B |
BIN
src/cloud/occi/lib/ui/public/images/one-compute.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
src/cloud/occi/lib/ui/public/images/one-network.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
src/cloud/occi/lib/ui/public/images/one-storage.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
After Width: | Height: | Size: 9.4 KiB |
After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
@ -18,12 +18,12 @@ var activeTab;
|
||||
var outerLayout, innerLayout;
|
||||
|
||||
function hideDialog(){
|
||||
innerLayout.close("south");
|
||||
innerLayout.close("east");
|
||||
}
|
||||
|
||||
function popDialog(content){
|
||||
$("#dialog").html(content);
|
||||
innerLayout.open("south");
|
||||
innerLayout.open("east");
|
||||
}
|
||||
|
||||
function popDialogLoading(){
|
||||
@ -92,15 +92,16 @@ $(document).ready(function () {
|
||||
, west__resizable: false
|
||||
});
|
||||
|
||||
var factor = 0.6;
|
||||
var dialog_height = Math.floor($(".outer-center").height()*factor);
|
||||
var factor = 0.45;
|
||||
var dialog_height = Math.floor($(".outer-center").width()*factor);
|
||||
|
||||
innerLayout = $('div.outer-center').layout({
|
||||
fxName: "slide"
|
||||
, initClosed: true
|
||||
, center__paneSelector: ".inner-center"
|
||||
, south__paneSelector: ".inner-south"
|
||||
, south__size: dialog_height
|
||||
, east__paneSelector: ".inner-east"
|
||||
, east__size: dialog_height
|
||||
, east__minSize: 400
|
||||
, spacing_open: 5 // ALL panes
|
||||
, spacing_closed: 5 // ALL panes
|
||||
});
|
||||
|
@ -14,7 +14,7 @@
|
||||
/* limitations under the License. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
//Simple recursion
|
||||
//Convert json into the XML that OCCI server can understand
|
||||
function json2xml(element,root_key) {
|
||||
var xml = "";
|
||||
if (!root_key) root_key="ROOT";
|
||||
@ -28,7 +28,7 @@ function json2xml(element,root_key) {
|
||||
//do not wrap arrays in root_key
|
||||
return xml;
|
||||
|
||||
} else
|
||||
} else
|
||||
xml += json2xml(value,key);
|
||||
});
|
||||
} else { //its a simple value. Base condition
|
||||
@ -225,7 +225,9 @@ var OCCI = {
|
||||
dataType: "xml ONEjson",
|
||||
data: data,
|
||||
success: function(response){
|
||||
return callback ? callback(request, response) : null;
|
||||
var res = {};
|
||||
res[resource] = response;
|
||||
return callback ? callback(request, res) : null;
|
||||
},
|
||||
error: function(response){
|
||||
return callback_error ?
|
||||
@ -310,9 +312,9 @@ var OCCI = {
|
||||
var callback = params.success;
|
||||
var callback_error = params.error;
|
||||
var id = params.data.id;
|
||||
var body = json2xml(params.data.body,resource)
|
||||
var body = json2xml(params.data.body,resource);
|
||||
|
||||
var request = OCCI.Helper.request(resource,method, [id, body]);
|
||||
var request = OCCI.Helper.request(resource,method, id);
|
||||
|
||||
$.ajax({
|
||||
url: resource.toLowerCase() + "/" + id,
|
||||
@ -428,35 +430,13 @@ var OCCI = {
|
||||
OCCI.Action.show(params,OCCI.Network.resource);
|
||||
},
|
||||
"publish": function(params){
|
||||
params.data.body = { "public": "YES" }
|
||||
params.data.body = { "PUBLIC": "YES" };
|
||||
OCCI.Action.update(params,OCCI.Network.resource,"publish");
|
||||
},
|
||||
"unpublish": function(params){
|
||||
params.data.body = { "public": "NO" }
|
||||
OCCI.Action.update(params,OpenNebula.Network.resource,"unpublish");
|
||||
params.data.body = { "PUBLIC": "NO" };
|
||||
OCCI.Action.update(params,OCCI.Network.resource,"unpublish");
|
||||
},
|
||||
/*
|
||||
"addleases" : function(params){
|
||||
var action_obj = params.data.extra_param;
|
||||
OpenNebula.Action.simple_action(params,
|
||||
OpenNebula.Network.resource,
|
||||
"addleases",
|
||||
action_obj);
|
||||
},
|
||||
"rmleases" : function(params){
|
||||
var action_obj = params.data.extra_param;
|
||||
OpenNebula.Action.simple_action(params,
|
||||
OpenNebula.Network.resource,
|
||||
"rmleases",
|
||||
action_obj);
|
||||
},
|
||||
"update": function(params){
|
||||
var action_obj = {"template_raw" : params.data.extra_param };
|
||||
OpenNebula.Action.simple_action(params,
|
||||
OpenNebula.Network.resource,
|
||||
"update",
|
||||
action_obj);
|
||||
},*/
|
||||
},
|
||||
|
||||
"VM": {
|
||||
@ -484,25 +464,27 @@ var OCCI = {
|
||||
},
|
||||
"cancel": function(params){
|
||||
params.data.body = { state : "CANCEL" };
|
||||
OCCI.Action.simple_action(params,OCCI.VM.resource,"cancel");
|
||||
OCCI.Action.update(params,OCCI.VM.resource,"cancel");
|
||||
},
|
||||
"suspend": function(params){
|
||||
params.data.body = { state : "SUSPENDED" };
|
||||
OCCI.Action.simple_action(params,OCCI.VM.resource,"suspend");
|
||||
OCCI.Action.update(params,OCCI.VM.resource,"suspend");
|
||||
},
|
||||
"resume": function(params){
|
||||
params.data.body = { state : "RESUME" };
|
||||
OCCI.Action.simple_action(params,OCCI.VM.resource,"resume");
|
||||
OCCI.Action.update(params,OCCI.VM.resource,"resume");
|
||||
},
|
||||
"done": function(params){
|
||||
params.data.body = { state : "DONE" };
|
||||
OCCI.Action.simple_action(params,OCCI.VM.resource,"done");
|
||||
},
|
||||
"saveas": function(params){
|
||||
var action_obj = params.data.extra_param;
|
||||
OCCI.Action.simple_action(params,OCCI.VM.resource,
|
||||
"saveas",action_obj);
|
||||
OCCI.Action.update(params,OCCI.VM.resource,"done");
|
||||
},
|
||||
"saveas" : function(params){
|
||||
var obj = params.data.extra_param;
|
||||
var disk_id = obj.disk_id;
|
||||
var im_name = obj.image_name;
|
||||
params.data.body = '<DISK id="'+disk_id+'"><SAVE_AS name="'+im_name+'" /></DISK>';
|
||||
OCCI.Action.update(params,OCCI.VM.resource,"saveas");
|
||||
}
|
||||
/* "vnc" : function(params,startstop){
|
||||
var callback = params.success;
|
||||
var callback_error = params.error;
|
||||
@ -543,7 +525,26 @@ var OCCI = {
|
||||
"resource": "STORAGE",
|
||||
|
||||
"create": function(params){
|
||||
OCCI.Action.create(params,OCCI.Image.resource);
|
||||
var callback = params.success;
|
||||
var callback_error = params.error;
|
||||
var data = {occixml : json2xml(params.data,OCCI.Image.resource)};
|
||||
var request = OCCI.Helper.request(OCCI.Image.resource,"create", data);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "storage",
|
||||
data: data,
|
||||
dataType: "xml ONEjson",
|
||||
success: function(response){
|
||||
var res = {};
|
||||
res["STORAGE"] = response;
|
||||
return callback ? callback(request, res) : null;
|
||||
},
|
||||
error: function(response){
|
||||
return callback_error ?
|
||||
callback_error(request, OCCI.Error(response)) : null;
|
||||
}
|
||||
});
|
||||
},
|
||||
"delete": function(params){
|
||||
OCCI.Action.delete(params,OCCI.Image.resource);
|
||||
@ -554,41 +555,22 @@ var OCCI = {
|
||||
"show": function(params){
|
||||
OCCI.Action.show(params,OCCI.Image.resource);
|
||||
},
|
||||
"update": function(params){
|
||||
var action_obj = {"template_raw" : params.data.extra_param };
|
||||
OCCI.Action.simple_action(params,
|
||||
OCCI.Image.resource,
|
||||
"update",
|
||||
action_obj);
|
||||
},
|
||||
"fetch_template" : function(params){
|
||||
OCCI.Action.show(params,OCCI.Image.resource,"template");
|
||||
},
|
||||
"enable": function(params){
|
||||
OCCI.Action.simple_action(params,OCCI.Image.resource,"enable");
|
||||
},
|
||||
"disable": function(params){
|
||||
OCCI.Action.simple_action(params,OCCI.Image.resource,"disable");
|
||||
},
|
||||
"publish": function(params){
|
||||
OCCI.Action.simple_action(params,OCCI.Image.resource,"publish");
|
||||
params.data.body = { "PUBLIC":"YES" };
|
||||
OCCI.Action.update(params,OCCI.Image.resource,"publish");
|
||||
},
|
||||
"unpublish": function(params){
|
||||
OCCI.Action.simple_action(params,OCCI.Image.resource,"unpublish");
|
||||
params.data.body = { "PUBLIC":"NO" };
|
||||
OCCI.Action.update(params,OCCI.Image.resource,"unpublish");
|
||||
},
|
||||
"persistent": function(params){
|
||||
OCCI.Action.simple_action(params,OCCI.Image.resource,"persistent");
|
||||
params.data.body = { "PERSISTENT":"YES" };
|
||||
OCCI.Action.update(params,OCCI.Image.resource,"persistent");
|
||||
},
|
||||
"nonpersistent": function(params){
|
||||
OCCI.Action.simple_action(params,OCCI.Image.resource,"nonpersistent");
|
||||
params.data.body = { "PERSISTENT":"NO" };
|
||||
OCCI.Action.update(params,OCCI.Image.resource,"nonpersistent");
|
||||
},
|
||||
"chtype": function(params){
|
||||
var action_obj = {"type" : params.data.extra_param};
|
||||
OCCI.Action.simple_action(params,
|
||||
OCCI.Image.resource,
|
||||
"chtype",
|
||||
action_obj);
|
||||
}
|
||||
},
|
||||
|
||||
"Template" : {
|
||||
@ -637,17 +619,4 @@ var OCCI = {
|
||||
}
|
||||
},
|
||||
|
||||
"Acl" : {
|
||||
"resource" : "ACL",
|
||||
|
||||
"create" : function(params){
|
||||
OCCI.Action.create(params,OCCI.Acl.resource);
|
||||
},
|
||||
"delete" : function(params){
|
||||
OCCI.Action.delete(params,OCCI.Acl.resource);
|
||||
},
|
||||
"list" : function(params){
|
||||
OCCI.Action.list(params,OCCI.Acl.resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,503 +0,0 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) */
|
||||
/* */
|
||||
/* 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 acls_tab_content =
|
||||
'<form id="acl_form" action="" action="javascript:alert(\'js error!\');">\
|
||||
<div class="action_blocks">\
|
||||
</div>\
|
||||
<table id="datatable_acls" class="display">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th class="check"><input type="checkbox" class="check_all" value="">'+tr("All")+'</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>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id="tbodyaclss">\
|
||||
</tbody>\
|
||||
</table>\
|
||||
</form>';
|
||||
|
||||
var create_acl_tmpl =
|
||||
'<form id="create_acl_form" action="">\
|
||||
<fieldset>\
|
||||
<div>\
|
||||
<label for="applies">'+tr("This rule applies to")+':</label>\
|
||||
<select name="applies" id="applies"></select>\
|
||||
<div class="clear"></div>\
|
||||
<label style="height:9em">'+tr("Affected resources")+':</label>\
|
||||
<input type="checkbox" name="res_host" class="resource_cb" value="HOST">'+tr("Hosts")+'</input><br />\
|
||||
<input type="checkbox" name="res_vm" class="resource_cb" value="VM">'+tr("Virtual Machines")+'</input><br />\
|
||||
<input type="checkbox" name="res_net" class="resource_cb" value="NET">'+tr("Virtual Networks")+'</input><br />\
|
||||
<input type="checkbox" name="res_image" class="resource_cb" value="IMAGE">'+tr("Images")+'</input><br />\
|
||||
<input type="checkbox" name="res_template" class="resource_cb" value="TEMPLATE">'+tr("Templates")+'</input><br />\
|
||||
<input type="checkbox" name="res_user" class="resource_cb" value="USER">'+tr("Users")+'</input><br />\
|
||||
<input type="checkbox" name="res_group" class="resource_cb" value="GROUP">'+tr("Groups")+'</input><br />\
|
||||
<div class="clear"></div>\
|
||||
<label for="mode_select" style="height:3em;">'+tr("Resource subset")+':</label>\
|
||||
<input type="radio" class="res_subgroup" name="mode_select" value="*" id="res_subgroup_all">'+tr("All")+'</input><br />\
|
||||
<input type="radio" class="res_subgroup" name="mode_select" value="res_id" id="res_subgroup_id">'+tr("Specific ID")+'</input><br />\
|
||||
<input type="radio" class="res_subgroup" name="mode_select" value="belonging_to" id="res_subgroup_group">'+tr("Owned by group")+'</input><br />\
|
||||
<div class="clear"></div>\
|
||||
<label for="res_id">'+tr("Resource ID")+':</label>\
|
||||
<input type="text" name="res_id" id="res_id"></input>\
|
||||
<div class="clear"></div>\
|
||||
<label for="belonging_to">'+tr("Group")+':</label>\
|
||||
<select name="belonging_to" id="belonging_to"></select>\
|
||||
<div class="clear"></div>\
|
||||
<label style="height:12em;">'+tr("Allowed operations")+':</label>\
|
||||
<input type="checkbox" name="right_create" class="right_cb" value="CREATE">'+tr("Create")+'</input><br />\
|
||||
<input type="checkbox" name="right_delete" class="right_cb" value="DELETE">'+tr("Delete")+'</input><br />\
|
||||
<input type="checkbox" name="right_use" class="right_cb" value="USE">'+tr("Use")+'</input><br />\
|
||||
<input type="checkbox" name="right_manage" class="right_cb" value="MANAGE">'+tr("Manage")+'</input><br />\
|
||||
<input type="checkbox" name="right_info" class="right_cb" value="INFO">'+tr("Get Information")+'</input><br />\
|
||||
<input type="checkbox" name="right_info_pool" class="right_cb" value="INFO_POOL">'+tr("Get Pool of resources")+'</input><br />\
|
||||
<input type="checkbox" name="right_info_pool_mine" class="right_cb" value="INFO_POOL_MINE">'+tr("Get Pool of my/group\'s resources")+'</input><br />\
|
||||
<input type="checkbox" name="right_chown" class="right_cb" value="CHOWN">'+tr("Change owner")+'</input><br />\
|
||||
<input type="checkbox" name="right_deploy" class="right_cb" value="DEPLOY">'+tr("Deploy")+'</input><br />\
|
||||
<div class="clear"></div>\
|
||||
<label for="acl_preview">'+tr("ACL String preview")+':</label>\
|
||||
<input type="text" name="acl_preview" id="acl_preview" style="width:400px;"></input>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
<fieldset>\
|
||||
<div class="form_buttons">\
|
||||
<button class="button" id="create_acl_submit" value="Acl.create">'+tr("Create")+'</button>\
|
||||
<button class="button" type="reset" value="reset">'+tr("Reset")+'</button>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
</form>';
|
||||
|
||||
var acl_actions = {
|
||||
"Acl.create" : {
|
||||
type: "create",
|
||||
call: OpenNebula.Acl.create,
|
||||
callback: function(){
|
||||
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");
|
||||
}
|
||||
},
|
||||
|
||||
"Acl.autorefresh" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
OpenNebula.Acl.list({
|
||||
timeout: true,
|
||||
success: updateAclsView,
|
||||
error: onError
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
"Acl.delete" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.Acl.delete,
|
||||
callback: deleteAclElement,
|
||||
elements: aclElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
}
|
||||
|
||||
var acl_buttons = {
|
||||
"Acl.refresh" : {
|
||||
type: "image",
|
||||
text: tr("Refresh list"),
|
||||
img: "images/Refresh-icon.png"
|
||||
},
|
||||
"Acl.create_dialog" : {
|
||||
type: "create_dialog",
|
||||
text: tr("+ New")
|
||||
},
|
||||
"Acl.delete" : {
|
||||
type: "action",
|
||||
text: tr("Delete")
|
||||
}
|
||||
}
|
||||
|
||||
var acls_tab = {
|
||||
title: tr("ACLs"),
|
||||
content: acls_tab_content,
|
||||
buttons: acl_buttons
|
||||
}
|
||||
|
||||
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));
|
||||
};
|
||||
};
|
||||
return user_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];
|
||||
|
||||
//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;
|
||||
};
|
||||
};
|
||||
//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);
|
||||
|
||||
return [user_str,resources_str,belonging_to,ops_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]
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
updateDashboard("acls",list);
|
||||
}
|
||||
|
||||
function setupCreateAclDialog(){
|
||||
dialogs_context.append('<div title=\"'+tr("Create ACL")+'\" 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
|
||||
});
|
||||
|
||||
$('#res_subgroup_all',dialog).attr('checked','checked');
|
||||
$('#res_id',dialog).attr('disabled','disabled');
|
||||
$('#belonging_to',dialog).attr('disabled','disabled');
|
||||
|
||||
$('button',dialog).button();
|
||||
|
||||
$('.res_subgroup',dialog).click(function(){
|
||||
var value = $(this).val();
|
||||
var context = $(this).parent();
|
||||
switch (value) {
|
||||
case "*":
|
||||
$('#res_id',context).attr('disabled','disabled');
|
||||
$('#belonging_to',context).attr('disabled','disabled');
|
||||
break;
|
||||
case "res_id":
|
||||
$('#res_id',context).removeAttr('disabled');
|
||||
$('#belonging_to').attr('disabled','disabled');
|
||||
break;
|
||||
case "belonging_to":
|
||||
$('#res_id',context).attr('disabled','disabled');
|
||||
$('#belonging_to',context).removeAttr('disabled');
|
||||
break;
|
||||
};
|
||||
});
|
||||
|
||||
$('input#res_id',dialog).keyup(function(){
|
||||
$(this).trigger("change");
|
||||
});
|
||||
|
||||
//update the rule preview every time some field changes
|
||||
$('input,select',dialog).change(function(){
|
||||
var context = $('#create_acl_form',$create_acl_dialog);
|
||||
var user = $('#applies',context).val();
|
||||
|
||||
if ($('#applies :selected',context).hasClass("user")){
|
||||
user='#'+user;
|
||||
} else if ($('#applies :selected',context).hasClass("group")){
|
||||
user = '@'+user;
|
||||
};
|
||||
|
||||
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="@"+$('#belonging_to',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 acl_string = user + ' ' + resources + '/' + belonging + ' ' + rights;
|
||||
$('#acl_preview',context).val(acl_string);
|
||||
|
||||
});
|
||||
|
||||
$('#create_acl_form',dialog).submit(function(){
|
||||
var user = $('#applies',this).val();
|
||||
if (!user.length) {
|
||||
notifyError(tr("Please specify to who this ACL applies"));
|
||||
return false;
|
||||
};
|
||||
|
||||
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',this).val().length;
|
||||
if (!l){
|
||||
notifyError("Please select a group 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);
|
||||
$create_acl_dialog.dialog('close');
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// Before popping up the dialog, some prepartions are
|
||||
// required: we have to put the right options in the
|
||||
// selects.
|
||||
function popUpCreateAclDialog(){
|
||||
var users = $('<select>'+users_select+'</select>');
|
||||
$('.empty_value',users).remove();
|
||||
$('option',users).addClass("user");
|
||||
users.prepend('<option value="">---'+tr("Users")+'---</option>');
|
||||
|
||||
var groups = $('<select>'+groups_select+'</select>');
|
||||
$('.empty_value',groups).remove();
|
||||
$('option',groups).addClass("group");
|
||||
groups.prepend('<option value="">---'+tr("Groups")+'---</option>');
|
||||
|
||||
var dialog = $create_acl_dialog;
|
||||
$('#applies',dialog).html('<option value="*">'+tr("All")+'</option>'+
|
||||
users.html()+groups.html());
|
||||
$('#belonging_to',dialog).html(groups_select);
|
||||
|
||||
$('#applies',dialog).trigger("change");
|
||||
dialog.dialog('open');
|
||||
}
|
||||
|
||||
// Prepare the autorefresh of the list
|
||||
function setAclAutorefresh(){
|
||||
setInterval(function(){
|
||||
var checked = $('input.check_item:checked',dataTable_acls);
|
||||
var filter = $("#datatable_acls_filter input",dataTable_acls.parents("#datatable_acls_wrapper")).attr('value');
|
||||
if (!checked.length && !filter.length){
|
||||
Sunstone.runAction("Acl.autorefresh");
|
||||
}
|
||||
},INTERVAL+someTime());
|
||||
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
//if we are not oneadmin, our tab will not even be in the DOM.
|
||||
dataTable_acls = $("#datatable_acls",main_tabs_context).dataTable({
|
||||
"bJQueryUI": true,
|
||||
"bSortClasses": false,
|
||||
"sPaginationType": "full_numbers",
|
||||
"bAutoWidth":false,
|
||||
"aoColumnDefs": [
|
||||
{ "bSortable": false, "aTargets": ["check"] },
|
||||
{ "sWidth": "60px", "aTargets": [0] },
|
||||
{ "sWidth": "35px", "aTargets": [1] }
|
||||
],
|
||||
"oLanguage": (datatable_lang != "") ?
|
||||
{
|
||||
sUrl: "locale/"+lang+"/"+datatable_lang
|
||||
} : ""
|
||||
});
|
||||
dataTable_acls.fnClearTable();
|
||||
addElement([
|
||||
spinner,
|
||||
'','','','',''],dataTable_acls);
|
||||
|
||||
Sunstone.runAction("Acl.list");
|
||||
|
||||
setupCreateAclDialog();
|
||||
setAclAutorefresh();
|
||||
|
||||
initCheckAllBoxes(dataTable_acls);
|
||||
tableCheckboxesListener(dataTable_acls);
|
||||
//shortenedInfoFields('#datatable_acls');
|
||||
|
||||
})
|
@ -1,300 +0,0 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) */
|
||||
/* */
|
||||
/* 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. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/** HISTORY_LENGTH currently ignored on server, but it doesn't harm to have it**/
|
||||
var HISTORY_LENGTH=40;
|
||||
var GRAPH_AUTOREFRESH_INTERVAL=60000; //60 secs
|
||||
|
||||
var graph1 = {
|
||||
title : "graph1",
|
||||
monitor_resources : "total,active,error",
|
||||
history_length : HISTORY_LENGTH
|
||||
};
|
||||
|
||||
var graph2 = {
|
||||
title : "graph2",
|
||||
monitor_resources : "cpu_usage",
|
||||
history_length : HISTORY_LENGTH
|
||||
};
|
||||
|
||||
var graph3 = {
|
||||
title : "graph3",
|
||||
monitor_resources : "mem_usage",
|
||||
history_length : HISTORY_LENGTH
|
||||
};
|
||||
|
||||
var graph4 = {
|
||||
title : "graph4",
|
||||
monitor_resources : "net_tx,net_rx",
|
||||
history_length : HISTORY_LENGTH
|
||||
};
|
||||
|
||||
var dashboard_tab_content =
|
||||
'<table id="dashboard_table">\
|
||||
<tr>\
|
||||
<td style="width:40%">\
|
||||
<table id="information_table" style="width:100%;">\
|
||||
<tr>\
|
||||
<td>\
|
||||
<div class="panel">\
|
||||
<h3>'+tr("Summary of resources")+'</h3>\
|
||||
<div class="panel_info">\
|
||||
\
|
||||
<table class="info_table">\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("VM Templates (total/public)")+'</td>\
|
||||
<td class="value_td"><span id="total_templates"></span><span id="public_templates"></span></td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("VM Instances")+' ('+
|
||||
tr("total")+'/<span class="green">'+
|
||||
tr("running")+'</span>/<span class="red">'+
|
||||
tr("failed")+'</span>)</td>\
|
||||
<td class="value_td"><span id="total_vms"></span><span id="running_vms" class="green"></span><span id="failed_vms" class="red"></span></td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Virtual Networks (total/public)")+'</td>\
|
||||
<td class="value_td"><span id="total_vnets"></span><span id="public_vnets"></span></td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Images (total/public)")+'</td>\
|
||||
<td class="value_td"><span id="total_images"></span><span id="public_images"></span></td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
\
|
||||
</div>\
|
||||
</div>\
|
||||
</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td>\
|
||||
<div class="panel">\
|
||||
<h3>'+tr("Quickstart")+'</h3>\
|
||||
<form id="quickstart_form"><fieldset>\
|
||||
<table style="width:100%;"><tr style="vertical-align:middle;"><td style="width:70%">\
|
||||
<label style="font-weight:bold;width:40px;height:4em;">New:</label>\
|
||||
<input type="radio" name="quickstart" value="Template.create_dialog">'+tr("VM Template")+'</input><br />\
|
||||
<input type="radio" name="quickstart" value="VM.create_dialog">'+tr("VM Instance")+'</input><br />\
|
||||
<input type="radio" name="quickstart" value="Network.create_dialog">'+tr("Virtual Network")+'</input><br />\
|
||||
<input type="radio" name="quickstart" value="Image.create_dialog">'+tr("Image")+'</input><br />\
|
||||
</td></tr></table>\
|
||||
</div>\
|
||||
</td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
</td>\
|
||||
<td style="width:60%">\
|
||||
<table id="historical_table" style="width:100%">\
|
||||
<tr>\
|
||||
<td>\
|
||||
<div class="panel">\
|
||||
<h3>'+tr("Historical monitoring information")+'</h3>\
|
||||
<div class="panel_info">\
|
||||
<table class="info_table">\
|
||||
<tr><td class="key_td graph_td">'+tr("Total VM count")+'</td>\
|
||||
<td class="graph_td" id="graph1_legend"></td></tr>\
|
||||
<tr><td id="graph1" colspan="2">'+spinner+'</td></tr>\
|
||||
<tr><td class="key_td graph_td">'+tr("Total VM CPU")+'</td>\
|
||||
<td class="graph_td" id="graph2_legend"></td></tr>\
|
||||
<tr><td id="graph2" colspan="2">'+spinner+'</td></tr>\
|
||||
<tr><td class="key_td graph_td">'+tr("Total VM Memory")+'</td>\
|
||||
<td class="graph_td" id="graph3_legend"></td></tr>\
|
||||
<tr><td id="graph3" colspan="2">'+spinner+'</td></tr>\
|
||||
<tr><td class="key_td graph_td">'+tr("VM Network stats")+'</td>\
|
||||
<td class="graph_td" id="graph4_legend"></td></tr>\
|
||||
<tr><td id="graph4" colspan="2">'+spinner+'</td></tr>\
|
||||
</table>\
|
||||
</div>\
|
||||
</div>\
|
||||
</td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
</td>\
|
||||
</tr></table>';
|
||||
|
||||
var dashboard_tab = {
|
||||
title: tr("Dashboard"),
|
||||
content: dashboard_tab_content
|
||||
}
|
||||
|
||||
Sunstone.addMainTab('dashboard_tab',dashboard_tab);
|
||||
|
||||
function plot_global_graph(data,info){
|
||||
var context = $('#historical_table',main_tabs_context);
|
||||
var id = info.title;
|
||||
var monitoring = data.monitoring;
|
||||
var serie;
|
||||
var series = [];
|
||||
var width = ($(window).width()-129)*48/100;
|
||||
var mon_count = 0;
|
||||
var labels_array = info.monitor_resources.split(',');
|
||||
|
||||
$('#'+id,context).html('<div id="'+id+'_graph" style="height:70px;width:'+width+'px;margin-bottom:10px;"><div>');
|
||||
|
||||
for (var i=0; i<labels_array.length; i++) {
|
||||
serie = {
|
||||
label: labels_array[i],
|
||||
data: monitoring[labels_array[i]]
|
||||
};
|
||||
|
||||
series.push(serie);
|
||||
mon_count++;
|
||||
};
|
||||
|
||||
var options = {
|
||||
legend : {
|
||||
show : true,
|
||||
noColumns: mon_count,
|
||||
container: $('#'+id+'_legend')
|
||||
},
|
||||
xaxis : {
|
||||
tickFormatter: function(val,axis){
|
||||
return pretty_time_axis(val);
|
||||
},
|
||||
},
|
||||
yaxis : { labelWidth: 40 }
|
||||
}
|
||||
|
||||
switch (id){
|
||||
case "graph3":
|
||||
case "graph4":
|
||||
options["yaxis"]["tickFormatter"] = function(val,axis) {
|
||||
return humanize_size(val);
|
||||
}
|
||||
}
|
||||
|
||||
$.plot($('#'+id+'_graph',context),series,options);
|
||||
}
|
||||
|
||||
function quickstart_setup(){
|
||||
|
||||
$('#dashboard_table #quickstart_form input',main_tabs_context).click(function(){
|
||||
Sunstone.runAction($(this).val());
|
||||
});
|
||||
}
|
||||
|
||||
function graph_autorefresh(){
|
||||
setInterval(function(){
|
||||
refresh_graphs();
|
||||
},GRAPH_AUTOREFRESH_INTERVAL+someTime());
|
||||
|
||||
}
|
||||
|
||||
function refresh_graphs(){
|
||||
Sunstone.runAction("VM.monitor_all", graph1);
|
||||
Sunstone.runAction("VM.monitor_all", graph2);
|
||||
Sunstone.runAction("VM.monitor_all", graph3);
|
||||
Sunstone.runAction("VM.monitor_all", graph4);
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
//Dashboard link listener
|
||||
$("#dashboard_table h3 a",main_tabs_context).live("click", function (){
|
||||
var tab = $(this).attr('href');
|
||||
showTab(tab);
|
||||
return false;
|
||||
});
|
||||
|
||||
emptyDashboard();
|
||||
|
||||
quickstart_setup();
|
||||
|
||||
refresh_graphs();
|
||||
graph_autorefresh();
|
||||
|
||||
});
|
||||
|
||||
//puts the dashboard values into "retrieving"
|
||||
function emptyDashboard(){
|
||||
$("#dashboard_tab .value_td span",main_tabs_context).html(spinner);
|
||||
}
|
||||
|
||||
|
||||
function updateDashboard(what,json_info){
|
||||
var db = $('#dashboard_tab',main_tabs_context);
|
||||
switch (what){
|
||||
case "hosts":
|
||||
var total_hosts=json_info.length;
|
||||
var active_hosts=0;
|
||||
$.each(json_info,function(){
|
||||
if (parseInt(this.HOST.STATE) < 3){
|
||||
active_hosts++;}
|
||||
});
|
||||
$('#total_hosts',db).html(total_hosts+' / ');
|
||||
$('#active_hosts',db).html(active_hosts);
|
||||
break;
|
||||
case "groups":
|
||||
var total_groups=json_info.length;
|
||||
$('#total_groups',db).html(total_groups);
|
||||
break;
|
||||
case "vms":
|
||||
var total_vms=json_info.length;
|
||||
var running_vms=0;
|
||||
failed_vms=0;
|
||||
$.each(json_info,function(){
|
||||
vm_state = parseInt(this.VM.STATE);
|
||||
if (vm_state == 3){
|
||||
running_vms++;
|
||||
}
|
||||
else if (vm_state == 7) {
|
||||
failed_vms++;
|
||||
}
|
||||
});
|
||||
$('#total_vms',db).html(total_vms+' / ');
|
||||
$('#running_vms',db).html(running_vms+' / ');
|
||||
$('#failed_vms',db).html(failed_vms);
|
||||
break;
|
||||
case "vnets":
|
||||
var public_vnets=0;
|
||||
var total_vnets=json_info.length;
|
||||
$.each(json_info,function(){
|
||||
if (parseInt(this.VNET.PUBLIC)){
|
||||
public_vnets++;}
|
||||
});
|
||||
$('#total_vnets',db).html(total_vnets+' / ');
|
||||
$('#public_vnets',db).html(public_vnets);
|
||||
break;
|
||||
case "users":
|
||||
var total_users=json_info.length;
|
||||
$('#total_users',db).html(total_users);
|
||||
break;
|
||||
case "images":
|
||||
var total_images=json_info.length;
|
||||
var public_images=0;
|
||||
$.each(json_info,function(){
|
||||
if (parseInt(this.IMAGE.PUBLIC)){
|
||||
public_images++;}
|
||||
});
|
||||
$('#total_images',db).html(total_images+' / ');
|
||||
$('#public_images',db).html(public_images);
|
||||
break;
|
||||
case "templates":
|
||||
var total_templates=json_info.length;
|
||||
var public_templates=0;
|
||||
$.each(json_info,function(){
|
||||
if (parseInt(this.VMTEMPLATE.PUBLIC)){
|
||||
public_templates++;
|
||||
}
|
||||
});
|
||||
$('#total_templates',db).html(total_templates+' / ');
|
||||
$('#public_templates',db).html(public_templates);
|
||||
break;
|
||||
case "acls":
|
||||
var total_acls=json_info.length;
|
||||
$('#total_acls',db).html(total_acls);
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,297 +0,0 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) */
|
||||
/* */
|
||||
/* 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 groups_select="";
|
||||
var dataTable_groups;
|
||||
var $create_group_dialog;
|
||||
|
||||
var groups_tab_content =
|
||||
'<form id="group_form" action="" action="javascript:alert(\'js error!\');">\
|
||||
<div class="action_blocks">\
|
||||
</div>\
|
||||
<table id="datatable_groups" class="display">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th class="check"><input type="checkbox" class="check_all" value="">'+tr("All")+'</input></th>\
|
||||
<th>'+tr("ID")+'</th>\
|
||||
<th>'+tr("Name")+'</th>\
|
||||
<th>'+tr("Users")+'</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id="tbodygroups">\
|
||||
</tbody>\
|
||||
</table>\
|
||||
</form>';
|
||||
|
||||
var create_group_tmpl =
|
||||
'<form id="create_group_form" action="">\
|
||||
<fieldset style="border:none;">\
|
||||
<div>\
|
||||
<label for="name">'+tr("Group name")+':</label>\
|
||||
<input type="text" name="name" id="name" /><br />\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
<fieldset>\
|
||||
<div class="form_buttons">\
|
||||
<button class="button" id="create_group_submit" value="Group.create">'+tr("Create")+'</button>\
|
||||
<button class="button" type="reset" value="reset">'+tr("Reset")+'</button>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
</form>';
|
||||
|
||||
|
||||
var group_actions = {
|
||||
"Group.create" : {
|
||||
type: "create",
|
||||
call : OpenNebula.Group.create,
|
||||
callback : addGroupElement,
|
||||
error : onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Group.create_dialog" : {
|
||||
type: "custom",
|
||||
call: popUpCreateGroupDialog
|
||||
},
|
||||
|
||||
"Group.list" : {
|
||||
type: "list",
|
||||
call: OpenNebula.Group.list,
|
||||
callback: updateGroupsView,
|
||||
error: onError,
|
||||
},
|
||||
|
||||
// "Group.showinfo" : {
|
||||
// type: "custom",
|
||||
// call: updateGroupInfo
|
||||
// },
|
||||
|
||||
"Group.autorefresh" : {
|
||||
type: "custom",
|
||||
call: function () {
|
||||
OpenNebula.Group.list({timeout: true, success: updateGroupsView,error: onError});
|
||||
}
|
||||
},
|
||||
|
||||
"Group.refresh" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
waitingNodes(dataTable_groups);
|
||||
Sunstone.runAction("Group.list");
|
||||
},
|
||||
error: onError
|
||||
},
|
||||
|
||||
"Group.delete" : {
|
||||
type: "multiple",
|
||||
call : OpenNebula.Group.delete,
|
||||
callback : deleteGroupElement,
|
||||
error : onError,
|
||||
elements: groupElements,
|
||||
notify:true
|
||||
},
|
||||
|
||||
// "Group.chown" : {
|
||||
// type: "multiple",
|
||||
// call : OpenNebula.Group.chown,
|
||||
// callback : updateGroupElement,
|
||||
// elements: function() { return getSelectedNodes(dataTable_groups); },
|
||||
// error : onError,
|
||||
// notify:true
|
||||
// },
|
||||
|
||||
}
|
||||
|
||||
var group_buttons = {
|
||||
"Group.refresh" : {
|
||||
type: "image",
|
||||
text: tr("Refresh list"),
|
||||
img: "images/Refresh-icon.png"
|
||||
},
|
||||
"Group.create_dialog" : {
|
||||
type: "create_dialog",
|
||||
text: tr("+ New Group")
|
||||
},
|
||||
// "Group.chown" : {
|
||||
// type: "confirm_with_select",
|
||||
// text: "Change group owner",
|
||||
// select: function(){return users_select},
|
||||
// tip: "Select the new group owner:",
|
||||
// condition : True
|
||||
// },
|
||||
|
||||
"Group.delete" : {
|
||||
type: "action",
|
||||
text: tr("Delete")
|
||||
}
|
||||
};
|
||||
|
||||
var groups_tab = {
|
||||
title: tr("Groups"),
|
||||
content: groups_tab_content,
|
||||
buttons: group_buttons
|
||||
}
|
||||
|
||||
Sunstone.addActions(group_actions);
|
||||
Sunstone.addMainTab('groups_tab',groups_tab);
|
||||
|
||||
function groupElements(){
|
||||
return getSelectedNodes(dataTable_groups);
|
||||
}
|
||||
|
||||
function groupElementArray(group_json){
|
||||
var group = group_json.GROUP;
|
||||
|
||||
var users_str="";
|
||||
if (group.USERS.ID &&
|
||||
group.USERS.ID.constructor == Array){
|
||||
for (var i=0; i<group.USERS.ID.length; i++){
|
||||
users_str+=getUserName(group.USERS.ID[i])+', ';
|
||||
};
|
||||
users_str=users_str.slice(0,-2);
|
||||
} else if (group.USERS.ID) {
|
||||
users_str=getUserName(group.USERS.ID);
|
||||
};
|
||||
|
||||
return [
|
||||
'<input class="check_item" type="checkbox" id="group_'+group.ID+'" name="selected_items" value="'+group.ID+'"/>',
|
||||
group.ID,
|
||||
group.NAME,
|
||||
users_str ];
|
||||
}
|
||||
|
||||
// function groupInfoListener(){
|
||||
// $('#groups_tab #tbodygroups tr',main_tabs_context).live("click",function(e){
|
||||
// //do nothing if we are clicking a checkbox!
|
||||
// if ($(e.target).is('input')) {return true;}
|
||||
// var aData = dataTable_groups.fnGetData(this);
|
||||
// var id = $(aData[0]).val();
|
||||
// Sunstone.runAction("Group.showinfo",id);
|
||||
// return false;
|
||||
// });
|
||||
// }
|
||||
|
||||
function updateGroupSelect(){
|
||||
groups_select = makeSelectOptions(dataTable_groups,
|
||||
1,//id_col
|
||||
2,//name_col
|
||||
[],//status_cols
|
||||
[]//bad_status_cols
|
||||
);
|
||||
}
|
||||
|
||||
function updateGroupElement(request, group_json){
|
||||
var id = group_json.GROUP.ID;
|
||||
var element = groupElementArray(group_json);
|
||||
updateSingleElement(element,dataTable_groups,'#group_'+id);
|
||||
//No need to update select as all items are in it always
|
||||
}
|
||||
|
||||
function deleteGroupElement(request){
|
||||
deleteElement(dataTable_groups,'#group_'+request.request.data);
|
||||
updateGroupSelect();
|
||||
}
|
||||
|
||||
function addGroupElement(request,group_json){
|
||||
var id = group_json.GROUP.ID;
|
||||
var element = groupElementArray(group_json);
|
||||
addElement(element,dataTable_groups);
|
||||
updateGroupSelect();
|
||||
}
|
||||
|
||||
//updates the list
|
||||
function updateGroupsView(request, group_list){
|
||||
group_list_json = group_list;
|
||||
var group_list_array = [];
|
||||
|
||||
$.each(group_list,function(){
|
||||
group_list_array.push(groupElementArray(this));
|
||||
});
|
||||
|
||||
updateView(group_list_array,dataTable_groups);
|
||||
updateGroupSelect(group_list);
|
||||
updateDashboard("groups",group_list);
|
||||
}
|
||||
|
||||
//Prepares the dialog to create
|
||||
function setupCreateGroupDialog(){
|
||||
dialogs_context.append('<div title=\"'+tr("Create group")+'\" id="create_group_dialog"></div>');
|
||||
$create_group_dialog = $('#create_group_dialog',dialogs_context);
|
||||
var dialog = $create_group_dialog;
|
||||
|
||||
dialog.html(create_group_tmpl);
|
||||
dialog.dialog({
|
||||
autoOpen: false,
|
||||
modal: true,
|
||||
width: 400
|
||||
});
|
||||
|
||||
$('button',dialog).button();
|
||||
|
||||
$('#create_group_form',dialog).submit(function(){
|
||||
var name=$('#name',this).val();
|
||||
var group_json = { "group" : { "name" : name }};
|
||||
Sunstone.runAction("Group.create",group_json);
|
||||
$create_group_dialog.dialog('close');
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function popUpCreateGroupDialog(){
|
||||
$create_group_dialog.dialog('open');
|
||||
return false;
|
||||
}
|
||||
|
||||
//Prepares the autorefresh
|
||||
function setGroupAutorefresh(){
|
||||
setInterval(function(){
|
||||
var checked = $('input.check_item:checked',dataTable_groups);
|
||||
var filter = $("#datatable_groups_filter input",dataTable_groups.parents("#datatable_groups_wrapper")).attr('value');
|
||||
if (!checked.length && !filter.length){
|
||||
Sunstone.runAction("Group.autorefresh");
|
||||
}
|
||||
},INTERVAL+someTime());
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
dataTable_groups = $("#datatable_groups",main_tabs_context).dataTable({
|
||||
"bJQueryUI": true,
|
||||
"bSortClasses": false,
|
||||
"sPaginationType": "full_numbers",
|
||||
"bAutoWidth":false,
|
||||
"aoColumnDefs": [
|
||||
{ "bSortable": false, "aTargets": ["check"] },
|
||||
{ "sWidth": "60px", "aTargets": [0] },
|
||||
{ "sWidth": "35px", "aTargets": [1] }
|
||||
],
|
||||
"oLanguage": (datatable_lang != "") ?
|
||||
{
|
||||
sUrl: "locale/"+lang+"/"+datatable_lang
|
||||
} : ""
|
||||
});
|
||||
|
||||
dataTable_groups.fnClearTable();
|
||||
addElement([
|
||||
spinner,
|
||||
'','',''],dataTable_groups);
|
||||
|
||||
Sunstone.runAction("Group.list");
|
||||
setupCreateGroupDialog();
|
||||
setGroupAutorefresh();
|
||||
|
||||
initCheckAllBoxes(dataTable_groups);
|
||||
tableCheckboxesListener(dataTable_groups);
|
||||
})
|
@ -1,634 +0,0 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) */
|
||||
/* */
|
||||
/* 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. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/*Host tab plugin*/
|
||||
/* HOST_HISTORY_LENGTH is ignored by server */
|
||||
var HOST_HISTORY_LENGTH = 40;
|
||||
var host_graphs = [
|
||||
{
|
||||
title : tr("CPU Monitoring information"),
|
||||
monitor_resources : "cpu_usage,used_cpu,max_cpu",
|
||||
humanize_figures : false,
|
||||
history_length : HOST_HISTORY_LENGTH
|
||||
},
|
||||
{
|
||||
title: tr("Memory monitoring information"),
|
||||
monitor_resources : "mem_usage,used_mem,max_mem",
|
||||
humanize_figures : true,
|
||||
history_length : HOST_HISTORY_LENGTH
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
var hosts_tab_content =
|
||||
'<form id="form_hosts" action="javascript:alert(\'js errors?!\')">\
|
||||
<div class="action_blocks">\
|
||||
</div>\
|
||||
<table id="datatable_hosts" class="display">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th class="check"><input type="checkbox" class="check_all" value="">' + tr("All") + '</input></th>\
|
||||
<th>' + tr("id") + '</th>\
|
||||
<th>' + tr("Name") + '</th>\
|
||||
<th>' + tr("Running VMs") + '</th>\
|
||||
<th>' + tr("CPU Use") + '</th>\
|
||||
<th>' + tr("Memory use") + '</th>\
|
||||
<th>' + tr("Status") + '</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id="tbodyhosts">\
|
||||
</tbody>\
|
||||
</table>\
|
||||
</form>';
|
||||
|
||||
var create_host_tmpl =
|
||||
'<div class="create_form"><form id="create_host_form" action="">\
|
||||
<fieldset>\
|
||||
<legend style="display:none;">' + tr("Host parameters") + '</legend>\
|
||||
<label for="name">' + tr("Name") + ':</label><input type="text" name="name" id="name" />\
|
||||
</fieldset>\
|
||||
<h3>' + tr("Drivers") + '</h3>\
|
||||
<fieldset>\
|
||||
<div class="manager clear" id="vmm_mads">\
|
||||
<label>' + tr("Virtualization Manager") + ':</label>\
|
||||
<select id="vmm_mad" name="vmm">\
|
||||
<option value="vmm_kvm">' + tr("KVM") + '</option>\
|
||||
<option value="vmm_xen">' + tr("XEN") + '</option>\
|
||||
<option value="vmm_ec2">' + tr("EC2") + '</option>\
|
||||
<option value="vmm_dummy">' + tr("Dummy") + '</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
<div class="manager clear" id="im_mads">\
|
||||
<label>' + tr("Information Manager") + ':</label>\
|
||||
<select id="im_mad" name="im">\
|
||||
<option value="im_kvm">' + tr("KVM") + '</option>\
|
||||
<option value="im_xen">' + tr("XEN") + '</option>\
|
||||
<option value="im_ec2">' + tr("EC2") + '</option>\
|
||||
<option value="im_dummy">' + tr("Dummy") + '</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
<div class="manager clear" id="vnm_mads">\
|
||||
<label>Virtual Network Manager:</label>\
|
||||
<select id="vnm_mad" name="vn">\
|
||||
<option value="dummy">Dummy</option>\
|
||||
<option value="etables">Etables</option>\
|
||||
<option value="ovswitch">Open vSwitch</option>\
|
||||
<option value="802.1Q">802.1Q</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
<div class="manager clear" id="tm_mads">\
|
||||
<label>' + tr("Transfer Manager") + ':</label>\
|
||||
<select id="tm_mad" name="tm">\
|
||||
<option value="tm_shared">' + tr("Shared") + '</option>\
|
||||
<option value="tm_ssh">' + tr("SSH") + '</option>\
|
||||
<option value="tm_dummy">' + tr("Dummy") + '</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
<fieldset>\
|
||||
<div class="form_buttons">\
|
||||
<div><button class="button" id="create_host_submit" value="OpenNebula.Host.create">' + tr("Create") + '</button>\
|
||||
<button class="button" type="reset" value="reset">' + tr("Reset") + '</button></div>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
</form></div>';
|
||||
|
||||
var hosts_select="";
|
||||
var dataTable_hosts;
|
||||
var $create_host_dialog;
|
||||
|
||||
//Setup actions
|
||||
var host_actions = {
|
||||
|
||||
"Host.create" : {
|
||||
type: "create",
|
||||
call : OpenNebula.Host.create,
|
||||
callback : addHostElement,
|
||||
error : onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Host.create_dialog" : {
|
||||
type: "custom",
|
||||
call: popUpCreateHostDialog
|
||||
},
|
||||
|
||||
"Host.list" : {
|
||||
type: "list",
|
||||
call: OpenNebula.Host.list,
|
||||
callback: updateHostsView,
|
||||
error: onError
|
||||
},
|
||||
|
||||
"Host.show" : {
|
||||
type: "single",
|
||||
call: OpenNebula.Host.show,
|
||||
callback: updateHostElement,
|
||||
error: onError
|
||||
},
|
||||
|
||||
"Host.showinfo" : {
|
||||
type: "single",
|
||||
call: OpenNebula.Host.show,
|
||||
callback: updateHostInfo,
|
||||
error: onError
|
||||
},
|
||||
|
||||
"Host.refresh" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
waitingNodes(dataTable_hosts);
|
||||
Sunstone.runAction("Host.list");
|
||||
},
|
||||
error: onError
|
||||
},
|
||||
|
||||
"Host.autorefresh" : {
|
||||
type: "custom",
|
||||
call : function() {
|
||||
OpenNebula.Host.list({timeout: true, success: updateHostsView,error: onError});
|
||||
}
|
||||
},
|
||||
|
||||
"Host.enable" : {
|
||||
type: "multiple",
|
||||
call : OpenNebula.Host.enable,
|
||||
callback : function (req) {
|
||||
Sunstone.runAction("Host.show",req.request.data[0]);
|
||||
},
|
||||
elements: hostElements,
|
||||
error : onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Host.disable" : {
|
||||
type: "multiple",
|
||||
call : OpenNebula.Host.disable,
|
||||
callback : function (req) {
|
||||
Sunstone.runAction("Host.show",req.request.data[0]);
|
||||
},
|
||||
elements: hostElements,
|
||||
error : onError,
|
||||
notify:true
|
||||
},
|
||||
|
||||
"Host.delete" : {
|
||||
type: "multiple",
|
||||
call : OpenNebula.Host.delete,
|
||||
callback : deleteHostElement,
|
||||
elements: hostElements,
|
||||
error : onError,
|
||||
notify:true
|
||||
},
|
||||
|
||||
"Host.monitor" : {
|
||||
type: "monitor",
|
||||
call : OpenNebula.Host.monitor,
|
||||
callback: function(req,response) {
|
||||
var info = req.request.data[0].monitor;
|
||||
plot_graph(response,'#host_monitoring_tab',
|
||||
'host_monitor_',info);
|
||||
},
|
||||
error: hostMonitorError
|
||||
},
|
||||
|
||||
"Host.monitor_all" : {
|
||||
type: "monitor_global",
|
||||
call: OpenNebula.Host.monitor_all,
|
||||
callback: function(req,response) {
|
||||
var info = req.request.data[0].monitor;
|
||||
plot_global_graph(response,info);
|
||||
},
|
||||
error: onError
|
||||
},
|
||||
|
||||
"Host.fetch_template" : {
|
||||
type: "single",
|
||||
call: OpenNebula.Host.fetch_template,
|
||||
callback: function (request,response) {
|
||||
$('#template_update_dialog #template_update_textarea').val(response.template);
|
||||
},
|
||||
error: onError
|
||||
},
|
||||
|
||||
"Host.update_dialog" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
popUpTemplateUpdateDialog("Host",
|
||||
makeSelectOptions(dataTable_hosts,
|
||||
1,//id_col
|
||||
2,//name_col
|
||||
[],
|
||||
[]
|
||||
),
|
||||
getSelectedNodes(dataTable_hosts));
|
||||
}
|
||||
},
|
||||
|
||||
"Host.update" : {
|
||||
type: "single",
|
||||
call: OpenNebula.Host.update,
|
||||
callback: function() {
|
||||
notifyMessage(tr("Template updated correctly"));
|
||||
},
|
||||
error: onError
|
||||
}
|
||||
};
|
||||
|
||||
var host_buttons = {
|
||||
"Host.refresh" : {
|
||||
type: "image",
|
||||
text: tr("Refresh list"),
|
||||
img: "images/Refresh-icon.png"
|
||||
},
|
||||
"Host.create_dialog" : {
|
||||
type: "create_dialog",
|
||||
text: tr("+ New")
|
||||
},
|
||||
"Host.update_dialog" : {
|
||||
type: "action",
|
||||
text: tr("Update a template"),
|
||||
alwaysActive: true
|
||||
},
|
||||
"Host.enable" : {
|
||||
type: "action",
|
||||
text: tr("Enable")
|
||||
},
|
||||
"Host.disable" : {
|
||||
type: "action",
|
||||
text: tr("Disable")
|
||||
},
|
||||
"Host.delete" : {
|
||||
type: "action",
|
||||
text: tr("Delete host")
|
||||
}
|
||||
};
|
||||
|
||||
var host_info_panel = {
|
||||
"host_info_tab" : {
|
||||
title: tr("Host information"),
|
||||
content:""
|
||||
},
|
||||
|
||||
"host_template_tab" : {
|
||||
title: tr("Host template"),
|
||||
content: ""
|
||||
},
|
||||
"host_monitoring_tab": {
|
||||
title: tr("Monitoring information"),
|
||||
content: ""
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var hosts_tab = {
|
||||
title: tr("Hosts"),
|
||||
content: hosts_tab_content,
|
||||
buttons: host_buttons
|
||||
}
|
||||
|
||||
Sunstone.addActions(host_actions);
|
||||
Sunstone.addMainTab('hosts_tab',hosts_tab);
|
||||
Sunstone.addInfoPanel("host_info_panel",host_info_panel);
|
||||
|
||||
|
||||
function hostElements(){
|
||||
return getSelectedNodes(dataTable_hosts);
|
||||
}
|
||||
|
||||
//Creates an array to be added to the dataTable from the JSON of a host.
|
||||
function hostElementArray(host_json){
|
||||
|
||||
var host = host_json.HOST;
|
||||
|
||||
//Calculate some values
|
||||
var acpu = parseInt(host.HOST_SHARE.MAX_CPU);
|
||||
if (!acpu) {acpu=100};
|
||||
acpu = acpu - parseInt(host.HOST_SHARE.CPU_USAGE);
|
||||
|
||||
var total_mem = parseInt(host.HOST_SHARE.MAX_MEM);
|
||||
var free_mem = parseInt(host.HOST_SHARE.FREE_MEM);
|
||||
|
||||
var ratio_mem = 0;
|
||||
if (total_mem) {
|
||||
ratio_mem = Math.round(((total_mem - free_mem) / total_mem) * 100);
|
||||
}
|
||||
|
||||
|
||||
var total_cpu = parseInt(host.HOST_SHARE.MAX_CPU);
|
||||
var used_cpu = Math.max(total_cpu - parseInt(host.HOST_SHARE.USED_CPU),acpu);
|
||||
|
||||
var ratio_cpu = 0;
|
||||
if (total_cpu){
|
||||
ratio_cpu = Math.round(((total_cpu - used_cpu) / total_cpu) * 100);
|
||||
}
|
||||
|
||||
|
||||
//progressbars html code - hardcoded jquery html result
|
||||
var pb_mem =
|
||||
'<div style="height:10px" class="ratiobar ui-progressbar ui-widget ui-widget-content ui-corner-all" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="'+ratio_mem+'">\
|
||||
<div class="ui-progressbar-value ui-widget-header ui-corner-left ui-corner-right" style="width: '+ratio_mem+'%;"/>\
|
||||
<span style="position:relative;left:90px;top:-4px;font-size:0.6em">'+ratio_mem+'%</span>\
|
||||
</div>\
|
||||
</div>';
|
||||
|
||||
var pb_cpu =
|
||||
'<div style="height:10px" class="ratiobar ui-progressbar ui-widget ui-widget-content ui-corner-all" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="'+ratio_cpu+'">\
|
||||
<div class="ui-progressbar-value ui-widget-header ui-corner-left ui-corner-right" style="width: '+ratio_cpu+'%;"/>\
|
||||
<span style="position:relative;left:90px;top:-4px;font-size:0.6em">'+ratio_cpu+'%</span>\
|
||||
</div>\
|
||||
</div>';
|
||||
|
||||
|
||||
return [
|
||||
'<input class="check_item" type="checkbox" id="host_'+host.ID+'" name="selected_items" value="'+host.ID+'"/>',
|
||||
host.ID,
|
||||
host.NAME,
|
||||
host.HOST_SHARE.RUNNING_VMS, //rvm
|
||||
pb_cpu,
|
||||
pb_mem,
|
||||
OpenNebula.Helper.resource_state("host_simple",host.STATE) ];
|
||||
}
|
||||
|
||||
//Listen to clicks on the tds of the tables and shows the info dialogs.
|
||||
function hostInfoListener(){
|
||||
$('#tbodyhosts tr',dataTable_hosts).live("click",function(e){
|
||||
//do nothing if we are clicking a checkbox!
|
||||
if ($(e.target).is('input')) {return true;}
|
||||
popDialogLoading();
|
||||
var aData = dataTable_hosts.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
Sunstone.runAction("Host.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
//updates the host select by refreshing the options in it
|
||||
function updateHostSelect(){
|
||||
hosts_select = makeSelectOptions(dataTable_hosts,
|
||||
1,//id_col
|
||||
2,//name_col
|
||||
[6,6],//status_cols
|
||||
["ERROR","OFF"]//bad_st
|
||||
);
|
||||
}
|
||||
|
||||
//callback for an action affecting a host element
|
||||
function updateHostElement(request, host_json){
|
||||
var id = host_json.HOST.ID;
|
||||
var element = hostElementArray(host_json);
|
||||
updateSingleElement(element,dataTable_hosts,'#host_'+id);
|
||||
updateHostSelect();
|
||||
}
|
||||
|
||||
//callback for actions deleting a host element
|
||||
function deleteHostElement(req){
|
||||
deleteElement(dataTable_hosts,'#host_'+req.request.data);
|
||||
updateHostSelect();
|
||||
}
|
||||
|
||||
//call back for actions creating a host element
|
||||
function addHostElement(request,host_json){
|
||||
var id = host_json.HOST.ID;
|
||||
var element = hostElementArray(host_json);
|
||||
addElement(element,dataTable_hosts);
|
||||
updateHostSelect();
|
||||
}
|
||||
|
||||
//callback to update the list of hosts.
|
||||
function updateHostsView (request,host_list){
|
||||
var host_list_array = [];
|
||||
|
||||
$.each(host_list,function(){
|
||||
//Grab table data from the host_list
|
||||
host_list_array.push(hostElementArray(this));
|
||||
});
|
||||
|
||||
updateView(host_list_array,dataTable_hosts);
|
||||
updateHostSelect();
|
||||
//dependency with the dashboard plugin
|
||||
updateDashboard("hosts",host_list);
|
||||
}
|
||||
|
||||
//Updates the host info panel tab's content and pops it up
|
||||
function updateHostInfo(request,host){
|
||||
var host_info = host.HOST;
|
||||
|
||||
//Information tab
|
||||
var info_tab = {
|
||||
title : tr("Host information"),
|
||||
content :
|
||||
'<table id="info_host_table" class="info_table">\
|
||||
<thead>\
|
||||
<tr><th colspan="2">' + tr("Host information") + ' - '+host_info.NAME+'</th></tr>\
|
||||
</thead>\
|
||||
<tbody>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("id") + '</td>\
|
||||
<td class="value_td">'+host_info.ID+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("State") + '</td>\
|
||||
<td class="value_td">'+tr(OpenNebula.Helper.resource_state("host",host_info.STATE))+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("IM MAD") + '</td>\
|
||||
<td class="value_td">'+host_info.IM_MAD+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("VM MAD") + '</td>\
|
||||
<td class="value_td">'+host_info.VM_MAD+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+ tr("VN MAD") +'</td>\
|
||||
<td class="value_td">'+host_info.VN_MAD+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+ tr("TM MAD") +'</td>\
|
||||
<td class="value_td">'+host_info.TM_MAD+'</td>\
|
||||
</tr>\
|
||||
</tbody>\
|
||||
</table>\
|
||||
<table id="host_shares_table" class="info_table">\
|
||||
<thead>\
|
||||
<tr><th colspan="2">' + tr("Host shares") + '</th></tr>\
|
||||
</thead>\
|
||||
<tbody>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Max Mem") + '</td>\
|
||||
<td class="value_td">'+humanize_size(host_info.HOST_SHARE.MAX_MEM)+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Used Mem (real)") + '</td>\
|
||||
<td class="value_td">'+humanize_size(host_info.HOST_SHARE.USED_MEM)+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Used Mem (allocated)") + '</td>\
|
||||
<td class="value_td">'+humanize_size(host_info.HOST_SHARE.MAX_USAGE)+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Used CPU (real)") + '</td>\
|
||||
<td class="value_td">'+host_info.HOST_SHARE.USED_CPU+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Used CPU (allocated)") + '</td>\
|
||||
<td class="value_td">'+host_info.HOST_SHARE.CPU_USAGE+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Running VMs") + '</td>\
|
||||
<td class="value_td">'+host_info.HOST_SHARE.RUNNING_VMS+'</td>\
|
||||
</tr>\
|
||||
</tbody>\
|
||||
</table>'
|
||||
}
|
||||
|
||||
//Template tab
|
||||
var template_tab = {
|
||||
title : tr("Host template"),
|
||||
content :
|
||||
'<table id="host_template_table" class="info_table" style="width:80%">\
|
||||
<thead><tr><th colspan="2">' + tr("Host template") + '</th></tr></thead>'+
|
||||
prettyPrintJSON(host_info.TEMPLATE)+
|
||||
'</table>'
|
||||
}
|
||||
|
||||
var monitor_tab = {
|
||||
title: tr("Monitoring information"),
|
||||
content : generateMonitoringDivs(host_graphs,"host_monitor_")
|
||||
}
|
||||
|
||||
//Sunstone.updateInfoPanelTab(info_panel_name,tab_name, new tab object);
|
||||
Sunstone.updateInfoPanelTab("host_info_panel","host_info_tab",info_tab);
|
||||
Sunstone.updateInfoPanelTab("host_info_panel","host_template_tab",template_tab);
|
||||
Sunstone.updateInfoPanelTab("host_info_panel","host_monitoring_tab",monitor_tab);
|
||||
|
||||
Sunstone.popUpInfoPanel("host_info_panel");
|
||||
//pop up panel while we retrieve the graphs
|
||||
for (var i=0; i<host_graphs.length; i++){
|
||||
Sunstone.runAction("Host.monitor",host_info.ID,host_graphs[i]);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Prepares the host creation dialog
|
||||
function setupCreateHostDialog(){
|
||||
dialogs_context.append('<div title=\"'+tr("Create host")+'\" id="create_host_dialog"></div>');
|
||||
$create_host_dialog = $('div#create_host_dialog');
|
||||
var dialog = $create_host_dialog;
|
||||
|
||||
dialog.html(create_host_tmpl);
|
||||
dialog.dialog({
|
||||
autoOpen: false,
|
||||
modal: true,
|
||||
width: 500
|
||||
});
|
||||
|
||||
$('button',dialog).button();
|
||||
|
||||
//Handle the form submission
|
||||
$('#create_host_form',dialog).submit(function(){
|
||||
if (!($('#name',this).val().length)){
|
||||
notifyError(tr("Host name missing!"));
|
||||
return false;
|
||||
}
|
||||
var host_json = {
|
||||
"host": {
|
||||
"name": $('#name',this).val(),
|
||||
"tm_mad": $('#tm_mad :selected',this).val(),
|
||||
"vm_mad": $('#vmm_mad :selected',this).val(),
|
||||
"vnm_mad": $('#vnm_mad :selected',this).val(),
|
||||
"im_mad": $('#im_mad :selected',this).val()
|
||||
}
|
||||
}
|
||||
|
||||
//Create the OpenNebula.Host.
|
||||
//If it's successfull we refresh the list.
|
||||
Sunstone.runAction("Host.create",host_json);
|
||||
$create_host_dialog.dialog('close');
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
//Open creation dialogs
|
||||
function popUpCreateHostDialog(){
|
||||
$create_host_dialog.dialog('open');
|
||||
return false;
|
||||
}
|
||||
|
||||
//Prepares the autorefresh for hosts
|
||||
function setHostAutorefresh() {
|
||||
setInterval(function(){
|
||||
var checked = $('input.check_item:checked',dataTable_hosts);
|
||||
var filter = $("#datatable_hosts_filter input",dataTable_hosts.parents('#datatable_hosts_wrapper')).attr('value');
|
||||
if (!checked.length && !filter.length){
|
||||
Sunstone.runAction("Host.autorefresh");
|
||||
}
|
||||
},INTERVAL+someTime());
|
||||
}
|
||||
|
||||
function hostMonitorError(req,error_json){
|
||||
var message = error_json.error.message;
|
||||
var info = req.request.data[0].monitor;
|
||||
var labels = info.monitor_resources;
|
||||
var id_suffix = labels.replace(/,/g,'_');
|
||||
var id = '#host_monitor_'+id_suffix;
|
||||
$('#host_monitoring_tab '+id).html('<div style="padding-left:20px;">'+message+'</div>');
|
||||
}
|
||||
|
||||
function hosts_sel() {
|
||||
return hosts_select;
|
||||
}
|
||||
|
||||
//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(){
|
||||
|
||||
//prepare host datatable
|
||||
dataTable_hosts = $("#datatable_hosts",main_tabs_context).dataTable({
|
||||
"bJQueryUI": true,
|
||||
"bSortClasses": false,
|
||||
"bAutoWidth":false,
|
||||
"sPaginationType": "full_numbers",
|
||||
"aoColumnDefs": [
|
||||
{ "bSortable": false, "aTargets": ["check"] },
|
||||
{ "sWidth": "60px", "aTargets": [0,3] },
|
||||
{ "sWidth": "35px", "aTargets": [1] },
|
||||
{ "sWidth": "100px", "aTargets": [6] },
|
||||
{ "sWidth": "200px", "aTargets": [4,5] }
|
||||
],
|
||||
"oLanguage": (datatable_lang != "") ?
|
||||
{
|
||||
sUrl: "locale/"+lang+"/"+datatable_lang
|
||||
} : ""
|
||||
});
|
||||
|
||||
//preload it
|
||||
dataTable_hosts.fnClearTable();
|
||||
addElement([
|
||||
spinner,
|
||||
'','','','','',''],dataTable_hosts);
|
||||
Sunstone.runAction("Host.list");
|
||||
|
||||
setupCreateHostDialog();
|
||||
|
||||
setHostAutorefresh();
|
||||
|
||||
initCheckAllBoxes(dataTable_hosts);
|
||||
tableCheckboxesListener(dataTable_hosts);
|
||||
hostInfoListener();
|
||||
});
|
446
src/cloud/occi/lib/ui/public/js/plugins/network.js
Normal file
@ -0,0 +1,446 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) */
|
||||
/* */
|
||||
/* 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. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/*Virtual networks tab plugin*/
|
||||
|
||||
var vnets_tab_content =
|
||||
'<form id="virtualNetworks_form" action="javascript:alert(\'js error!\');">\
|
||||
<div class="action_blocks">\
|
||||
</div>\
|
||||
<table id="datatable_vnetworks" class="display">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th class="check"><input type="checkbox" class="check_all" value="">'+tr("All")+'</input></th>\
|
||||
<th>'+tr("ID")+'</th>\
|
||||
<th>'+tr("Name")+'</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id="tbodyvnetworks">\
|
||||
</tbody>\
|
||||
</table>\
|
||||
</form>';
|
||||
|
||||
var create_vn_tmpl =
|
||||
'<div id="vn_tabs">\
|
||||
<div id="easy">\
|
||||
<form id="create_vn_form_easy" action="">\
|
||||
<fieldset>\
|
||||
<label for="name">'+tr("Name")+':</label>\
|
||||
<input type="text" name="name" id="name" /><br />\
|
||||
</fieldset>\
|
||||
<div class="clear"></div>\
|
||||
<div id="ranged">\
|
||||
<fieldset>\
|
||||
<label for="net_address">'+tr("Network Address")+':</label>\
|
||||
<input type="text" name="net_address" id="net_address" /><div class="clear" />\
|
||||
<label for="net_size">'+tr("Network Size")+':</label>\
|
||||
<input type="text" name="net_size" id="net_size" /><br />\
|
||||
</fieldset>\
|
||||
</div>\
|
||||
<div class="clear"></div>\
|
||||
</fieldset>\
|
||||
<div class="form_buttons">\
|
||||
<button class="vnet_close_dialog_link"/>\
|
||||
<button class="button" id="create_vn" value="vn/create" />\
|
||||
<button class="button" type="reset" id="reset_vn" value="reset" />\
|
||||
</div>\
|
||||
</form>\
|
||||
</div>\
|
||||
</div>';
|
||||
|
||||
|
||||
var vnet_dashboard = '<div class="dashboard_p">\
|
||||
<img class="dashboard_img" src="images/one-network.png" alt="one-network" />\
|
||||
<p>'+tr("In this view you can easily manage OpenNebula Network resources. You can add, remove, publish or unpublish virtual networks.")+'</p>\
|
||||
<p>'+tr("Compute resources can be attached to these networks at creation time. Virtual machines will be provided with an IP and the correct parameters to ensure connectivity.")+'</p>\
|
||||
<p>'+tr("There are currently")+' <b><span id="vnet_dashboard_count" /></b> '+tr("networks")+'.</p>\
|
||||
</div>';
|
||||
|
||||
var dataTable_vNetworks;
|
||||
var $create_vn_dialog;
|
||||
|
||||
//Setup actions
|
||||
|
||||
var vnet_actions = {
|
||||
"Network.create" : {
|
||||
type: "create",
|
||||
call: OCCI.Network.create,
|
||||
callback: addVNetworkElement,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Network.create_dialog" : {
|
||||
type: "custom",
|
||||
call: popUpCreateVnetDialog
|
||||
},
|
||||
|
||||
"Network.list" : {
|
||||
type: "list",
|
||||
call: OCCI.Network.list,
|
||||
callback: updateVNetworksView,
|
||||
error: onError
|
||||
},
|
||||
|
||||
"Network.show" : {
|
||||
type: "single",
|
||||
call: OCCI.Network.show,
|
||||
callback: updateVNetworkElement,
|
||||
error: onError
|
||||
},
|
||||
|
||||
"Network.showinfo" : {
|
||||
type: "single",
|
||||
call: OCCI.Network.show,
|
||||
callback: updateVNetworkInfo,
|
||||
error: onError
|
||||
|
||||
},
|
||||
|
||||
"Network.refresh" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
waitingNodes(dataTable_vNetworks);
|
||||
Sunstone.runAction("Network.list");
|
||||
}
|
||||
},
|
||||
|
||||
"Network.autorefresh" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
OCCI.Network.list({timeout: true, success: updateVNetworksView, error: onError});
|
||||
}
|
||||
},
|
||||
|
||||
"Network.publish" : {
|
||||
type: "multiple",
|
||||
call: OCCI.Network.publish,
|
||||
callback: vnShow,
|
||||
elements: vnElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Network.unpublish" : {
|
||||
type: "multiple",
|
||||
call: OCCI.Network.unpublish,
|
||||
callback: vnShow,
|
||||
elements: vnElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Network.delete" : {
|
||||
type: "multiple",
|
||||
call: OCCI.Network.delete,
|
||||
callback: deleteVNetworkElement,
|
||||
elements: vnElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
var vnet_buttons = {
|
||||
"Network.refresh" : {
|
||||
type: "image",
|
||||
text: tr("Refresh list"),
|
||||
img: "images/Refresh-icon.png"
|
||||
},
|
||||
|
||||
"Network.create_dialog" : {
|
||||
type: "create_dialog",
|
||||
text: tr("+ New")
|
||||
},
|
||||
|
||||
"Network.publish" : {
|
||||
type: "action",
|
||||
text: tr("Publish")
|
||||
},
|
||||
|
||||
"Network.unpublish" : {
|
||||
type: "action",
|
||||
text: tr("Unpublish")
|
||||
},
|
||||
|
||||
"Network.delete" : {
|
||||
type: "action",
|
||||
text: tr("Delete")
|
||||
}
|
||||
}
|
||||
|
||||
var vnet_info_panel = {
|
||||
"vnet_info_tab" : {
|
||||
title: tr("Network information"),
|
||||
content: ""
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
var vnet_create_panel = {
|
||||
"vnet_create_panel" : {
|
||||
title: tr("Create network"),
|
||||
content: create_vn_tmpl
|
||||
},
|
||||
}
|
||||
|
||||
var vnets_tab = {
|
||||
title: tr("Networks"),
|
||||
content: vnets_tab_content,
|
||||
buttons: vnet_buttons
|
||||
}
|
||||
|
||||
Sunstone.addActions(vnet_actions);
|
||||
Sunstone.addMainTab('vnets_tab',vnets_tab);
|
||||
Sunstone.addInfoPanel('vnet_info_panel',vnet_info_panel);
|
||||
Sunstone.addInfoPanel('vnet_create_panel',vnet_create_panel);
|
||||
|
||||
|
||||
function vnElements(){
|
||||
return getSelectedNodes(dataTable_vNetworks);
|
||||
}
|
||||
|
||||
function vnShow(req){
|
||||
//Sunstone.runAction("Network.show",req.request.data[0]);
|
||||
}
|
||||
|
||||
//returns an array with the VNET information fetched from the JSON object
|
||||
function vNetworkElementArray(vn_json){
|
||||
var network = vn_json.NETWORK;
|
||||
|
||||
if (network.name){
|
||||
id = network.href.split("/");
|
||||
id = id[id.length-1];
|
||||
name = network.name;
|
||||
}
|
||||
else {
|
||||
id = network.ID;
|
||||
name = network.NAME;
|
||||
};
|
||||
|
||||
return [
|
||||
'<input class="check_item" type="checkbox" id="vnetwork_'+id+'" name="selected_items" value="'+id+'"/>',
|
||||
id,
|
||||
name
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
//Adds a listener to show the extended info when clicking on a row
|
||||
function vNetworkInfoListener(){
|
||||
|
||||
$('#tbodyvnetworks tr',dataTable_vNetworks).live("click", function(e){
|
||||
if ($(e.target).is('input')) {return true;}
|
||||
popDialogLoading();
|
||||
var aData = dataTable_vNetworks.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
Sunstone.runAction("Network.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
//Callback to update a vnet element after an action on it
|
||||
function updateVNetworkElement(request, vn_json){
|
||||
id = vn_json.NETWORK.ID;
|
||||
element = vNetworkElementArray(vn_json);
|
||||
updateSingleElement(element,dataTable_vNetworks,'#vnetwork_'+id);
|
||||
}
|
||||
|
||||
//Callback to delete a vnet element from the table
|
||||
function deleteVNetworkElement(req){
|
||||
deleteElement(dataTable_vNetworks,'#vnetwork_'+req.request.data);
|
||||
}
|
||||
|
||||
//Callback to add a new element
|
||||
function addVNetworkElement(request,vn_json){
|
||||
var element = vNetworkElementArray(vn_json);
|
||||
addElement(element,dataTable_vNetworks);
|
||||
}
|
||||
|
||||
//updates the list of virtual networks
|
||||
function updateVNetworksView(request, network_list){
|
||||
var network_list_array = [];
|
||||
|
||||
$.each(network_list,function(){
|
||||
network_list_array.push(vNetworkElementArray(this));
|
||||
});
|
||||
|
||||
updateView(network_list_array,dataTable_vNetworks);
|
||||
//dependency with dashboard
|
||||
//updateDashboard("vnets",network_list);
|
||||
|
||||
}
|
||||
|
||||
//updates the information panel tabs and pops the panel up
|
||||
function updateVNetworkInfo(request,vn){
|
||||
var vn_info = vn.NETWORK;
|
||||
var info_tab_content =
|
||||
'<table id="info_vn_table" class="info_table">\
|
||||
<thead>\
|
||||
<tr><th colspan="2">'+tr("Virtual Network")+' '+vn_info.ID+' '+
|
||||
tr("information")+'</th></tr>\
|
||||
</thead>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("ID")+'</td>\
|
||||
<td class="value_td">'+vn_info.ID+'</td>\
|
||||
<tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Name")+'</td>\
|
||||
<td class="value_td">'+vn_info.NAME+'</td>\
|
||||
<tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Public")+'</td>\
|
||||
<td class="value_td">'+ vn_info.PUBLIC.toLowerCase() +'</td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
<div class="form_buttons">\
|
||||
<button class="vnet_close_dialog_link"/></div>';
|
||||
|
||||
var info_tab = {
|
||||
title: tr("Virtual Network information"),
|
||||
content: info_tab_content
|
||||
};
|
||||
|
||||
Sunstone.updateInfoPanelTab("vnet_info_panel","vnet_info_tab",info_tab);
|
||||
|
||||
Sunstone.popUpInfoPanel("vnet_info_panel");
|
||||
$('#dialog .vnet_close_dialog_link').button({
|
||||
text:false,
|
||||
icons: { primary: "ui-icon-closethick" }
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function popUpCreateVnetDialog() {
|
||||
//$create_vn_dialog.dialog('open');
|
||||
//Handle submission of the easy mode
|
||||
Sunstone.popUpInfoPanel("vnet_create_panel");
|
||||
var dialog=$('#dialog');
|
||||
$create_vn_dialog = dialog;
|
||||
|
||||
$('#create_vn',dialog).button({
|
||||
icons: {
|
||||
primary: "ui-icon-check"
|
||||
},
|
||||
text: false
|
||||
});
|
||||
$('#reset_vn',dialog).button({
|
||||
icons: {
|
||||
primary: "ui-icon-document"
|
||||
},
|
||||
text: false
|
||||
});
|
||||
$('.vnet_close_dialog_link',dialog).button({
|
||||
icons: {
|
||||
primary: "ui-icon-closethick"
|
||||
},
|
||||
text: false
|
||||
});
|
||||
|
||||
$('#create_vn_form_easy',dialog).submit(function(){
|
||||
//Fetch values
|
||||
var name = $('#name',this).val();
|
||||
if (!name.length){
|
||||
notifyError(tr("Virtual Network name missing!"));
|
||||
return false;
|
||||
}
|
||||
var bridge = $('#bridge',this).val();
|
||||
|
||||
//TODO: Name and bridge provided?!
|
||||
|
||||
var network_json = null;
|
||||
var network_addr = $('#net_address',this).val();
|
||||
var network_size = $('#net_size',this).val();
|
||||
|
||||
if (!network_addr.length){
|
||||
notifyError(tr("Please provide a network address"));
|
||||
return false;
|
||||
};
|
||||
|
||||
//we form the object for the request
|
||||
network_json = {
|
||||
"SIZE" : network_size,
|
||||
"ADDRESS" : network_addr,
|
||||
"NAME" : name
|
||||
};
|
||||
|
||||
Sunstone.runAction("Network.create",network_json);
|
||||
popUpVNetDashboard();
|
||||
return false;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function popUpVNetDashboard(){
|
||||
var count = dataTable_vNetworks.fnGetNodes().length;
|
||||
popDialog(vnet_dashboard);
|
||||
$('#dialog #vnet_dashboard_count').text(count);
|
||||
}
|
||||
|
||||
function setVNetAutorefresh() {
|
||||
setInterval(function(){
|
||||
var checked = $('input.check_item:checked',dataTable_vNetworks);
|
||||
var filter = $("#datatable_vnetworks_filter input",
|
||||
dataTable_vNetworks.parents("#datatable_vnetworks_wrapper")).attr('value');
|
||||
if (!checked.length && !filter.length){
|
||||
Sunstone.runAction("Network.autorefresh");
|
||||
}
|
||||
},INTERVAL+someTime());
|
||||
};
|
||||
|
||||
//The DOM is ready and the ready() from sunstone.js
|
||||
//has been executed at this point.
|
||||
$(document).ready(function(){
|
||||
|
||||
dataTable_vNetworks = $("#datatable_vnetworks",main_tabs_context).dataTable({
|
||||
"bJQueryUI": true,
|
||||
"bSortClasses": false,
|
||||
"bAutoWidth":false,
|
||||
"sPaginationType": "full_numbers",
|
||||
"aoColumnDefs": [
|
||||
{ "bSortable": false, "aTargets": ["check"] },
|
||||
{ "sWidth": "60px", "aTargets": [0] },
|
||||
{ "sWidth": "35px", "aTargets": [1] },
|
||||
],
|
||||
"oLanguage": (datatable_lang != "") ?
|
||||
{
|
||||
sUrl: "locale/"+lang+"/"+datatable_lang
|
||||
} : ""
|
||||
});
|
||||
|
||||
dataTable_vNetworks.fnClearTable();
|
||||
addElement([
|
||||
spinner,
|
||||
'',''],dataTable_vNetworks);
|
||||
Sunstone.runAction("Network.list");
|
||||
|
||||
setVNetAutorefresh();
|
||||
|
||||
initCheckAllBoxes(dataTable_vNetworks);
|
||||
tableCheckboxesListener(dataTable_vNetworks);
|
||||
vNetworkInfoListener();
|
||||
|
||||
$('#li_vnets_tab a').click(function(){
|
||||
popUpVNetDashboard();
|
||||
//return false;
|
||||
});
|
||||
|
||||
$('.vnet_close_dialog_link').live("click",function(){
|
||||
popUpVNetDashboard();
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
646
src/cloud/occi/lib/ui/public/js/plugins/storage.js
Normal file
@ -0,0 +1,646 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2011, OpenNebula Project Leads (OCCI.org) */
|
||||
/* */
|
||||
/* 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. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/*Images tab plugin*/
|
||||
|
||||
var images_tab_content =
|
||||
'<form id="image_form" action="" action="javascript:alert(\'js error!\');">\
|
||||
<div class="action_blocks">\
|
||||
</div>\
|
||||
<table id="datatable_images" class="display">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th class="check"><input type="checkbox" class="check_all" value="">'+tr("All")+'</input></th>\
|
||||
<th>'+tr("ID")+'</th>\
|
||||
<th>'+tr("Name")+'</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id="tbodyimages">\
|
||||
</tbody>\
|
||||
</table>\
|
||||
</form>';
|
||||
|
||||
var create_image_tmpl =
|
||||
'<div id="img_tabs">\
|
||||
<div id="img_easy">\
|
||||
<form id="create_image_form_easy" method="POST" enctype="multipart/form-data" action="javascript:alert(\'js errors?!\')">\
|
||||
<p style="font-size:0.8em;text-align:right;"><i>'+
|
||||
tr("Fields marked with")+' <span style="display:inline-block;" class="ui-icon ui-icon-alert" /> '+
|
||||
tr("are mandatory")+'</i><br />\
|
||||
<fieldset>\
|
||||
<div class="img_param">\
|
||||
<label for="img_name">'+tr("Name")+':</label>\
|
||||
<input type="text" name="img_name" id="img_name" />\
|
||||
<div class="tip">'+tr("Name that the Image will get. Every image must have a unique name.")+'</div>\
|
||||
</div>\
|
||||
<div class="img_param">\
|
||||
<label for="img_desc">'+tr("Description")+':</label>\
|
||||
<textarea name="img_desc" id="img_desc" style="height:4em"></textarea>\
|
||||
<div class="tip">'+tr("Human readable description of the image for other users.")+'</div>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
<fieldset>\
|
||||
<div class="img_param">\
|
||||
<label for="img_type">'+tr("Type")+':</label>\
|
||||
<select name="img_type" id="img_type">\
|
||||
<option value="OS">'+tr("OS")+'</option>\
|
||||
<option value="CDROM">'+tr("CD-ROM")+'</option>\
|
||||
<option value="DATABLOCK">'+tr("Datablock")+'</option>\
|
||||
</select>\
|
||||
<div class="tip">'+tr("Type of the image, explained in detail in the following section. If omitted, the default value is the one defined in oned.conf (install default is OS).")+'</div>\
|
||||
</div>\
|
||||
<div class="img_param">\
|
||||
<label for="img_size">'+tr("Size")+':</label>\
|
||||
<input type="text" name="img_size" id="img_size" />\
|
||||
<div class="tip">'+tr("Size of the datablock in MB.")+'</div>\
|
||||
</div>\
|
||||
<div class="img_param">\
|
||||
<label for="img_fstype">'+tr("FS type")+':</label>\
|
||||
<input type="text" name="img_fstype" id="img_fstype" />\
|
||||
<div class="tip">'+tr("Type of file system to be built. This can be any value understood by mkfs unix command.")+'</div>\
|
||||
</div>\
|
||||
<div class="img_param" id="upload_div">\
|
||||
<label for="file-uploader" style="width: 60px">'+tr("Upload image")+':</label>\
|
||||
<div id="file-uploader">\
|
||||
</div><div class="clear" />\
|
||||
<label for="upload-progress">'+tr("Upload progress")+':</label>\
|
||||
<div id="upload-progress"></div>\
|
||||
</div>\
|
||||
<!--\
|
||||
<div class="img_param">\
|
||||
<label for="img_public">'+tr("Public")+':</label>\
|
||||
<input type="checkbox" id="img_public" name="img_public" value="YES" />\
|
||||
<div class="tip">'+tr("Public scope of the image")+'</div>\
|
||||
</div>\
|
||||
<div class="img_param">\
|
||||
<label for="img_persistent">'+tr("Persistent")+':</label>\
|
||||
<input type="checkbox" id="img_persistent" name="img_persistent" value="YES" />\
|
||||
<div class="tip">'+tr("Persistence of the image")+'</div>\
|
||||
</div>\
|
||||
<div class="img_param">\
|
||||
-->\
|
||||
<div class="form_buttons">\
|
||||
<button class="image_close_dialog_link"/>\
|
||||
<button class="button" id="create_image" value="Image.create" />\
|
||||
<button class="button" type="reset" id="reset_image" value="reset" />\
|
||||
</div>\
|
||||
</form>\
|
||||
</div>\
|
||||
</div>';
|
||||
|
||||
var image_dashboard = '<div class="dashboard_p">\
|
||||
<img class="dashboard_img" src="images/one-storage.png" alt="one-storage" />\
|
||||
<p>'+tr("The Storage view offers you an overview of your current images. Storage elements are attached to compute resources at creation time. They can also be extracted from running virtual machines by taking an snapshot.")+'</p>\
|
||||
<p>'+tr("You can add new storages by clicking \"new\". Image files will be uploaded to OpenNebula and set ready to be used.")+'</p>\
|
||||
<p>'+tr("Additionally, you can run several operations on defined storages, such as defining their persistance. Persistent images can only be used by 1 virtual machine, and the changes made by it have effect on the base image. Non-persistent images are cloned before being used in a Virtual Machine, therefore changes are lost unless a snapshot is taken prior to Virtual Machine shutdown.")+'</p>\
|
||||
<p>'+tr("There are currently")+' <b><span id="image_dashboard_count" /></b> '+tr("images")+'.</p>\
|
||||
</div>';
|
||||
|
||||
var dataTable_images;
|
||||
var $create_image_dialog;
|
||||
|
||||
var image_actions = {
|
||||
|
||||
"Image.create" : {
|
||||
type: "create",
|
||||
call: OCCI.Image.create,
|
||||
callback: addImageElement,
|
||||
error: onError,
|
||||
notify:true
|
||||
},
|
||||
|
||||
"Image.create_dialog" : {
|
||||
type: "custom",
|
||||
call: popUpCreateImageDialog
|
||||
},
|
||||
|
||||
"Image.list" : {
|
||||
type: "list",
|
||||
call: OCCI.Image.list,
|
||||
callback: updateImagesView,
|
||||
error: onError
|
||||
},
|
||||
|
||||
"Image.show" : {
|
||||
type : "single",
|
||||
call: OCCI.Image.show,
|
||||
callback: updateImageElement,
|
||||
error: onError
|
||||
},
|
||||
|
||||
"Image.showinfo" : {
|
||||
type: "single",
|
||||
call: OCCI.Image.show,
|
||||
callback: updateImageInfo,
|
||||
error: onError
|
||||
},
|
||||
|
||||
"Image.refresh" : {
|
||||
type: "custom",
|
||||
call: function () {
|
||||
waitingNodes(dataTable_images);
|
||||
Sunstone.runAction("Image.list");
|
||||
},
|
||||
},
|
||||
|
||||
"Image.autorefresh" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
OCCI.Image.list({timeout: true, success: updateImagesView, error: onError});
|
||||
}
|
||||
},
|
||||
|
||||
"Image.persistent" : {
|
||||
type: "multiple",
|
||||
call: OCCI.Image.persistent,
|
||||
callback: function (req) {
|
||||
//Sunstone.runAction("Image.show",req.request.data[0]);
|
||||
},
|
||||
elements: imageElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Image.nonpersistent" : {
|
||||
type: "multiple",
|
||||
call: OCCI.Image.nonpersistent,
|
||||
callback: function (req) {
|
||||
//Sunstone.runAction("Image.show",req.request.data[0]);
|
||||
},
|
||||
elements: imageElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Image.publish" : {
|
||||
type: "multiple",
|
||||
call: OCCI.Image.publish,
|
||||
callback: function (req) {
|
||||
//Sunstone.runAction("Image.show",req.request.data[0]);
|
||||
},
|
||||
elements: imageElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Image.unpublish" : {
|
||||
type: "multiple",
|
||||
call: OCCI.Image.unpublish,
|
||||
callback: function (req) {
|
||||
//Sunstone.runAction("Image.show",req.request.data[0]);
|
||||
},
|
||||
elements: imageElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Image.delete" : {
|
||||
type: "multiple",
|
||||
call: OCCI.Image.delete,
|
||||
callback: deleteImageElement,
|
||||
elements: imageElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
var image_buttons = {
|
||||
"Image.refresh" : {
|
||||
type: "image",
|
||||
text: tr("Refresh list"),
|
||||
img: "images/Refresh-icon.png"
|
||||
},
|
||||
"Image.create_dialog" : {
|
||||
type: "create_dialog",
|
||||
text: tr('+ New')
|
||||
},
|
||||
"Image.update_dialog" : {
|
||||
type: "action",
|
||||
text: tr("Update a template"),
|
||||
alwaysActive: true
|
||||
},
|
||||
"action_list" : {
|
||||
type: "select",
|
||||
actions: {
|
||||
"Image.publish" : {
|
||||
type: "action",
|
||||
text: tr("Publish")
|
||||
},
|
||||
"Image.unpublish" : {
|
||||
type: "action",
|
||||
text: tr("Unpublish")
|
||||
},
|
||||
"Image.persistent" : {
|
||||
type: "action",
|
||||
text: tr("Make persistent")
|
||||
},
|
||||
"Image.nonpersistent" : {
|
||||
type: "action",
|
||||
text: tr("Make non persistent")
|
||||
}
|
||||
}
|
||||
},
|
||||
"Image.delete" : {
|
||||
type: "action",
|
||||
text: tr("Delete")
|
||||
}
|
||||
}
|
||||
|
||||
var image_info_panel = {
|
||||
"image_info_tab" : {
|
||||
title: tr("Image information"),
|
||||
content: ""
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
var image_create_panel = {
|
||||
"image_create_panel" : {
|
||||
title: tr("Add storage"),
|
||||
content: create_image_tmpl
|
||||
},
|
||||
};
|
||||
|
||||
var images_tab = {
|
||||
title: tr("Storage"),
|
||||
content: images_tab_content,
|
||||
buttons: image_buttons
|
||||
}
|
||||
|
||||
Sunstone.addActions(image_actions);
|
||||
Sunstone.addMainTab('images_tab',images_tab);
|
||||
Sunstone.addInfoPanel('image_info_panel',image_info_panel);
|
||||
Sunstone.addInfoPanel('image_create_panel',image_create_panel);
|
||||
|
||||
|
||||
function imageElements() {
|
||||
return getSelectedNodes(dataTable_images);
|
||||
}
|
||||
|
||||
// Returns an array containing the values of the image_json and ready
|
||||
// to be inserted in the dataTable
|
||||
function imageElementArray(image_json){
|
||||
//Changing this? It may affect to the is_public() and is_persistent() functions.
|
||||
var image = image_json.STORAGE;
|
||||
var id,name;
|
||||
|
||||
if (image.name){
|
||||
id = image.href.split("/");
|
||||
id = id[id.length-1];
|
||||
name = image.name;
|
||||
}
|
||||
else {
|
||||
id = image.ID;
|
||||
name = image.NAME;
|
||||
};
|
||||
|
||||
return [
|
||||
'<input class="check_item" type="checkbox" id="image_'+id+'" name="selected_items" value="'+id+'"/>',
|
||||
id,
|
||||
name
|
||||
];
|
||||
}
|
||||
|
||||
// Set up the listener on the table TDs to show the info panel
|
||||
function imageInfoListener(){
|
||||
$('#tbodyimages tr',dataTable_images).live("click",function(e){
|
||||
var target = $(e.target);
|
||||
|
||||
if (target.is('input') || target.is('select') || target.is('option'))
|
||||
return true;
|
||||
|
||||
popDialogLoading();
|
||||
var aData = dataTable_images.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
Sunstone.runAction("Image.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// Callback to update an element in the dataTable
|
||||
function updateImageElement(request, image_json){
|
||||
var id = image_json.STORAGE.ID;
|
||||
var element = imageElementArray(image_json);
|
||||
updateSingleElement(element,dataTable_images,'#image_'+id);
|
||||
}
|
||||
|
||||
// Callback to remove an element from the dataTable
|
||||
function deleteImageElement(req){
|
||||
deleteElement(dataTable_images,'#image_'+req.request.data);
|
||||
}
|
||||
|
||||
// Callback to add an image element
|
||||
function addImageElement(request, image_json){
|
||||
var element = imageElementArray(image_json);
|
||||
addElement(element,dataTable_images);
|
||||
}
|
||||
|
||||
// Callback to refresh the list of images
|
||||
function updateImagesView(request, images_list){
|
||||
var image_list_array = [];
|
||||
|
||||
$.each(images_list,function(){
|
||||
image_list_array.push(imageElementArray(this));
|
||||
});
|
||||
|
||||
updateView(image_list_array,dataTable_images);
|
||||
//updateDashboard("images",images_list);
|
||||
}
|
||||
|
||||
// Callback to update the information panel tabs and pop it up
|
||||
function updateImageInfo(request,img){
|
||||
var img_info = img.STORAGE;
|
||||
var info_tab = {
|
||||
title: tr("Image information"),
|
||||
content:
|
||||
'<table id="info_img_table" class="info_table" style="width:80%;">\
|
||||
<thead>\
|
||||
<tr><th colspan="2">'+tr("Image")+' "'+img_info.NAME+'" '+
|
||||
tr("information")+'</th></tr>\
|
||||
</thead>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("ID")+'</td>\
|
||||
<td class="value_td">'+img_info.ID+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Name")+'</td>\
|
||||
<td class="value_td">'+img_info.NAME+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Type")+'</td>\
|
||||
<td class="value_td">'+OCCI.Helper.image_type(img_info.TYPE)+'</td>\
|
||||
</tr>\
|
||||
<td class="key_td">'+tr("Public")+'</td>\
|
||||
<td class="value_td">'+img_info.PUBLIC.toLowerCase()+'</td>\
|
||||
</tr>\
|
||||
</tr>\
|
||||
<td class="key_td">'+tr("Persistent")+'</td>\
|
||||
<td class="value_td">'+img_info.PERSISTENT.toLowerCase()+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Filesystem type")+'</td>\
|
||||
<td class="value_td">'+(typeof img_info.FSTYPE === "string" ? img_info.FSTYPE : "--")+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Size (Mb)")+'</td>\
|
||||
<td class="value_td">'+img_info.SIZE+'</td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
<div class="form_buttons">\
|
||||
<button class="image_close_dialog_link"/></div>'
|
||||
};
|
||||
|
||||
Sunstone.updateInfoPanelTab("image_info_panel","image_info_tab",info_tab);
|
||||
Sunstone.popUpInfoPanel("image_info_panel");
|
||||
$('#dialog .image_close_dialog_link').button({
|
||||
text:false,
|
||||
icons: { primary: "ui-icon-closethick" }
|
||||
});
|
||||
}
|
||||
|
||||
function popUpCreateImageDialog(){
|
||||
Sunstone.popUpInfoPanel("image_create_panel");
|
||||
var dialog = $('#dialog');
|
||||
$create_image_dialog = dialog;
|
||||
|
||||
$('#create_image',dialog).button({
|
||||
icons: {
|
||||
primary: "ui-icon-check"
|
||||
},
|
||||
text: false
|
||||
});
|
||||
$('#reset_image',dialog).button({
|
||||
icons: {
|
||||
primary: "ui-icon-document"
|
||||
},
|
||||
text: false
|
||||
});
|
||||
$('.image_close_dialog_link',dialog).button({
|
||||
icons: {
|
||||
primary: "ui-icon-closethick"
|
||||
},
|
||||
text: false
|
||||
});
|
||||
|
||||
setupTips(dialog);
|
||||
|
||||
$('#img_fstype',dialog).parents('div.img_param').hide();
|
||||
$('#img_size',dialog).parents('div.img_param').hide();
|
||||
|
||||
$('#img_public',dialog).click(function(){
|
||||
$('#img_persistent',$create_image_dialog).removeAttr('checked');
|
||||
});
|
||||
|
||||
$('#img_persistent',dialog).click(function(){
|
||||
$('#img_public',$create_image_dialog).removeAttr('checked');
|
||||
});
|
||||
|
||||
$('#img_type',dialog).change(function(){
|
||||
if ($(this).val() == "DATABLOCK"){
|
||||
$('#img_fstype',$create_image_dialog).parents('div.img_param').show();
|
||||
$('#img_size',$create_image_dialog).parents('div.img_param').show();
|
||||
$('#upload_div',$create_image_dialog).hide();
|
||||
} else {
|
||||
$('#img_fstype',$create_image_dialog).parents('div.img_param').hide();
|
||||
$('#img_size',$create_image_dialog).parents('div.img_param').hide();
|
||||
$('#upload_div',$create_image_dialog).show();
|
||||
};
|
||||
});
|
||||
|
||||
$('#upload-progress',dialog).progressbar({value:0});
|
||||
$('#upload-progress',dialog).css({
|
||||
border: "1px solid #AAAAAA",
|
||||
position: "relative",
|
||||
// bottom: "29px",
|
||||
width: "210px",
|
||||
// left: "133px",
|
||||
height: "15px",
|
||||
display: "inline-block",
|
||||
});
|
||||
$('#upload-progress div',dialog).css("border","1px solid #AAAAAA");
|
||||
|
||||
var img_obj;
|
||||
|
||||
var uploader = new qq.FileUploaderBasic({
|
||||
button: $('#file-uploader',$create_image_dialog)[0],
|
||||
action: 'ui/upload',
|
||||
multiple: false,
|
||||
params: {},
|
||||
showMessage: function(message){
|
||||
notifyMessage(message);
|
||||
},
|
||||
onSubmit: function(id, fileName){
|
||||
var xml = json2xml(img_obj,"STORAGE");
|
||||
|
||||
uploader.setParams({
|
||||
occixml : xml,
|
||||
file: fileName
|
||||
});
|
||||
|
||||
$('#upload-progress',dialog).show();
|
||||
},
|
||||
onProgress: function(id, fileName, loaded, total){
|
||||
$('#upload-progress',dialog).progressbar("option","value",Math.floor(loaded*100/total));
|
||||
},
|
||||
onComplete: function(id, fileName, responseJSON){
|
||||
popUpImageDashboard();
|
||||
notifyMessage("Image uploaded correctly");
|
||||
Sunstone.runAction("Image.list");
|
||||
return false;
|
||||
},
|
||||
onCancel: function(id, fileName){
|
||||
},
|
||||
});
|
||||
|
||||
var file_input = false;
|
||||
uploader._button._options.onChange = function(input) {
|
||||
file_input = input; return false;
|
||||
};
|
||||
|
||||
$('#file-uploader input').removeAttr("style");
|
||||
|
||||
var processCreateImageForm = function(){
|
||||
var dialog = $create_image_dialog;
|
||||
|
||||
var img_json = {};
|
||||
|
||||
var name = $('#img_name',dialog).val();
|
||||
if (!name){
|
||||
notifyError(tr("You must specify a name"));
|
||||
return false;
|
||||
};
|
||||
img_json["NAME"] = name;
|
||||
|
||||
|
||||
var desc = $('#img_desc',dialog).val();
|
||||
if (desc){
|
||||
img_json["DESCRIPTION"] = desc;
|
||||
}
|
||||
|
||||
var type = $('#img_type',dialog).val();
|
||||
img_json["TYPE"]= type;
|
||||
|
||||
if (type == "DATABLOCK"){
|
||||
var fstype = $('#img_fstype',dialog).val();
|
||||
var im_size = $('#img_size',dialog).val();
|
||||
if (!fstype || !im_size){
|
||||
notifyError(tr("You must specify size and FS type"));
|
||||
return false;
|
||||
};
|
||||
img_json["FSTYPE"] = fstype;
|
||||
img_json["SIZE"] = im_size;
|
||||
} else {
|
||||
if (!$('#file-uploader input').val()){
|
||||
notifyError(tr("You must select a file to upload"));
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
//img_json["PUBLIC"] = $('#img_public:checked',this).length ? "YES" : "NO";
|
||||
|
||||
//img_json["PERSISTENT"] = $('#img_persistent:checked',this).length ? "YES" : "NO";
|
||||
|
||||
return img_json;
|
||||
};
|
||||
|
||||
$('#create_image_form_easy',dialog).submit(function(){
|
||||
var type = $('#img_type',dialog).val();
|
||||
img_obj = processCreateImageForm();
|
||||
if (!img_obj) return false;
|
||||
if (type == "DATABLOCK"){
|
||||
Sunstone.runAction("Image.create",img_obj);
|
||||
popUpImageDashboard();
|
||||
} else {
|
||||
uploader._onInputChange(file_input);
|
||||
};
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function popUpImageDashboard(){
|
||||
var count = dataTable_images.fnGetNodes().length;
|
||||
popDialog(image_dashboard);
|
||||
$('#dialog #image_dashboard_count').text(count);
|
||||
};
|
||||
|
||||
// Set the autorefresh interval for the datatable
|
||||
function setImageAutorefresh() {
|
||||
setInterval(function(){
|
||||
var checked = $('input.check_item:checked',dataTable_images);
|
||||
var filter = $("#datatable_images_filter input",
|
||||
dataTable_images.parents("#datatable_images_wrapper")).attr('value');
|
||||
if (!checked.length && !filter.length){
|
||||
Sunstone.runAction("Image.autorefresh");
|
||||
}
|
||||
},INTERVAL+someTime());
|
||||
};
|
||||
|
||||
/*
|
||||
function is_public_image(id){
|
||||
var data = getElementData(id,"#image",dataTable_images)[7];
|
||||
return $(data).attr('checked');
|
||||
};
|
||||
|
||||
function is_persistent_image(id){
|
||||
var data = getElementData(id,"#image",dataTable_images)[8];
|
||||
return $(data).attr('checked');
|
||||
};
|
||||
*/
|
||||
|
||||
//The DOM is ready at this point
|
||||
$(document).ready(function(){
|
||||
|
||||
dataTable_images = $("#datatable_images",main_tabs_context).dataTable({
|
||||
"bJQueryUI": true,
|
||||
"bSortClasses": false,
|
||||
"bAutoWidth":false,
|
||||
"sPaginationType": "full_numbers",
|
||||
"aoColumnDefs": [
|
||||
{ "bSortable": false, "aTargets": ["check"] },
|
||||
{ "sWidth": "60px", "aTargets": [0] },
|
||||
{ "sWidth": "35px", "aTargets": [1] },
|
||||
],
|
||||
"oLanguage": (datatable_lang != "") ?
|
||||
{
|
||||
sUrl: "locale/"+lang+"/"+datatable_lang
|
||||
} : ""
|
||||
});
|
||||
|
||||
dataTable_images.fnClearTable();
|
||||
addElement([
|
||||
spinner,
|
||||
'',''],dataTable_images);
|
||||
Sunstone.runAction("Image.list");
|
||||
|
||||
setImageAutorefresh();
|
||||
|
||||
initCheckAllBoxes(dataTable_images);
|
||||
tableCheckboxesListener(dataTable_images);
|
||||
imageInfoListener();
|
||||
|
||||
$('#li_images_tab a').click(function(){
|
||||
popUpImageDashboard();
|
||||
//return false;
|
||||
});
|
||||
|
||||
$('.image_close_dialog_link').live("click",function(){
|
||||
popUpVNetDashboard();
|
||||
return false;
|
||||
});
|
||||
|
||||
})
|
@ -1,482 +0,0 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) */
|
||||
/* */
|
||||
/* 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 users_select="";
|
||||
var $create_user_dialog;
|
||||
var $update_pw_dialog;
|
||||
|
||||
var users_tab_content =
|
||||
'<form id="user_form" action="" action="javascript:alert(\'js error!\');">\
|
||||
<div class="action_blocks">\
|
||||
</div>\
|
||||
<table id="datatable_users" class="display">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th class="check"><input type="checkbox" class="check_all" value="">'+tr("All")+'</input></th>\
|
||||
<th>'+tr("ID")+'</th>\
|
||||
<th>'+tr("Name")+'</th>\
|
||||
<th>'+tr("Group")+'</th>\
|
||||
<th>'+tr("Authentication driver")+'</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id="tbodyusers">\
|
||||
</tbody>\
|
||||
</table>\
|
||||
</form>';
|
||||
|
||||
var create_user_tmpl =
|
||||
'<form id="create_user_form" action="">\
|
||||
<fieldset>\
|
||||
<div>\
|
||||
<label for="username">'+tr("Username")+':</label>\
|
||||
<input type="text" name="username" id="username" /><br />\
|
||||
<label for="pass">'+tr("Password")+':</label>\
|
||||
<input type="password" name="pass" id="pass" />\
|
||||
<label for="driver">'+tr("Authentication")+':</label>\
|
||||
<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="server_cipher">'+tr("Server (Cipher)")+'</option>\
|
||||
<option value="server_x509">'+tr("Server (x509)")+'</option>\
|
||||
<option value="public">'+tr("Public")+'</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
<fieldset>\
|
||||
<div class="form_buttons">\
|
||||
<button class="button" id="create_user_submit" value="user/create">Create</button>\
|
||||
<button class="button" type="reset" value="reset">Reset</button>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
</form>';
|
||||
|
||||
var update_pw_tmpl = '<form id="update_user_pw_form" action="">\
|
||||
<fieldset>\
|
||||
<div>\
|
||||
<div>'+tr("This will change the password for the selected users")+':</div>\
|
||||
<label for="new_password">'+tr("New password")+':</label>\
|
||||
<input type="password" name="new_password" id="new_password" />\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
<fieldset>\
|
||||
<div class="form_buttons">\
|
||||
<button class="button" id="update_pw_submit" value="User.update">'+tr("Change")+'</button>\
|
||||
<button class="button" type="reset" value="reset">'+tr("Reset")+'</button>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
</form>';
|
||||
|
||||
|
||||
var user_actions = {
|
||||
"User.create" : {
|
||||
type: "create",
|
||||
call: OpenNebula.User.create,
|
||||
callback: addUserElement,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"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 () {
|
||||
waitingNodes(dataTable_users);
|
||||
Sunstone.runAction("User.list");
|
||||
},
|
||||
},
|
||||
|
||||
"User.autorefresh" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
OpenNebula.User.list({
|
||||
timeout: true,
|
||||
success: updateUsersView,
|
||||
error: onError
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
"User.update_password" : {
|
||||
type: "custom",
|
||||
call: popUpUpdatePasswordDialog
|
||||
},
|
||||
|
||||
"User.passwd" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.User.passwd,
|
||||
//nocallback
|
||||
elements: userElements,
|
||||
error: onError
|
||||
},
|
||||
"User.chgrp" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.User.chgrp,
|
||||
callback : function(req){
|
||||
Sunstone.runAction("User.show",req.request.data[0]);
|
||||
},
|
||||
elements : userElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"User.chauth" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.User.chauth,
|
||||
callback : function(req){
|
||||
Sunstone.runAction("User.show",req.request.data[0]);
|
||||
},
|
||||
elements: userElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
// "User.addgroup" : {
|
||||
// type: "multiple",
|
||||
// call: OpenNebula.User.addgroup,
|
||||
// callback : function(req){
|
||||
// Sunstone.runAction("User.show",req.request.data[0]);
|
||||
// },
|
||||
// elements : function() {return getSelectedNodes(dataTable_users);},
|
||||
// error: onError,
|
||||
// notify: true
|
||||
// },
|
||||
|
||||
// "User.delgroup" : {
|
||||
// type: "multiple",
|
||||
// call: OpenNebula.User.delgroup,
|
||||
// callback : function(req){
|
||||
// Sunstone.runAction("User.show",req.request.data[0]);
|
||||
// },
|
||||
// elements : function() {return getSelectedNodes(dataTable_users);},
|
||||
// error: onError,
|
||||
// notify: true
|
||||
// },
|
||||
|
||||
"User.show" : {
|
||||
type: "single",
|
||||
call: OpenNebula.User.show,
|
||||
callback: updateUserElement,
|
||||
error: onError
|
||||
},
|
||||
|
||||
"User.delete" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.User.delete,
|
||||
callback: deleteUserElement,
|
||||
elements: userElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"User.fetch_template" : {
|
||||
type: "single",
|
||||
call: OpenNebula.User.fetch_template,
|
||||
callback: function (request,response) {
|
||||
$('#template_update_dialog #template_update_textarea').val(response.template);
|
||||
},
|
||||
error: onError
|
||||
},
|
||||
|
||||
"User.update_dialog" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
popUpTemplateUpdateDialog("User",
|
||||
makeSelectOptions(dataTable_users,
|
||||
1,//id_col
|
||||
2,//name_col
|
||||
[],
|
||||
[]
|
||||
),
|
||||
getSelectedNodes(dataTable_users));
|
||||
}
|
||||
},
|
||||
|
||||
"User.update" : {
|
||||
type: "single",
|
||||
call: OpenNebula.User.update,
|
||||
callback: function() {
|
||||
notifyMessage(tr("Template updated correctly"));
|
||||
},
|
||||
error: onError
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var user_buttons = {
|
||||
"User.refresh" : {
|
||||
type: "image",
|
||||
text: tr("Refresh list"),
|
||||
img: "images/Refresh-icon.png"
|
||||
},
|
||||
"User.create_dialog" : {
|
||||
type: "create_dialog",
|
||||
text: tr("+ New")
|
||||
},
|
||||
"User.update_dialog" : {
|
||||
type: "action",
|
||||
text: tr("Update a template"),
|
||||
alwaysActive: true
|
||||
},
|
||||
"User.update_password" : {
|
||||
type : "action",
|
||||
text : tr("Change password"),
|
||||
},
|
||||
"User.chgrp" : {
|
||||
type: "confirm_with_select",
|
||||
text: tr("Change group"),
|
||||
select: groups_sel,
|
||||
tip: tr("This will change the main group of the selected users. Select the new group")+":"
|
||||
},
|
||||
"User.chauth" : {
|
||||
type: "confirm_with_select",
|
||||
text: tr("Change authentication"),
|
||||
select: function() {
|
||||
return '<option value="core" selected="selected">'+tr("Core")+'</option>\
|
||||
<option value="ssh">'+tr("SSH")+'</option>\
|
||||
<option value="x509">'+tr("x509")+'</option>\
|
||||
<option value="server_cipher">'+tr("Server (Cipher)")+'</option>\
|
||||
<option value="server_x509">'+tr("Server (x509)")+'</option>\
|
||||
<option value="public">'+tr("Public")+'</option>'
|
||||
},
|
||||
tip: tr("Please choose the new type of authentication for the selected users")+":"
|
||||
},
|
||||
// "User.addgroup" : {
|
||||
// type: "confirm_with_select",
|
||||
// text: "Add to group",
|
||||
// select: function(){ return groups_select; },
|
||||
// tip: "Select the new group to add users:",
|
||||
// condition: True
|
||||
// },
|
||||
// "User.delgroup" : {
|
||||
// type: "confirm_with_select",
|
||||
// text: "Delete from group",
|
||||
// select: function(){ return groups_select; },
|
||||
// tip: "Select the group from which to delete users:",
|
||||
// condition: True
|
||||
// },
|
||||
"User.delete" : {
|
||||
type: "action",
|
||||
text: "Delete"
|
||||
}
|
||||
}
|
||||
|
||||
var users_tab = {
|
||||
title: tr("Users"),
|
||||
content: users_tab_content,
|
||||
buttons: user_buttons
|
||||
}
|
||||
|
||||
Sunstone.addActions(user_actions);
|
||||
Sunstone.addMainTab('users_tab',users_tab);
|
||||
|
||||
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;
|
||||
|
||||
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
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
function updateUserSelect(){
|
||||
users_select = makeSelectOptions(dataTable_users,
|
||||
1,//id_col
|
||||
2,//name_col
|
||||
[],//status_cols
|
||||
[]//bad status values
|
||||
);
|
||||
}
|
||||
|
||||
// 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);
|
||||
updateUserSelect();
|
||||
}
|
||||
|
||||
// Callback to add a single user element
|
||||
function addUserElement(request,user_json){
|
||||
var element = userElementArray(user_json);
|
||||
addElement(element,dataTable_users);
|
||||
updateUserSelect();
|
||||
}
|
||||
|
||||
// Callback to update the list of users
|
||||
function updateUsersView(request,users_list){
|
||||
var user_list_array = [];
|
||||
|
||||
$.each(users_list,function(){
|
||||
user_list_array.push(userElementArray(this));
|
||||
});
|
||||
updateView(user_list_array,dataTable_users);
|
||||
updateDashboard("users",users_list);
|
||||
updateUserSelect();
|
||||
}
|
||||
|
||||
// Prepare the user creation dialog
|
||||
function setupCreateUserDialog(){
|
||||
dialogs_context.append('<div title=\"'+tr("Create user")+'\" id="create_user_dialog"></div>');
|
||||
$create_user_dialog = $('#create_user_dialog',dialogs_context);
|
||||
var dialog = $create_user_dialog;
|
||||
dialog.html(create_user_tmpl);
|
||||
|
||||
//Prepare jquery dialog
|
||||
dialog.dialog({
|
||||
autoOpen: false,
|
||||
modal:true,
|
||||
width: 400
|
||||
});
|
||||
|
||||
$('button',dialog).button();
|
||||
|
||||
$('#create_user_form',dialog).submit(function(){
|
||||
var user_name=$('#username',this).val();
|
||||
var user_password=$('#pass',this).val();
|
||||
var driver = $('#driver', this).val();
|
||||
|
||||
if (!user_name.length || !user_password.length){
|
||||
notifyError(tr("User name and password must be filled in"));
|
||||
return false;
|
||||
}
|
||||
|
||||
var user_json = { "user" :
|
||||
{ "name" : user_name,
|
||||
"password" : user_password,
|
||||
"auth_driver" : driver
|
||||
}
|
||||
};
|
||||
Sunstone.runAction("User.create",user_json);
|
||||
$create_user_dialog.dialog('close');
|
||||
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);
|
||||
|
||||
//Prepare jquery dialog
|
||||
dialog.dialog({
|
||||
autoOpen: false,
|
||||
modal:true,
|
||||
width: 400
|
||||
});
|
||||
|
||||
$('button',dialog).button();
|
||||
|
||||
$('#update_user_pw_form',dialog).submit(function(){
|
||||
var pw=$('#new_password',this).val();
|
||||
|
||||
if (!pw.length){
|
||||
notifyError(tr("Fill in a new password"));
|
||||
return false;
|
||||
}
|
||||
|
||||
Sunstone.runAction("User.passwd",getSelectedNodes(dataTable_users),pw);
|
||||
$update_pw_dialog.dialog('close');
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
function popUpCreateUserDialog(){
|
||||
$create_user_dialog.dialog('open');
|
||||
}
|
||||
|
||||
|
||||
function popUpUpdatePasswordDialog(){
|
||||
$update_pw_dialog.dialog('open');
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Prepare the autorefresh of the list
|
||||
function setUserAutorefresh(){
|
||||
setInterval(function(){
|
||||
var checked = $('input.check_item:checked',dataTable_users);
|
||||
var filter = $("#datatable_users_filter input",
|
||||
dataTable_users.parents("#datatable_users_wrapper")).attr('value');
|
||||
if (!checked.length && !filter.length){
|
||||
Sunstone.runAction("User.autorefresh");
|
||||
}
|
||||
},INTERVAL+someTime());
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
//if we are not oneadmin, our tab will not even be in the DOM.
|
||||
dataTable_users = $("#datatable_users",main_tabs_context).dataTable({
|
||||
"bJQueryUI": true,
|
||||
"bSortClasses": false,
|
||||
"sPaginationType": "full_numbers",
|
||||
"bAutoWidth":false,
|
||||
"aoColumnDefs": [
|
||||
{ "bSortable": false, "aTargets": ["check"] },
|
||||
{ "sWidth": "60px", "aTargets": [0] },
|
||||
{ "sWidth": "35px", "aTargets": [1] },
|
||||
{ "sWidth": "150px", "aTargets": [4] }
|
||||
],
|
||||
"oLanguage": (datatable_lang != "") ?
|
||||
{
|
||||
sUrl: "locale/"+lang+"/"+datatable_lang
|
||||
} : ""
|
||||
});
|
||||
dataTable_users.fnClearTable();
|
||||
addElement([
|
||||
spinner,
|
||||
'','','',''],dataTable_users);
|
||||
|
||||
Sunstone.runAction("User.list");
|
||||
|
||||
setupCreateUserDialog();
|
||||
setupUpdatePasswordDialog();
|
||||
setUserAutorefresh();
|
||||
|
||||
initCheckAllBoxes(dataTable_users);
|
||||
tableCheckboxesListener(dataTable_users);
|
||||
//shortenedInfoFields('#datatable_users');
|
||||
|
||||
})
|
@ -498,9 +498,11 @@ function getSelectedNodes(dataTable){
|
||||
function makeSelectOptions(dataTable,
|
||||
id_col,name_col,
|
||||
status_cols,
|
||||
bad_status_values){
|
||||
bad_status_values,no_empty_opt){
|
||||
var nodes = dataTable.fnGetData();
|
||||
var select = '<option class="empty_value" value="">'+tr("Please select")+'</option>';
|
||||
var select = "";
|
||||
if (!no_empty_opt)
|
||||
select = '<option class="empty_value" value="">'+tr("Please select")+'</option>';
|
||||
var array;
|
||||
for (var j=0; j<nodes.length;j++){
|
||||
var elem = nodes[j];
|
||||
|
@ -366,6 +366,11 @@ $(document).ready(function(){
|
||||
$('.action_blocks .action_list:visible',main_tabs_context).hide();
|
||||
});
|
||||
|
||||
$('.close_dialog_link').live("click",function(){
|
||||
hideDialog();
|
||||
return false;
|
||||
});
|
||||
|
||||
//Start with the dashboard (supposing we have one).
|
||||
showTab('#dashboard_tab');
|
||||
|
||||
|
12
src/cloud/occi/lib/ui/public/vendor/crypto-js/2.3.0-crypto-sha1.js
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Crypto-JS v2.3.0
|
||||
* http://code.google.com/p/crypto-js/
|
||||
* Copyright (c) 2011, Jeff Mott. All rights reserved.
|
||||
* http://code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
if(typeof Crypto=="undefined"||!Crypto.util)(function(){var k=window.Crypto={},l=k.util={rotl:function(a,c){return a<<c|a>>>32-c},rotr:function(a,c){return a<<32-c|a>>>c},endian:function(a){if(a.constructor==Number)return l.rotl(a,8)&16711935|l.rotl(a,24)&4278255360;for(var c=0;c<a.length;c++)a[c]=l.endian(a[c]);return a},randomBytes:function(a){for(var c=[];a>0;a--)c.push(Math.floor(Math.random()*256));return c},bytesToWords:function(a){for(var c=[],b=0,d=0;b<a.length;b++,d+=8)c[d>>>5]|=a[b]<<24-
|
||||
d%32;return c},wordsToBytes:function(a){for(var c=[],b=0;b<a.length*32;b+=8)c.push(a[b>>>5]>>>24-b%32&255);return c},bytesToHex:function(a){for(var c=[],b=0;b<a.length;b++){c.push((a[b]>>>4).toString(16));c.push((a[b]&15).toString(16))}return c.join("")},hexToBytes:function(a){for(var c=[],b=0;b<a.length;b+=2)c.push(parseInt(a.substr(b,2),16));return c},bytesToBase64:function(a){if(typeof btoa=="function")return btoa(m.bytesToString(a));for(var c=[],b=0;b<a.length;b+=3)for(var d=a[b]<<16|a[b+1]<<
|
||||
8|a[b+2],e=0;e<4;e++)b*8+e*6<=a.length*8?c.push("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d>>>6*(3-e)&63)):c.push("=");return c.join("")},base64ToBytes:function(a){if(typeof atob=="function")return m.stringToBytes(atob(a));a=a.replace(/[^A-Z0-9+\/]/ig,"");for(var c=[],b=0,d=0;b<a.length;d=++b%4)d!=0&&c.push(("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(b-1))&Math.pow(2,-2*d+8)-1)<<d*2|"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(b))>>>
|
||||
6-d*2);return c}};k=k.charenc={};k.UTF8={stringToBytes:function(a){return m.stringToBytes(unescape(encodeURIComponent(a)))},bytesToString:function(a){return decodeURIComponent(escape(m.bytesToString(a)))}};var m=k.Binary={stringToBytes:function(a){for(var c=[],b=0;b<a.length;b++)c.push(a.charCodeAt(b)&255);return c},bytesToString:function(a){for(var c=[],b=0;b<a.length;b++)c.push(String.fromCharCode(a[b]));return c.join("")}}})();
|
||||
(function(){var k=Crypto,l=k.util,m=k.charenc,a=m.UTF8,c=m.Binary,b=k.SHA1=function(d,e){var g=l.wordsToBytes(b._sha1(d));return e&&e.asBytes?g:e&&e.asString?c.bytesToString(g):l.bytesToHex(g)};b._sha1=function(d){if(d.constructor==String)d=a.stringToBytes(d);var e=l.bytesToWords(d),g=d.length*8;d=[];var n=1732584193,h=-271733879,i=-1732584194,j=271733878,o=-1009589776;e[g>>5]|=128<<24-g%32;e[(g+64>>>9<<4)+15]=g;for(g=0;g<e.length;g+=16){for(var q=n,r=h,s=i,t=j,u=o,f=0;f<80;f++){if(f<16)d[f]=e[g+
|
||||
f];else{var p=d[f-3]^d[f-8]^d[f-14]^d[f-16];d[f]=p<<1|p>>>31}p=(n<<5|n>>>27)+o+(d[f]>>>0)+(f<20?(h&i|~h&j)+1518500249:f<40?(h^i^j)+1859775393:f<60?(h&i|h&j|i&j)-1894007588:(h^i^j)-899497514);o=j;j=i;i=h<<30|h>>>2;h=n;n=p}n+=q;h+=r;i+=s;j+=t;o+=u}return[n,h,i,j,o]};b._blocksize=16;b._digestsize=20})();
|
9
src/cloud/occi/lib/ui/public/vendor/crypto-js/NEW-BSD-LICENSE.txt
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
© 2009–2011 by Jeff Mott. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation or other materials provided with the distribution.
|
||||
* Neither the name Crypto-JS nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS," AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
6
src/cloud/occi/lib/ui/public/vendor/crypto-js/NOTICE
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
THIRD-PARTY SOFTWARE
|
||||
|
||||
* Author: Jeff Mott (http://code.google.com/u/Jeff.Mott.OR/)
|
||||
* Info: http://code.google.com/p/crypto-js/
|
||||
* Copyright: Copyright 2009-2012 by Jeff Mott,all rights reserved.
|
||||
* License: New BSD License. See NEW-BSD-LICENSE.txt
|
6
src/cloud/occi/lib/ui/public/vendor/fileuploader/NOTICE
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
THIRD-PARTY SOFTWARE
|
||||
|
||||
* Author: Andrew Valums (http://github.com/valums)
|
||||
* Info: https://github.com/valums/file-uploader
|
||||
* Copyright: Copyright 2010 Andrew Valums.
|
||||
* License: GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) and GNU LGPL 2 or later (http://www.gnu.org/licenses/lgpl-2.1.html)
|
1247
src/cloud/occi/lib/ui/public/vendor/fileuploader/fileuploader.js
vendored
Normal file
6
src/cloud/occi/lib/ui/public/vendor/xml2json/NOTICE
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
THIRD-PARTY SOFTWARE
|
||||
|
||||
* Author: Diego (diago@fyneworks.com)
|
||||
* Info: http://www.fyneworks.com/jquery/xml-to-json/
|
||||
* Copyright: Copyright 2008 Fyneworks.com
|
||||
* License: Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL licenses (http://www.gnu.org/licenses/gpl.html)
|
@ -1,12 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>OpenNebula Sunstone Login</title>
|
||||
<title>OpenNebula Self-Service Login</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/login.css" />
|
||||
|
||||
<!-- Vendor Libraries -->
|
||||
<script type="text/javascript" src="vendor/jQuery/jquery-1.7.1.min.js"></script>
|
||||
<script type="text/javascript" src="http://crypto-js.googlecode.com/files/2.3.0-crypto-sha1.js"></script>
|
||||
<script type="text/javascript" src="vendor/crypto-js/2.3.0-crypto-sha1.js"></script>
|
||||
<!-- End Vendor Libraries -->
|
||||
|
||||
<script type="text/javascript" src="js/occi.js"></script>
|
||||
@ -18,7 +18,7 @@
|
||||
<body>
|
||||
<div id="header">
|
||||
<div id="logo">
|
||||
The OpenNebula Cloud Operations Center
|
||||
OpenNebula Self-Service portal
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>OpenNebula OCCI</title>
|
||||
<title>OpenNebula Self-Service</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
|
||||
|
||||
<!-- Vendor Libraries -->
|
||||
@ -17,6 +17,7 @@
|
||||
<script type="text/javascript" src="vendor/jQueryUI/jquery-ui-1.8.16.custom.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/jQueryLayout/jquery.layout-latest.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/dataTables/jquery.dataTables.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/fileuploader/fileuploader.js"></script>
|
||||
|
||||
<!-- End Vendor Libraries -->
|
||||
|
||||
@ -36,12 +37,17 @@
|
||||
|
||||
<!--Base plugins-->
|
||||
|
||||
<script type="text/javascript" src="js/plugins/compute.js"></script>
|
||||
<script type="text/javascript" src="js/plugins/storage.js"></script>
|
||||
<script type="text/javascript" src="js/plugins/network.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div class="outer-center">
|
||||
<div class="inner-center">
|
||||
</div>
|
||||
<div id="dialog" class="inner-south"></div>
|
||||
<div id="dialog" class="inner-east"></div>
|
||||
</div>
|
||||
|
||||
<div id="menu" class="outer-west">
|
||||
@ -51,7 +57,7 @@
|
||||
|
||||
<div id="header" class="ui-layout-north">
|
||||
<div id="logo">
|
||||
<img src="images/opennebula-sunstone-small.png"/>
|
||||
<img src="images/opennebula-selfservice-small.png"/>
|
||||
</div>
|
||||
<div id="login-info">
|
||||
Welcome <span id="user"></span> | <a href="#" id="logout">Sign Out</a>
|
||||
@ -62,6 +68,7 @@
|
||||
<a href="http://opennebula.org/community:community" target="_blank">Community</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="footer" class="ui-layout-south">
|
||||
Copyright 2002-2011 © OpenNebula Project Leads (<a href="http://opennebula.org" target="_blank">OpenNebula.org</a>). All Rights Reserved. OpenNebula 3.1.0
|
||||
</div>
|