From 945edac370d45a1f31e7dcbc56073a8e36226e4c Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Tue, 14 Aug 2012 11:08:48 -0700 Subject: [PATCH] CS-15796: Disable security group dropdown when in advanced zone --- ui/css/cloudstack3.css | 8 +++++ ui/scripts/autoscaler.js | 47 ++++++++++++++++++++++++++++++ ui/scripts/ui-custom/autoscaler.js | 20 ++++--------- 3 files changed, 61 insertions(+), 14 deletions(-) diff --git a/ui/css/cloudstack3.css b/ui/css/cloudstack3.css index 1e92aa20907..f046d55bdb4 100644 --- a/ui/css/cloudstack3.css +++ b/ui/css/cloudstack3.css @@ -9743,6 +9743,14 @@ div.ui-dialog div.acl div.multi-edit div.data div.data-body div.data-item table max-height: 600px; } +.ui-dialog div.autoscaler div.form-container div.form-item.disabled { + /*+opacity:50%;*/ + filter: alpha(opacity=50); + -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=50); + -moz-opacity: 0.5; + opacity: 0.5; +} + .ui-dialog div.autoscaler .detail-actions { } diff --git a/ui/scripts/autoscaler.js b/ui/scripts/autoscaler.js index a039fca2109..d90605d7c1e 100644 --- a/ui/scripts/autoscaler.js +++ b/ui/scripts/autoscaler.js @@ -17,6 +17,53 @@ var totalScaleDownCondition = 0; cloudStack.autoscaler = { + preFilter: function(args) { + var $autoscaler = args.$autoscaler; + var isAdvancedZone = false; + + // Hide fields for advanced zone + $.ajax({ + url: createURL('listZones'), + data: { + id: args.context.networks[0].zoneid, + listAll: true + }, + async: false, + success: function(json) { + var zone = json.listzonesresponse.zone[0]; + + if (zone.networktype == 'Advanced') { + isAdvancedZone = true; + } + else + isAdvancedZone = false; + } + }); + + // Run pre-filter + if (args.data == null) { //from a new LB rule + $autoscaler.find('select[name=serviceOfferingId]').removeAttr('disabled'); + $autoscaler.find('select[name=securityGroups]').removeAttr('disabled'); + $autoscaler.find('select[name=diskOfferingId]').removeAttr('disabled'); + } else { //from an existing LB rule + $autoscaler.find('select[name=serviceOfferingId]').attr('disabled', true); + $autoscaler.find('select[name=securityGroups]').attr('disabled', true); + $autoscaler.find('select[name=diskOfferingId]').attr('disabled', true); + + if(args.data.isAdvanced != null) { + $autoscaler.find('input[type=checkbox]').trigger('click'); + $autoscaler.find('input[type=checkbox]').attr('checked', 'checked'); + } + } + + if (isAdvancedZone) { + $autoscaler.find('.form-item[rel=securityGroups]') + .addClass('disabled') + .attr('title', 'Security groups are only selectable for Basic zones'); + $autoscaler.find('select[name=securityGroups]').attr('disabled', true); + } + }, + // UI actions to appear in dialog autoscaleActions: { enable: { diff --git a/ui/scripts/ui-custom/autoscaler.js b/ui/scripts/ui-custom/autoscaler.js index 881c0dcff56..3afc8b3414e 100644 --- a/ui/scripts/ui-custom/autoscaler.js +++ b/ui/scripts/ui-custom/autoscaler.js @@ -366,20 +366,12 @@ $loading.remove(); renderDialogContent(args); - if (args.data == null) { //from a new LB rule - $autoscalerDialog.find('select[name=serviceOfferingId]').removeAttr('disabled'); - $autoscalerDialog.find('select[name=securityGroups]').removeAttr('disabled'); - $autoscalerDialog.find('select[name=diskOfferingId]').removeAttr('disabled'); - } - else { //from an existing LB rule - $autoscalerDialog.find('select[name=serviceOfferingId]').attr('disabled', true); - $autoscalerDialog.find('select[name=securityGroups]').attr('disabled', true); - $autoscalerDialog.find('select[name=diskOfferingId]').attr('disabled', true); - - if(args.data.isAdvanced != null) { - $autoscalerDialog.find('input[type=checkbox]').trigger('click'); - $autoscalerDialog.find('input[type=checkbox]').attr('checked', 'checked'); - } + if (cloudStack.autoscaler.preFilter) { + cloudStack.autoscaler.preFilter({ + data: args.data, + $autoscaler: $autoscalerDialog, + context: context + }); } } }