mirror of
https://github.com/ansible/awx.git
synced 2026-03-22 03:17:39 -02:30
[UI] Org Admin permissions for Instance Groups
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
function CapacityAdjuster (templateUrl, ProcessErrors, Wait) {
|
function CapacityAdjuster (templateUrl, ProcessErrors, Wait) {
|
||||||
return {
|
return {
|
||||||
scope: {
|
scope: {
|
||||||
state: '='
|
state: '=',
|
||||||
|
disabled: '@'
|
||||||
},
|
},
|
||||||
templateUrl: templateUrl('instance-groups/capacity-adjuster/capacity-adjuster'),
|
templateUrl: templateUrl('instance-groups/capacity-adjuster/capacity-adjuster'),
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
@@ -17,7 +18,6 @@ function CapacityAdjuster (templateUrl, ProcessErrors, Wait) {
|
|||||||
|
|
||||||
scope.min_capacity = _.min(adjustment_values, 'value');
|
scope.min_capacity = _.min(adjustment_values, 'value');
|
||||||
scope.max_capacity = _.max(adjustment_values, 'value');
|
scope.max_capacity = _.max(adjustment_values, 'value');
|
||||||
|
|
||||||
},
|
},
|
||||||
controller: function($http) {
|
controller: function($http) {
|
||||||
const vm = this || {};
|
const vm = this || {};
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
min="0"
|
min="0"
|
||||||
max="1"
|
max="1"
|
||||||
step="0.1"
|
step="0.1"
|
||||||
|
ng-disabled="{{disabled}}"
|
||||||
ng-change="vm.slide(state)"/>
|
ng-change="vm.slide(state)"/>
|
||||||
<p>{{max_capacity.label}} {{max_capacity.value}}</p>
|
<p>{{max_capacity.label}} {{max_capacity.value}}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
type="button"
|
type="button"
|
||||||
ng-click="$state.go('instanceGroups.instances.modal.add')"
|
ng-click="$state.go('instanceGroups.instances.modal.add')"
|
||||||
class="at-Button--add"
|
class="at-Button--add"
|
||||||
|
ng-show="vm.isSuperuser"
|
||||||
aria-expanded="false">
|
aria-expanded="false">
|
||||||
</button>
|
</button>
|
||||||
<div ui-view="modal"></div>
|
<div ui-view="modal"></div>
|
||||||
@@ -37,15 +38,18 @@
|
|||||||
ng-class="{'at-Row--active': (instance.id === vm.activeId)}">
|
ng-class="{'at-Row--active': (instance.id === vm.activeId)}">
|
||||||
<div class="at-Row-toggle">
|
<div class="at-Row-toggle">
|
||||||
<div class="ScheduleToggle"
|
<div class="ScheduleToggle"
|
||||||
ng-class="{'is-on': instance.enabled}">
|
ng-class="{'is-on': instance.enabled,
|
||||||
|
'ScheduleToggle--disabled': vm.rowAction.toggle._disabled}">
|
||||||
<button ng-show="instance.enabled"
|
<button ng-show="instance.enabled"
|
||||||
class="ScheduleToggle-switch is-on ng-hide"
|
class="ScheduleToggle-switch is-on ng-hide"
|
||||||
ng-click="vm.toggle(instance)">
|
ng-click="vm.toggle(instance)"
|
||||||
|
ng-disabled="vm.rowAction.toggle._disabled">
|
||||||
{{:: vm.strings.get('ON') }}
|
{{:: vm.strings.get('ON') }}
|
||||||
</button>
|
</button>
|
||||||
<button ng-show="!instance.enabled"
|
<button ng-show="!instance.enabled"
|
||||||
class="ScheduleToggle-switch"
|
class="ScheduleToggle-switch"
|
||||||
ng-click="vm.toggle(instance)">
|
ng-click="vm.toggle(instance)"
|
||||||
|
ng-disabled="vm.rowAction.toggle._disabled">
|
||||||
{{:: vm.strings.get('OFF') }}
|
{{:: vm.strings.get('OFF') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -63,7 +67,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="at-Row-actions">
|
<div class="at-Row-actions">
|
||||||
<capacity-adjuster state="instance"></capacity-adjuster>
|
<capacity-adjuster state="instance" disabled="{{vm.rowAction.capacity_adjustment._disabled}}"></capacity-adjuster>
|
||||||
<capacity-bar label-value="Used Capacity" capacity="instance.consumed_capacity" total-capacity="instance.capacity"></capacity-bar>
|
<capacity-bar label-value="Used Capacity" capacity="instance.consumed_capacity" total-capacity="instance.capacity"></capacity-bar>
|
||||||
</div>
|
</div>
|
||||||
</at-row>
|
</at-row>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ function InstancesController ($scope, $state, $http, models, Instance, strings,
|
|||||||
vm.panelTitle = instanceGroup.get('name');
|
vm.panelTitle = instanceGroup.get('name');
|
||||||
vm.instances = instanceGroup.get('related.instances.results');
|
vm.instances = instanceGroup.get('related.instances.results');
|
||||||
vm.instance_group_id = instanceGroup.get('id');
|
vm.instance_group_id = instanceGroup.get('id');
|
||||||
|
vm.isSuperuser = $scope.$root.user_is_superuser;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
@@ -47,6 +48,15 @@ function InstancesController ($scope, $state, $http, models, Instance, strings,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vm.rowAction = {
|
||||||
|
toggle: {
|
||||||
|
_disabled: !vm.isSuperuser
|
||||||
|
},
|
||||||
|
capacity_adjustment: {
|
||||||
|
_disabled: !vm.isSuperuser
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
vm.toggle = (toggled) => {
|
vm.toggle = (toggled) => {
|
||||||
const instance = _.find(vm.instances, 'id', toggled.id);
|
const instance = _.find(vm.instances, 'id', toggled.id);
|
||||||
instance.enabled = !instance.enabled;
|
instance.enabled = !instance.enabled;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export default ['$scope', '$filter', '$state', 'Alert', 'resolvedModels', 'Datas
|
|||||||
const { instanceGroup } = resolvedModels;
|
const { instanceGroup } = resolvedModels;
|
||||||
|
|
||||||
vm.strings = strings;
|
vm.strings = strings;
|
||||||
|
vm.isSuperuser = $scope.$root.user_is_superuser;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
@@ -32,6 +33,12 @@ export default ['$scope', '$filter', '$state', 'Alert', 'resolvedModels', 'Datas
|
|||||||
vm.activeId = parseInt($state.params.instance_group_id);
|
vm.activeId = parseInt($state.params.instance_group_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
vm.rowAction = {
|
||||||
|
trash: instance_group => {
|
||||||
|
return vm.isSuperuser && instance_group.name !== 'tower';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
vm.deleteInstanceGroup = instance_group => {
|
vm.deleteInstanceGroup = instance_group => {
|
||||||
if (!instance_group) {
|
if (!instance_group) {
|
||||||
Alert(strings.get('error.DELETE'), strings.get('alert.MISSING_PARAMETER'));
|
Alert(strings.get('error.DELETE'), strings.get('alert.MISSING_PARAMETER'));
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
type="button"
|
type="button"
|
||||||
ui-sref="instanceGroups.add"
|
ui-sref="instanceGroups.add"
|
||||||
class="at-Button--add"
|
class="at-Button--add"
|
||||||
|
ng-show="vm.isSuperuser"
|
||||||
aria-haspopup="true"
|
aria-haspopup="true"
|
||||||
aria-expanded="false">
|
aria-expanded="false">
|
||||||
</button>
|
</button>
|
||||||
@@ -60,7 +61,7 @@
|
|||||||
|
|
||||||
<div class="at-Row-actions">
|
<div class="at-Row-actions">
|
||||||
<capacity-bar label-value="Used Capacity" capacity="instance_group.consumed_capacity" total-capacity="instance_group.capacity"></capacity-bar>
|
<capacity-bar label-value="Used Capacity" capacity="instance_group.consumed_capacity" total-capacity="instance_group.capacity"></capacity-bar>
|
||||||
<at-row-action icon="fa-trash" ng-click="vm.deleteInstanceGroup(instance_group)" ng-if="instance_group.name !== 'tower'">
|
<at-row-action icon="fa-trash" ng-click="vm.deleteInstanceGroup(instance_group)" ng-if="vm.rowAction.trash(instance_group)">
|
||||||
</at-row-action>
|
</at-row-action>
|
||||||
</div>
|
</div>
|
||||||
</at-row>
|
</at-row>
|
||||||
|
|||||||
@@ -20,7 +20,8 @@
|
|||||||
|
|
||||||
&.ScheduleToggle--disabled {
|
&.ScheduleToggle--disabled {
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
border-color: @default-link !important;
|
background-color: none;
|
||||||
|
border-color: @d7grey !important;
|
||||||
.ScheduleToggle-switch {
|
.ScheduleToggle-switch {
|
||||||
background-color: @d7grey !important;
|
background-color: @d7grey !important;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
|
|||||||
Reference in New Issue
Block a user