mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
adding delete jt service
This commit is contained in:
parent
1afeed3588
commit
2401865f59
@ -55,6 +55,8 @@ import 'tower/shared/InventoryTree';
|
||||
import 'tower/shared/Timer';
|
||||
import 'tower/shared/Socket';
|
||||
|
||||
import 'tower/job-templates/main';
|
||||
|
||||
/*#if DEBUG#*/
|
||||
import {__deferLoadIfEnabled} from 'tower/debug';
|
||||
__deferLoadIfEnabled();
|
||||
@ -74,6 +76,7 @@ var tower = angular.module('Tower', [
|
||||
'UserFormDefinition',
|
||||
'FormGenerator',
|
||||
'OrganizationListDefinition',
|
||||
'jobTemplates',
|
||||
'UserListDefinition',
|
||||
'UserHelper',
|
||||
'PromptDialog',
|
||||
|
@ -13,6 +13,7 @@
|
||||
* @description This controller's for the Inventory page
|
||||
*/
|
||||
|
||||
import 'tower/job-templates/main';
|
||||
|
||||
export function InventoriesList($scope, $rootScope, $location, $log, $routeParams, $compile, $filter, Rest, Alert, InventoryList, generateList,
|
||||
LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, Wait, Stream,
|
||||
@ -483,7 +484,7 @@ InventoriesAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log
|
||||
export function InventoriesEdit($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryForm, GenerateForm, Rest,
|
||||
Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, generateList, OrganizationList, SearchInit, PaginateInit,
|
||||
LookUpInit, GetBasePath, ParseTypeChange, Wait, ToJSON, ParseVariableString, Stream, RelatedSearchInit, RelatedPaginateInit,
|
||||
Prompt, PlaybookRun, CreateDialog) {
|
||||
Prompt, PlaybookRun, CreateDialog, deleteJobTemplate) {
|
||||
|
||||
ClearScope();
|
||||
|
||||
@ -491,7 +492,6 @@ export function InventoriesEdit($scope, $rootScope, $compile, $location, $log, $
|
||||
var defaultUrl = GetBasePath('inventory'),
|
||||
form = InventoryForm(),
|
||||
generator = GenerateForm,
|
||||
jobtemplateUrl = GetBasePath('job_templates'),
|
||||
inventory_id = $routeParams.inventory_id,
|
||||
master = {},
|
||||
fld, json_data, data,
|
||||
@ -689,15 +689,6 @@ export function InventoriesEdit($scope, $rootScope, $compile, $location, $log, $
|
||||
"label": "Copy",
|
||||
"onClick": function() {
|
||||
copyAction();
|
||||
// setTimeout(function(){
|
||||
// scope.$apply(function(){
|
||||
// if(mode==='survey-taker'){
|
||||
// scope.$emit('SurveyTakerCompleted');
|
||||
// } else{
|
||||
// scope.saveSurvey();
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
},
|
||||
"icon": "fa-copy",
|
||||
"class": "btn btn-primary",
|
||||
@ -816,9 +807,7 @@ export function InventoriesEdit($scope, $rootScope, $compile, $location, $log, $
|
||||
action = function () {
|
||||
$('#prompt-modal').modal('hide');
|
||||
Wait('start');
|
||||
var url = jobtemplateUrl+id;
|
||||
Rest.setUrl(url);
|
||||
Rest.destroy()
|
||||
deleteJobTemplate(id)
|
||||
.success(function () {
|
||||
$('#prompt-modal').modal('hide');
|
||||
$scope.search(form.related.scan_job_templates.iterator);
|
||||
@ -826,7 +815,7 @@ export function InventoriesEdit($scope, $rootScope, $compile, $location, $log, $
|
||||
.error(function (data) {
|
||||
Wait('stop');
|
||||
ProcessErrors($scope, data, status, null, { hdr: 'Error!',
|
||||
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||
msg: 'DELETE returned status: ' + status });
|
||||
});
|
||||
};
|
||||
|
||||
@ -835,14 +824,15 @@ export function InventoriesEdit($scope, $rootScope, $compile, $location, $log, $
|
||||
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',
|
||||
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'generateList', 'OrganizationList', 'SearchInit',
|
||||
'PaginateInit', 'LookUpInit', 'GetBasePath', 'ParseTypeChange', 'Wait', 'ToJSON', 'ParseVariableString', 'Stream', 'RelatedSearchInit', 'RelatedPaginateInit',
|
||||
'Prompt', 'PlaybookRun', 'CreateDialog'
|
||||
'Prompt', 'PlaybookRun', 'CreateDialog', 'deleteJobTemplate'
|
||||
];
|
||||
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
import jobTemplates from 'tower/job-templates/main';
|
||||
import {describeModule} from '../describe-module';
|
||||
|
||||
describeModule(jobTemplates.name)
|
||||
.testService('deleteJobTemplate', function(test, restStub) {
|
||||
|
||||
var service;
|
||||
|
||||
test.withService(function(_service) {
|
||||
service = _service;
|
||||
});
|
||||
|
||||
it('deletes the job template', function() {
|
||||
var result = {};
|
||||
|
||||
var actual = service();
|
||||
|
||||
restStub.succeedOn('destroy', result);
|
||||
restStub.flush();
|
||||
|
||||
expect(actual).to.eventually.equal(result);
|
||||
|
||||
});
|
||||
});
|
@ -0,0 +1,20 @@
|
||||
var rest, getBasePath;
|
||||
|
||||
export default
|
||||
[ 'Rest',
|
||||
'GetBasePath',
|
||||
function(_rest, _getBasePath) {
|
||||
rest = _rest;
|
||||
getBasePath = _getBasePath;
|
||||
return deleteJobTemplate;
|
||||
}
|
||||
];
|
||||
|
||||
function deleteJobTemplate(id) {
|
||||
var url = getBasePath('job_templates');
|
||||
|
||||
url = url + id;
|
||||
|
||||
rest.setUrl(url);
|
||||
return rest.destroy();
|
||||
}
|
5
awx/ui/static/js/job-templates/main.js
Normal file
5
awx/ui/static/js/job-templates/main.js
Normal file
@ -0,0 +1,5 @@
|
||||
import deleteJobTemplate from './delete-job-template.service';
|
||||
|
||||
export default
|
||||
angular.module('jobTemplates', [])
|
||||
.service('deleteJobTemplate', deleteJobTemplate);
|
@ -35,10 +35,19 @@ RestStub.prototype =
|
||||
|
||||
return this.deferred.promise;
|
||||
},
|
||||
destroy: function() {
|
||||
this.deferred = this.deferred || {};
|
||||
this.deferred.destroy = this[this.currentUrl];
|
||||
|
||||
return this.deferred.destroy.promise;
|
||||
},
|
||||
succeedAt: function(url, value) {
|
||||
assertUrlDeferred(url, this);
|
||||
this[url].resolve(value);
|
||||
},
|
||||
succeedOn: function(method, value) {
|
||||
this.deferred[method] = value;
|
||||
},
|
||||
succeed: function(value) {
|
||||
this.deferred.resolve(value);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user