From facea2317804ecca8b615fbcc52214d8a46aba0f Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 21 Sep 2012 18:24:03 +0200 Subject: [PATCH 1/8] Appflow: reset role fields when adding role. Delete as link instead of button --- .../js/user-plugins/apptools.appflow.templates.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js b/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js index 0b76aa9a3e..3d75377666 100644 --- a/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js +++ b/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js @@ -601,6 +601,7 @@ function setupCreateServiceTemplateDialog(){ var row = $(this).parents('tr'); removeParentRole(row.attr('name')); row.fadeOut().remove(); + return false; }); $('select[name="parents"]', dialog).change(function(){ @@ -651,13 +652,18 @@ function setupCreateServiceTemplateDialog(){ str += ''+ cardinality +''; str += ''+ template +''; str += ''+ parents.join(',') +''; - str += ''; + str += 'Delete'; str += ''; var ok = addParentRole(name); - if (ok) + if (ok){ $('table#current_roles tbody', dialog).append($(str).hide().fadeIn()); + $('input[name="name"]', context).val(""); + $('input[name="cardinality"]', context).val("1"); + //unselect selected parents + $('select[name="parents"] option[clicked="clicked"]').trigger('click'); + } else notifyError(tr("There is already a role with this name!")); From df9b50f47489a231eb86a4b001178a23e8ea4497 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 25 Sep 2012 17:34:56 +0200 Subject: [PATCH 2/8] Appstage: fix wrong datatable name --- stage/sunstone/public/js/user-plugins/apptools.appstage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stage/sunstone/public/js/user-plugins/apptools.appstage.js b/stage/sunstone/public/js/user-plugins/apptools.appstage.js index cc5e8be5fb..5cea915394 100644 --- a/stage/sunstone/public/js/user-plugins/apptools.appstage.js +++ b/stage/sunstone/public/js/user-plugins/apptools.appstage.js @@ -238,7 +238,7 @@ var appstage_actions = { "AppStage.refresh" : { type: "custom", call: function () { - waitingNodes(dataTable_appStages); + waitingNodes(dataTable_appstages); Sunstone.runAction("AppStage.list"); } }, @@ -497,7 +497,7 @@ function updateAppStageInfo(request,elem){ \ \ '; - }; + }; } // Form options of compatible templates From dbb2bf215b1a1b0b457b46185789fbe8731b8a91 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 25 Sep 2012 17:35:13 +0200 Subject: [PATCH 3/8] Appflow: add update properties dialog to service templates --- .../apptools.appflow.templates.js | 159 +++++++++++++++--- 1 file changed, 133 insertions(+), 26 deletions(-) diff --git a/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js b/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js index 775a9ab204..8879583136 100644 --- a/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js +++ b/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js @@ -139,19 +139,13 @@ var create_service_template_tmpl = '\ \ '; -/* + var update_service_template_tmpl = '
\ -

'+tr("Please, choose and modify the flowironment you want to update")+':

\ +

'+tr("Please, choose and modify the service template")+':

\
\ - \ - \ -
\ - \ - \ -
\ - \ + \ + \
\
\ \ @@ -162,36 +156,34 @@ var update_service_template_tmpl = \ \ \ - \ - \ - \ + \ + \ + \ \ \ \ - \ - \ - \ + \ + \ + \ \ \ \ - \ - \ - \ + \ + \ + \ \
'+tr("Admin")+'
'+tr("Owner")+'
'+tr("Group")+'
'+tr("Other")+'
\
\ - \ -
\ - \
\
\
\ - \
\
\
'; -*/ + var dataTable_service_templates; var $create_service_template_dialog; @@ -210,6 +202,11 @@ var service_template_actions = { call: popUpCreateServiceTemplateDialog }, + "ServiceTemplate.update_dialog" : { + type : "custom", + call : popUpServiceTemplateUpdateDialog + }, + "ServiceTemplate.list" : { type: "list", call: ServiceTemplate.list, @@ -288,10 +285,20 @@ var service_template_actions = { "ServiceTemplate.chmod" : { type: "single", call: ServiceTemplate.chmod, -// callback error: onError, notify: true }, + + "ServiceTemplate.fetch_permissions" : { + type : "single", + call : ServiceTemplate.show, + callback : function(request, json){ + var dialog = $('#service_template_update_dialog form'); + var tmpl = json.DOCUMENT; + setPermissionsTable(tmpl, dialog); + }, + error: onError + }, /* "ServiceTemplate.clone_dialog" : { type: "custom", @@ -324,6 +331,13 @@ var service_template_buttons = { type: "create_dialog", text: tr("+ New") }, + + "ServiceTemplate.update_dialog" : { + type: "action", + text: tr("Update properties"), + alwaysActive: true + }, + "ServiceTemplate.instantiate" : { type: "action", text: tr("Instantiate") @@ -724,6 +738,99 @@ function popUpCreateServiceTemplateDialog(){ } +function setupServiceTemplateUpdateDialog(){ + //Append to DOM + dialogs_context.append('
'); + var dialog = $('#service_template_update_dialog',dialogs_context); + + //Put HTML in place + dialog.html(update_service_template_tmpl); + + var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window + + //Convert into jQuery + dialog.dialog({ + autoOpen:false, + width:500, + modal:true, + height:height, + resizable:true + }); + + $('button',dialog).button(); + + $('#service_template_update_select',dialog).change(function(){ + var id = $(this).val(); + $('.permissions_table input', dialog).removeAttr('checked'); + $('.permissions_table', dialog).removeAttr('update'); + if (id && id.length){ + Sunstone.runAction("ServiceTemplate.fetch_permissions", id); + }; + }); + + $('.permissions_table input',dialog).change(function(){ + $(this).parents('table').attr('update','update'); + }); + + $('form',dialog).submit(function(){ + var dialog = $(this); + var id = $('#service_template_update_select',dialog).val(); + if (!id || !id.length) { + $(this).parents('#service_template_update_dialog').dialog('close'); + return false; + }; + + var permissions = $('.permissions_table',dialog); + if (permissions.attr('update')){ + var perms = { + octet : buildOctet(permissions) + }; + Sunstone.runAction("ServiceTemplate.chmod", id, perms); + }; + + $(this).parents('#service_template_update_dialog').dialog('close'); + return false; + }); +}; + + +function popUpServiceTemplateUpdateDialog(){ + var select = makeSelectOptions(dataTable_service_templates, + 1,//id_col + 4,//name_col + [], + [] + ); + var sel_elems = getSelectedNodes(dataTable_service_templates); + + + var dialog = $('#service_template_update_dialog'); + $('#service_template_update_select', dialog).html(select); +// $('#service_template_update_textarea',dialog).val(""); + $('.permissions_table input', dialog).removeAttr('checked'); + $('.permissions_table', dialog).removeAttr('update'); + + if (sel_elems.length >= 1){ //several items in the list are selected + //grep them + var new_select= sel_elems.length > 1? '' : ""; + $('option','').each(function(){ + var val = $(this).val(); + if ($.inArray(val,sel_elems) >= 0){ + new_select+=''; + }; + }); + $('#service_template_update_select', dialog).html(new_select); + if (sel_elems.length == 1) { + $('#service_template_update_select option', + dialog).attr('selected','selected'); + $('#service_template_update_select', dialog).trigger("change"); + }; + }; + + dialog.dialog('open'); + return false; +} + // Set the autorefresh interval for the datatable function setServiceTemplateAutorefresh() { setInterval(function(){ @@ -848,7 +955,7 @@ $(document).ready(function(){ setupCreateServiceTemplateDialog(); - + setupServiceTemplateUpdateDialog(); // setupImageCloneDialog(); setServiceTemplateAutorefresh(); From 23f2139fa2219e6c0ab3121229e7bc284426d597 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 25 Sep 2012 18:02:08 +0200 Subject: [PATCH 4/8] Appflow: add update properties dialog to services --- .../user-plugins/apptools.appflow.services.js | 159 +++++++++++++++--- 1 file changed, 131 insertions(+), 28 deletions(-) diff --git a/flow/sunstone/public/js/user-plugins/apptools.appflow.services.js b/flow/sunstone/public/js/user-plugins/apptools.appflow.services.js index 45d4b2f9cc..e4ee9e3f7f 100644 --- a/flow/sunstone/public/js/user-plugins/apptools.appflow.services.js +++ b/flow/sunstone/public/js/user-plugins/apptools.appflow.services.js @@ -162,19 +162,15 @@ var create_service_tmpl = '\ \ \ '; +*/ + var update_service_tmpl = '
\ -

'+tr("Please, choose and modify the flowironment you want to update")+':

\ +

'+tr("Please, choose and modify the service")+':

\
\ - \ - \ -
\ - \ - \ -
\ - \ + \ + \
\
\ \ @@ -185,42 +181,38 @@ var update_service_tmpl = \ \ \ - \ - \ - \ + \ + \ + \ \ \ \ - \ - \ - \ + \ + \ + \ \ \ \ - \ - \ - \ + \ + \ + \ \
'+tr("Admin")+'
'+tr("Owner")+'
'+tr("Group")+'
'+tr("Other")+'
\
\ - \ -
\ - \
\
\
\ - \
\
\
'; -*/ + var dataTable_services; //var $create_service_dialog; var service_actions = { - - "Service.list" : { type: "list", call: Service.list, @@ -228,6 +220,11 @@ var service_actions = { error: onError }, + "Service.update_dialog" : { + type : "custom", + call : popUpServiceUpdateDialog + }, + "Service.show" : { type : "single", call: Service.show, @@ -291,11 +288,21 @@ var service_actions = { "Service.chmod" : { type: "single", call: Service.chmod, -// callback error: onError, notify: true }, + "Service.fetch_permissions" : { + type : "single", + call : Service.show, + callback : function(request, json){ + var dialog = $('#service_update_dialog form'); + var tmpl = json.DOCUMENT; + setPermissionsTable(tmpl, dialog); + }, + error: onError + }, + "Service.shutdown" : { type: "multiple", call: Service.shutdown, @@ -333,6 +340,13 @@ var service_buttons = { text: '', alwaysActive: true }, + + "Service.update_dialog" : { + type: "action", + text: tr("Update properties"), + alwaysActive: true + }, + "Service.chown" : { type: "confirm_with_select", text: tr("Change owner"), @@ -688,8 +702,98 @@ function updateServiceInfo(request,elem){ } +function setupServiceUpdateDialog(){ + //Append to DOM + dialogs_context.append('
'); + var dialog = $('#service_update_dialog', dialogs_context); + + //Put HTML in place + dialog.html(update_service_tmpl); + + var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window + + //Convert into jQuery + dialog.dialog({ + autoOpen:false, + width:500, + modal:true, + height:height, + resizable:true + }); + + $('button',dialog).button(); + + $('#service_update_select',dialog).change(function(){ + var id = $(this).val(); + $('.permissions_table input', dialog).removeAttr('checked'); + $('.permissions_table', dialog).removeAttr('update'); + if (id && id.length){ + Sunstone.runAction("Service.fetch_permissions", id); + }; + }); + + $('.permissions_table input',dialog).change(function(){ + $(this).parents('table').attr('update','update'); + }); + + $('form',dialog).submit(function(){ + var dialog = $(this); + var id = $('#service_update_select',dialog).val(); + if (!id || !id.length) { + $(this).parents('#service_update_dialog').dialog('close'); + return false; + }; + + var permissions = $('.permissions_table',dialog); + if (permissions.attr('update')){ + var perms = { + octet : buildOctet(permissions) + }; + Sunstone.runAction("Service.chmod", id, perms); + }; + + $(this).parents('#service_update_dialog').dialog('close'); + return false; + }); +}; +function popUpServiceUpdateDialog(){ + var select = makeSelectOptions(dataTable_services, + 1,//id_col + 4,//name_col + [], + [] + ); + var sel_elems = getSelectedNodes(dataTable_services); + + + var dialog = $('#service_update_dialog'); + $('#service_update_select', dialog).html(select); +// $('#service_update_textarea',dialog).val(""); + $('.permissions_table input', dialog).removeAttr('checked'); + $('.permissions_table', dialog).removeAttr('update'); + + if (sel_elems.length >= 1){ //several items in the list are selected + //grep them + var new_select= sel_elems.length > 1? '' : ""; + $('option','').each(function(){ + var val = $(this).val(); + if ($.inArray(val,sel_elems) >= 0){ + new_select+=''; + }; + }); + $('#service_update_select', dialog).html(new_select); + if (sel_elems.length == 1) { + $('#service_update_select option', + dialog).attr('selected','selected'); + $('#service_update_select', dialog).trigger("change"); + }; + }; + + dialog.dialog('open'); + return false; +} // Set the autorefresh interval for the datatable @@ -817,8 +921,7 @@ $(document).ready(function(){ '','','','','',''],dataTable_services); Sunstone.runAction("Service.list"); - - + setupServiceUpdateDialog(); // setupImageCloneDialog(); setServiceAutorefresh(); From 124037eb45c48eda0c7d90d390c91c4749d0f503 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 25 Sep 2012 18:10:40 +0200 Subject: [PATCH 5/8] Appflow: clean roles from wizard after succesful creation --- .../public/js/user-plugins/apptools.appflow.templates.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js b/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js index 8879583136..99413f0062 100644 --- a/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js +++ b/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js @@ -192,7 +192,13 @@ var service_template_actions = { "ServiceTemplate.create" : { type: "create", call: ServiceTemplate.create, - callback: addServiceTemplateElement, + callback: function(req, res){ + //empty creation dialog roles after successful creation + var dialog = $create_service_template_dialog; + $('table#current_roles tbody', dialog).empty(); + $('select[name="parents"]', dialog).empty(); + addServiceTemplateElement(req, res); + }, error: onError, notify:true }, From 146431d61add1533071527d1c6815a8eff006bf6 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 25 Sep 2012 18:24:03 +0200 Subject: [PATCH 6/8] Appflow: do not show roles/vms tabs when there are no roles defined (in template info and services info) --- .../user-plugins/apptools.appflow.services.js | 25 ++++++++----------- .../apptools.appflow.templates.js | 17 ++++--------- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/flow/sunstone/public/js/user-plugins/apptools.appflow.services.js b/flow/sunstone/public/js/user-plugins/apptools.appflow.services.js index e4ee9e3f7f..2214b7cda6 100644 --- a/flow/sunstone/public/js/user-plugins/apptools.appflow.services.js +++ b/flow/sunstone/public/js/user-plugins/apptools.appflow.services.js @@ -386,13 +386,7 @@ var service_info_panel = { "service_info_tab" : { title: tr("Service information"), content: "" - }, -/* - "service_node_tab" : { - title: tr("Node"), - content: "" } -*/ } var services_tab = { @@ -556,7 +550,7 @@ function updateServiceInfo(request,elem){ ' var roles = elem_info.TEMPLATE.BODY.roles - if (roles) + if (roles && roles.length) for (var i = 0; i < roles.length; i++) { roles_info += ''+tr("Role")+' '+roles[i].name+'\ \ @@ -586,8 +580,6 @@ function updateServiceInfo(request,elem){ content: roles_info } - - var vms_tab = { title : "Virtual Machines", content : '\ @@ -636,13 +628,18 @@ function updateServiceInfo(request,elem){ Sunstone.updateInfoPanelTab("service_info_panel", "service_info_tab",info_tab); - Sunstone.updateInfoPanelTab("service_info_panel", - "service_role_tab",roles_tab); - - if (roles.length) + if (roles.length){ + Sunstone.addInfoPanelTab("service_info_panel", + "service_role_tab",roles_tab); Sunstone.updateInfoPanelTab("service_info_panel", "service_vms_tab",vms_tab); - + } + else { + Sunstone.removeInfoPanelTab("service_info_panel", + "service_role_tab"); + Sunstone.removeInfoPanelTab("service_info_panel", + "service_vms_tab"); + }; Sunstone.updateInfoPanelTab("service_info_panel", "service_log_tab",logs_tab); diff --git a/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js b/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js index 99413f0062..58fa0f62cf 100644 --- a/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js +++ b/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js @@ -383,13 +383,7 @@ var service_template_info_panel = { "service_template_info_tab" : { title: tr("Service information"), content: "" - }, -/* - "service_template_node_tab" : { - title: tr("Node"), - content: "" } -*/ } var service_templates_tab = { @@ -531,15 +525,11 @@ function updateServiceTemplateInfo(request,elem){ ' }; - - - - var roles_info = '\ ' var roles = elem_info.TEMPLATE.BODY.roles - if (roles) + if (roles && roles.length > 0) for (var i = 0; i < roles.length; i++) { roles_info += '\ \ @@ -575,7 +565,10 @@ function updateServiceTemplateInfo(request,elem){ } */ Sunstone.updateInfoPanelTab("service_template_info_panel","service_template_info_tab",info_tab); - Sunstone.updateInfoPanelTab("service_template_info_panel","service_template_roles_tab",roles_tab); + if (roles && roles.length > 0) + Sunstone.addInfoPanelTab("service_template_info_panel","service_template_roles_tab",roles_tab); + else + Sunstone.removeInfoPanelTab("service_template_info_panel","service_template_roles_tab"); Sunstone.popUpInfoPanel("service_template_info_panel"); From cd55dfde94c28d49d16a7ad2c8df1960b4b802f9 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 25 Sep 2012 18:27:20 +0200 Subject: [PATCH 7/8] Appflow: fix/set confirmation messages on delete --- .../public/js/user-plugins/apptools.appflow.services.js | 3 ++- .../public/js/user-plugins/apptools.appflow.templates.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/flow/sunstone/public/js/user-plugins/apptools.appflow.services.js b/flow/sunstone/public/js/user-plugins/apptools.appflow.services.js index 2214b7cda6..ab08479243 100644 --- a/flow/sunstone/public/js/user-plugins/apptools.appflow.services.js +++ b/flow/sunstone/public/js/user-plugins/apptools.appflow.services.js @@ -373,7 +373,8 @@ var service_buttons = { }, "Service.delete" : { type: "confirm", - text: tr("Delete") + text: tr("Delete"), + tip: tr("This will delete the selected services") }, "Service.help" : { type: "action", diff --git a/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js b/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js index 58fa0f62cf..1b60c786ca 100644 --- a/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js +++ b/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js @@ -370,7 +370,8 @@ var service_template_buttons = { */ "ServiceTemplate.delete" : { type: "confirm", - text: tr("Delete") + text: tr("Delete"), + tip: tr("This will delete the selected templates") }, "ServiceTemplate.help" : { type: "action", From 8b0055a8f8b41d26f49309b255bbdc4b291973e3 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 25 Sep 2012 18:48:14 +0200 Subject: [PATCH 8/8] Appflow: add some tips and mandatory icons when creating templates --- .../apptools.appflow.templates.js | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js b/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js index 1b60c786ca..3ab499af24 100644 --- a/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js +++ b/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js @@ -84,36 +84,45 @@ var service_template_tab_content = '\ var create_service_template_tmpl = '\
\ +

'+ + tr("Fields marked with")+' '+ + tr("are mandatory")+'
\

\ ' + tr("Service") + '\ -
\ +
\ \ +
'+ tr("Name for this template") +'
\
\ -
\ +
\ \ \ +
'+ tr("Straight strategy will instantiate each role in order: parents role will be deployed before their children. None strategy will instantiate the roles regardless of their relationships.") +'
\
\
\
\ ' + tr("Roles") + '\ -
\ +
\ \ +
'+ tr("Name for the role") +'
\
\ -
\ +
\ \ +
'+ tr("Number of VMs to instantiate with this role") +'
\
\ -
\ +
\ \ \ +
'+ tr("Template associated to this role") +'
\
\
\ \ \ +
'+ tr("Mark the roles that will be deployed before this one when using the straight strategy") +'
\
\ \ \ @@ -956,6 +965,9 @@ $(document).ready(function(){ setupCreateServiceTemplateDialog(); setupServiceTemplateUpdateDialog(); + setupTips($create_service_template_dialog); + $('.st_man .man_icon', + $create_service_template_dialog).css('display', 'inline-block'); // setupImageCloneDialog(); setServiceTemplateAutorefresh();
'+tr("Role")+' '+roles[i].name+'