mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 02:50:02 -03:30
AC-985 edit now edit's inventory properties via dialog- using the same edit code already written for the wrench button on inventory->groups/hosts page.
This commit is contained in:
parent
77b285f632
commit
7434bb8a9e
@ -12,7 +12,7 @@
|
||||
|
||||
function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, InventoryList,
|
||||
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
||||
ClearScope, ProcessErrors, GetBasePath, Wait, Stream)
|
||||
ClearScope, ProcessErrors, GetBasePath, Wait, Stream, EditInventoryProperties)
|
||||
{
|
||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||
//scope.
|
||||
@ -128,9 +128,21 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (scope.removeRefreshInventories) {
|
||||
scope.removeRefreshInventories();
|
||||
}
|
||||
scope.removeRefreshInventories = scope.$on('RefreshInventories', function() {
|
||||
// Reflect changes after inventory properties edit completes
|
||||
scope.search(list.iterator);
|
||||
});
|
||||
|
||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
||||
|
||||
scope.editInventoryProperties = function(inventory_id) {
|
||||
EditInventoryProperties({ scope: scope, inventory_id: inventory_id });
|
||||
}
|
||||
|
||||
scope.addInventory = function() {
|
||||
$location.path($location.path() + '/add');
|
||||
}
|
||||
@ -186,7 +198,7 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res
|
||||
|
||||
InventoriesList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'InventoryList', 'GenerateList',
|
||||
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors',
|
||||
'GetBasePath', 'Wait', 'Stream' ];
|
||||
'GetBasePath', 'Wait', 'Stream', 'EditInventoryProperties'];
|
||||
|
||||
|
||||
function InventoriesAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryForm,
|
||||
|
||||
@ -27,7 +27,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
Rest.options()
|
||||
.success( function(data, status, headers, config) {
|
||||
var choices = data.actions.GET.source.choices
|
||||
console.log(choices);
|
||||
for (var i=0; i < choices.length; i++) {
|
||||
if (choices[i][0] !== 'file') {
|
||||
scope[variable].push({
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationListDefinition', 'ListGenerator', 'AuthService',
|
||||
'InventoryHelper', 'InventoryFormDefinition', 'ParseHelper'
|
||||
'InventoryHelper', 'InventoryFormDefinition', 'ParseHelper', 'SearchHelper'
|
||||
])
|
||||
|
||||
.factory('SaveInventory', ['InventoryForm', 'Rest', 'Alert', 'ProcessErrors', 'LookUpInit', 'OrganizationList',
|
||||
@ -20,6 +20,7 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
|
||||
// Save inventory property modifications
|
||||
|
||||
var scope = params.scope;
|
||||
|
||||
var form = InventoryForm;
|
||||
var defaultUrl=GetBasePath('inventory');
|
||||
|
||||
@ -71,7 +72,6 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
|
||||
}
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to update inventory. POST returned status: ' + status });
|
||||
});
|
||||
@ -85,9 +85,9 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
|
||||
|
||||
|
||||
.factory('EditInventoryProperties', ['InventoryForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LookUpInit', 'OrganizationList',
|
||||
'GetBasePath', 'ParseTypeChange', 'SaveInventory', 'Wait',
|
||||
'GetBasePath', 'ParseTypeChange', 'SaveInventory', 'Wait', 'Store', 'SearchInit',
|
||||
function(InventoryForm, GenerateForm, Rest, Alert, ProcessErrors, LookUpInit, OrganizationList, GetBasePath, ParseTypeChange, SaveInventory,
|
||||
Wait) {
|
||||
Wait, Store, SearchInit) {
|
||||
return function(params) {
|
||||
|
||||
var parent_scope = params.scope
|
||||
@ -98,6 +98,9 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
|
||||
var defaultUrl=GetBasePath('inventory');
|
||||
var master = {};
|
||||
|
||||
// Hang onto current search params
|
||||
var PreviousSearchParams = Store('CurrentSearchParams');
|
||||
|
||||
form.well = false;
|
||||
//form.formLabelSize = 'col-lg-3';
|
||||
//form.formFieldSize = 'col-lg-9';
|
||||
@ -116,8 +119,6 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
|
||||
scope.formModalInfo = false;
|
||||
scope.formModalHeader = 'Inventory Properties';
|
||||
|
||||
$('#form-modal .btn-success').removeClass('btn-none').addClass('btn-success');
|
||||
|
||||
Wait('start');
|
||||
Rest.setUrl(GetBasePath('inventory') + inventory_id + '/');
|
||||
Rest.get()
|
||||
@ -170,7 +171,6 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
|
||||
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Failed to get inventory: ' + inventory_id + '. GET returned: ' + status });
|
||||
});
|
||||
@ -179,11 +179,41 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
|
||||
scope.removeInventorySaved();
|
||||
}
|
||||
scope.removeInventorySaved = scope.$on('InventorySaved', function() {
|
||||
$('#form-modal').modal('hide');
|
||||
$('#form-modal').modal('hide');
|
||||
// Restore prior search state
|
||||
if (scope.searchCleanp) {
|
||||
scope.searchCleanup();
|
||||
}
|
||||
SearchInit({
|
||||
scope: parent_scope,
|
||||
set: PreviousSearchParams.set,
|
||||
list: PreviousSearchParams.list,
|
||||
url: PreviousSearchParams.defaultUrl,
|
||||
iterator: PreviousSearchParams.iterator,
|
||||
sort_order: PreviousSearchParams.sort_order,
|
||||
setWidgets: false
|
||||
});
|
||||
parent_scope.$emit('RefreshInventories');
|
||||
});
|
||||
|
||||
scope.cancelModal = function() {
|
||||
// Restore prior search state
|
||||
if (scope.searchCleanp) {
|
||||
scope.searchCleanup();
|
||||
}
|
||||
SearchInit({
|
||||
scope: parent_scope,
|
||||
set: PreviousSearchParams.set,
|
||||
list: PreviousSearchParams.list,
|
||||
url: PreviousSearchParams.defaultUrl,
|
||||
iterator: PreviousSearchParams.iterator,
|
||||
sort_order: PreviousSearchParams.sort_order,
|
||||
setWidgets: false
|
||||
});
|
||||
}
|
||||
|
||||
scope.formModalAction = function() {
|
||||
scope.inventory_id = inventory_id;
|
||||
parent_scope.inventory_id = inventory_id;
|
||||
parent_scope.inventory_name = scope.inventory_name;
|
||||
SaveInventory({ scope: scope });
|
||||
}
|
||||
|
||||
@ -27,14 +27,15 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
var list = params.list;
|
||||
var iterator = (params.iterator) ? params.iterator : list.iterator;
|
||||
var setWidgets = (params.setWidgets == false) ? false : true;
|
||||
|
||||
var sort_order, expected_objects=0, found_objects=0;
|
||||
var sort_order = params.sort_order || '';
|
||||
var expected_objects=0, found_objects=0;
|
||||
|
||||
var params = {
|
||||
set: set,
|
||||
defaultUrl: defaultUrl,
|
||||
list: list,
|
||||
iterator: iterator
|
||||
iterator: iterator,
|
||||
sort_order: sort_order
|
||||
};
|
||||
|
||||
Store('CurrentSearchParams', params); // Save in case Activity Stream widget needs to restore
|
||||
@ -136,6 +137,17 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
}
|
||||
}
|
||||
|
||||
var params = {
|
||||
set: set,
|
||||
defaultUrl: defaultUrl,
|
||||
list: list,
|
||||
iterator: iterator,
|
||||
sort_order: sort_order
|
||||
};
|
||||
|
||||
Store('CurrentSearchParams', params); // Save in case Activity Stream widget needs to restore
|
||||
|
||||
|
||||
// Functions to handle search widget changes
|
||||
scope.setSearchField = function(iterator, fld, label, widget) {
|
||||
|
||||
@ -237,7 +249,8 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
//
|
||||
scope[iterator + 'Loading'] = (load == undefined || load == true) ? true : false;
|
||||
var url = defaultUrl;
|
||||
|
||||
var connect;
|
||||
|
||||
//finalize and execute the query
|
||||
scope[iterator + 'Page'] = (page) ? parseInt(page) - 1 : 0;
|
||||
if (scope[iterator + 'SearchParams']) {
|
||||
@ -248,14 +261,17 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
url += '&' + scope[iterator + 'SearchParams'];
|
||||
}
|
||||
}
|
||||
url = url.replace(/\&\&/,'&');
|
||||
url += (scope[iterator + '_page_size']) ? '&page_size=' + scope[iterator + '_page_size'] : "";
|
||||
connect = (/\/$/.test(url)) ? '?' : '&';
|
||||
url += (scope[iterator + '_page_size']) ? connect + 'page_size=' + scope[iterator + '_page_size'] : "";
|
||||
if (page) {
|
||||
url += '&page=' + page;
|
||||
connect = (/\/$/.test(url)) ? '?' : '&';
|
||||
url += connect + 'page=' + page;
|
||||
}
|
||||
if (scope[iterator + 'ExtraParms']) {
|
||||
url += scope[iterator + 'ExtraParms'];
|
||||
connect = (/\/$/.test(url)) ? '?' : '&';
|
||||
url += connect + scope[iterator + 'ExtraParms'];
|
||||
}
|
||||
url = url.replace(/\&\&/,'&');
|
||||
Refresh({ scope: scope, set: set, iterator: iterator, url: url });
|
||||
});
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@ angular.module('InventoriesListDefinition', [])
|
||||
},
|
||||
edit: {
|
||||
label: 'Edit',
|
||||
ngClick: "editInventory(\{\{ inventory.id \}\})",
|
||||
ngClick: 'editInventoryProperties(inventory.id)',
|
||||
awToolTip: 'Edit inventory',
|
||||
dataPlacement: 'top'
|
||||
},
|
||||
|
||||
@ -267,7 +267,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
||||
var parent_scope = params.scope;
|
||||
|
||||
// Hang onto current search params
|
||||
var PreviousSearchParams = Store('SearchInitParams');
|
||||
var PreviousSearchParams = Store('CurrentSearchParams');
|
||||
|
||||
// pass in an inventory name to fix breadcrumb display
|
||||
var inventory_name = (params) ? params.inventory_name : null;
|
||||
@ -340,6 +340,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
||||
list: PreviousSearchParams.list,
|
||||
url: PreviousSearchParams.defaultUrl,
|
||||
iterator: PreviousSearchParams.iterator,
|
||||
sort_order: PreviousSearchParams.sort_order,
|
||||
setWidgets: false });
|
||||
}
|
||||
if (inUrl) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user