diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index 27dc045ee2..077b4d1998 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -590,7 +590,8 @@ angular.module('Tower', [ $rootScope.configureTower = function(){ ConfigureTower({ - scope: $rootScope + scope: $rootScope, + parent_scope: $rootScope }); }; diff --git a/awx/ui/static/js/helpers/ConfigureTower.js b/awx/ui/static/js/helpers/ConfigureTower.js index 55e07c4e43..cf424780fc 100644 --- a/awx/ui/static/js/helpers/ConfigureTower.js +++ b/awx/ui/static/js/helpers/ConfigureTower.js @@ -17,13 +17,14 @@ angular.module('ConfigureTowerHelper', [ 'Utilities', 'RestServices', 'Schedules 'GeneratorHelpers']) .factory('ConfigureTower', ['Wait', 'CreateDialog', 'ConfigureTowerJobsList', 'GenerateList', 'GetBasePath' , 'SearchInit' , 'PaginateInit', 'PlaybookRun', 'LoadSchedulesScope', - 'SchedulesList', 'SchedulesControllerInit' , 'ConfigureTowerSchedule', 'Rest' , 'ProcessErrors', + 'SchedulesList', 'SchedulesControllerInit' , 'ConfigureTowerSchedule', 'Rest' , 'ProcessErrors', 'Empty', 'Prompt', function(Wait, CreateDialog, ConfigureTowerJobsList, GenerateList, GetBasePath, SearchInit, PaginateInit, PlaybookRun, LoadSchedulesScope, - SchedulesList, SchedulesControllerInit, ConfigureTowerSchedule, Rest, ProcessErrors) { + SchedulesList, SchedulesControllerInit, ConfigureTowerSchedule, Rest, ProcessErrors, Empty, Prompt) { return function(params) { // Set modal dimensions based on viewport width var scope = params.scope.$new(), + parent_scope = params.scope, callback = 'OpenConfig', defaultUrl = GetBasePath('system_job_templates'), list = ConfigureTowerJobsList, @@ -77,7 +78,7 @@ angular.module('ConfigureTowerHelper', [ 'Utilities', 'RestServices', 'Schedules SchedulesControllerInit({ scope: scope, - // parent_scope: parent_scope, + parent_scope: parent_scope, // list: list }); @@ -194,14 +195,6 @@ angular.module('ConfigureTowerHelper', [ 'Utilities', 'RestServices', 'Schedules }; scope.configureSchedule = function(id) { - // scope.addSchedule(); - // schedule_scope.editSchedule = function(id) { - // GroupsScheduleEdit({ scope: schedule_scope, mode: 'edit', url: GetBasePath('schedules') + id + '/' }); - // }; - - // schedule_scope.addSchedule = function() { - // GroupsScheduleEdit({ scope: schedule_scope, mode: 'add', url: url }); - // }; Rest.setUrl(scheduleUrl+id+'/schedules/'); Rest.get() .success(function(data) { @@ -228,32 +221,70 @@ angular.module('ConfigureTowerHelper', [ 'Utilities', 'RestServices', 'Schedules }; - // scope.deleteSystemSchedule = function(id){ - // Rest.setUrl(scheduleUrl+id+'/schedules/'); - // Rest.get() - // .success(function(data) { + scope.deleteSystemSchedule = function(id){ + var url, hdr,action; + Rest.setUrl(scheduleUrl+id+'/schedules/'); + Rest.get() + .success(function(data) { + //delete the schedule if one exists + if(data.count>0){ + if(!Empty(data.results[0].url)){ + url = data.results[0].url; + hdr = 'Delete Schedule'; + action = function () { + Wait('start'); + Rest.setUrl(url); + Rest.destroy() + .success(function () { + $('#prompt-modal').modal('hide'); + Wait('stop'); + scope.$emit(callback, id); + }) + .error(function (data, status) { + try { + $('#prompt-modal').modal('hide'); + } + catch(e) { + // ignore + } + ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + + ' failed. DELETE returned: ' + status }); + }); + }; + Prompt({ + hdr: hdr, + body: "