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