1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

Added support for schedule.enabled to Jobs page.

This commit is contained in:
Chris Houseknecht 2014-03-25 10:02:10 -04:00
parent 71904c3b5b
commit f153105f79
7 changed files with 120 additions and 50 deletions

View File

@ -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 });
};
@ -87,6 +96,13 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
DeleteJob({ scope: running_scope, id: id });
};
scheduled_scope.toggleSchedule = function(id) {
ToggleScheduleEnabled({
scope: scheduled_scope,
id: id
});
};
});
if ($scope.removeChoicesReady) {
@ -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,

View File

@ -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'
});
};
}]);

View File

@ -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'])
}
});
};
}])
/**
* 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 });
});
};
}]);

View File

@ -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)",

View File

@ -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',

View File

@ -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",

View File

@ -292,10 +292,21 @@ 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')) {
try {
$(this).popover('hide');
}
catch(e) {
// ignore
}
}
});
$('.popover').each(function() {
// remove lingering popover <div>. Seems to be a bug in TB3 RC1