mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Fixes to schedules helper and lists.
This commit is contained in:
parent
3219700d9d
commit
89474973fc
@ -10,9 +10,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBreadCrumbs, LoadScope, RunningJobsList, CompletedJobsList, QueuedJobsList,
|
||||
ScheduledJobsList, GetChoices, GetBasePath, Wait, Find, JobsControllerInit, DeleteSchedule, ToggleSchedule,
|
||||
LoadDialogPartial, ScheduledJobEdit) {
|
||||
function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBreadCrumbs, LoadSchedulesScope, LoadJobsScope, RunningJobsList, CompletedJobsList, QueuedJobsList,
|
||||
ScheduledJobsList, GetChoices, GetBasePath, Wait) {
|
||||
|
||||
ClearScope();
|
||||
|
||||
@ -34,7 +33,7 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
|
||||
}
|
||||
$scope.removeBuildJobsList = $scope.$on('buildJobsList', function() {
|
||||
completed_scope = $scope.$new();
|
||||
LoadScope({
|
||||
LoadJobsScope({
|
||||
parent_scope: $scope,
|
||||
scope: completed_scope,
|
||||
list: CompletedJobsList,
|
||||
@ -42,7 +41,7 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
|
||||
url: GetBasePath('unified_jobs') + '?or__status=successful&or__status=failed&or__status=error&or__status=canceled'
|
||||
});
|
||||
running_scope = $scope.$new();
|
||||
LoadScope({
|
||||
LoadJobsScope({
|
||||
parent_scope: $scope,
|
||||
scope: running_scope,
|
||||
list: RunningJobsList,
|
||||
@ -50,7 +49,7 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
|
||||
url: GetBasePath('unified_jobs') + '?status=running'
|
||||
});
|
||||
queued_scope = $scope.$new();
|
||||
LoadScope({
|
||||
LoadJobsScope({
|
||||
parent_scope: $scope,
|
||||
scope: queued_scope,
|
||||
list: QueuedJobsList,
|
||||
@ -58,40 +57,13 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
|
||||
url: GetBasePath('unified_jobs') + '?or__status=pending&or__status=waiting&or__status=new'
|
||||
});
|
||||
scheduled_scope = $scope.$new();
|
||||
LoadScope({
|
||||
LoadSchedulesScope({
|
||||
parent_scope: $scope,
|
||||
scope: scheduled_scope,
|
||||
list: ScheduledJobsList,
|
||||
id: 'scheduled-jobs',
|
||||
url: GetBasePath('schedules')
|
||||
});
|
||||
|
||||
if (scheduled_scope.removeSchedulesRefresh) {
|
||||
scheduled_scope.removeSchedulesRefresh();
|
||||
}
|
||||
scheduled_scope.removeSchedulesRefresh = scheduled_scope.$on('SchedulesRefresh', function() {
|
||||
scheduled_scope.search(ScheduledJobsList.iterator);
|
||||
});
|
||||
|
||||
scheduled_scope.toggleSchedule = function(id) {
|
||||
ToggleSchedule({
|
||||
scope: scheduled_scope,
|
||||
id: id,
|
||||
callback: 'SchedulesRefresh'
|
||||
});
|
||||
};
|
||||
|
||||
scheduled_scope.deleteSchedule = function(id) {
|
||||
DeleteSchedule({
|
||||
scope: scheduled_scope,
|
||||
id: id,
|
||||
callback: 'SchedulesRefresh'
|
||||
});
|
||||
};
|
||||
|
||||
scheduled_scope.editSchedule = function(id) {
|
||||
ScheduledJobEdit({ scope: scheduled_scope, id: id });
|
||||
};
|
||||
});
|
||||
|
||||
if ($scope.removeChoicesReady) {
|
||||
@ -122,22 +94,16 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
|
||||
callback: 'choicesReady'
|
||||
});
|
||||
|
||||
LoadDialogPartial({
|
||||
scope: $scope,
|
||||
element_id: 'schedule-dialog-target',
|
||||
callback: 'choicesReady'
|
||||
});
|
||||
|
||||
$scope.refreshJobs = function() {
|
||||
queued_scope.search('queued_job');
|
||||
running_scope.search('running_job');
|
||||
completed_scope.search('completed_job');
|
||||
scheduled_scope.search('schedules');
|
||||
};
|
||||
}
|
||||
|
||||
JobsListController.$inject = ['$scope', '$compile', 'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'LoadScope', 'RunningJobsList', 'CompletedJobsList',
|
||||
'QueuedJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'Wait', 'Find', 'JobsControllerInit',
|
||||
'DeleteSchedule', 'ToggleSchedule', 'LoadDialogPartial', 'ScheduledJobEdit'];
|
||||
JobsListController.$inject = ['$scope', '$compile', 'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'LoadSchedulesScope', 'LoadJobsScope', 'RunningJobsList', 'CompletedJobsList',
|
||||
'QueuedJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'Wait' ];
|
||||
|
||||
function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, JobForm, JobTemplateForm, GenerateForm, Rest,
|
||||
Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList,
|
||||
|
||||
@ -10,13 +10,13 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
function ScheduleEditController($scope, $compile, $location, $routeParams, SchedulesList, GenerateList, Rest, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
||||
GetBasePath, LookUpInit, Wait, SchedulerInit, Breadcrumbs, SearchInit, PaginateInit, PageRangeSetup, EditSchedule, AddSchedule, Find, ToggleSchedule, DeleteSchedule,
|
||||
LoadDialogPartial) {
|
||||
function ScheduleEditController($scope, $compile, $location, $routeParams, SchedulesList, Rest, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
||||
GetBasePath, Wait, Breadcrumbs, Find, LoadDialogPartial, LoadSchedulesScope) {
|
||||
|
||||
ClearScope();
|
||||
|
||||
var base, e, id, url, parentObject;
|
||||
var base, e, id, url, parentObject,
|
||||
schedules_scope = $scope.$new();
|
||||
|
||||
base = $location.path().replace(/^\//, '').split('/')[0];
|
||||
|
||||
@ -43,111 +43,32 @@ LoadDialogPartial) {
|
||||
e.html(Breadcrumbs({ list: SchedulesList, mode: 'edit' }));
|
||||
$compile(e)($scope);
|
||||
|
||||
// Add schedules list
|
||||
GenerateList.inject(SchedulesList, {
|
||||
mode: 'edit',
|
||||
id: 'schedule-list-target',
|
||||
breadCrumbs: false,
|
||||
searchSize: 'col-lg-4 col-md-4 col-sm-3'
|
||||
});
|
||||
|
||||
// Change later to use GetBasePath(base)
|
||||
//switch(base) {
|
||||
// case 'job_templates':
|
||||
// url = '/static/sample/data/schedules/data.json';
|
||||
// break;
|
||||
// case 'projects':
|
||||
// url = '/static/sample/data/schedules/projects/data.json';
|
||||
// break;
|
||||
//}
|
||||
|
||||
url += "schedules/";
|
||||
|
||||
SearchInit({
|
||||
scope: $scope,
|
||||
set: 'schedules',
|
||||
LoadSchedulesScope({
|
||||
parent_scope: $scope,
|
||||
scope: schedules_scope,
|
||||
list: SchedulesList,
|
||||
id: 'schedule-list-target',
|
||||
url: url
|
||||
});
|
||||
|
||||
PaginateInit({
|
||||
scope: $scope,
|
||||
list: SchedulesList,
|
||||
url: url
|
||||
});
|
||||
|
||||
$scope.search(SchedulesList.iterator);
|
||||
});
|
||||
|
||||
$scope.editSchedule = function(id) {
|
||||
var schedule = Find({ list: $scope.schedules, key: 'id', val: id });
|
||||
EditSchedule({ scope: $scope, schedule: schedule, url: url });
|
||||
};
|
||||
|
||||
$scope.addSchedule = function() {
|
||||
var schedule = { };
|
||||
schedule.enabled = true;
|
||||
AddSchedule({ scope: $scope, schedule: schedule, url: url });
|
||||
};
|
||||
|
||||
if ($scope.removeScheduleRefresh) {
|
||||
$scope.removeScheduleRefresh();
|
||||
}
|
||||
$scope.removeScheduleToggled = $scope.$on('ScheduleRefresh', function() {
|
||||
$scope.search(SchedulesList.iterator);
|
||||
});
|
||||
|
||||
$scope.toggleSchedule = function(id) {
|
||||
ToggleSchedule({
|
||||
scope: $scope,
|
||||
id: id,
|
||||
callback: 'ScheduleToggled'
|
||||
// Load the parent object
|
||||
Wait('start');
|
||||
id = $routeParams.id;
|
||||
url = GetBasePath(base) + id + '/';
|
||||
Rest.setUrl(url);
|
||||
Rest.get()
|
||||
.success(function(data) {
|
||||
parentObject = data;
|
||||
$scope.$emit('ParentLoaded');
|
||||
})
|
||||
.error(function(data, status) {
|
||||
ProcessErrors($scope, data, status, null, { hdr: 'Error!',
|
||||
msg: 'Call to ' + url + ' failed. GET returned: ' + status });
|
||||
});
|
||||
};
|
||||
|
||||
$scope.toggleSchedule = function(id) {
|
||||
ToggleSchedule({
|
||||
scope: $scope,
|
||||
id: id,
|
||||
callback: 'SchedulesRefresh'
|
||||
});
|
||||
};
|
||||
|
||||
$scope.deleteSchedule = function(id) {
|
||||
DeleteSchedule({
|
||||
scope: $scope,
|
||||
id: id,
|
||||
callback: 'SchedulesRefresh'
|
||||
});
|
||||
};
|
||||
|
||||
if ($scope.removeLoadParent) {
|
||||
$scope.removeLoadParent();
|
||||
}
|
||||
$scope.removeLoadParent = $scope.$on('LoadParent', function() {
|
||||
// Load the parent object
|
||||
id = $routeParams.id;
|
||||
url = GetBasePath(base) + id + '/';
|
||||
Rest.setUrl(url);
|
||||
Rest.get()
|
||||
.success(function(data) {
|
||||
parentObject = data;
|
||||
$scope.$emit('ParentLoaded');
|
||||
})
|
||||
.error(function(status) {
|
||||
ProcessErrors($scope, null, status, null, { hdr: 'Error!',
|
||||
msg: 'Call to ' + url + ' failed. GET returned: ' + status });
|
||||
});
|
||||
});
|
||||
|
||||
LoadDialogPartial({
|
||||
scope: $scope,
|
||||
element_id: 'schedule-dialog-target',
|
||||
callback: 'LoadParent',
|
||||
});
|
||||
}
|
||||
|
||||
ScheduleEditController.$inject = ['$scope', '$compile', '$location', '$routeParams', 'SchedulesList', 'GenerateList', 'Rest', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
|
||||
'ClearScope', 'GetBasePath', 'LookUpInit', 'Wait', 'SchedulerInit', 'Breadcrumbs', 'SearchInit', 'PaginateInit', 'PageRangeSetup', 'EditSchedule', 'AddSchedule',
|
||||
'Find', 'ToggleSchedule', 'DeleteSchedule', 'LoadDialogPartial'
|
||||
];
|
||||
ScheduleEditController.$inject = [ '$scope', '$compile', '$location', '$routeParams', 'SchedulesList', 'Rest', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope',
|
||||
'GetBasePath', 'Wait', 'Breadcrumbs', 'Find', 'LoadDialogPartial', 'LoadSchedulesScope' ];
|
||||
@ -10,7 +10,7 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('JobsHelper', ['Utilities', 'RestServices', 'FormGenerator', 'JobSummaryDefinition', 'InventoryHelper', 'GeneratorHelpers',
|
||||
'JobSubmissionHelper', 'SchedulesHelper', 'LogViewerHelper'])
|
||||
'JobSubmissionHelper', 'LogViewerHelper', 'SearchHelper', 'PaginationHelpers', 'ListGenerator'])
|
||||
|
||||
/**
|
||||
* JobsControllerInit({ scope: $scope });
|
||||
@ -261,7 +261,7 @@ angular.module('JobsHelper', ['Utilities', 'RestServices', 'FormGenerator', 'Job
|
||||
* Called from JobsList controller to load each section or list on the page
|
||||
*
|
||||
*/
|
||||
.factory('LoadScope', ['SearchInit', 'PaginateInit', 'GenerateList', 'JobsControllerInit', 'Rest',
|
||||
.factory('LoadJobsScope', ['SearchInit', 'PaginateInit', 'GenerateList', 'JobsControllerInit', 'Rest',
|
||||
function(SearchInit, PaginateInit, GenerateList, JobsControllerInit, Rest) {
|
||||
return function(params) {
|
||||
var parent_scope = params.parent_scope,
|
||||
@ -345,10 +345,6 @@ angular.module('JobsHelper', ['Utilities', 'RestServices', 'FormGenerator', 'Job
|
||||
else if (list.name === 'queued_jobs') {
|
||||
itm.status_tip = 'Pending';
|
||||
}
|
||||
else if (list.name === 'scheduled_jobs') {
|
||||
itm.enabled = (itm.enabled) ? true : false;
|
||||
itm.play_tip = (itm.enabled) ? 'Schedule is Active. Click to temporarily stop.' : 'Schedule is temporarily stopped. Click to activate.';
|
||||
}
|
||||
|
||||
// Copy summary_field values
|
||||
for (field in list.fields) {
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
||||
angular.module('SchedulesHelper', ['Utilities', 'RestServices', 'SchedulesHelper', 'SearchHelper', 'PaginationHelpers', 'ListGenerator'])
|
||||
|
||||
.factory('ShowSchedulerModal', ['Wait', function(Wait) {
|
||||
return function(params) {
|
||||
@ -111,34 +111,43 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
||||
};
|
||||
}])
|
||||
|
||||
.factory('EditSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest', 'ToAPI', 'ProcessErrors',
|
||||
function(SchedulerInit, ShowSchedulerModal, Wait, Rest, ToAPI, ProcessErrors) {
|
||||
.factory('EditSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest', 'ToAPI', 'ProcessErrors', 'GetBasePath',
|
||||
function(SchedulerInit, ShowSchedulerModal, Wait, Rest, ToAPI, ProcessErrors, GetBasePath) {
|
||||
return function(params) {
|
||||
var scope = params.scope,
|
||||
schedule = params.schedule,
|
||||
url = params.url,
|
||||
scheduler;
|
||||
Wait('start');
|
||||
$('#form-container').empty();
|
||||
scheduler = SchedulerInit({ scope: scope, requireFutureStartTime: false });
|
||||
scheduler.inject('form-container', false);
|
||||
scheduler.injectDetail('occurrences', false);
|
||||
|
||||
ShowSchedulerModal({ scope: scope });
|
||||
scope.showRRuleDetail = false;
|
||||
|
||||
if (!/DTSTART/.test(schedule.rrule)) {
|
||||
schedule.rrule += ";DTSTART=" + schedule.dtstart.replace(/\.\d+Z$/,'Z');
|
||||
id = params.id,
|
||||
schedule, scheduler,
|
||||
url = GetBasePath('schedules') + id + '/';
|
||||
|
||||
if (scope.removeScheduleFound) {
|
||||
scope.removeScheduleFound();
|
||||
}
|
||||
|
||||
setTimeout(function(){
|
||||
$('#scheduler-modal-dialog').dialog('open');
|
||||
scope.$apply(function() {
|
||||
scheduler.setRRule(schedule.rrule);
|
||||
scheduler.setName(schedule.name);
|
||||
});
|
||||
$('#schedulerName').focus();
|
||||
}, 500);
|
||||
scope.removeScheduleFound = scope.$on('ScheduleFound', function() {
|
||||
$('#form-container').empty();
|
||||
scheduler = SchedulerInit({ scope: scope, requireFutureStartTime: false });
|
||||
scheduler.inject('form-container', false);
|
||||
scheduler.injectDetail('occurrences', false);
|
||||
|
||||
ShowSchedulerModal({ scope: scope });
|
||||
scope.showRRuleDetail = false;
|
||||
|
||||
if (!/DTSTART/.test(schedule.rrule)) {
|
||||
schedule.rrule += ";DTSTART=" + schedule.dtstart.replace(/\.\d+Z$/,'Z');
|
||||
}
|
||||
schedule.rrule = schedule.rrule.replace(/ RRULE:/,';');
|
||||
schedule.rrule = schedule.rrule.replace(/DTSTART:/,'DTSTART=');
|
||||
|
||||
setTimeout(function(){
|
||||
Wait('stop');
|
||||
$('#scheduler-modal-dialog').dialog('open');
|
||||
scope.$apply(function() {
|
||||
scheduler.setRRule(schedule.rrule);
|
||||
scheduler.setName(schedule.name);
|
||||
});
|
||||
$('#schedulerName').focus();
|
||||
}, 500);
|
||||
|
||||
});
|
||||
|
||||
scope.saveSchedule = function() {
|
||||
var newSchedule, rrule;
|
||||
@ -151,7 +160,7 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
||||
schedule.rrule = ToAPI(rrule.toString());
|
||||
schedule.description = (/error/.test(rrule.toText())) ? '' : rrule.toText();
|
||||
Rest.setUrl(url);
|
||||
Rest.post(schedule)
|
||||
Rest.put(schedule)
|
||||
.success(function(){
|
||||
Wait('stop');
|
||||
$('#scheduler-modal-dialog').dialog('close');
|
||||
@ -170,17 +179,34 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Wait('start');
|
||||
|
||||
// Get the existing record
|
||||
Rest.setUrl(url);
|
||||
Rest.get()
|
||||
.success(function(data) {
|
||||
schedule = data;
|
||||
scope.$emit('ScheduleFound');
|
||||
})
|
||||
.error(function(data,status){
|
||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||
msg: 'Failed to retrieve schedule ' + id + ' GET returned: ' + status });
|
||||
});
|
||||
};
|
||||
}])
|
||||
|
||||
.factory('AddSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest', 'ToAPI', 'ProcessErrors',
|
||||
function(SchedulerInit, ShowSchedulerModal, Wait, Rest, ToAPI, ProcessErrors) {
|
||||
.factory('AddSchedule', ['$location', '$routeParams', 'SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest', 'ToAPI', 'ProcessErrors', 'GetBasePath', 'Empty',
|
||||
function($location, $routeParams, SchedulerInit, ShowSchedulerModal, Wait, Rest, ToAPI, ProcessErrors, GetBasePath, Empty) {
|
||||
return function(params) {
|
||||
var scope = params.scope,
|
||||
url = params.url,
|
||||
schedule = params.schedule,
|
||||
callback= params.callback,
|
||||
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||
url = GetBasePath(base),
|
||||
scheduler;
|
||||
|
||||
url += (!Empty($routeParams.id)) ? $routeParams.id + '/schedules/' : '';
|
||||
|
||||
Wait('start');
|
||||
$('#form-container').empty();
|
||||
scheduler = SchedulerInit({ scope: scope, requireFutureStartTime: false });
|
||||
@ -195,7 +221,7 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
||||
}, 300);
|
||||
|
||||
scope.saveSchedule = function() {
|
||||
var newSchedule, rrule;
|
||||
var newSchedule, rrule, schedule = {};
|
||||
$('#scheduler-tabs a:first').tab('show');
|
||||
if (scheduler.isValid()) {
|
||||
Wait('start');
|
||||
@ -207,8 +233,13 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
||||
Rest.setUrl(url);
|
||||
Rest.post(schedule)
|
||||
.success(function(){
|
||||
Wait('stop');
|
||||
$('#scheduler-modal-dialog').dialog('close');
|
||||
if (callback) {
|
||||
scope.$emit(callback);
|
||||
}
|
||||
else {
|
||||
Wait('stop');
|
||||
}
|
||||
})
|
||||
.error(function(data, status){
|
||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||
@ -227,6 +258,9 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
||||
};
|
||||
}])
|
||||
|
||||
/**
|
||||
* Inject the scheduler_dialog.html wherever needed
|
||||
*/
|
||||
.factory('LoadDialogPartial', ['Rest', '$compile', 'ProcessErrors', function(Rest, $compile, ProcessErrors) {
|
||||
return function(params) {
|
||||
|
||||
@ -273,13 +307,16 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
||||
if (scope.removeScheduleFound) {
|
||||
scope.removeScheduleFound();
|
||||
}
|
||||
scope.removeScheduleFound = scope.$on('removeScheduleFound', function(e, data) {
|
||||
scope.removeScheduleFound = scope.$on('ScheduleFound', function(e, data) {
|
||||
data.enabled = (data.enabled) ? false : true;
|
||||
Rest.put(data)
|
||||
.success( function() {
|
||||
if (callback) {
|
||||
scope.$emit(callback, id);
|
||||
}
|
||||
else {
|
||||
Wait('stop');
|
||||
}
|
||||
})
|
||||
.error( function() {
|
||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||
@ -287,11 +324,13 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
||||
});
|
||||
});
|
||||
|
||||
// Get the existing record
|
||||
Wait('start');
|
||||
|
||||
// Get the schedule
|
||||
Rest.setUrl(url);
|
||||
Rest.get()
|
||||
.success(function(){
|
||||
|
||||
.success(function(data) {
|
||||
scope.$emit('ScheduleFound', data);
|
||||
})
|
||||
.error(function(data,status){
|
||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||
@ -354,6 +393,10 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
||||
};
|
||||
}])
|
||||
|
||||
/**
|
||||
* Convert rrule string to an API agreeable format
|
||||
*
|
||||
*/
|
||||
.factory('ToAPI', [ function() {
|
||||
return function(rrule) {
|
||||
var response;
|
||||
@ -362,6 +405,136 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
||||
});
|
||||
return response;
|
||||
};
|
||||
}])
|
||||
|
||||
|
||||
.factory('SchedulesControllerInit', ['ToggleSchedule', 'DeleteSchedule', 'EditSchedule', 'AddSchedule',
|
||||
function(ToggleSchedule, DeleteSchedule, EditSchedule, AddSchedule) {
|
||||
return function(params) {
|
||||
var scope = params.scope,
|
||||
list = params.list;
|
||||
|
||||
scope.toggleSchedule = function(event, id) {
|
||||
try {
|
||||
$(event.target).tooltip('hide');
|
||||
}
|
||||
catch(e) {
|
||||
// ignore
|
||||
}
|
||||
ToggleSchedule({
|
||||
scope: scope,
|
||||
id: id,
|
||||
callback: 'SchedulesRefresh'
|
||||
});
|
||||
};
|
||||
|
||||
scope.deleteSchedule = function(id) {
|
||||
DeleteSchedule({
|
||||
scope: scope,
|
||||
id: id,
|
||||
callback: 'SchedulesRefresh'
|
||||
});
|
||||
};
|
||||
|
||||
scope.editSchedule = function(id) {
|
||||
EditSchedule({
|
||||
scope: scope,
|
||||
id: id,
|
||||
callback: 'SchedulesRefresh'
|
||||
});
|
||||
};
|
||||
|
||||
scope.addSchedule = function() {
|
||||
AddSchedule({
|
||||
scope: scope,
|
||||
callback: 'SchedulesRefresh'
|
||||
});
|
||||
};
|
||||
|
||||
scope.$on('SchedulesRefresh', function() {
|
||||
scope.search(list.iterator);
|
||||
});
|
||||
};
|
||||
}])
|
||||
|
||||
/**
|
||||
*
|
||||
* Called from a controller to setup the scope for a schedules list
|
||||
*
|
||||
*/
|
||||
.factory('LoadSchedulesScope', ['SearchInit', 'PaginateInit', 'GenerateList', 'SchedulesControllerInit',
|
||||
function(SearchInit, PaginateInit, GenerateList, SchedulesControllerInit) {
|
||||
return function(params) {
|
||||
var parent_scope = params.parent_scope,
|
||||
scope = params.scope,
|
||||
list = params.list,
|
||||
id = params.id,
|
||||
url = params.url,
|
||||
pageSize = params.pageSize || 5;
|
||||
|
||||
GenerateList.inject(list, {
|
||||
mode: 'edit',
|
||||
id: id,
|
||||
breadCrumbs: false,
|
||||
scope: scope,
|
||||
searchSize: 'col-lg-4 col-md-6 col-sm-12 col-xs-12',
|
||||
showSearch: true
|
||||
});
|
||||
|
||||
SearchInit({
|
||||
scope: scope,
|
||||
set: list.name,
|
||||
list: list,
|
||||
url: url
|
||||
});
|
||||
|
||||
PaginateInit({
|
||||
scope: scope,
|
||||
list: list,
|
||||
url: url,
|
||||
pageSize: pageSize
|
||||
});
|
||||
|
||||
scope.iterator = list.iterator;
|
||||
|
||||
if (scope.removePostRefresh) {
|
||||
scope.removePostRefresh();
|
||||
}
|
||||
scope.$on('PostRefresh', function(){
|
||||
|
||||
SchedulesControllerInit({
|
||||
scope: scope,
|
||||
list: list
|
||||
});
|
||||
|
||||
scope[list.name].forEach(function(item, item_idx) {
|
||||
var fld, field,
|
||||
itm = scope[list.name][item_idx];
|
||||
itm.enabled = (itm.enabled) ? true : false;
|
||||
if (itm.enabled) {
|
||||
itm.play_tip = 'Schedule is Active. Click to temporarily stop.';
|
||||
itm.status = 'active';
|
||||
itm.status_tip = 'Schedule is Active. Click to temporarily stop.';
|
||||
}
|
||||
else {
|
||||
itm.play_tip = 'Schedule is temporarily stopped. Click to activate.';
|
||||
itm.status = 'stopped';
|
||||
itm.status_tip = 'Schedule is temporarily stopped. Click to activate.';
|
||||
}
|
||||
// Copy summary_field values
|
||||
for (field in list.fields) {
|
||||
fld = list.fields[field];
|
||||
if (fld.sourceModel) {
|
||||
if (itm.summary_fields[fld.sourceModel]) {
|
||||
itm[field] = itm.summary_fields[fld.sourceModel][fld.sourceField];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
parent_scope.$emit('listLoaded');
|
||||
});
|
||||
scope.search(list.iterator);
|
||||
};
|
||||
}]);
|
||||
|
||||
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
angular.module('ScheduledJobsDefinition', [])
|
||||
.value( 'ScheduledJobsList', {
|
||||
|
||||
name: 'scheduled_jobs',
|
||||
iterator: 'scheduled_job',
|
||||
name: 'schedules',
|
||||
iterator: 'schedule',
|
||||
editTitle: 'Scheduled Jobs',
|
||||
'class': 'table-condensed',
|
||||
index: true,
|
||||
@ -20,32 +20,35 @@ angular.module('ScheduledJobsDefinition', [])
|
||||
well: false,
|
||||
|
||||
fields: {
|
||||
status: {
|
||||
label: 'Status',
|
||||
columnClass: 'col-md-2 col-sm-2 col-xs-2',
|
||||
awToolTip: "{{ scheduled_job.status_tip }}",
|
||||
awTipPlacement: "top",
|
||||
icon: 'icon-job-{{ scheduled_job.status }}',
|
||||
iconOnly: true,
|
||||
ngClick: "toggleSchedule(scheduled_job.id)"
|
||||
},
|
||||
next_run: {
|
||||
label: 'Next Run',
|
||||
link: false,
|
||||
searchable: false,
|
||||
columnClass: "col-md-2 hidden-xs",
|
||||
filter: "date:'MM/dd/yy HH:mm:ss'",
|
||||
key: true,
|
||||
desc: true
|
||||
},
|
||||
type: {
|
||||
label: 'Type',
|
||||
link: false,
|
||||
sourceModel: '',
|
||||
sourceField: '',
|
||||
columnClass: "col-md-2 hidden-sm hidden-xs"
|
||||
},
|
||||
template_name: {
|
||||
name: {
|
||||
label: 'Name',
|
||||
columnClass: "col-md-3 col-xs-5",
|
||||
sourceModel: "template",
|
||||
sourceField: "name"
|
||||
}
|
||||
/*,
|
||||
dtend: {
|
||||
label: 'Ends On',
|
||||
searchable: false,
|
||||
filter: "date:'MM/dd/yy HH:mm:ss'",
|
||||
columnClass: "col-md-2 hidden-xs"
|
||||
}*/
|
||||
},
|
||||
|
||||
actions: {
|
||||
@ -60,7 +63,7 @@ angular.module('ScheduledJobsDefinition', [])
|
||||
fieldActions: {
|
||||
"play": {
|
||||
mode: "all",
|
||||
ngClick: "toggleSchedule(scheduled_job.id)",
|
||||
ngClick: "toggleSchedule($event, schedule.id)",
|
||||
awToolTip: "{{ scheduled_job.play_tip }}",
|
||||
dataTipWatch: "scheduled_job.play_tip",
|
||||
iconClass: "{{ 'fa icon-schedule-enabled-' + scheduled_job.enabled }}",
|
||||
|
||||
@ -24,7 +24,7 @@ angular.module('SchedulesListDefinition', [])
|
||||
key: true,
|
||||
label: 'Name',
|
||||
ngClick: "editSchedule(schedule.id)",
|
||||
columnClass: "col-md-5 col-sm-3 col-xs-3"
|
||||
columnClass: "col-md-3 col-sm-3 col-xs-3"
|
||||
},
|
||||
next_run: {
|
||||
label: 'Next Run',
|
||||
@ -62,7 +62,7 @@ angular.module('SchedulesListDefinition', [])
|
||||
fieldActions: {
|
||||
"play": {
|
||||
mode: "all",
|
||||
ngClick: "toggleSchedule(schedule.id)",
|
||||
ngClick: "toggleSchedule($event, schedule.id)",
|
||||
awToolTip: "{{ schedule.play_tip }}",
|
||||
dataTipWatch: "schedule.play_tip",
|
||||
iconClass: "{{ 'fa icon-schedule-enabled-' + schedule.enabled }}",
|
||||
|
||||
@ -35,5 +35,6 @@
|
||||
</div>
|
||||
<div id="schedule-dialog-target"></div>
|
||||
<div ng-include="'/static/partials/logviewer.html'"></div>
|
||||
<div ng-include="'/static/partials/schedule_dialog.html'"></div>
|
||||
</div>
|
||||
</div>
|
||||
@ -8,4 +8,4 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="schedule-dialog-target"></div>
|
||||
<div ng-include="'/static/partials/schedule_dialog.html'"></div>
|
||||
Loading…
x
Reference in New Issue
Block a user