diff --git a/awx/ui/static/js/controllers/Jobs.js b/awx/ui/static/js/controllers/Jobs.js index 675d63b924..a2bc6d7c11 100644 --- a/awx/ui/static/js/controllers/Jobs.js +++ b/awx/ui/static/js/controllers/Jobs.js @@ -11,7 +11,7 @@ 'use strict'; function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBreadCrumbs, LoadScope, RunningJobsList, CompletedJobsList, QueuedJobsList, - ScheduledJobsList, GetChoices, GetBasePath, Wait, DeleteJob) { + ScheduledJobsList, GetChoices, GetBasePath, Wait, DeleteJob, ToggleScheduleEnabled, Find) { ClearScope(); @@ -75,6 +75,15 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea url: GetBasePath('schedules') }); + if (scheduled_scope.removeScheduleToggled) { + scheduled_scope.removeScheduleToggled(); + } + scheduled_scope.removeScheduleToggled = function(e, id) { + //scheduled_scope.search(ScheduledJobsList.iterator); + var schedule = Find({ list: scheduled_scope[ScheduledJobsList.name], key: 'id', val: id}); + schedule.enabled = (schedule.enabled) ? false : true; + }; + completed_scope.deleteJob = function(id) { DeleteJob({ scope: completed_scope, id: id }); }; @@ -86,6 +95,13 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea running_scope.deleteJob = function(id) { DeleteJob({ scope: running_scope, id: id }); }; + + scheduled_scope.toggleSchedule = function(id) { + ToggleScheduleEnabled({ + scope: scheduled_scope, + id: id + }); + }; }); @@ -120,7 +136,7 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea } JobsListController.$inject = ['$scope', '$compile', 'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'LoadScope', 'RunningJobsList', 'CompletedJobsList', - 'QueuedJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'Wait', 'DeleteJob']; + 'QueuedJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'Wait', 'DeleteJob', 'ToggleScheduleEnabled', 'Find']; function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, JobForm, JobTemplateForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList, diff --git a/awx/ui/static/js/helpers/Jobs.js b/awx/ui/static/js/helpers/Jobs.js index 7f71276b5d..50851813a5 100644 --- a/awx/ui/static/js/helpers/Jobs.js +++ b/awx/ui/static/js/helpers/Jobs.js @@ -9,7 +9,7 @@ 'use strict'; -angular.module('JobsHelper', ['Utilities', 'FormGenerator', 'JobSummaryDefinition', 'InventoryHelper', 'GeneratorHelpers']) +angular.module('JobsHelper', ['Utilities', 'FormGenerator', 'JobSummaryDefinition', 'InventoryHelper', 'GeneratorHelpers', 'SchedulesHelper']) .factory('JobStatusToolTip', [ function () { @@ -326,5 +326,17 @@ function(Find, GetBasePath, Rest, Wait, ProcessErrors, Prompt){ }); }; +}]) + +.factory('ToggleScheduleEnabled', ['ToggleSchedule', function(ToggleSchedule) { + return function(params) { + var scope = params.scope, + id = params.id; + ToggleSchedule({ + scope: scope, + id: id, + callback: 'ScheduleToggled' + }); + }; }]); diff --git a/awx/ui/static/js/helpers/Schedules.js b/awx/ui/static/js/helpers/Schedules.js index af165b56ce..38eea7f05a 100644 --- a/awx/ui/static/js/helpers/Schedules.js +++ b/awx/ui/static/js/helpers/Schedules.js @@ -107,38 +107,6 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper']) }; }]) - /*.factory('ShowDetails', [ function() { - return function(params) { - - var scope = params.scope, - scheduler = params.scheduler, - e = params.e, - rrule; - - if ($(e.target).text() === 'Details') { - if (scheduler.isValid()) { - scope.schedulerIsValid = true; - rrule = scheduler.getRRule(); - scope.occurrence_list = []; - scope.dateChoice = 'utc'; - rrule.all(function(date, i){ - if (i < 10) { - scope.occurrence_list.push({ utc: date.toUTCString(), local: date.toString() }); - return true; - } - return false; - }); - scope.rrule_nlp_description = rrule.toText().replace(/^RRule error.*$/,'Natural language description not available'); - scope.rrule = scheduler.getValue().rrule; - } - else { - scope.schedulerIsValid = false; - $('#scheduler-tabs a:first').tab('show'); - } - } - }; - }])*/ - .factory('EditSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest', function(SchedulerInit, ShowSchedulerModal, Wait, Rest) { return function(params) { @@ -246,4 +214,67 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper']) } }); }; - }]); \ No newline at end of file + }]) + + /** + * Flip a schedule's enable flag + * + * ToggleSchedule({ + * scope: scope, + * id: schedule.id to update + * callback: scope.$emit label to call when update completes + * }); + * + */ + .factory('ToggleSchedule', ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', function(Wait, GetBasePath, ProcessErrors, Rest) { + return function(params) { + var scope = params.scope, + id = params.id, + callback = params.callback, + url = GetBasePath('schedules') + id +'/'; + + // Perform the update + if (scope.removeScheduleFound) { + scope.removeScheduleFound(); + } + scope.removeScheduleFound = scope.$on('removeScheduleFound', function(e, data) { + data.enabled = (data.enabled) ? false : true; + Rest.put(data) + .success( function() { + if (callback) { + scope.$emit(callback, id); + } + }) + .error( function() { + ProcessErrors(scope, data, status, null, { hdr: 'Error!', + msg: 'Failed to update schedule ' + id + ' PUT returned: ' + status }); + }); + }); + + // Get the existing record + Rest.setUrl(url); + Rest.get() + .success(function(){ + + }) + .error(function(data,status){ + ProcessErrors(scope, data, status, null, { hdr: 'Error!', + msg: 'Failed to retrieve schedule ' + id + ' GET returned: ' + status }); + }); + }; + }]); + + + + + + + + + + + + + + + diff --git a/awx/ui/static/js/lists/JobTemplates.js b/awx/ui/static/js/lists/JobTemplates.js index 903a828ce2..f803b8ae22 100644 --- a/awx/ui/static/js/lists/JobTemplates.js +++ b/awx/ui/static/js/lists/JobTemplates.js @@ -48,13 +48,6 @@ angular.module('JobTemplatesListDefinition', []) }, fieldActions: { - edit: { - label: 'Edit', - ngClick: "editJobTemplate(job_template.id)", - awToolTip: 'Edit template', - "class": 'btn-default btn-xs', - dataPlacement: 'top' - }, submit: { label: 'Launch', mode: 'all', @@ -69,6 +62,13 @@ angular.module('JobTemplatesListDefinition', []) awToolTip: 'Schedule future job template runs', dataPlacement: 'top' }, + edit: { + label: 'Edit', + ngClick: "editJobTemplate(job_template.id)", + awToolTip: 'Edit template', + "class": 'btn-default btn-xs', + dataPlacement: 'top' + }, "delete": { label: 'Delete', ngClick: "deleteJobTemplate(job_template.id, job_template.name)", diff --git a/awx/ui/static/js/lists/Projects.js b/awx/ui/static/js/lists/Projects.js index 0e6fe77192..7309dbd2fd 100644 --- a/awx/ui/static/js/lists/Projects.js +++ b/awx/ui/static/js/lists/Projects.js @@ -92,11 +92,6 @@ angular.module('ProjectsListDefinition', []) }, fieldActions: { - edit: { - ngClick: "editProject(project.id)", - awToolTip: 'Edit the project', - dataPlacement: 'top' - }, scm_update: { ngClick: 'SCMUpdate(project.id)', awToolTip: "{{ project.scm_update_tooltip }}", @@ -115,6 +110,11 @@ angular.module('ProjectsListDefinition', []) awToolTip: 'Schedule future SCM updates', dataPlacement: 'top' }, + edit: { + ngClick: "editProject(project.id)", + awToolTip: 'Edit the project', + dataPlacement: 'top' + }, "delete": { ngClick: "deleteProject(project.id, project.name)", awToolTip: 'Delete the project', diff --git a/awx/ui/static/js/lists/ScheduledJobs.js b/awx/ui/static/js/lists/ScheduledJobs.js index 2d7332403d..3ec9bd9fae 100644 --- a/awx/ui/static/js/lists/ScheduledJobs.js +++ b/awx/ui/static/js/lists/ScheduledJobs.js @@ -60,7 +60,7 @@ angular.module('ScheduledJobsDefinition', []) awToolTip: "{{ scheduled_job.play_tip }}", dataTipWatch: "scheduled_job.play_tip", iconClass: "{{ 'fa icon-schedule-enabled-' + scheduled_job.enabled }}", - dataPlacement: 'top', + dataPlacement: 'top' }, "edit": { mode: "all", diff --git a/awx/ui/static/lib/ansible/directives.js b/awx/ui/static/lib/ansible/directives.js index 3884ceddec..1776ba7f80 100644 --- a/awx/ui/static/lib/ansible/directives.js +++ b/awx/ui/static/lib/ansible/directives.js @@ -292,9 +292,20 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job content: attrs.awPopOver, trigger: trigger, html: true, container: container }); $(element).click(function() { var self = $(this); + try { + self.tooltip('hide'); + } + catch(e) { + // ignore + } $('.help-link, .help-link-white').each( function() { if (self.attr('id') !== $(this).attr('id')) { - $(this).popover('hide'); + try { + $(this).popover('hide'); + } + catch(e) { + // ignore + } } }); $('.popover').each(function() {