From 516121374a92fb21d5984aef4240597ebbc437e7 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 13 Jan 2012 20:00:13 +0100 Subject: [PATCH 1/2] SelfService: small fixes Add checkboxes to compute creation resource selects. Add ids next to the checkboxes names. Hitting return now submits instead of closing the creation dialogs. Treat the case when description is undefined. (cherry picked from commit 8d18227865885970ffc305a442b46f1eab14f3b9) --- .../occi/lib/ui/public/js/plugins/compute.js | 16 ++++++++++++---- .../occi/lib/ui/public/js/plugins/network.js | 4 ++-- .../occi/lib/ui/public/js/plugins/storage.js | 6 +++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/cloud/occi/lib/ui/public/js/plugins/compute.js b/src/cloud/occi/lib/ui/public/js/plugins/compute.js index fb64497c31..aaab2fc1c4 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/compute.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/compute.js @@ -93,8 +93,8 @@ var create_vm_tmpl ='
\ \ \
\ - \ - \ + \ + \ \
\ \ @@ -695,6 +695,10 @@ function popUpCreateVMDialog(){ ); $('#network_box',dialog).html(net_select); + $('#network_box option',dialog).each(function(){ + $(this).text('☐ '+$(this).text()+' (id:'+$(this).val()+')'); + }); + var image_select = makeSelectOptions(dataTable_images, 1,//id_col @@ -704,6 +708,10 @@ function popUpCreateVMDialog(){ true); $('#disk_box',dialog).html(image_select); + $('#disk_box option',dialog).each(function(){ + $(this).text('☐ '+$(this).text()+' (id:'+$(this).val()+')'); + }); + $('#network_box,#disk_box',dialog).change(function(){ $(this).val(""); @@ -713,11 +721,11 @@ function popUpCreateVMDialog(){ $('#network_box option,#disk_box option',dialog).click(function(){ var clicked = $(this).attr('clicked'); if (clicked){//unbold, unmark - $(this).text($(this).text().replace(/✓/g,'')); + $(this).text($(this).text().replace(/☒/g,'☐')); $(this).removeAttr('clicked'); } else {//bold,mark - $(this).text("✓"+$(this).text()); + $(this).text($(this).text().replace(/☐/g,'☒')); $(this).attr('clicked','clicked'); } return false; diff --git a/src/cloud/occi/lib/ui/public/js/plugins/network.js b/src/cloud/occi/lib/ui/public/js/plugins/network.js index 436b040939..257eb9cf04 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/network.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/network.js @@ -53,8 +53,8 @@ var create_vn_tmpl =
\ \
\ - \ - \ + \ + \ \
\
\ diff --git a/src/cloud/occi/lib/ui/public/js/plugins/storage.js b/src/cloud/occi/lib/ui/public/js/plugins/storage.js index d6fbfe10d9..5b7f768d40 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/storage.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/storage.js @@ -92,8 +92,8 @@ var create_image_tmpl =
\ -->\
\ - \ - \ + \ + \ \
\ \ @@ -369,7 +369,7 @@ function updateImageInfo(request,img){ \ \ '+tr("Description")+'\ - '+img_info.DESCRIPTION+'\ + '+(img_info.DESCRIPTION ? img_info.DESCRIPTION : "--")+'\ \ \ '+tr("Type")+'\ From 0c1121a8d3f2e57db27d75f11d50890ca24fb752 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Sat, 14 Jan 2012 14:43:11 +0100 Subject: [PATCH 2/2] Sunstone: add user info tab Information tab pops up when clicking on elements from the user table. (cherry picked from commit a99477871abd11718555fef62118e19e9d2768ff) --- src/sunstone/public/js/plugins/users-tab.js | 75 +++++++++++++++++++-- src/sunstone/public/locale/en_US/en_US.js | 2 + 2 files changed, 71 insertions(+), 6 deletions(-) diff --git a/src/sunstone/public/js/plugins/users-tab.js b/src/sunstone/public/js/plugins/users-tab.js index bb5e20eda2..a9d35c164f 100644 --- a/src/sunstone/public/js/plugins/users-tab.js +++ b/src/sunstone/public/js/plugins/users-tab.js @@ -186,6 +186,13 @@ var user_actions = { error: onError }, + "User.showinfo" : { + type: "single", + call: OpenNebula.User.show, + callback: updateUserInfo, + error: onError + }, + "User.delete" : { type: "multiple", call: OpenNebula.User.delete, @@ -285,7 +292,14 @@ var user_buttons = { type: "confirm", text: tr("Delete") } -} +}; + +var user_info_panel = { + "user_info_tab" : { + title: tr("User information"), + content:"" + }, +}; var users_tab = { title: tr("Users"), @@ -295,6 +309,7 @@ var users_tab = { Sunstone.addActions(user_actions); Sunstone.addMainTab('users_tab',users_tab); +Sunstone.addInfoPanel("user_info_panel",user_info_panel); function userElements(){ return getSelectedNodes(dataTable_users); @@ -312,8 +327,21 @@ function userElementArray(user_json){ user.GNAME, user.AUTH_DRIVER ] -} +}; +function userInfoListener(){ + $('#tbodyusers tr',dataTable_users).live("click",function(e){ + //do nothing if we are clicking a checkbox! + if ($(e.target).is('input')) return true; + var aData = dataTable_users.fnGetData(this); + var id = $(aData[0]).val(); + if (!id) return true; + + popDialogLoading(); + Sunstone.runAction("User.showinfo",id); + return false; + }); +}; function updateUserSelect(){ users_select = makeSelectOptions(dataTable_users, @@ -354,7 +382,42 @@ function updateUsersView(request,users_list){ updateView(user_list_array,dataTable_users); updateDashboard("users",users_list); updateUserSelect(); -} +}; + +function updateUserInfo(request,user){ + var user_info = user.USER; + + var info_tab = { + title : tr("User information"), + content : + '\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
' + tr("User information") + ' - '+user_info.NAME+'
' + tr("id") + ''+user_info.ID+'
' + tr("Group") + ''+user_info.GNAME+'
' + tr("Authentication driver") + ''+user_info.AUTH_DRIVER+'
\ + \ + '+ + prettyPrintJSON(user_info.TEMPLATE)+ + '
' + tr("User template") + '
' + }; + + Sunstone.updateInfoPanelTab("user_info_panel","user_info_tab",info_tab); + Sunstone.popUpInfoPanel("user_info_panel"); +}; // Prepare the user creation dialog function setupCreateUserDialog(){ @@ -461,7 +524,7 @@ $(document).ready(function(){ ], "oLanguage": (datatable_lang != "") ? { - sUrl: "locale/"+lang+"/"+datatable_lang + sUrl: "locale/"+lang+"/"+datatable_lang } : "" }); dataTable_users.fnClearTable(); @@ -478,5 +541,5 @@ $(document).ready(function(){ initCheckAllBoxes(dataTable_users); tableCheckboxesListener(dataTable_users); //shortenedInfoFields('#datatable_users'); - -}) + userInfoListener(); +}); diff --git a/src/sunstone/public/locale/en_US/en_US.js b/src/sunstone/public/locale/en_US/en_US.js index abd23e3ef1..91db79fee5 100644 --- a/src/sunstone/public/locale/en_US/en_US.js +++ b/src/sunstone/public/locale/en_US/en_US.js @@ -431,9 +431,11 @@ locale={ "Used Mem (real)":"", "Useful for power management, for example, normally required for graceful shutdown to work":"", "User":"", + "User information":"", "Username":"", "User name and password must be filled in":"", "Users":"", + "User template":"", "Value":"", "Value of the context variable":"", "Value of the custom variable":"",