From 6972b32e8bcee41afd89cd551970aac40801f610 Mon Sep 17 00:00:00 2001 From: chris Houseknecht Date: Fri, 17 Jan 2014 13:33:16 -0500 Subject: [PATCH] AC-946: deferred host filter until after sync status window dismissed. --- awx/ui/static/js/helpers/Groups.js | 68 +++++++++++++++++------------- awx/ui/static/less/ansible-ui.less | 4 ++ 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/awx/ui/static/js/helpers/Groups.js b/awx/ui/static/js/helpers/Groups.js index 490f3f0f06..f268818079 100644 --- a/awx/ui/static/js/helpers/Groups.js +++ b/awx/ui/static/js/helpers/Groups.js @@ -93,11 +93,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' var found = false; var group = Find({ list: scope.groups, key: 'id', val: tree_id }); - if (scope.showHosts) { - if (scope.selected_tree_id !== tree_id) - scope.showHosts(tree_id, group_id, false); - } - if (group) { if (Empty(group.source)) { Alert('Missing Configuration', 'The selected group is not configured for inventory sync. ' + @@ -116,7 +111,10 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' ShowUpdateStatus({ group_name: data.summary_fields.group.name, last_update: url, - license_error: (data.summary_fields.last_update && data.summary_fields.last_update.license_error) ? true : false + license_error: ( (data.summary_fields.last_update && data.summary_fields.last_update.license_error) ? true : false ), + tree_id: tree_id, + group_id: group_id, + parent_scope: scope }); }) .error( function(data, status, headers, config) { @@ -1064,33 +1062,55 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' .factory('ShowUpdateStatus', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GenerateForm', - 'Prompt', 'ProcessErrors', 'GetBasePath', 'FormatDate', 'InventoryStatusForm', 'Wait', + 'Prompt', 'ProcessErrors', 'GetBasePath', 'FormatDate', 'InventoryStatusForm', 'Wait', 'Empty', function($rootScope, $location, $log, $routeParams, Rest, Alert, GenerateForm, Prompt, ProcessErrors, GetBasePath, - FormatDate, InventoryStatusForm, Wait) { + FormatDate, InventoryStatusForm, Wait, Empty) { return function(params) { var group_name = params.group_name; var last_update = params.last_update; var generator = GenerateForm; var form = InventoryStatusForm; - var license_error = params.license_error - var scope; - + var license_error = params.license_error; + var tree_id = params.tree_id; + var group_id = params.group_id; + var parent_scope = params.parent_scope; + if (last_update == undefined || last_update == null || last_update == ''){ Wait('stop'); Alert('Missing Configuration', 'The selected group is not configured for inventory sync. ' + 'Edit the group and provide Source information.', 'alert-info'); } else { + var scope = generator.inject(form, { mode: 'edit', modal: true, related: false, showModal: false }); + generator.reset(); + + scope.formModalAction = function() { + console.log('tree_id: ' + tree_id); + console.log('selected_tree_id: ' + parent_scope.selected_tree_id); + $('#form-modal').modal("hide"); + if (parent_scope && parent_scope.showHosts && !Empty(tree_id)) { + if (parent_scope.selected_tree_id !== tree_id) + parent_scope.showHosts(tree_id, group_id, false); + } + } + + if (scope.removeUpdateStatusReady) { + scope.removeUpdateStatusReady(); + } + scope.removeUpdateStatusReady = scope.$on('UpdateStatusReady', function(e) { + scope.formModalActionLabel = 'OK'; + scope.formModalCancelShow = false; + scope.formModalInfo = false; + scope.formModalHeader = group_name + ' - Inventory Sync'; + $('#form-modal').modal('show'); + Wait('stop'); + }); + // Retrieve detail record and prepopulate the form Rest.setUrl(last_update); Rest.get() - .success( function(data, status, headers, config) { - $('#form-modal').on('shown.bs.modal', function() { - Wait('stop'); - }); - scope = generator.inject(form, { mode: 'edit', modal: true, related: false}); - generator.reset(); + .success( function(data, status, headers, config) { for (var fld in form.fields) { if (data[fld]) { if (fld == 'created') { @@ -1102,21 +1122,9 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' } } scope.license_error = license_error; - scope.formModalAction = function() { - $('#form-modal').modal("hide"); - } - scope.formModalActionLabel = 'OK'; - scope.formModalCancelShow = false; - scope.formModalInfo = false; - scope.formModalHeader = group_name + ' - Inventory Sync'; - - if (!scope.$$phase) { - scope.$digest(); - } - + scope.$emit('UpdateStatusReady'); }) .error( function(data, status, headers, config) { - Wait('stop'); $('#form-modal').modal("hide"); ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve last update: ' + last_update + '. GET status: ' + status }); diff --git a/awx/ui/static/less/ansible-ui.less b/awx/ui/static/less/ansible-ui.less index a9d5760afb..0060e39b74 100644 --- a/awx/ui/static/less/ansible-ui.less +++ b/awx/ui/static/less/ansible-ui.less @@ -710,6 +710,10 @@ input[type="checkbox"].checkbox-no-label { button { margin-left: 4px; } + + .fa-lg { + vertical-align: -8%; + } } #home-list-actions {