diff --git a/src/sunstone/public/css/application.css b/src/sunstone/public/css/application.css index 4d2a4ad743..4e0ca48f29 100644 --- a/src/sunstone/public/css/application.css +++ b/src/sunstone/public/css/application.css @@ -407,7 +407,7 @@ tr.even:hover{ .top_button { font-size: 0.8em; height: 25px; - margin: 3px 0; + margin: 3px 2px; vertical-align: middle; /*width: 89px;*/ } @@ -417,6 +417,13 @@ tr.even:hover{ vertical-align: middle; } +.image_button { + font-size: 0.8em; + margin: 3px 2px; + vertical-align: middle; + border:0; +} + /* .multi_action_slct{ font-size: 0.7em; diff --git a/src/sunstone/public/js/one-ui_views.js b/src/sunstone/public/js/one-ui_views.js index c2a2e9d53e..e741e4e960 100644 --- a/src/sunstone/public/js/one-ui_views.js +++ b/src/sunstone/public/js/one-ui_views.js @@ -2186,8 +2186,12 @@ function setupTips(){ //Crawls the user dataTable for that. If such user is not found, //we return the uid. function getUserName(uid){ + var user = "uid "+uid; + if (!dataTable_users) { + return user; + } nodes = dataTable_users.fnGetData(); - user = "uid "+uid; + $.each(nodes,function(){ if (uid == this[1]) { user = this[2]; diff --git a/src/sunstone/public/js/opennebula.js b/src/sunstone/public/js/opennebula.js index 23aa229b52..ab7a13955d 100644 --- a/src/sunstone/public/js/opennebula.js +++ b/src/sunstone/public/js/opennebula.js @@ -1275,7 +1275,6 @@ var OpenNebula = { var callback = params.success; var callback_error = params.error; var timeout = params.timeout || false; - var resource = OpenNebula.Cluster.resource; var resource = OpenNebula.Cluster.resource; var request = OpenNebula.Helper.request(resource,"list"); @@ -1444,7 +1443,7 @@ var OpenNebula = { var callback_error = params.error; var timeout = params.timeout || false; - var resource = OpenNebula.Cluster.resource; + var resource = OpenNebula.User.resource; var request = OpenNebula.Helper.request(resource,"list"); $.ajax({ diff --git a/src/sunstone/public/js/plugins/dashboard-tab.js b/src/sunstone/public/js/plugins/dashboard-tab.js index 016dc097a9..30f7a93fed 100644 --- a/src/sunstone/public/js/plugins/dashboard-tab.js +++ b/src/sunstone/public/js/plugins/dashboard-tab.js @@ -19,9 +19,9 @@ var dashboard_tab_content = \ \
\ -

Hosts\ +

Hosts\
\ - +\ + +\
\

\
\ @@ -40,9 +40,9 @@ var dashboard_tab_content = \ \
\ -

Clusters\ +

Clusters\
\ - +\ + +\
\

\
\ @@ -59,9 +59,9 @@ var dashboard_tab_content = \ \
\ -

Virtual Machines\ +

Virtual Machines\
\ - +\ + +\
\

\
\ @@ -84,9 +84,9 @@ var dashboard_tab_content = \ \
\ -

Virtual Networks\ +

Virtual Networks\
\ - +\ + +\
\

\
\ @@ -109,9 +109,9 @@ var dashboard_tab_content = \
\

\ - Images\ + Images\
\ - +\ + +\
\

\
\ @@ -130,9 +130,9 @@ var dashboard_tab_content = \ \
\ -

Users\ +

Users\
\ - +\ + +\
\

\
\ diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js index 0e24295ef5..8aa4c801b8 100644 --- a/src/sunstone/public/js/plugins/hosts-tab.js +++ b/src/sunstone/public/js/plugins/hosts-tab.js @@ -310,12 +310,12 @@ var host_buttons = { }; var host_info_panel = { - "info_tab" : { + "host_info_tab" : { title: "Host information", content:"" }, - "template_tab" : { + "host_template_tab" : { title: "Host template", content: "" } @@ -326,7 +326,7 @@ for (action in host_actions){ } // title, content, buttons, id -Sunstone.addMainTab('hosts_tab','Hosts',hosts_tab_content,host_buttons); +Sunstone.addMainTab('hosts_tab','Hosts & Clusters',hosts_tab_content,host_buttons); Sunstone.addInfoPanel("host_info_panel",host_info_panel); diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js index e1311fd34d..dfb7777887 100644 --- a/src/sunstone/public/js/plugins/images-tab.js +++ b/src/sunstone/public/js/plugins/images-tab.js @@ -208,8 +208,21 @@ var image_actions = { "Image.addattr" : { type: "multiple", - call: OpenNebula.Image.addattr, - callback: function (req) { + call: function(obj){ + var id_attr = obj.data.id; + var name = $('#img_attr_name').val(); + var value = $('#img_attr_value').val(); + OpenNebula.Image.addattr( + {data: { + id: id_attr, + name: name, + value: value + }, + success: obj.success, + error: obj.error + }); + }, + callback : function (req) { Sunstone.runAction("Image.show",req.request.data[0]); }, dataTable: function(){return dataTable_images}, @@ -222,9 +235,25 @@ var image_actions = { call: popUpImageAddattrDialog }, + "Image.updateattr_dialog" : { + type: "custom", + call: popUpImageAddattrDialog + }, + "Image.rmattr" : { type: "multiple", - call: OpenNebula.Image.rmattr, + call: function(obj){ + var id_attr = obj.data.id; + var name = $('#img_attr_name').val(); + OpenNebula.Image.rmattr( + {data: { + id: id_attr, + name: name + }, + success: obj.success, + error: obj.error + }); + }, callback: function (req) { Sunstone.runAction("Image.show",req.request.data[0]); }, @@ -234,9 +263,8 @@ var image_actions = { }, "Image.rmattr_dialog" : { - type: "custom" + type: "custom", call: popUpImageRmattrDialog, - notify: False }, "Image.enable" : { @@ -335,12 +363,12 @@ var image_buttons = { text: "Add attribute", condition: True }, - "Image.addattr_dialog" : { + "Image.updateattr_dialog" : { type: "action", text: "Update attribute", condition: True }, - "Image.rmattr_dialog:" : { + "Image.rmattr_dialog" : { type: "action", text: "Remove attribute", condition: True @@ -389,12 +417,14 @@ var image_buttons = { } var image_info_panel = { - "info_tab" : { - + "image_info_tab" : { + title: "Image information", + content: "" }, - "template_tab" : { - + "image_template_tab" : { + title: "Image template", + content: "" } } @@ -493,6 +523,73 @@ function updateImagesView(request, images_list){ } +function setupImageAttributesDialogs(){ + $('div#dialogs').append('
'); + + $('#image_attributes_dialog').html( + '
\ +
\ +
\ +
\ +
\ + \ + \ +
\ +
\ + \ + \ +
\ +
\ + \ + \ +
\ +
\ +
'); + + $('#image_attributes_dialog').dialog({ + autoOpen:false, + width:400, + modal:true, + height:220, + resizable:false, + }); + + $('#image_attributes_dialog button').button(); + + $('#img_attr_name').keyup(function(){ + $(this).val($(this).val().toUpperCase()); + }); + + $('#image_attributes_dialog #img_attr_cancel').click(function(){ + $('#image_attributes_dialog').dialog('close'); + return false; + }); + +} + +function popUpImageAddattrDialog(){ + + $('#img_attr_value').show(); + $('#img_attr_value').prev().show(); + var desc = "Please write the name and value of the attribute. It will be added or updated in all selected images:"; + $('#img_attr_proceed').val("Image.addattr"); + $('#img_attr_action_desc').html(desc); + $('#image_attributes_dialog').dialog('open'); + return false; +} + +function popUpImageRmattrDialog(){ + + $('#img_attr_value').hide(); + $('#img_attr_value').prev().hide(); + var desc = "Please type the attribute you want to remove:"; + $('#img_attr_proceed').val("Image.rmattr"); + $('#img_attr_action_desc').html(desc); + $('#image_attributes_dialog').dialog('open'); + return false; +} + + function updateImageInfo(request,img){ var img_info = img.IMAGE; var info_tab = { @@ -721,6 +818,8 @@ $(document).ready(function(){ Sunstone.runAction("Image.list"); setupCreateImageDialog(); + setupImageAttributesDialogs(); + setupTips($('#create_image_dialog')); setInterval(function(){ var nodes = $('input:checked',dataTable_images.fnGetNodes()); @@ -734,11 +833,4 @@ $(document).ready(function(){ tableCheckboxesListener(dataTable_images); imageInfoListener(); -} - - - - - - - +}) diff --git a/src/sunstone/public/js/plugins/users-tab.js b/src/sunstone/public/js/plugins/users-tab.js index 399fbf0599..4913f8363d 100644 --- a/src/sunstone/public/js/plugins/users-tab.js +++ b/src/sunstone/public/js/plugins/users-tab.js @@ -70,7 +70,7 @@ var user_actions = { "User.list" : { type: "list", - call: OpenNebula.User.list + call: OpenNebula.User.list, callback: updateUsersView, error: onError, notify: False @@ -229,4 +229,4 @@ $(document).ready(function(){ initCheckAllBoxes(dataTable_users); tableCheckboxesListener(dataTable_users); -} +}) diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index 1895bc7fa8..7d32e5a5ba 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -494,12 +494,12 @@ var vm_actions = { }, "VM.create_dialog" : { - type: "custom" + type: "custom", call: popUpCreateVMDialog, }, "VM.list" : { - type: "list" + type: "list", call: OpenNebula.VM.list, callback: updateVMachinesView, error: onError, @@ -662,7 +662,7 @@ var vm_actions = { }, "VM.log" : { - type: "single" + type: "single", call: OpenNebula.VM.log, callback: function(req,res) { var log_lines = res.split("\n"); @@ -798,20 +798,23 @@ var vm_buttons = { "VM.delete" : { type: "confirm", text: "Delete", - tip: "This will delete the selected VMs from the database" + tip: "This will delete the selected VMs from the database", condition: True } } var vm_info_panel = { - "info_tab" : { - + "vm_info_tab" : { + title: "Virtual Machine information", + content: "" }, - "template_tab" : { - + "vm_template_tab" : { + title: "VM template", + content: "" }, - "log_tab" : { - + "vm_log_tab" : { + title: "VM log", + content: "" } } @@ -1725,7 +1728,7 @@ $(document).ready(function(){ initCheckAllBoxes(dataTable_vMachines); tableCheckboxesListener(dataTable_vMachines); vMachineInfoListener(); + setupTips($('#create_vm_dialog')); -} - +}) diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js index aceaaa060f..8bc4d99f4d 100644 --- a/src/sunstone/public/js/plugins/vnets-tab.js +++ b/src/sunstone/public/js/plugins/vnets-tab.js @@ -137,7 +137,7 @@ var vnet_actions = { "Network.create_dialog" : { type: "custom", - call: popUpCreateNetworkDialog + call: popUpCreateVnetDialog }, "Network.list" : { @@ -162,7 +162,7 @@ var vnet_actions = { callback: updateVNetworkInfo, error: onError, notify: False - } + }, "Network.refresh" : { @@ -242,11 +242,13 @@ var vnet_buttons = { } var vnet_info_panel = { - "info_tab" : { - + "vnet_info_tab" : { + title: "Virtual network information", + content: "" }, - "template_tab" : { - + "vnet_template_tab" : { + title: "Virtual network template", + content: "" } } @@ -389,10 +391,11 @@ function updateVNetworkInfo(request,vn){ } -function setupCreateVNetDialog { - +function setupCreateVNetDialog() { $('div#dialogs').append('
'); + $('#create_vn_dialog').html(create_vn_tmpl); + //Prepare the jquery-ui dialog. Set style options here. $('#create_vn_dialog').dialog({ @@ -519,7 +522,7 @@ function setupCreateVNetDialog { }); } -function popUpCreateVnetDialog { +function popUpCreateVnetDialog() { $('#create_vn_dialog').dialog('open'); } @@ -557,8 +560,7 @@ $(document).ready(function(){ initCheckAllBoxes(dataTable_vNetworks); tableCheckboxesListener(dataTable_vNetworks); - vNetworkInfoListener() + vNetworkInfoListener(); -} - +}); diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js index a50c0740f8..6edf2197a6 100644 --- a/src/sunstone/public/js/sunstone-util.js +++ b/src/sunstone/public/js/sunstone-util.js @@ -154,7 +154,7 @@ function tableCheckboxesListener(dataTable){ total_length = nodes.length; checked_length = $('input:checked',nodes).length; - if (total_length == checked_length){ + if (total_length == checked_length && total_length != 0){ $('.check_all',dataTable).attr("checked","checked"); } else { $('.check_all',dataTable).removeAttr("checked"); @@ -165,11 +165,11 @@ function tableCheckboxesListener(dataTable){ if (last_action_b.length && last_action_b.val().length){ last_action_b.button("enable"); }; - $('.new_button',context).button("enable"); + $('.create_dialog_button',context).button("enable"); } else { $('.top_button, .list_button',context).button("disable"); last_action_b.button("disable"); - $('.new_button',context).button("enable"); + $('.create_dialog_button',context).button("enable"); } }); @@ -333,6 +333,52 @@ function waitingNodes(dataTable){ } }; +function getUserName(uid){ + var user = "uid "+uid; + if (typeof(dataTable_users) == "undefined") { + return user; + } + nodes = dataTable_users.fnGetData(); + + $.each(nodes,function(){ + if (uid == this[1]) { + user = this[2]; + return false; + } + }); + return user; + +} + + +//Replaces all class"tip" divs with an information icon that +//displays the tip information on mouseover. +function setupTips(context){ + $('div.tip',context).each(function(){ + tip = $(this).html(); + $(this).html(''); + $(this).append(''); + + $(this).append(''); + + + $('span.tipspan',this).html(tip); + $(this).parent().append('
'); + $('span.tipspan',this).hide(); + $('span.info_icon',this).hover(function(e){ + var top, left; + top = e.pageY - 15;// - $(this).parents('#create_vm_dialog').offset().top - 15; + left = e.pageX + 15;// - $(this).parents('#create_vm_dialog').offset().left; + $(this).next().css( + {"top":top+"px", + "left":left+"px"}); + $(this).next().fadeIn(); + },function(){ + $(this).next().fadeOut(); + }); + }); +} + function True(){ return true; diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js index ef9419a75f..c103b64476 100644 --- a/src/sunstone/public/js/sunstone.js +++ b/src/sunstone/public/js/sunstone.js @@ -56,8 +56,9 @@ var Sunstone = { "addMainTab" : function(tab_id,title_arg,content_arg, buttons_arg,refresh,condition_f) { SunstoneCfg["tabs"][tab_id] = {title: title_arg, content: content_arg, - buttons: buttons_arg. - condition: condition_f }; + buttons: buttons_arg, + condition: condition_f + }; if (refresh){ } @@ -94,7 +95,7 @@ var Sunstone = { $('ul',info_panel).append('
  • '+tab.title+'
  • '); info_panel.append('
    '+tab.content+'
    '); } - if (selected){ + if (selected_tab){ return info_panel.tabs({selected: selected_tab}); } return info_panel.tabs({selected: 0}); @@ -230,7 +231,6 @@ $(document).ready(function(){ initListButtons(); setupCreateDialogs(); //listener for create setupConfirmDialogs(); - setupTips(); $('.action_button').live("click",function(){ @@ -351,7 +351,7 @@ function insertButtonsInTab(tab_name){ button_code += ''; break; case "image": - button_code = ''+button.text+''; + button_code = ''+button.text+''; break; case "create_dialog": button_code = ''; @@ -609,30 +609,4 @@ function popUpConfirmWithSelectDialog(target_elem){ } -//Replaces all class"tip" divs with an information icon that -//displays the tip information on mouseover. -function setupTips(){ - $('div.tip').each(function(){ - tip = $(this).html(); - $(this).html(''); - $(this).append(''); - $(this).append(''); - - - $('span.tipspan',this).html(tip); - $(this).parent().append('
    '); - $('span.tipspan',this).hide(); - $('span.info_icon',this).hover(function(e){ - var top, left; - top = e.pageY - 15;// - $(this).parents('#create_vm_dialog').offset().top - 15; - left = e.pageX + 15;// - $(this).parents('#create_vm_dialog').offset().left; - $(this).next().css( - {"top":top+"px", - "left":left+"px"}); - $(this).next().fadeIn(); - },function(){ - $(this).next().fadeOut(); - }); - }); -} diff --git a/src/sunstone/templates/index.html b/src/sunstone/templates/index.html index e0358c84a2..dde5991aa2 100644 --- a/src/sunstone/templates/index.html +++ b/src/sunstone/templates/index.html @@ -24,6 +24,10 @@ + + + +