mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 19:51:08 -03:30
On Job Template save: redirect to proper dest
return to job template list if adding/editing a job template from the list; likewise return to hte inventory properties if adding/editing from that page
This commit is contained in:
@@ -482,7 +482,7 @@ InventoriesAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log
|
|||||||
|
|
||||||
export function InventoriesEdit($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryForm, GenerateForm, Rest,
|
export function InventoriesEdit($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryForm, GenerateForm, Rest,
|
||||||
Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, generateList, OrganizationList, SearchInit, PaginateInit,
|
Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, generateList, OrganizationList, SearchInit, PaginateInit,
|
||||||
LookUpInit, GetBasePath, ParseTypeChange, Wait, ToJSON, ParseVariableString, Stream, RelatedSearchInit, RelatedPaginateInit) {
|
LookUpInit, GetBasePath, ParseTypeChange, Wait, ToJSON, ParseVariableString, Stream, RelatedSearchInit, RelatedPaginateInit, Prompt) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -490,6 +490,7 @@ export function InventoriesEdit($scope, $rootScope, $compile, $location, $log, $
|
|||||||
var defaultUrl = GetBasePath('inventory'),
|
var defaultUrl = GetBasePath('inventory'),
|
||||||
form = InventoryForm(),
|
form = InventoryForm(),
|
||||||
generator = GenerateForm,
|
generator = GenerateForm,
|
||||||
|
jobtemplateUrl = GetBasePath('job_templates'),
|
||||||
inventory_id = $routeParams.inventory_id,
|
inventory_id = $routeParams.inventory_id,
|
||||||
master = {},
|
master = {},
|
||||||
fld, json_data, data,
|
fld, json_data, data,
|
||||||
@@ -498,7 +499,7 @@ export function InventoriesEdit($scope, $rootScope, $compile, $location, $log, $
|
|||||||
form.well = true;
|
form.well = true;
|
||||||
form.formLabelSize = null;
|
form.formLabelSize = null;
|
||||||
form.formFieldSize = null;
|
form.formFieldSize = null;
|
||||||
$scope.inventory_id = inventory_id;
|
$scope.inventory_id = inventory_id;
|
||||||
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
||||||
|
|
||||||
generator.reset();
|
generator.reset();
|
||||||
@@ -509,8 +510,7 @@ export function InventoriesEdit($scope, $rootScope, $compile, $location, $log, $
|
|||||||
$scope.inventoryLoadedRemove();
|
$scope.inventoryLoadedRemove();
|
||||||
}
|
}
|
||||||
$scope.projectLoadedRemove = $scope.$on('inventoryLoaded', function () {
|
$scope.projectLoadedRemove = $scope.$on('inventoryLoaded', function () {
|
||||||
var set, opts=[];
|
var set;
|
||||||
|
|
||||||
for (set in relatedSets) {
|
for (set in relatedSets) {
|
||||||
$scope.search(relatedSets[set].iterator);
|
$scope.search(relatedSets[set].iterator);
|
||||||
}
|
}
|
||||||
@@ -659,14 +659,37 @@ export function InventoriesEdit($scope, $rootScope, $compile, $location, $log, $
|
|||||||
$location.path($location.path()+'/job_templates/'+this.scan_job_template.id);
|
$location.path($location.path()+'/job_templates/'+this.scan_job_template.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.deleteScanJob = function(){
|
$scope.deleteScanJob = function () {
|
||||||
$location.path($location.path()+'/job_templates/add');
|
var id = this.scan_job_template.id ,
|
||||||
};
|
action = function () {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
Wait('start');
|
||||||
|
var url = jobtemplateUrl+id;
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.destroy()
|
||||||
|
.success(function () {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
$scope.search(form.related.scan_job_templates.iterator);
|
||||||
|
})
|
||||||
|
.error(function (data) {
|
||||||
|
Wait('stop');
|
||||||
|
ProcessErrors($scope, data, status, null, { hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
|
body: '<div class=\"alert alert-info\">Delete job template ' + this.scan_job_template.name + '?</div>',
|
||||||
|
action: action
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InventoriesEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'InventoryForm', 'GenerateForm',
|
InventoriesEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'InventoryForm', 'GenerateForm',
|
||||||
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'generateList', 'OrganizationList', 'SearchInit',
|
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'generateList', 'OrganizationList', 'SearchInit',
|
||||||
'PaginateInit', 'LookUpInit', 'GetBasePath', 'ParseTypeChange', 'Wait', 'ToJSON', 'ParseVariableString', 'Stream', 'RelatedSearchInit', 'RelatedPaginateInit'
|
'PaginateInit', 'LookUpInit', 'GetBasePath', 'ParseTypeChange', 'Wait', 'ToJSON', 'ParseVariableString', 'Stream', 'RelatedSearchInit', 'RelatedPaginateInit', 'Prompt'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -486,7 +486,17 @@ export function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $
|
|||||||
|
|
||||||
|
|
||||||
function saveCompleted() {
|
function saveCompleted() {
|
||||||
setTimeout(function() { $scope.$apply(function() { $location.path('/job_templates'); }); }, 500);
|
setTimeout(function() {
|
||||||
|
$scope.$apply(function() {
|
||||||
|
var base = $location.path().replace(/^\//, '').split('/')[0];
|
||||||
|
if (base === 'job_templates') {
|
||||||
|
ReturnToCaller();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ReturnToCaller(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($scope.removeTemplateSaveSuccess) {
|
if ($scope.removeTemplateSaveSuccess) {
|
||||||
@@ -979,7 +989,17 @@ export function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log,
|
|||||||
});
|
});
|
||||||
|
|
||||||
function saveCompleted() {
|
function saveCompleted() {
|
||||||
setTimeout(function() { $scope.$apply(function() { $location.path('/job_templates'); }); }, 500);
|
setTimeout(function() {
|
||||||
|
$scope.$apply(function() {
|
||||||
|
var base = $location.path().replace(/^\//, '').split('/')[0];
|
||||||
|
if (base === 'job_templates') {
|
||||||
|
ReturnToCaller();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ReturnToCaller(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($scope.removeTemplateSaveSuccess) {
|
if ($scope.removeTemplateSaveSuccess) {
|
||||||
|
|||||||
@@ -99,14 +99,14 @@ export default
|
|||||||
related: {
|
related: {
|
||||||
scan_job_templates: {
|
scan_job_templates: {
|
||||||
type: 'collection',
|
type: 'collection',
|
||||||
title: 'Scan Jobs',
|
title: 'Scan Job Templates',
|
||||||
iterator: 'scan_job_template',
|
iterator: 'scan_job_template',
|
||||||
index: false,
|
index: false,
|
||||||
open: false,
|
open: false,
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
add: {
|
add: {
|
||||||
ngClick: "addScanJob(inventory_id)",
|
ngClick: "addScanJob()",
|
||||||
icon: 'icon-plus',
|
icon: 'icon-plus',
|
||||||
label: 'Add',
|
label: 'Add',
|
||||||
awToolTip: 'Add a scan job template'
|
awToolTip: 'Add a scan job template'
|
||||||
@@ -127,14 +127,14 @@ export default
|
|||||||
fieldActions: {
|
fieldActions: {
|
||||||
edit: {
|
edit: {
|
||||||
label: 'Edit',
|
label: 'Edit',
|
||||||
ngClick: "editScanJob(inventory_id)",
|
ngClick: "editScanJob()",
|
||||||
icon: 'icon-edit',
|
icon: 'icon-edit',
|
||||||
awToolTip: 'Edit the scan job template',
|
awToolTip: 'Edit the scan job template',
|
||||||
'class': 'btn btn-default'
|
'class': 'btn btn-default'
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
label: 'Delete',
|
label: 'Delete',
|
||||||
ngClick: "deleteScanJob(inventory_id)",
|
ngClick: "deleteScanJob()",
|
||||||
icon: 'icon-trash',
|
icon: 'icon-trash',
|
||||||
"class": 'btn-danger',
|
"class": 'btn-danger',
|
||||||
awToolTip: 'Delete the scan job template'
|
awToolTip: 'Delete the scan job template'
|
||||||
|
|||||||
Reference in New Issue
Block a user