Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #479 from eucalyptus/GUI-637
Browse files Browse the repository at this point in the history
GUI-637: Minor optimizations for IAM add policy page
  • Loading branch information
kamalgill committed Mar 26, 2014
2 parents c755f4a + a6128ca commit 6431066
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
22 changes: 14 additions & 8 deletions eucaconsole/static/js/pages/iam_policy_wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ angular.module('IAMPolicyWizard', [])
$scope.actionsList = [];
$scope.urlParams = $.url().param();
$scope.timestamp = (new Date()).toISOString().replace(/[-:TZ\.]/g, '');
$scope.selectedOperatorType = '';
$scope.initController = function (options) {
$scope.policyJsonEndpoint = options['policyJsonEndpoint'];
$scope.cloudType = options['cloudType'];
Expand Down Expand Up @@ -77,16 +78,15 @@ angular.module('IAMPolicyWizard', [])
}, 100);
};
$scope.initCodeMirror = function () {
$scope.codeEditor = CodeMirror.fromTextArea($scope.policyTextarea, {
mode: "javascript",
lineWrapping: true,
styleActiveLine: true,
lineNumbers: true
$(document).ready(function () {
$scope.codeEditor = CodeMirror.fromTextArea($scope.policyTextarea, {
mode: "javascript",
lineWrapping: true,
styleActiveLine: true,
lineNumbers: true
});
});
};
$scope.visitStep = function(step) {
$('#tabStep' + step).click();
};
$scope.setPolicyName = function (policyType) {
var typeNameMapping = {
'admin_access': 'AccountAdminAccessPolicy',
Expand Down Expand Up @@ -322,6 +322,12 @@ angular.module('IAMPolicyWizard', [])

return '';
};
$scope.setOperators = function (conditionKey) {
$scope[conditionKey.replace('ConditionKey', 'ConditionOperator')] = '';
$timeout(function () {
$scope.selectedOperatorType = $scope.getConditionType($scope[conditionKey]);
}, 50);
}
})
;

25 changes: 12 additions & 13 deletions eucaconsole/templates/policies/policy_generator.pt
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@
</label>
<div class="row">
<div class="small-6 columns">
<select class="condition-keys" ng-model="${cond_key}">
<select class="condition-keys" ng-model="${cond_key}"
ng-change="setOperators('${cond_key}')">
<option value="" i18n:translate="">Select key...</option>
<optgroup label="EC2 Conditions" tal:condition="namespace == 'ec2'" tal:omit-tag="">
<option value="ec2:AvailabilityZone"
Expand Down Expand Up @@ -253,15 +254,13 @@
<div class="small-6 columns">
<select class="condition-operators" ng-model="${cond_operator}">
<option value="" i18n:translate="">select...</option>
<optgroup label="ARN Conditions"
ng-if="${cond_key} &amp;&amp; getConditionType(${cond_key}) == 'ARN'">
<optgroup label="ARN Conditions" ng-if="selectedOperatorType == 'ARN'">
<option value="ArnEquals">ArnEquals</option>
<option value="ArnNotEquals">ArnNotEquals</option>
<option value="ArnLike">ArnLike</option>
<option value="ArnNotLike">ArnNotLike</option>
</optgroup>
<optgroup label="String Conditions"
ng-if="${cond_key} &amp;&amp; getConditionType(${cond_key}) == 'STRING'">
<optgroup label="String Conditions" ng-if="selectedOperatorType == 'STRING'">
<option value="StringEquals">StringEquals</option>
<option value="StringNotEquals">StringNotEquals</option>
<option value="StringEqualsIgnoreCase">StringEqualsIgnoreCase</option>
Expand All @@ -270,31 +269,27 @@
<option value="StringNotLike">StringNotLike</option>
</optgroup>
<option value="Null">Null</option>
<optgroup label="Numeric Conditions"
ng-if="${cond_key} &amp;&amp; getConditionType(${cond_key}) == 'NUMERIC'">
<optgroup label="Numeric Conditions" ng-if="selectedOperatorType == 'NUMERIC'">
<option value="NumericEquals">NumericEquals</option>
<option value="NumericNotEquals">NumericNotEquals</option>
<option value="NumericLessThan">NumericLessThan</option>
<option value="NumericLessThanEquals">NumericLessThanEquals</option>
<option value="NumericGreaterThan">NumericGreaterThan</option>
<option value="NumericGreaterThanEquals">NumericGreaterThanEquals</option>
</optgroup>
<optgroup label="Date Conditions"
ng-if="${cond_key} &amp;&amp; getConditionType(${cond_key}) == 'DATE'">
<optgroup label="Date Conditions" ng-if="selectedOperatorType == 'DATE'">
<option value="DateEquals">DateEquals</option>
<option value="DateNotEquals">DateNotEquals</option>
<option value="DateLessThan">DateLessThan</option>
<option value="DateLessThanEquals">DateLessThanEquals</option>
<option value="DateGreaterThan">DateGreaterThan</option>
<option value="DateGreaterThanEquals">DateGreaterThanEquals</option>
</optgroup>
<optgroup label="IP Conditions"
ng-if="${cond_key} &amp;&amp; getConditionType(${cond_key}) == 'IP'">
<optgroup label="IP Conditions" ng-if="selectedOperatorType == 'IP'">
<option value="IpAddress">IpAddress</option>
<option value="NotIpAddress">NotIpAddress</option>
</optgroup>
<option value="Bool"
ng-if="${cond_key} &amp;&amp; getConditionType(${cond_key}) == 'BOOL'">
<option value="Bool" ng-if="selectedOperatorType == 'BOOL'">
Bool
</option>
</select>
Expand Down Expand Up @@ -392,6 +387,10 @@
<!--! Input field for Numeric inputs -->
<input type="number" class="condition-value numeric"
ng-if="${cond_operator} &amp;&amp; getConditionType(${cond_key}) == 'NUMERIC'" />
<!--! Input field for User* and String* -->
<input type="text" class="condition-value userstringlike"
ng-if="${cond_operator} &amp;&amp; ${cond_key}.toLowerCase().indexOf('user') !== -1
&amp;&amp; getConditionType(${cond_key}) == 'STRING'" />
</div>
<a class="button tiny round" i18n:translate=""
ng-click="addCondition('${action}', $event)">
Expand Down

0 comments on commit 6431066

Please sign in to comment.