mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
Merge pull request #1322 from marshmalien/fix/1293-delete-ig-infinite-spinner
Fix infinite Wait spinner when deleting instance group
This commit is contained in:
@@ -9,6 +9,10 @@ function InstanceGroupsStrings (BaseString) {
|
|||||||
EDIT_BREADCRUMB_LABEL: t.s('EDIT INSTANCE GROUP')
|
EDIT_BREADCRUMB_LABEL: t.s('EDIT INSTANCE GROUP')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ns.list = {
|
||||||
|
PANEL_TITLE: t.s('INSTANCE GROUPS')
|
||||||
|
};
|
||||||
|
|
||||||
ns.tab = {
|
ns.tab = {
|
||||||
DETAILS: t.s('DETAILS'),
|
DETAILS: t.s('DETAILS'),
|
||||||
INSTANCES: t.s('INSTANCES'),
|
INSTANCES: t.s('INSTANCES'),
|
||||||
@@ -27,6 +31,17 @@ function InstanceGroupsStrings (BaseString) {
|
|||||||
ns.jobs = {
|
ns.jobs = {
|
||||||
PANEL_TITLE: t.s('Jobs')
|
PANEL_TITLE: t.s('Jobs')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ns.error = {
|
||||||
|
HEADER: this.error.HEADER,
|
||||||
|
CALL: this.error.CALL,
|
||||||
|
DELETE: t.s('Unable to delete instance group.'),
|
||||||
|
};
|
||||||
|
|
||||||
|
ns.alert = {
|
||||||
|
MISSING_PARAMETER: t.s('Instance Group parameter is missing.'),
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InstanceGroupsStrings.$inject = ['BaseStringService'];
|
InstanceGroupsStrings.$inject = ['BaseStringService'];
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
export default ['$scope', 'resolvedModels', 'Dataset', '$state', 'ComponentsStrings', 'ProcessErrors', 'Wait',
|
export default ['$scope', '$filter', '$state', 'Alert', 'resolvedModels', 'Dataset', 'InstanceGroupsStrings','ProcessErrors', 'Prompt', 'Wait',
|
||||||
function($scope, resolvedModels, Dataset, $state, strings, ProcessErrors, Wait) {
|
function($scope, $filter, $state, Alert, resolvedModels, Dataset, strings, ProcessErrors, Prompt, Wait) {
|
||||||
const vm = this;
|
const vm = this;
|
||||||
const { instanceGroup } = resolvedModels;
|
const { instanceGroup } = resolvedModels;
|
||||||
|
|
||||||
vm.strings = strings;
|
vm.strings = strings;
|
||||||
$scope.selection = {};
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
@@ -33,31 +32,43 @@ export default ['$scope', 'resolvedModels', 'Dataset', '$state', 'ComponentsStri
|
|||||||
vm.activeId = parseInt($state.params.instance_group_id);
|
vm.activeId = parseInt($state.params.instance_group_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
vm.delete = () => {
|
vm.deleteInstanceGroup = instance_group => {
|
||||||
Wait('start');
|
if (!instance_group) {
|
||||||
let deletables = $scope.selection;
|
Alert(strings.get('error.DELETE'), strings.get('alert.MISSING_PARAMETER'));
|
||||||
deletables = Object.keys(deletables).filter((n) => deletables[n]);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
deletables.forEach((data) => {
|
Prompt({
|
||||||
let promise = instanceGroup.http.delete({resource: data});
|
action() {
|
||||||
Promise.resolve(promise).then(vm.onSaveSuccess)
|
$('#prompt-modal').modal('hide');
|
||||||
.catch(({data, status}) => {
|
Wait('start');
|
||||||
ProcessErrors($scope, data, status, null, {
|
instanceGroup
|
||||||
hdr: 'Error!',
|
.request('delete', instance_group.id)
|
||||||
msg: 'Call failed. Return status: ' + status
|
.then(() => handleSuccessfulDelete(instance_group))
|
||||||
});
|
.catch(createErrorHandler('delete instance group', 'DELETE'))
|
||||||
})
|
.finally(() => Wait('stop'));
|
||||||
.finally(() => {
|
},
|
||||||
Wait('stop');
|
hdr: strings.get('DELETE'),
|
||||||
});
|
resourceName: $filter('sanitize')(instance_group.name),
|
||||||
|
body: `${strings.get('deleteResource.CONFIRM', 'instance group')}`
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.onSaveSuccess = () => {
|
function handleSuccessfulDelete(instance_group) {
|
||||||
$state.transitionTo($state.current, $state.params, {
|
if (parseInt($state.params.instance_group_id, 0) === instance_group.id) {
|
||||||
reload: true, location: true, inherit: false, notify: true
|
$state.go('instanceGroups', $state.params, { reload: true });
|
||||||
});
|
} else {
|
||||||
};
|
$state.go('.', $state.params, { reload: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createErrorHandler(path, action) {
|
||||||
|
return ({ data, status }) => {
|
||||||
|
const hdr = strings.get('error.HEADER');
|
||||||
|
const msg = strings.get('error.CALL', { path, action, status });
|
||||||
|
ProcessErrors($scope, data, status, null, { hdr, msg });
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
$scope.createInstanceGroup = () => {
|
$scope.createInstanceGroup = () => {
|
||||||
$state.go('instanceGroups.add');
|
$state.go('instanceGroups.add');
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<at-panel>
|
<at-panel>
|
||||||
<at-panel-heading hide-dismiss="true">
|
<at-panel-heading hide-dismiss="true">
|
||||||
{{ vm.strings.get('layout.INSTANCE_GROUPS') }}
|
{{ vm.strings.get('list.PANEL_TITLE') }}
|
||||||
<span class="badge List-titleBadge">
|
<span class="badge List-titleBadge">
|
||||||
{{ instanceGroupCount }}
|
{{ instanceGroupCount }}
|
||||||
</span>
|
</span>
|
||||||
@@ -19,10 +19,6 @@
|
|||||||
search-tags="searchTags">
|
search-tags="searchTags">
|
||||||
</smart-search>
|
</smart-search>
|
||||||
<div class="at-List-toolbarAction">
|
<div class="at-List-toolbarAction">
|
||||||
<div ng-click="vm.delete()"
|
|
||||||
class="at-RowAction at-RowAction--danger">
|
|
||||||
<i class="fa fa-trash"></i>
|
|
||||||
</div>
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
ui-sref="instanceGroups.add"
|
ui-sref="instanceGroups.add"
|
||||||
@@ -37,10 +33,6 @@
|
|||||||
<at-row ng-repeat="instance_group in instance_groups"
|
<at-row ng-repeat="instance_group in instance_groups"
|
||||||
ng-class="{'at-Row--active': (instance_group.id === vm.activeId)}">
|
ng-class="{'at-Row--active': (instance_group.id === vm.activeId)}">
|
||||||
|
|
||||||
<input type="checkbox"
|
|
||||||
class="at-Row-checkbox"
|
|
||||||
ng-model="selection[instance_group.id]"/>
|
|
||||||
|
|
||||||
<div class="at-Row-items">
|
<div class="at-Row-items">
|
||||||
<at-row-item
|
<at-row-item
|
||||||
header-value="{{ instance_group.name }}"
|
header-value="{{ instance_group.name }}"
|
||||||
@@ -67,6 +59,8 @@
|
|||||||
|
|
||||||
<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)">
|
||||||
|
</at-row-action>
|
||||||
</div>
|
</div>
|
||||||
</at-row>
|
</at-row>
|
||||||
</at-list>
|
</at-list>
|
||||||
|
|||||||
Reference in New Issue
Block a user