diff --git a/flow/sunstone/public/js/apptools-appflow-templates.js b/flow/sunstone/public/js/apptools-appflow-templates.js index cf28cb9593..2198a9beda 100644 --- a/flow/sunstone/public/js/apptools-appflow-templates.js +++ b/flow/sunstone/public/js/apptools-appflow-templates.js @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // // limitations under the License. // //------------------------------------------------------------------------- // +var selected_row_template_role_id; +var last_selected_row_template_role; var ServiceTemplate = { "resource" : 'DOCUMENT', @@ -692,7 +694,7 @@ function updateServiceTemplateInfo(request,elem){ title : "Roles", content : '
\
\ - \ +
\ \ \ \ @@ -717,13 +719,14 @@ function updateServiceTemplateInfo(request,elem){ setPermissionsTable(elem_info,''); $("#service_template_info_panel_refresh", $("#service_template_info_panel")).click(function(){ - $(this).html(spinner); - Sunstone.runAction('ServiceTemplate.showinfo', elem_info.ID); - }); + $(this).html(spinner); + selected_row_template_role_id = $($('td.markrowselected',serviceTemplaterolesDataTable.fnGetNodes())[1]).html(); + Sunstone.runAction('ServiceTemplate.showinfo', elem_info.ID); + }) var roles = elem_info.TEMPLATE.BODY.roles if (roles && roles.length) { - servicerolesDataTable = $('#datatable_service_roles').dataTable({ + serviceTemplaterolesDataTable = $('#datatable_service_template_roles').dataTable({ "bSortClasses": false, "bAutoWidth":false, "aoColumnDefs": [ @@ -742,49 +745,61 @@ function updateServiceTemplateInfo(request,elem){ this.parents ? this.parents.join(', ') : '-' ]) - var info_str = "
\ - "+tr("Role")+" - "+this.name+""; + updateView(role_elements ,serviceTemplaterolesDataTable); - info_str += "
\ -
'+tr("Name")+'
\ + $('tbody tr',serviceTemplaterolesDataTable).live("click",function(e){ + var aData = serviceTemplaterolesDataTable.fnGetData(this); + var role_name = $(aData[0]).val(); + + var role_index = serviceTemplaterolesDataTable.fnGetPosition(this); + + generate_template_role_div(role_index); + + if(last_selected_row_template_role) { + last_selected_row_template_role.children().each(function(){ + $(this).removeClass('markrowselected'); + }); + } + + last_selected_row_template_role = $(this); + $(this).children().each(function(){ + $(this).addClass('markrowselected'); + }); + }); + }); + + var generate_template_role_div = function(role_index) { + var role = roles[role_index] + var info_str = '\ +
\ + '+tr("Role")+' - '+role.name+''; + + info_str += "
\ +
\ \ - \ + \ \ "; - if (this.shutdown_action) { - info_str += "\ - \ - \ - "; - } - if (this.min_vms) { - info_str += "\ - \ - \ - "; - } - if (this.max_vms) { - info_str += "\ - \ - \ - "; - } - if (this.cooldown) { - info_str += "\ - \ - \ - "; - } + info_str += "\ + \ + \ + \ + \ + \ + \ + \ + \ + "; info_str += "\
"+tr("Information")+"
"+tr("Shutdown action")+""+this.shutdown_action+"
"+tr("Min VMs")+""+this.min_vms+"
"+tr("Max VMs")+""+this.max_vms+"
"+tr("Cooldown")+""+this.cooldown+"
"+tr("Shutdown action")+""+(role.shutdown_action || "-")+""+tr("Cooldown")+""+(role.cooldown || "-")+""+tr("Min VMs")+""+(role.min_vms || "-")+""+tr("Max VMs")+""+(role.max_vms || "-")+"
"; info_str += "
\ -
"; +
"; - if (this.elasticity_policies && this.elasticity_policies.length > 0) { + if (role.elasticity_policies && role.elasticity_policies.length > 0) { info_str += '\ \ \ @@ -804,15 +819,15 @@ function updateServiceTemplateInfo(request,elem){ \ '; - $.each(this.elasticity_policies, function(){ + $.each(role.elasticity_policies, function(){ info_str += '\ \ \ - \ + \ \ - \ - \ - \ + \ + \ + \ ' }); @@ -820,7 +835,7 @@ function updateServiceTemplateInfo(request,elem){
'+this.type+''+this.adjust+''+this.min_adjust_step+''+(this.min_adjust_step || "-")+''+this.expression+''+this.period+''+this.period_number+''+this.cooldown+''+(this.period || "-")+''+(this.period_number || "-")+''+(this.cooldown || "-")+'
'; } - if (this.scheduled_policies && this.scheduled_policies.length > 0) { + if (role.scheduled_policies && role.scheduled_policies.length > 0) { info_str += '\ \ \ @@ -838,11 +853,11 @@ function updateServiceTemplateInfo(request,elem){ \ '; - $.each(this.scheduled_policies, function(){ + $.each(role.scheduled_policies, function(){ info_str += '\ \ \ - '; + '; if (this['start_time']) { info_str += ''; @@ -857,14 +872,23 @@ function updateServiceTemplateInfo(request,elem){
'+this.type+''+this.adjust+''+this.min_adjust_step+''+(this.min_adjust_step || "-")+'start_time
'; } - info_str += "
"; + info_str += '
\ + \ +
' - info_str += "" - $(info_str).appendTo(context); - }); + context.html(info_str); + } - updateView(role_elements ,servicerolesDataTable); + if(selected_row_template_role_id) { + $.each($(serviceTemplaterolesDataTable.fnGetNodes()),function(){ + if($($('td',this)[1]).html()==selected_row_template_role_id) { + $('td',this)[2].click(); + } + }); + } } + + setupTips($("#roles_form")); } function setup_policy_tab_content(policy_section, html_policy_id) {