mirror of
https://github.com/ansible/awx.git
synced 2026-02-28 00:08:44 -03:30
Fixes to schedules helper and lists.
This commit is contained in:
@@ -10,9 +10,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBreadCrumbs, LoadScope, RunningJobsList, CompletedJobsList, QueuedJobsList,
|
function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBreadCrumbs, LoadSchedulesScope, LoadJobsScope, RunningJobsList, CompletedJobsList, QueuedJobsList,
|
||||||
ScheduledJobsList, GetChoices, GetBasePath, Wait, Find, JobsControllerInit, DeleteSchedule, ToggleSchedule,
|
ScheduledJobsList, GetChoices, GetBasePath, Wait) {
|
||||||
LoadDialogPartial, ScheduledJobEdit) {
|
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -34,7 +33,7 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
|
|||||||
}
|
}
|
||||||
$scope.removeBuildJobsList = $scope.$on('buildJobsList', function() {
|
$scope.removeBuildJobsList = $scope.$on('buildJobsList', function() {
|
||||||
completed_scope = $scope.$new();
|
completed_scope = $scope.$new();
|
||||||
LoadScope({
|
LoadJobsScope({
|
||||||
parent_scope: $scope,
|
parent_scope: $scope,
|
||||||
scope: completed_scope,
|
scope: completed_scope,
|
||||||
list: CompletedJobsList,
|
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'
|
url: GetBasePath('unified_jobs') + '?or__status=successful&or__status=failed&or__status=error&or__status=canceled'
|
||||||
});
|
});
|
||||||
running_scope = $scope.$new();
|
running_scope = $scope.$new();
|
||||||
LoadScope({
|
LoadJobsScope({
|
||||||
parent_scope: $scope,
|
parent_scope: $scope,
|
||||||
scope: running_scope,
|
scope: running_scope,
|
||||||
list: RunningJobsList,
|
list: RunningJobsList,
|
||||||
@@ -50,7 +49,7 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
|
|||||||
url: GetBasePath('unified_jobs') + '?status=running'
|
url: GetBasePath('unified_jobs') + '?status=running'
|
||||||
});
|
});
|
||||||
queued_scope = $scope.$new();
|
queued_scope = $scope.$new();
|
||||||
LoadScope({
|
LoadJobsScope({
|
||||||
parent_scope: $scope,
|
parent_scope: $scope,
|
||||||
scope: queued_scope,
|
scope: queued_scope,
|
||||||
list: QueuedJobsList,
|
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'
|
url: GetBasePath('unified_jobs') + '?or__status=pending&or__status=waiting&or__status=new'
|
||||||
});
|
});
|
||||||
scheduled_scope = $scope.$new();
|
scheduled_scope = $scope.$new();
|
||||||
LoadScope({
|
LoadSchedulesScope({
|
||||||
parent_scope: $scope,
|
parent_scope: $scope,
|
||||||
scope: scheduled_scope,
|
scope: scheduled_scope,
|
||||||
list: ScheduledJobsList,
|
list: ScheduledJobsList,
|
||||||
id: 'scheduled-jobs',
|
id: 'scheduled-jobs',
|
||||||
url: GetBasePath('schedules')
|
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) {
|
if ($scope.removeChoicesReady) {
|
||||||
@@ -122,22 +94,16 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
|
|||||||
callback: 'choicesReady'
|
callback: 'choicesReady'
|
||||||
});
|
});
|
||||||
|
|
||||||
LoadDialogPartial({
|
|
||||||
scope: $scope,
|
|
||||||
element_id: 'schedule-dialog-target',
|
|
||||||
callback: 'choicesReady'
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.refreshJobs = function() {
|
$scope.refreshJobs = function() {
|
||||||
queued_scope.search('queued_job');
|
queued_scope.search('queued_job');
|
||||||
running_scope.search('running_job');
|
running_scope.search('running_job');
|
||||||
completed_scope.search('completed_job');
|
completed_scope.search('completed_job');
|
||||||
|
scheduled_scope.search('schedules');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
JobsListController.$inject = ['$scope', '$compile', 'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'LoadScope', 'RunningJobsList', 'CompletedJobsList',
|
JobsListController.$inject = ['$scope', '$compile', 'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'LoadSchedulesScope', 'LoadJobsScope', 'RunningJobsList', 'CompletedJobsList',
|
||||||
'QueuedJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'Wait', 'Find', 'JobsControllerInit',
|
'QueuedJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'Wait' ];
|
||||||
'DeleteSchedule', 'ToggleSchedule', 'LoadDialogPartial', 'ScheduledJobEdit'];
|
|
||||||
|
|
||||||
function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, JobForm, JobTemplateForm, GenerateForm, Rest,
|
function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, JobForm, JobTemplateForm, GenerateForm, Rest,
|
||||||
Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList,
|
Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList,
|
||||||
|
|||||||
@@ -10,13 +10,13 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function ScheduleEditController($scope, $compile, $location, $routeParams, SchedulesList, GenerateList, Rest, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
function ScheduleEditController($scope, $compile, $location, $routeParams, SchedulesList, Rest, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
||||||
GetBasePath, LookUpInit, Wait, SchedulerInit, Breadcrumbs, SearchInit, PaginateInit, PageRangeSetup, EditSchedule, AddSchedule, Find, ToggleSchedule, DeleteSchedule,
|
GetBasePath, Wait, Breadcrumbs, Find, LoadDialogPartial, LoadSchedulesScope) {
|
||||||
LoadDialogPartial) {
|
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
var base, e, id, url, parentObject;
|
var base, e, id, url, parentObject,
|
||||||
|
schedules_scope = $scope.$new();
|
||||||
|
|
||||||
base = $location.path().replace(/^\//, '').split('/')[0];
|
base = $location.path().replace(/^\//, '').split('/')[0];
|
||||||
|
|
||||||
@@ -43,111 +43,32 @@ LoadDialogPartial) {
|
|||||||
e.html(Breadcrumbs({ list: SchedulesList, mode: 'edit' }));
|
e.html(Breadcrumbs({ list: SchedulesList, mode: 'edit' }));
|
||||||
$compile(e)($scope);
|
$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/";
|
url += "schedules/";
|
||||||
|
|
||||||
SearchInit({
|
LoadSchedulesScope({
|
||||||
scope: $scope,
|
parent_scope: $scope,
|
||||||
set: 'schedules',
|
scope: schedules_scope,
|
||||||
list: SchedulesList,
|
list: SchedulesList,
|
||||||
|
id: 'schedule-list-target',
|
||||||
url: url
|
url: url
|
||||||
});
|
});
|
||||||
|
|
||||||
PaginateInit({
|
|
||||||
scope: $scope,
|
|
||||||
list: SchedulesList,
|
|
||||||
url: url
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.search(SchedulesList.iterator);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.editSchedule = function(id) {
|
// Load the parent object
|
||||||
var schedule = Find({ list: $scope.schedules, key: 'id', val: id });
|
Wait('start');
|
||||||
EditSchedule({ scope: $scope, schedule: schedule, url: url });
|
id = $routeParams.id;
|
||||||
};
|
url = GetBasePath(base) + id + '/';
|
||||||
|
Rest.setUrl(url);
|
||||||
$scope.addSchedule = function() {
|
Rest.get()
|
||||||
var schedule = { };
|
.success(function(data) {
|
||||||
schedule.enabled = true;
|
parentObject = data;
|
||||||
AddSchedule({ scope: $scope, schedule: schedule, url: url });
|
$scope.$emit('ParentLoaded');
|
||||||
};
|
})
|
||||||
|
.error(function(data, status) {
|
||||||
if ($scope.removeScheduleRefresh) {
|
ProcessErrors($scope, data, status, null, { hdr: 'Error!',
|
||||||
$scope.removeScheduleRefresh();
|
msg: 'Call to ' + url + ' failed. GET returned: ' + status });
|
||||||
}
|
|
||||||
$scope.removeScheduleToggled = $scope.$on('ScheduleRefresh', function() {
|
|
||||||
$scope.search(SchedulesList.iterator);
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.toggleSchedule = function(id) {
|
|
||||||
ToggleSchedule({
|
|
||||||
scope: $scope,
|
|
||||||
id: id,
|
|
||||||
callback: 'ScheduleToggled'
|
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
$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',
|
ScheduleEditController.$inject = [ '$scope', '$compile', '$location', '$routeParams', 'SchedulesList', 'Rest', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope',
|
||||||
'ClearScope', 'GetBasePath', 'LookUpInit', 'Wait', 'SchedulerInit', 'Breadcrumbs', 'SearchInit', 'PaginateInit', 'PageRangeSetup', 'EditSchedule', 'AddSchedule',
|
'GetBasePath', 'Wait', 'Breadcrumbs', 'Find', 'LoadDialogPartial', 'LoadSchedulesScope' ];
|
||||||
'Find', 'ToggleSchedule', 'DeleteSchedule', 'LoadDialogPartial'
|
|
||||||
];
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('JobsHelper', ['Utilities', 'RestServices', 'FormGenerator', 'JobSummaryDefinition', 'InventoryHelper', 'GeneratorHelpers',
|
angular.module('JobsHelper', ['Utilities', 'RestServices', 'FormGenerator', 'JobSummaryDefinition', 'InventoryHelper', 'GeneratorHelpers',
|
||||||
'JobSubmissionHelper', 'SchedulesHelper', 'LogViewerHelper'])
|
'JobSubmissionHelper', 'LogViewerHelper', 'SearchHelper', 'PaginationHelpers', 'ListGenerator'])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JobsControllerInit({ scope: $scope });
|
* 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
|
* 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) {
|
function(SearchInit, PaginateInit, GenerateList, JobsControllerInit, Rest) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
var parent_scope = params.parent_scope,
|
var parent_scope = params.parent_scope,
|
||||||
@@ -345,10 +345,6 @@ angular.module('JobsHelper', ['Utilities', 'RestServices', 'FormGenerator', 'Job
|
|||||||
else if (list.name === 'queued_jobs') {
|
else if (list.name === 'queued_jobs') {
|
||||||
itm.status_tip = 'Pending';
|
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
|
// Copy summary_field values
|
||||||
for (field in list.fields) {
|
for (field in list.fields) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
angular.module('SchedulesHelper', ['Utilities', 'RestServices', 'SchedulesHelper', 'SearchHelper', 'PaginationHelpers', 'ListGenerator'])
|
||||||
|
|
||||||
.factory('ShowSchedulerModal', ['Wait', function(Wait) {
|
.factory('ShowSchedulerModal', ['Wait', function(Wait) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
@@ -111,34 +111,43 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
|||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('EditSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest', 'ToAPI', 'ProcessErrors',
|
.factory('EditSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest', 'ToAPI', 'ProcessErrors', 'GetBasePath',
|
||||||
function(SchedulerInit, ShowSchedulerModal, Wait, Rest, ToAPI, ProcessErrors) {
|
function(SchedulerInit, ShowSchedulerModal, Wait, Rest, ToAPI, ProcessErrors, GetBasePath) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
schedule = params.schedule,
|
id = params.id,
|
||||||
url = params.url,
|
schedule, scheduler,
|
||||||
scheduler;
|
url = GetBasePath('schedules') + id + '/';
|
||||||
Wait('start');
|
|
||||||
$('#form-container').empty();
|
if (scope.removeScheduleFound) {
|
||||||
scheduler = SchedulerInit({ scope: scope, requireFutureStartTime: false });
|
scope.removeScheduleFound();
|
||||||
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');
|
|
||||||
}
|
}
|
||||||
|
scope.removeScheduleFound = scope.$on('ScheduleFound', function() {
|
||||||
setTimeout(function(){
|
$('#form-container').empty();
|
||||||
$('#scheduler-modal-dialog').dialog('open');
|
scheduler = SchedulerInit({ scope: scope, requireFutureStartTime: false });
|
||||||
scope.$apply(function() {
|
scheduler.inject('form-container', false);
|
||||||
scheduler.setRRule(schedule.rrule);
|
scheduler.injectDetail('occurrences', false);
|
||||||
scheduler.setName(schedule.name);
|
|
||||||
});
|
ShowSchedulerModal({ scope: scope });
|
||||||
$('#schedulerName').focus();
|
scope.showRRuleDetail = false;
|
||||||
}, 500);
|
|
||||||
|
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() {
|
scope.saveSchedule = function() {
|
||||||
var newSchedule, rrule;
|
var newSchedule, rrule;
|
||||||
@@ -151,7 +160,7 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
|||||||
schedule.rrule = ToAPI(rrule.toString());
|
schedule.rrule = ToAPI(rrule.toString());
|
||||||
schedule.description = (/error/.test(rrule.toText())) ? '' : rrule.toText();
|
schedule.description = (/error/.test(rrule.toText())) ? '' : rrule.toText();
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post(schedule)
|
Rest.put(schedule)
|
||||||
.success(function(){
|
.success(function(){
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$('#scheduler-modal-dialog').dialog('close');
|
$('#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',
|
.factory('AddSchedule', ['$location', '$routeParams', 'SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest', 'ToAPI', 'ProcessErrors', 'GetBasePath', 'Empty',
|
||||||
function(SchedulerInit, ShowSchedulerModal, Wait, Rest, ToAPI, ProcessErrors) {
|
function($location, $routeParams, SchedulerInit, ShowSchedulerModal, Wait, Rest, ToAPI, ProcessErrors, GetBasePath, Empty) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
url = params.url,
|
callback= params.callback,
|
||||||
schedule = params.schedule,
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
|
url = GetBasePath(base),
|
||||||
scheduler;
|
scheduler;
|
||||||
|
|
||||||
|
url += (!Empty($routeParams.id)) ? $routeParams.id + '/schedules/' : '';
|
||||||
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
$('#form-container').empty();
|
$('#form-container').empty();
|
||||||
scheduler = SchedulerInit({ scope: scope, requireFutureStartTime: false });
|
scheduler = SchedulerInit({ scope: scope, requireFutureStartTime: false });
|
||||||
@@ -195,7 +221,7 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
|||||||
}, 300);
|
}, 300);
|
||||||
|
|
||||||
scope.saveSchedule = function() {
|
scope.saveSchedule = function() {
|
||||||
var newSchedule, rrule;
|
var newSchedule, rrule, schedule = {};
|
||||||
$('#scheduler-tabs a:first').tab('show');
|
$('#scheduler-tabs a:first').tab('show');
|
||||||
if (scheduler.isValid()) {
|
if (scheduler.isValid()) {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
@@ -207,8 +233,13 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
|||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post(schedule)
|
Rest.post(schedule)
|
||||||
.success(function(){
|
.success(function(){
|
||||||
Wait('stop');
|
|
||||||
$('#scheduler-modal-dialog').dialog('close');
|
$('#scheduler-modal-dialog').dialog('close');
|
||||||
|
if (callback) {
|
||||||
|
scope.$emit(callback);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Wait('stop');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.error(function(data, status){
|
.error(function(data, status){
|
||||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
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) {
|
.factory('LoadDialogPartial', ['Rest', '$compile', 'ProcessErrors', function(Rest, $compile, ProcessErrors) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
|
|
||||||
@@ -273,13 +307,16 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
|||||||
if (scope.removeScheduleFound) {
|
if (scope.removeScheduleFound) {
|
||||||
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;
|
data.enabled = (data.enabled) ? false : true;
|
||||||
Rest.put(data)
|
Rest.put(data)
|
||||||
.success( function() {
|
.success( function() {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
scope.$emit(callback, id);
|
scope.$emit(callback, id);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Wait('stop');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.error( function() {
|
.error( function() {
|
||||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
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.setUrl(url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success(function(){
|
.success(function(data) {
|
||||||
|
scope.$emit('ScheduleFound', data);
|
||||||
})
|
})
|
||||||
.error(function(data,status){
|
.error(function(data,status){
|
||||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
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() {
|
.factory('ToAPI', [ function() {
|
||||||
return function(rrule) {
|
return function(rrule) {
|
||||||
var response;
|
var response;
|
||||||
@@ -362,6 +405,136 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
|||||||
});
|
});
|
||||||
return response;
|
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', [])
|
angular.module('ScheduledJobsDefinition', [])
|
||||||
.value( 'ScheduledJobsList', {
|
.value( 'ScheduledJobsList', {
|
||||||
|
|
||||||
name: 'scheduled_jobs',
|
name: 'schedules',
|
||||||
iterator: 'scheduled_job',
|
iterator: 'schedule',
|
||||||
editTitle: 'Scheduled Jobs',
|
editTitle: 'Scheduled Jobs',
|
||||||
'class': 'table-condensed',
|
'class': 'table-condensed',
|
||||||
index: true,
|
index: true,
|
||||||
@@ -20,32 +20,35 @@ angular.module('ScheduledJobsDefinition', [])
|
|||||||
well: false,
|
well: false,
|
||||||
|
|
||||||
fields: {
|
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: {
|
next_run: {
|
||||||
label: 'Next Run',
|
label: 'Next Run',
|
||||||
link: false,
|
link: false,
|
||||||
searchable: false,
|
searchable: false,
|
||||||
columnClass: "col-md-2 hidden-xs",
|
columnClass: "col-md-2 hidden-xs",
|
||||||
|
filter: "date:'MM/dd/yy HH:mm:ss'",
|
||||||
key: true,
|
key: true,
|
||||||
desc: true
|
desc: true
|
||||||
},
|
},
|
||||||
type: {
|
type: {
|
||||||
label: 'Type',
|
label: 'Type',
|
||||||
link: false,
|
link: false,
|
||||||
|
sourceModel: '',
|
||||||
|
sourceField: '',
|
||||||
columnClass: "col-md-2 hidden-sm hidden-xs"
|
columnClass: "col-md-2 hidden-sm hidden-xs"
|
||||||
},
|
},
|
||||||
template_name: {
|
name: {
|
||||||
label: 'Name',
|
label: 'Name',
|
||||||
columnClass: "col-md-3 col-xs-5",
|
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: {
|
actions: {
|
||||||
@@ -60,7 +63,7 @@ angular.module('ScheduledJobsDefinition', [])
|
|||||||
fieldActions: {
|
fieldActions: {
|
||||||
"play": {
|
"play": {
|
||||||
mode: "all",
|
mode: "all",
|
||||||
ngClick: "toggleSchedule(scheduled_job.id)",
|
ngClick: "toggleSchedule($event, schedule.id)",
|
||||||
awToolTip: "{{ scheduled_job.play_tip }}",
|
awToolTip: "{{ scheduled_job.play_tip }}",
|
||||||
dataTipWatch: "scheduled_job.play_tip",
|
dataTipWatch: "scheduled_job.play_tip",
|
||||||
iconClass: "{{ 'fa icon-schedule-enabled-' + scheduled_job.enabled }}",
|
iconClass: "{{ 'fa icon-schedule-enabled-' + scheduled_job.enabled }}",
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ angular.module('SchedulesListDefinition', [])
|
|||||||
key: true,
|
key: true,
|
||||||
label: 'Name',
|
label: 'Name',
|
||||||
ngClick: "editSchedule(schedule.id)",
|
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: {
|
next_run: {
|
||||||
label: 'Next Run',
|
label: 'Next Run',
|
||||||
@@ -62,7 +62,7 @@ angular.module('SchedulesListDefinition', [])
|
|||||||
fieldActions: {
|
fieldActions: {
|
||||||
"play": {
|
"play": {
|
||||||
mode: "all",
|
mode: "all",
|
||||||
ngClick: "toggleSchedule(schedule.id)",
|
ngClick: "toggleSchedule($event, schedule.id)",
|
||||||
awToolTip: "{{ schedule.play_tip }}",
|
awToolTip: "{{ schedule.play_tip }}",
|
||||||
dataTipWatch: "schedule.play_tip",
|
dataTipWatch: "schedule.play_tip",
|
||||||
iconClass: "{{ 'fa icon-schedule-enabled-' + schedule.enabled }}",
|
iconClass: "{{ 'fa icon-schedule-enabled-' + schedule.enabled }}",
|
||||||
|
|||||||
@@ -35,5 +35,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="schedule-dialog-target"></div>
|
<div id="schedule-dialog-target"></div>
|
||||||
<div ng-include="'/static/partials/logviewer.html'"></div>
|
<div ng-include="'/static/partials/logviewer.html'"></div>
|
||||||
|
<div ng-include="'/static/partials/schedule_dialog.html'"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -8,4 +8,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="schedule-dialog-target"></div>
|
<div ng-include="'/static/partials/schedule_dialog.html'"></div>
|
||||||
Reference in New Issue
Block a user