');
+ $('#'+id,context).html('
');
for (var i=0; i
\
@@ -93,9 +92,7 @@ var group_actions = {
waitingNodes(dataTable_groups);
Sunstone.runAction("Group.list");
},
- callback: function(){},
- error: onError,
- notify: false
+ error: onError
},
"Group.delete" : {
@@ -103,7 +100,7 @@ var group_actions = {
call : OpenNebula.Group.delete,
callback : deleteGroupElement,
error : onError,
- elements: function() { return getSelectedNodes(dataTable_groups); },
+ elements: groupElements,
notify:true
},
@@ -122,13 +119,11 @@ var group_buttons = {
"Group.refresh" : {
type: "image",
text: "Refresh list",
- img: "images/Refresh-icon.png",
- condition: True
+ img: "images/Refresh-icon.png"
},
"Group.create_dialog" : {
type: "create_dialog",
- text: "+ New Group",
- condition : True
+ text: "+ New Group"
},
// "Group.chown" : {
// type: "confirm_with_select",
@@ -140,21 +135,23 @@ var group_buttons = {
"Group.delete" : {
type: "action",
- text: "Delete",
- condition : True
+ text: "Delete"
}
};
var groups_tab = {
title: 'Groups',
content: groups_tab_content,
- buttons: group_buttons,
- condition: True
+ 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;
@@ -176,19 +173,24 @@ function groupElementArray(group_json){
users_str ];
}
-function groupInfoListener(){
- $('#tbodygroups tr').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 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,2,-1,"",-1);
+ groups_select = makeSelectOptions(dataTable_groups,
+ 1,//id_col
+ 2,//name_col
+ [],//status_cols
+ []//bad_status_cols
+ );
}
function updateGroupElement(request, group_json){
@@ -199,7 +201,7 @@ function updateGroupElement(request, group_json){
}
function deleteGroupElement(request){
- deleteElement(dataTable_groups,'#group_'+req.request.data);
+ deleteElement(dataTable_groups,'#group_'+request.request.data);
updateGroupSelect();
}
@@ -226,27 +228,30 @@ function updateGroupsView(request, group_list){
//Prepares the dialog to create
function setupCreateGroupDialog(){
- $('div#dialogs').append('');
- $('#create_group_dialog').html(create_group_tmpl);
- $('#create_group_dialog').dialog({
+ dialogs_context.append('');
+ $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
});
- $('#create_group_dialog button').button();
+ $('button',dialog).button();
- $('#create_group_form').submit(function(){
+ $('#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');
+ $create_group_dialog.dialog('close');
return false;
});
}
function popUpCreateGroupDialog(){
- $('#create_group_dialog').dialog('open');
+ $create_group_dialog.dialog('open');
return false;
}
@@ -254,7 +259,7 @@ function popUpCreateGroupDialog(){
function setGroupAutorefresh(){
setInterval(function(){
var checked = $('input:checked',dataTable_groups.fnGetNodes());
- var filter = $("#datatable_groups_filter input").attr("value");
+ var filter = $("#datatable_groups_filter input",dataTable_groups.parents("#datatable_groups_wrapper")).attr("value");
if (!checked.length && !filter.length){
Sunstone.runAction("Group.autorefresh");
}
@@ -262,7 +267,7 @@ function setGroupAutorefresh(){
}
$(document).ready(function(){
- dataTable_groups = $("#datatable_groups").dataTable({
+ dataTable_groups = $("#datatable_groups",main_tabs_context).dataTable({
"bJQueryUI": true,
"bSortClasses": false,
"sPaginationType": "full_numbers",
diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js
index 333388c144..655fe75d07 100644
--- a/src/sunstone/public/js/plugins/hosts-tab.js
+++ b/src/sunstone/public/js/plugins/hosts-tab.js
@@ -15,7 +15,7 @@
/* -------------------------------------------------------------------------- */
/*Host tab plugin*/
-
+/* HOST_HISTORY_LENGTH is ignored by server */
var HOST_HISTORY_LENGTH = 40;
var host_graphs = [
{
@@ -98,8 +98,8 @@ var create_host_tmpl =
';
var hosts_select="";
-var host_list_json = {};
var dataTable_hosts;
+var $create_host_dialog;
//Setup actions
var host_actions = {
@@ -121,8 +121,7 @@ var host_actions = {
type: "list",
call: OpenNebula.Host.list,
callback: updateHostsView,
- error: onError,
- notify: false
+ error: onError
},
"Host.show" : {
@@ -145,9 +144,7 @@ var host_actions = {
waitingNodes(dataTable_hosts);
Sunstone.runAction("Host.list");
},
- callback: function(){},
- error: onError,
- notify:false
+ error: onError
},
"Host.autorefresh" : {
@@ -163,7 +160,7 @@ var host_actions = {
callback : function (req) {
Sunstone.runAction("Host.show",req.request.data[0]);
},
- elements: function() { return getSelectedNodes(dataTable_hosts); },
+ elements: hostElements,
error : onError,
notify: true
},
@@ -174,7 +171,7 @@ var host_actions = {
callback : function (req) {
Sunstone.runAction("Host.show",req.request.data[0]);
},
- elements: function() { return getSelectedNodes(dataTable_hosts); },
+ elements: hostElements,
error : onError,
notify:true
},
@@ -183,7 +180,7 @@ var host_actions = {
type: "multiple",
call : OpenNebula.Host.delete,
callback : deleteHostElement,
- elements: function() { return getSelectedNodes(dataTable_hosts); },
+ elements: hostElements,
error : onError,
notify:true
},
@@ -215,8 +212,7 @@ var host_actions = {
callback: function (request,response) {
$('#template_update_dialog #template_update_textarea').val(response.template);
},
- error: onError,
- notify: false
+ error: onError
},
"Host.update_dialog" : {
@@ -232,8 +228,7 @@ var host_actions = {
callback: function() {
notifyMessage("Template updated correctly");
},
- error: onError,
- notify: false
+ error: onError
}
};
@@ -241,34 +236,28 @@ var host_buttons = {
"Host.refresh" : {
type: "image",
text: "Refresh list",
- img: "images/Refresh-icon.png",
- condition: True
+ img: "images/Refresh-icon.png"
},
"Host.create_dialog" : {
type: "create_dialog",
- text: "+ New",
- condition :True
+ text: "+ New"
},
"Host.update_dialog" : {
type: "action",
text: "Update a template",
- condition: True,
alwaysActive: true
},
"Host.enable" : {
type: "action",
- text: "Enable",
- condition : True
+ text: "Enable"
},
"Host.disable" : {
type: "action",
- text: "Disable",
- condition : True
+ text: "Disable"
},
"Host.delete" : {
type: "action",
- text: "Delete host",
- condition : True
+ text: "Delete host"
}
};
@@ -292,8 +281,7 @@ var host_info_panel = {
var hosts_tab = {
title: 'Hosts',
content: hosts_tab_content,
- buttons: host_buttons,
- condition: True
+ buttons: host_buttons
}
Sunstone.addActions(host_actions);
@@ -301,6 +289,10 @@ 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){
@@ -357,8 +349,7 @@ function hostElementArray(host_json){
//Listen to clicks on the tds of the tables and shows the info dialogs.
function hostInfoListener(){
- $('#tbodyhosts tr').live("click",function(e){
-
+ $('#tbodyhosts tr',dataTable_hosts).live("click",function(e){
//do nothing if we are clicking a checkbox!
if ($(e.target).is('input')) {return true;}
popDialogLoading();
@@ -371,7 +362,12 @@ function hostInfoListener(){
//updates the host select by refreshing the options in it
function updateHostSelect(){
- hosts_select = makeSelectOptions(dataTable_hosts,1,2,7,"DISABLED",-1);
+ 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
@@ -398,7 +394,6 @@ function addHostElement(request,host_json){
//callback to update the list of hosts.
function updateHostsView (request,host_list){
- host_list_json = host_list;
var host_list_array = [];
$.each(host_list,function(){
@@ -409,7 +404,7 @@ function updateHostsView (request,host_list){
updateView(host_list_array,dataTable_hosts);
updateHostSelect();
//dependency with the dashboard plugin
- updateDashboard("hosts",host_list_json);
+ updateDashboard("hosts",host_list);
}
//Updates the host info panel tab's content and pops it up
@@ -511,18 +506,21 @@ function updateHostInfo(request,host){
//Prepares the host creation dialog
function setupCreateHostDialog(){
- $('div#dialogs').append('
');
- $('div#create_host_dialog').html(create_host_tmpl);
- $('#create_host_dialog').dialog({
+ dialogs_context.append('
');
+ $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
});
- $('#create_host_dialog button').button();
+ $('button',dialog).button();
//Handle the form submission
- $('#create_host_form').submit(function(){
+ $('#create_host_form',dialog).submit(function(){
if (!($('#name',this).val().length)){
notifyError("Host name missing!");
return false;
@@ -539,14 +537,14 @@ function setupCreateHostDialog(){
//Create the OpenNebula.Host.
//If it's successfull we refresh the list.
Sunstone.runAction("Host.create",host_json);
- $('#create_host_dialog').dialog('close');
+ $create_host_dialog.dialog('close');
return false;
});
}
//Open creation dialogs
function popUpCreateHostDialog(){
- $('#create_host_dialog').dialog('open');
+ $create_host_dialog.dialog('open');
return false;
}
@@ -554,7 +552,7 @@ function popUpCreateHostDialog(){
function setHostAutorefresh() {
setInterval(function(){
var checked = $('input:checked',dataTable_hosts.fnGetNodes());
- var filter = $("#datatable_hosts_filter input").attr("value");
+ var filter = $("#datatable_hosts_filter input",dataTable_hosts.parents('#datatable_hosts_wrapper')).attr("value");
if (!checked.length && !filter.length){
Sunstone.runAction("Host.autorefresh");
}
@@ -570,6 +568,9 @@ function hostMonitorError(req,error_json){
$('#host_monitoring_tab '+id).html('
'+message+'
');
}
+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
@@ -577,7 +578,7 @@ function hostMonitorError(req,error_json){
$(document).ready(function(){
//prepare host datatable
- dataTable_hosts = $("#datatable_hosts").dataTable({
+ dataTable_hosts = $("#datatable_hosts",main_tabs_context).dataTable({
"bJQueryUI": true,
"bSortClasses": false,
"bAutoWidth":false,
diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js
index e0a675456a..b1ed59e5cb 100644
--- a/src/sunstone/public/js/plugins/images-tab.js
+++ b/src/sunstone/public/js/plugins/images-tab.js
@@ -156,8 +156,8 @@ var create_image_tmpl =
';
var images_select = "";
-var image_list_json = {};
var dataTable_images;
+var $create_image_dialog;
var image_actions = {
@@ -216,8 +216,7 @@ var image_actions = {
callback: function (request,response) {
$('#template_update_dialog #template_update_textarea').val(response.template);
},
- error: onError,
- notify: false
+ error: onError
},
"Image.update_dialog" : {
@@ -233,8 +232,7 @@ var image_actions = {
callback: function() {
notifyMessage("Template updated correctly");
},
- error: onError,
- notify: false
+ error: onError
},
"Image.enable" : {
@@ -243,7 +241,7 @@ var image_actions = {
callback: function (req) {
Sunstone.runAction("Image.show",req.request.data[0]);
},
- elements: function() { return getSelectedNodes(dataTable_images); },
+ elements: imageElements,
error: onError,
notify: true
},
@@ -254,7 +252,7 @@ var image_actions = {
callback: function (req) {
Sunstone.runAction("Image.show",req.request.data[0]);
},
- elements: function() { return getSelectedNodes(dataTable_images); },
+ elements: imageElements,
error: onError,
notify: true
},
@@ -265,7 +263,7 @@ var image_actions = {
callback: function (req) {
Sunstone.runAction("Image.show",req.request.data[0]);
},
- elements: function() { return getSelectedNodes(dataTable_images); },
+ elements: imageElements,
error: onError,
notify: true
},
@@ -276,7 +274,7 @@ var image_actions = {
callback: function (req) {
Sunstone.runAction("Image.show",req.request.data[0]);
},
- elements: function() { return getSelectedNodes(dataTable_images); },
+ elements: imageElements,
error: onError,
notify: true
},
@@ -287,7 +285,7 @@ var image_actions = {
callback: function (req) {
Sunstone.runAction("Image.show",req.request.data[0]);
},
- elements: function() { return getSelectedNodes(dataTable_images); },
+ elements: imageElements,
error: onError,
notify: true
},
@@ -298,7 +296,7 @@ var image_actions = {
callback: function (req) {
Sunstone.runAction("Image.show",req.request.data[0]);
},
- elements: function() { return getSelectedNodes(dataTable_images); },
+ elements: imageElements,
error: onError,
notify: true
},
@@ -307,7 +305,7 @@ var image_actions = {
type: "multiple",
call: OpenNebula.Image.delete,
callback: deleteImageElement,
- elements: function() { return getSelectedNodes(dataTable_images); },
+ elements: imageElements,
error: onError,
notify: true
},
@@ -318,7 +316,7 @@ var image_actions = {
callback: function (req) {
Sunstone.runAction("Image.show",req.request.data[0]);
},
- elements: function() { return getSelectedNodes(dataTable_images); },
+ elements: imageElements,
error: onError,
notify: true
},
@@ -329,7 +327,7 @@ var image_actions = {
callback: function (req) {
Sunstone.runAction("Image.show",req.request.data[0]);
},
- elements: function() { return getSelectedNodes(dataTable_images); },
+ elements: imageElements,
error: onError,
notify: true
}
@@ -340,74 +338,63 @@ var image_buttons = {
"Image.refresh" : {
type: "image",
text: "Refresh list",
- img: "images/Refresh-icon.png",
- condition: True
+ img: "images/Refresh-icon.png"
},
"Image.create_dialog" : {
type: "create_dialog",
- text: "+ New",
- condition: True
+ text: "+ New"
},
"Image.update_dialog" : {
type: "action",
text: "Update a template",
- condition: True,
alwaysActive: true
},
"Image.chown" : {
type: "confirm_with_select",
text: "Change owner",
- select: function() {return users_select;},
+ select: users_sel,
tip: "Select the new owner:",
- condition: function() { return gid == 0; }
+ condition: mustBeAdmin
},
"Image.chgrp" : {
type: "confirm_with_select",
text: "Change group",
- select: function() {return groups_select;},
+ select: groups_sel,
tip: "Select the new group:",
- condition: function() { return gid == 0; }
+ condition: mustBeAdmin
},
"action_list" : {
type: "select",
- condition: True,
actions: {
"Image.enable" : {
type: "action",
- text: "Enable",
- condition: True
+ text: "Enable"
},
"Image.disable" : {
type: "action",
- text: "Disable",
- condition: True
+ text: "Disable"
},
"Image.publish" : {
type: "action",
- text: "Publish",
- condition: True
+ text: "Publish"
},
"Image.unpublish" : {
type: "action",
- text: "Unpublish",
- condition: True
+ text: "Unpublish"
},
"Image.persistent" : {
type: "action",
- text: "Make persistent",
- condition: True
+ text: "Make persistent"
},
"Image.nonpersistent" : {
type: "action",
- text: "Make non persistent",
- condition: True
+ text: "Make non persistent"
}
}
},
"Image.delete" : {
type: "action",
- text: "Delete",
- condition: True
+ text: "Delete"
}
}
@@ -427,14 +414,18 @@ var image_info_panel = {
var images_tab = {
title: "Images",
content: images_tab_content,
- buttons: image_buttons,
- condition: True
+ buttons: image_buttons
}
Sunstone.addActions(image_actions);
Sunstone.addMainTab('images_tab',images_tab);
Sunstone.addInfoPanel('image_info_panel',image_info_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){
@@ -456,8 +447,7 @@ function imageElementArray(image_json){
// Set up the listener on the table TDs to show the info panel
function imageInfoListener(){
-
- $('#tbodyimages tr').live("click",function(e){
+ $('#tbodyimages tr',dataTable_images).live("click",function(e){
if ($(e.target).is('input')) {return true;}
popDialogLoading();
var aData = dataTable_images.fnGetData(this);
@@ -470,11 +460,16 @@ function imageInfoListener(){
//Updates the select input field with an option for each image
function updateImageSelect(){
images_select =
- makeSelectOptions(dataTable_images,1,4,9,"DISABLED",2);
+ makeSelectOptions(dataTable_images,
+ 1,
+ 4,
+ [9,9,9],
+ ["DISABLED","LOCKED","ERROR"]
+ );
//update static selectors:
//in the VM section
- $('div.vm_section#disks select#IMAGE_ID').html(images_select);
+ $('div.vm_section#disks select#IMAGE_ID', $create_template_dialog).html(images_select);
}
// Callback to update an element in the dataTable
@@ -500,16 +495,15 @@ function addImageElement(request, image_json){
// Callback to refresh the list of images
function updateImagesView(request, images_list){
- image_list_json = images_list;
var image_list_array = [];
- $.each(image_list_json,function(){
+
+ $.each(images_list,function(){
image_list_array.push(imageElementArray(this));
});
updateView(image_list_array,dataTable_images);
updateImageSelect();
- updateDashboard("images",image_list_json);
-
+ updateDashboard("images",images_list);
}
// Callback to update the information panel tabs and pop it up
@@ -582,85 +576,82 @@ function updateImageInfo(request,img){
// Prepare the image creation dialog
function setupCreateImageDialog(){
- $('div#dialogs').append('
');
-
- //Insert HTML in place
- $('#create_image_dialog').html(create_image_tmpl);
+ dialogs_context.append('
');
+ $create_image_dialog = $('#create_image_dialog',dialogs_context);
+ var dialog = $create_image_dialog;
+ dialog.html(create_image_tmpl);
var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window
//Prepare jquery dialog
- $('#create_image_dialog').dialog({
+ dialog.dialog({
autoOpen: false,
modal:true,
width: 520,
height: height
});
- $('#img_tabs').tabs();
- $('#create_image_dialog button').button();
- $('#img_type option').first().attr("selected","selected");
- $('#datablock_img').attr("disabled","disabled");
+ $('#img_tabs',dialog).tabs();
+ $('button',dialog).button();
+ $('#img_type option',dialog).first().attr("selected","selected");
+ $('#datablock_img',dialog).attr("disabled","disabled");
- //Chrome workaround
- $('select#img_type').change(function(){
- $(this).trigger("click");
- });
-
- $('select#img_type').click(function(){
+ $('select#img_type',dialog).change(function(){
var value = $(this).val();
+ var context = $create_image_dialog;
switch (value){
case "DATABLOCK":
- $('#datablock_img').removeAttr("disabled");
+ $('#datablock_img',context).removeAttr("disabled");
break;
default:
- $('#datablock_img').attr("disabled","disabled");
- $('#path_img').attr("checked","checked");
- $('#img_source,#img_fstype,#img_size').parent().hide();
- $('#img_path').parent().show();
+ $('#datablock_img',context).attr("disabled","disabled");
+ $('#path_img',context).attr("checked","checked");
+ $('#img_source,#img_fstype,#img_size',context).parent().hide();
+ $('#img_path',context).parent().show();
}
});
- $('#img_source,#img_fstype,#img_size').parent().hide();
- $('#path_img').attr("checked","checked");
- $('#img_path').parent().addClass("img_man");
+ $('#img_source,#img_fstype,#img_size',dialog).parent().hide();
+ $('#path_img',dialog).attr("checked","checked");
+ $('#img_path',dialog).parent().addClass("img_man");
- $('#img_public').click(function(){
- $('#img_persistent').removeAttr("checked");
+ $('#img_public',dialog).click(function(){
+ $('#img_persistent',$create_image_dialog).removeAttr("checked");
});
- $('#img_persistent').click(function(){
- $('#img_public').removeAttr("checked");
+ $('#img_persistent',dialog).click(function(){
+ $('#img_public',$create_image_dialog).removeAttr("checked");
});
$('#src_path_select input').click(function(){
+ var context = $create_image_dialog;
var value = $(this).val();
switch (value){
case "path":
- $('#img_source,#img_fstype,#img_size').parent().hide();
- $('#img_source,#img_fstype,#img_size').parent().removeClass("img_man");
- $('#img_path').parent().show();
- $('#img_path').parent().addClass("img_man");
+ $('#img_source,#img_fstype,#img_size',context).parent().hide();
+ $('#img_source,#img_fstype,#img_size',context).parent().removeClass("img_man");
+ $('#img_path',context).parent().show();
+ $('#img_path',context).parent().addClass("img_man");
break;
case "source":
- $('#img_path,#img_fstype,#img_size').parent().hide();
- $('#img_path,#img_fstype,#img_size').parent().removeClass("img_man");
- $('#img_source').parent().show();
- $('#img_source').parent().addClass("img_man");
+ $('#img_path,#img_fstype,#img_size',context).parent().hide();
+ $('#img_path,#img_fstype,#img_size',context).parent().removeClass("img_man");
+ $('#img_source',context).parent().show();
+ $('#img_source',context).parent().addClass("img_man");
break;
case "datablock":
- $('#img_source,#img_path').parent().hide();
- $('#img_source,#img_path').parent().removeClass("img_man");
- $('#img_fstype,#img_size').parent().show();
- $('#img_fstype,#img_size').parent().addClass("img_man");
+ $('#img_source,#img_path',context).parent().hide();
+ $('#img_source,#img_path',context).parent().removeClass("img_man");
+ $('#img_fstype,#img_size',context).parent().show();
+ $('#img_fstype,#img_size',context).parent().addClass("img_man");
break;
}
});
- $('#create_image_form_easy').submit(function(){
+ $('#create_image_form_easy',dialog).submit(function(){
var exit = false;
$('.img_man',this).each(function(){
if (!$('input',this).val().length){
@@ -672,41 +663,41 @@ function setupCreateImageDialog(){
if (exit) { return false; }
var img_json = {};
- var name = $('#img_name').val();
+ var name = $('#img_name',this).val();
img_json["NAME"] = name;
- var desc = $('#img_desc').val();
+ var desc = $('#img_desc',this).val();
if (desc.length){
img_json["DESCRIPTION"] = desc;
}
- var type = $('#img_type').val();
+ var type = $('#img_type',this).val();
img_json["TYPE"]= type;
- img_json["PUBLIC"] = $('#img_public:checked').length ? "YES" : "NO";
+ img_json["PUBLIC"] = $('#img_public:checked',this).length ? "YES" : "NO";
- img_json["PERSISTENT"] = $('#img_persistent:checked').length ? "YES" : "NO";
+ img_json["PERSISTENT"] = $('#img_persistent:checked',this).length ? "YES" : "NO";
- var dev_prefix = $('#img_dev_prefix').val();
+ var dev_prefix = $('#img_dev_prefix',this).val();
if (dev_prefix.length){
img_json["DEV_PREFIX"] = dev_prefix;
}
- var bus = $('#img_bus').val();
+ var bus = $('#img_bus',this).val();
img_json["BUS"] = bus;
- switch ($('#src_path_select input:checked').val()){
+ switch ($('#src_path_select input:checked',this).val()){
case "path":
- path = $('#img_path').val();
+ path = $('#img_path',this).val();
img_json["PATH"] = path;
break;
case "source":
- source = $('#img_source').val();
+ source = $('#img_source',this).val();
img_json["SOURCE"] = source;
break;
case "datablock":
- size = $('#img_size').val();
- fstype = $('#img_fstype').val();
+ size = $('#img_size',this).val();
+ fstype = $('#img_fstype',this).val();
img_json["SIZE"] = size;
img_json["FSTYPE"] = fstype;
break;
@@ -714,28 +705,28 @@ function setupCreateImageDialog(){
var obj = { "image" : img_json };
Sunstone.runAction("Image.register", obj);
- $('#create_image_dialog').dialog('close');
+ $create_image_dialog.dialog('close');
return false;
});
- $('#create_image_form_manual').submit(function(){
+ $('#create_image_form_manual',dialog).submit(function(){
var template=$('#template',this).val();
Sunstone.runAction("Image.register",template);
- $('#create_image_dialog').dialog('close');
+ $create_image_dialog.dialog('close');
return false;
});
-
}
function popUpCreateImageDialog(){
- $('#create_image_dialog').dialog('open');
+ $create_image_dialog.dialog('open');
}
// Set the autorefresh interval for the datatable
function setImageAutorefresh() {
setInterval(function(){
var checked = $('input:checked',dataTable_images.fnGetNodes());
- var filter = $("#datatable_images_filter input").attr("value");
+ var filter = $("#datatable_images_filter input",
+ dataTable_images.parents("#datatable_images_wrapper")).attr("value");
if (!checked.length && !filter.length){
Sunstone.runAction("Image.autorefresh");
}
@@ -745,7 +736,7 @@ function setImageAutorefresh() {
//The DOM is ready at this point
$(document).ready(function(){
- dataTable_images = $("#datatable_images").dataTable({
+ dataTable_images = $("#datatable_images",main_tabs_context).dataTable({
"bJQueryUI": true,
"bSortClasses": false,
"bAutoWidth":false,
@@ -765,7 +756,7 @@ $(document).ready(function(){
Sunstone.runAction("Image.list");
setupCreateImageDialog();
- setupTips($('#create_image_dialog'));
+ setupTips($create_image_dialog);
setImageAutorefresh();
initCheckAllBoxes(dataTable_images);
diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js
index 61853318c3..cd89b8856b 100644
--- a/src/sunstone/public/js/plugins/templates-tab.js
+++ b/src/sunstone/public/js/plugins/templates-tab.js
@@ -581,8 +581,8 @@ var create_template_tmpl = '
\
';
var templates_select = "";
-var template_list_json = {};
var dataTable_templates;
+var $create_template_dialog;
var template_actions = {
@@ -648,8 +648,7 @@ var template_actions = {
callback: function() {
notifyMessage("Template updated correctly");
},
- error: onError,
- notify: false
+ error: onError
},
"Template.fetch_template" : {
@@ -658,45 +657,39 @@ var template_actions = {
callback: function (request,response) {
$('#template_update_dialog #template_update_textarea').val(response.template);
},
- error: onError,
- notify: false
+ error: onError
},
"Template.publish" : {
type: "multiple",
call: OpenNebula.Template.publish,
- callback: function (req) {
- Sunstone.runAction("Template.show",req.request.data[0]);
- },
- elements: function() { return getSelectedNodes(dataTable_templates); },
+ callback: templateShow,
+ elements: templateElements,
error: onError,
notify: true
},
"Template.unpublish" : {
- type: "multiple",
- call: OpenNebula.Template.unpublish,
- callback: function (req) {
- Sunstone.runAction("Template.show",req.request.data[0]);
- },
- elements: function() { return getSelectedNodes(dataTable_templates); },
- error: onError,
- notify: true
+ type: "multiple",
+ call: OpenNebula.Template.unpublish,
+ callback: templateShow,
+ elements: templateElements,
+ error: onError,
+ notify: true
},
"Template.delete" : {
- type: "multiple",
- call: OpenNebula.Template.delete,
- callback: deleteTemplateElement,
- elements: function() { return getSelectedNodes(dataTable_templates); },
- error: onError,
- notify: true
+ type: "multiple",
+ call: OpenNebula.Template.delete,
+ callback: deleteTemplateElement,
+ elements: templateElements,
+ error: onError,
+ notify: true
},
"Template.instantiate" : {
type: "single",
call: OpenNebula.Template.instantiate,
- callback: function(){},
error: onError,
notify: true
},
@@ -709,89 +702,75 @@ var template_actions = {
Sunstone.runAction("Template.instantiate",this,"");
});
Sunstone.runAction("VM.refresh");
- },
- notify: false
+ }
},
"Template.chown" : {
type: "multiple",
call: OpenNebula.Template.chown,
- callback: function (req) {
- Sunstone.runAction("Template.show",req.request.data[0]);
- },
- elements: function() { return getSelectedNodes(dataTable_templates); },
+ callback: templateShow,
+ elements: templateElements,
error:onError,
notify: true
},
"Template.chgrp" : {
type: "multiple",
call: OpenNebula.Template.chgrp,
- callback: function (req) {
- Sunstone.runAction("Template.show",req.request.data[0]);
- },
- elements: function() { return getSelectedNodes(dataTable_templates); },
+ callback: templateShow,
+ elements: templateElements,
error:onError,
notify: true
}
}
-
var template_buttons = {
"Template.refresh" : {
type: "image",
text: "Refresh list",
- img: "images/Refresh-icon.png",
- condition: True
+ img: "images/Refresh-icon.png"
},
"Template.create_dialog" : {
type: "create_dialog",
- text: "+ New",
- condition: True
+ text: "+ New"
},
"Template.update_dialog" : {
type: "action",
text: "Update a template",
- condition: True,
alwaysActive: true
},
"Template.instantiate_vms" : {
type: "action",
- text: "Instantiate",
- condition: True
+ text: "Instantiate"
},
"Template.chown" : {
type: "confirm_with_select",
text: "Change owner",
- select: function() {return users_select;},
+ select: users_sel,
tip: "Select the new owner:",
- condition: function(){return gid==0;}
+ condition: mustBeAdmin
},
"Template.chgrp" : {
type: "confirm_with_select",
text: "Change group",
- select: function() {return groups_select;},
+ select: groups_sel,
tip: "Select the new group:",
- condition: function(){return gid==0;}
+ condition: mustBeAdmin
},
"action_list" : {
type: "select",
- condition: True,
actions: {
"Template.publish" : {
type: "action",
- text: "Publish",
- condition: True
+ text: "Publish"
},
"Template.unpublish" : {
type: "action",
- text: "Unpublish",
- condition: True
+ text: "Unpublish"
},
}
},
"Template.delete" : {
type: "action",
- text: "Delete",
- condition: True
+ text: "Delete"
}
}
@@ -805,14 +784,23 @@ var template_info_panel = {
var templates_tab = {
title: "Templates",
content: templates_tab_content,
- buttons: template_buttons,
- condition: True
+ buttons: template_buttons
}
Sunstone.addActions(template_actions);
Sunstone.addMainTab('templates_tab',templates_tab);
Sunstone.addInfoPanel('template_info_panel',template_info_panel);
+//Returns selected elements in the template table
+function templateElements(){
+ return getSelectedNodes(dataTable_templates);
+}
+
+//Runs a show action on the template with from a prev request
+function templateShow(req){
+ Sunstone.runAction("Template.show",req.request.data[0]);
+}
+
// Returns an array containing the values of the template_json and ready
// to be inserted in the dataTable
function templateElementArray(template_json){
@@ -830,8 +818,7 @@ function templateElementArray(template_json){
// Set up the listener on the table TDs to show the info panel
function templateInfoListener(){
-
- $('#tbodytemplates tr').live("click",function(e){
+ $('#tbodytemplates tr',dataTable_templates).live("click",function(e){
if ($(e.target).is('input')) {return true;}
popDialogLoading();
var aData = dataTable_templates.fnGetData(this);
@@ -844,11 +831,15 @@ function templateInfoListener(){
//Updates the select input field with an option for each template
function updateTemplateSelect(){
templates_select =
- makeSelectOptions(dataTable_templates,1,4,7,"no",2);
+ makeSelectOptions(dataTable_templates,
+ 1,//id_col
+ 4,//name_col
+ [7],//published_col
+ ["no"]//bad status col
+ );
//update static selectors:
- $('#create_vm_dialog #template_id').html(templates_select);
- $('#speed_virt').html(templates_select);
+ $('#template_id', $create_vm_dialog).html(templates_select);
}
// Callback to update an element in the dataTable
@@ -874,15 +865,15 @@ function addTemplateElement(request, template_json){
// Callback to refresh the list of templates
function updateTemplatesView(request, templates_list){
- template_list_json = templates_list;
var template_list_array = [];
- $.each(template_list_json,function(){
+
+ $.each(templates_list,function(){
template_list_array.push(templateElementArray(this));
});
updateView(template_list_array,dataTable_templates);
updateTemplateSelect();
- updateDashboard("templates",template_list_json);
+ updateDashboard("templates",templates_list);
}
@@ -935,7 +926,6 @@ function updateTemplateInfo(request,template){
Sunstone.updateInfoPanelTab("template_info_panel","template_template_tab",template_tab);
Sunstone.popUpInfoPanel("template_info_panel");
-
}
// Prepare the template creation dialog
@@ -950,30 +940,30 @@ function setupCreateTemplateDialog(){
// ui.index // zero-based index of the selected (clicked) tab
//disable all items
- $(items).attr("disabled","disabled");
+ $(items,dialog).attr("disabled","disabled");
//hide all mandatory icons
- $('.vm_param .man_icon').css("display","none");
+ $('.vm_param .man_icon',dialog).css("display","none");
//empty selects
- $('div#os_boot_opts select#BOOT').empty();
- $('div#disks select#TYPE').empty();
- $('div#disks select#BUS').empty();
+ $('select#BOOT',section_os_boot).empty();
+ $('select#TYPE',section_disks).empty();
+ $('select#BUS',section_disks).empty();
//hide options about boot method
$('div#kernel_bootloader',section_os_boot).show();
- $('.kernel, .bootloader', $('div#os_boot_opts')).hide();
- $('div#os_boot_opts select#BOOT').parent().hide();
+ $('.kernel, .bootloader', section_os_boot).hide();
+ $('select#BOOT',section_os_boot).parent().hide();
//unselect boot method
- $('select#boot_method option').removeAttr("selected");
+ $('select#boot_method option',section_os_boot).removeAttr("selected");
//hide non common sections
$(section_inputs).hide();
$(section_graphics).hide();
//Repopulate images select
- $('div.vm_section#disks select#IMAGE_ID').html(images_select);
+ $('select#IMAGE_ID',section_disks).html(images_select);
//Repopulate network select
- $('div.vm_section#networks select#NETWORK_ID').html(vnetworks_select);
+ $('select#NETWORK_ID',section_networks).html(vnetworks_select);
switch(ui.index){
@@ -1020,8 +1010,8 @@ function setupCreateTemplateDialog(){
var enable_kvm = function(){
man_class="kvm";
opt_class="kvm_opt";
- $(kvm_items).removeAttr("disabled");
- $('.kvm .man_icon').css("display","inline-block");
+ $(kvm_items,dialog).removeAttr("disabled");
+ $('.kvm .man_icon',dialog).css("display","inline-block");
//KVM particularities:
// * Add custom disk types
@@ -1040,7 +1030,7 @@ function setupCreateTemplateDialog(){
\
';
- $('div#disks select#TYPE').html(type_opts);
+ $('select#TYPE',section_disks).html(type_opts);
var boot_opts =
'
\
@@ -1048,16 +1038,16 @@ function setupCreateTemplateDialog(){
\
';
- $('div#os_boot_opts select#BOOT').html(boot_opts);
- $('div#os_boot_opts select#BOOT').parent().show();
- $('select#boot_method option#no_boot').html("Driver default");
+ $('select#BOOT',section_os_boot).html(boot_opts);
+ $('select#BOOT',section_os_boot).parent().show();
+ $('select#boot_method option#no_boot',section_os_boot).html("Driver default");
var bus_opts =
'
\
\
';
- $('div#disks select#BUS').html(bus_opts);
+ $('select#BUS',section_disks).html(bus_opts);
$('input#TYPE', section_raw).val("kvm");
@@ -1069,8 +1059,8 @@ function setupCreateTemplateDialog(){
var enable_xen = function(){
man_class="xen";
opt_class="xen_opt";
- $(xen_items).removeAttr("disabled");
- $('.xen .man_icon').css("display","inline-block");
+ $(xen_items,dialog).removeAttr("disabled");
+ $('.xen .man_icon',dialog).css("display","inline-block");
// XEN particularities:
// * Add custom disk types
@@ -1087,15 +1077,15 @@ function setupCreateTemplateDialog(){
\
';
- $('div#disks select#TYPE').html(type_opts);
+ $('select#TYPE',section_disks).html(type_opts);
- $('select#boot_method option#no_boot').html("Please choose");
+ $('select#boot_method option#no_boot',section_os_boot).html("Please choose");
var bus_opts =
'
\
';
- $('div#disks select#BUS').html(bus_opts);
+ $('select#BUS',section_disks).html(bus_opts);
$('input#TYPE', section_raw).val("xen");
$(section_graphics).show();
@@ -1105,8 +1095,8 @@ function setupCreateTemplateDialog(){
var enable_vmware = function() {
man_class="vmware";
opt_class="vmware_opt";
- $(vmware_items).removeAttr("disabled");
- $('.vmware .man_icon').css("display","inline-block");
+ $(vmware_items,dialog).removeAttr("disabled");
+ $('.vmware .man_icon',dialog).css("display","inline-block");
//VMWARE particularities
// * Add custom disk types
@@ -1119,7 +1109,7 @@ function setupCreateTemplateDialog(){
\
';
- $('div#disks select#TYPE').html(type_opts);
+ $('select#TYPE',section_disks).html(type_opts);
$('div#kernel_bootloader',section_os_boot).hide();
@@ -1127,10 +1117,9 @@ function setupCreateTemplateDialog(){
'
\
';
- $('div#disks select#BUS').html(bus_opts);
-
+ $('select#BUS',section_disks).html(bus_opts);
$('input#TYPE', section_raw).val("vmware");
- }
+ };
//This function checks that all mandatory items within a section
//have some value. Returns true if so, false if not.
@@ -1143,14 +1132,14 @@ function setupCreateTemplateDialog(){
//we fail it the item is enabled and has no value
$.each(man_items,function(){
- if ($(this).parents(".vm_param").attr("disabled") ||
- !($(this).val().length)) {
+ var item = $(this);
+ if (item.parents(".vm_param").attr("disabled") ||
+ !(item.val().length)) {
r = false;
return false;
};
});
return r;
-
};
//Adds an option element to a multiple select box. Before doing so,
@@ -1174,12 +1163,13 @@ function setupCreateTemplateDialog(){
//With each enabled field we form a JSON object
var id = null;
$.each(fields,function(){
- if (!($(this).parents(".vm_param").attr("disabled")) &&
- $(this).val().length){
+ var field = $(this);
+ if (!(field.parents(".vm_param").attr("disabled")) &&
+ field.val().length){
//Pick up parent's ID if we do not have one
- id = $(this).attr('id').length ? $(this).attr('id') : $(this).parent().attr('id');
- value[id] = $(this).val();
- }
+ id = field.attr('id').length ? field.attr('id') : field.parent().attr('id');
+ value[id] = field.val();
+ };
});
var value_string = JSON.stringify(value);
var option=
@@ -1192,7 +1182,7 @@ function setupCreateTemplateDialog(){
//Removes selected elements from a multiple select box
var box_remove_element = function(section_tag,box_tag){
- var context = $(section_tag);
+ var context = $(section_tag,dialog);
$('select'+box_tag+' :selected',context).remove();
return false;
};
@@ -1207,22 +1197,25 @@ function setupCreateTemplateDialog(){
var fields = $.merge(inputs,selects);
fields.each(function(){
- if (!($(this).parents(".vm_param").attr("disabled"))){ //if ! disabled
- if ($(this).val().length){ //if has a length
- template_json[$(this).attr('id')]=$(this).val();
- }
- }
+ var field=$(this);
+ if (!(field.parents(".vm_param").attr("disabled"))){ //if ! disabled
+ if (field.val().length){ //if has a length
+ template_json[field.attr('id')]=field.val();
+ };
+ };
});
- }
+ };
- // Given an array (usually empty), a section (context) and a tag for
- // a multiple select in that section, it adds the contents of the
- // box as objects in the array.
- // TODO: Make it return a new array?
- var addBoxJSON = function(array,context,box_tag){
+ // Given a section (context) and a tag for
+ // a multiple select in that section, it adds the
+ // JSON values to an array parsed as objects.
+ // Returns the array
+ var addBoxJSON = function(context,box_tag){
+ var array = [];
$('select'+box_tag+' option',context).each(function(){
array.push( JSON.parse($(this).val()) );
});
+ return array;
}
//Given an object, removes those elements which are empty
@@ -1259,7 +1252,7 @@ function setupCreateTemplateDialog(){
//Toggles the icon when a section is folded/unfolded
var iconToggle = function(){
- $('.icon_right').toggle(
+ $('.icon_right',dialog).toggle(
function(e){
$('span',e.currentTarget).removeClass("ui-icon-plusthick");
$('span',e.currentTarget).addClass("ui-icon-minusthick");
@@ -1293,13 +1286,8 @@ function setupCreateTemplateDialog(){
return false;
});
- //Chrome workaround
- $('#boot_method').change(function(){
- $(this).trigger("click");
- });
-
//Depending on the boot method we enable/disable some options
- $('#boot_method',section_os_boot).click(function(){
+ $('#boot_method',section_os_boot).change(function(){
select = $(this).val();
switch (select)
{
@@ -1378,14 +1366,9 @@ function setupCreateTemplateDialog(){
//hide_disabled(section_disks);
});
- //Chrome workaround
- $('select#TYPE',section_disks).change(function(){
- $(this).trigger('click');
- });
-
//Depending on the type of disk we need to show/hide
//different options and make then mandatory or not
- $('select#TYPE',section_disks).click(function(){
+ $('select#TYPE',section_disks).change(function(){
var select = $(this).val();
switch (select) {
//size,format,target
@@ -1475,8 +1458,8 @@ function setupCreateTemplateDialog(){
//hide_disabled(section_disks);
});
- //Our filter for the disks section fields is the mandatory
- //filter for this section
+ //Our filter for the disks section fields is the standard
+ //mandatory filter applied for this section
var diskFilter = function(){
return mandatory_filter(section_disks);
};
@@ -1495,7 +1478,7 @@ function setupCreateTemplateDialog(){
var networks_setup = function(){
$('.vm_param',section_networks).hide();
- $('.firewall_select').hide();
+ $('.firewall_select',section_networks).hide();
$('fieldset',section_networks).hide();
$('#add_networks',section_networks).click(function(){
@@ -1531,7 +1514,7 @@ function setupCreateTemplateDialog(){
//hide_disabled(section_networks);
});
- $('#black_white_tcp',section_networks).live("change",function(){
+ $('#black_white_tcp',section_networks).change(function(){
switch ($(this).val()) {
case "whitelist":
$('#BLACK_PORTS_TCP',section_networks).parent().attr("disabled","disabled");
@@ -1553,7 +1536,7 @@ function setupCreateTemplateDialog(){
};
});
- $('#black_white_udp',section_networks).live("change",function(){
+ $('#black_white_udp',section_networks).change(function(){
switch ($(this).val()) {
case "whitelist":
$('#BLACK_PORTS_UDP',section_networks).parent().attr("disabled","disabled");
@@ -1604,7 +1587,7 @@ function setupCreateTemplateDialog(){
$('#add_input_button',section_inputs).click(function(){
//no filter
- box_add_element(section_inputs,'#inputs_box',True);
+ box_add_element(section_inputs,'#inputs_box',function(){return true});
return false;
});
$('#remove_input_button',section_inputs).click(function(){
@@ -1654,11 +1637,10 @@ function setupCreateTemplateDialog(){
$('#PORT',section_graphics).parent().hide();
$('#PASSWD',section_graphics).parent().hide();
$('#KEYMAP',section_graphics).parent().hide();
-
}
});
- }
+ };
//Set up the context section - TODO: Apply improvements here...
var context_setup = function(){
@@ -1687,8 +1669,6 @@ function setupCreateTemplateDialog(){
box_remove_element(section_context,'#context_box');
return false;
});
-
-
};
// Set up the placement section
@@ -1746,17 +1726,21 @@ filled in");
//***CREATE VM DIALOG MAIN BODY***
- $('div#dialogs').append('
');
+ dialogs_context.append('
');
+ $create_template_dialog = $('#create_template_dialog',dialogs_context)
+ var dialog = $create_template_dialog;
+
//Insert HTML in place
- $('#create_template_dialog').html(create_template_tmpl);
+ dialog.html(create_template_tmpl);
+
//Enable tabs
- $('#template_create_tabs').tabs({
+ $('#template_create_tabs',dialog).tabs({
select:vmTabChange
});
//Prepare jquery dialog
var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window
- $('#create_template_dialog').dialog({
+ dialog.dialog({
autoOpen: false,
modal: true,
width: 600,
@@ -1764,26 +1748,26 @@ filled in");
});
// Enhace buttons
- $('#create_template_dialog button').button();
+ $('button',dialog).button();
// Re-Setup tips
- setupTips($('#create_template_dialog'));
+ setupTips(dialog);
//Enable different icon for folded/unfolded categories
iconToggle(); //toogle +/- buttons
//Sections, used to stay within their scope
- var section_capacity = $('#capacity');
- var section_os_boot = $('#os_boot_opts');
- var section_features = $('#features');
- var section_disks = $('#disks');
- var section_networks = $('#networks');
- var section_inputs = $('#inputs');
- var section_graphics = $('#graphics');
- var section_context = $('#context');
- var section_placement = $('#placement');
- var section_raw = $('#raw');
- var section_custom_var = $('#custom_var');
+ var section_capacity = $('div#capacity',dialog);
+ var section_os_boot = $('div#os_boot_opts',dialog);
+ var section_features = $('div#features',dialog);
+ var section_disks = $('div#disks',dialog);
+ var section_networks = $('div#networks',dialog);
+ var section_inputs = $('div#inputs',dialog);
+ var section_graphics = $('div#graphics',dialog);
+ var section_context = $('div#context',dialog);
+ var section_placement = $('div#placement',dialog);
+ var section_raw = $('div#raw',dialog);
+ var section_custom_var = $('div#custom_var',dialog);
//Different selector for items of kvm and xen (mandatory and optional)
var items = '.vm_param input,.vm_param select';
@@ -1805,14 +1789,15 @@ filled in");
vmTabChange(0,{index : 0}); //enable kvm
//Fold/unfold all sections button
- $('#fold_unfold_vm_params').toggle(
+ $('#fold_unfold_vm_params',dialog).toggle(
function(){
- $('.vm_section fieldset').show();
+ $('.vm_section fieldset',$create_template_dialog).show();
return false;
},
function(){
- $('.vm_section fieldset').hide();
- $('.vm_section fieldset').first().show(); //Show capacity opts
+ $('.vm_section fieldset',$create_template_dialog).hide();
+ //Show capacity opts
+ $('.vm_section fieldset',$create_template_dialog).first().show();
return false;
});
@@ -1830,7 +1815,7 @@ filled in");
custom_variables_setup();
//Process form
- $('button#create_template_form_easy').click(function(){
+ $('button#create_template_form_easy',dialog).click(function(){
//validate form
var vm_json = {};
@@ -1869,18 +1854,15 @@ filled in");
//process disks -> fetch from box
scope = section_disks;
- vm_json["DISK"] = [];
- addBoxJSON(vm_json["DISK"],scope,'#disks_box');
+ vm_json["DISK"] = addBoxJSON(scope,'#disks_box');
//process nics -> fetch from box
scope = section_networks;
- vm_json["NIC"] = [];
- addBoxJSON(vm_json["NIC"],scope,'#nics_box');
+ vm_json["NIC"] = addBoxJSON(scope,'#nics_box');
//process inputs -> fetch from box
scope = section_inputs;
- vm_json["INPUT"] = [];
- addBoxJSON(vm_json["INPUT"],scope,'#inputs_box');
+ vm_json["INPUT"] = addBoxJSON(scope,'#inputs_box');
//process graphics -> fetch fields with value
scope = section_graphics;
@@ -1928,41 +1910,42 @@ filled in");
Sunstone.runAction("Template.create",vm_json);
- $('#create_template_dialog').dialog('close');
+ $create_template_dialog.dialog('close');
return false;
});
//Handle manual forms
- $('button#create_template_form_manual').click(function(){
- var template = $('#textarea_vm_template').val();
+ $('button#create_template_form_manual',$create_template_dialog).click(function(){
+ var template = $('textarea#textarea_vm_template',$create_template_dialog).val();
//wrap it in the "vm" object
template = {"vmtemplate": {"template_raw": template}};
Sunstone.runAction("Template.create",template);
- $('#create_template_dialog').dialog('close');
+ $create_template_dialog.dialog('close');
return false;
});
//Reset form - empty boxes
- $('button#reset_vm_form').click(function(){
+ $('button#reset_vm_form',dialog).click(function(){
$('select#disks_box option',section_disks).remove();
$('select#nics_box option',section_networks).remove();
$('select#inputs_box option',section_inputs).remove();
+ $('select#custom_var_box option',section_custom_var).remove();
return true;
});
-
}
function popUpCreateTemplateDialog(){
- $('#create_template_dialog').dialog('open');
+ $create_template_dialog.dialog('open');
}
// Set the autorefresh interval for the datatable
function setTemplateAutorefresh() {
setInterval(function(){
var checked = $('input:checked',dataTable_templates.fnGetNodes());
- var filter = $("#datatable_templates_filter input").attr("value");
+ var filter = $("#datatable_templates_filter input",
+ dataTable_templates.parents('#datatable_templates_wrapper')).attr("value");
if (!checked.length && !filter.length){
Sunstone.runAction("Template.autorefresh");
}
@@ -1972,7 +1955,7 @@ function setTemplateAutorefresh() {
//The DOM is ready at this point
$(document).ready(function(){
- dataTable_templates = $("#datatable_templates").dataTable({
+ dataTable_templates = $("#datatable_templates",main_tabs_context).dataTable({
"bJQueryUI": true,
"bSortClasses": false,
"bAutoWidth":false,
diff --git a/src/sunstone/public/js/plugins/users-tab.js b/src/sunstone/public/js/plugins/users-tab.js
index d36105e279..0c48249ef8 100644
--- a/src/sunstone/public/js/plugins/users-tab.js
+++ b/src/sunstone/public/js/plugins/users-tab.js
@@ -15,9 +15,9 @@
/* -------------------------------------------------------------------------- */
/*Users tab plugin*/
-var user_list_json = {};
var dataTable_users;
var users_select="";
+var $create_user_dialog;
var users_tab_content =
'