mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
Wiring scheduler pieces
This commit is contained in:
@@ -16,7 +16,7 @@ LoadDialogPartial) {
|
|||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
var base, e, id, parentObject, url;
|
var base, e, id, url, parentObject;
|
||||||
|
|
||||||
base = $location.path().replace(/^\//, '').split('/')[0];
|
base = $location.path().replace(/^\//, '').split('/')[0];
|
||||||
|
|
||||||
@@ -52,52 +52,31 @@ LoadDialogPartial) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Change later to use GetBasePath(base)
|
// Change later to use GetBasePath(base)
|
||||||
switch(base) {
|
//switch(base) {
|
||||||
case 'job_templates':
|
// case 'job_templates':
|
||||||
url = '/static/sample/data/schedules/data.json';
|
// url = '/static/sample/data/schedules/data.json';
|
||||||
break;
|
// break;
|
||||||
case 'projects':
|
// case 'projects':
|
||||||
url = '/static/sample/data/schedules/projects/data.json';
|
// url = '/static/sample/data/schedules/projects/data.json';
|
||||||
break;
|
// break;
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
url += "schedules/";
|
||||||
|
|
||||||
SearchInit({
|
SearchInit({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
set: 'schedules',
|
set: 'schedules',
|
||||||
list: SchedulesList,
|
list: SchedulesList,
|
||||||
url: url
|
url: url
|
||||||
});
|
});
|
||||||
|
|
||||||
PaginateInit({
|
PaginateInit({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
list: SchedulesList,
|
list: SchedulesList,
|
||||||
url: url
|
url: url
|
||||||
});
|
});
|
||||||
|
|
||||||
Rest.setUrl(url);
|
$scope.search(SchedulesList.iterator);
|
||||||
Rest.get()
|
|
||||||
.success(function(data) {
|
|
||||||
var i, modifier;
|
|
||||||
PageRangeSetup({
|
|
||||||
scope: $scope,
|
|
||||||
count: data.count,
|
|
||||||
next: data.next,
|
|
||||||
previous: data.previous,
|
|
||||||
iterator: SchedulesList.iterator
|
|
||||||
});
|
|
||||||
$scope[SchedulesList.iterator + 'Loading'] = false;
|
|
||||||
for (i = 1; i <= 3; i++) {
|
|
||||||
modifier = (i === 1) ? '' : i;
|
|
||||||
$scope[SchedulesList.iterator + 'HoldInput' + modifier] = false;
|
|
||||||
}
|
|
||||||
$scope.schedules = data.results;
|
|
||||||
window.scrollTo(0, 0);
|
|
||||||
Wait('stop');
|
|
||||||
$scope.$emit('PostRefresh');
|
|
||||||
$scope.schedules = data.results;
|
|
||||||
})
|
|
||||||
.error(function(data, status) {
|
|
||||||
ProcessErrors($scope, data, status, null, { hdr: 'Error!',
|
|
||||||
msg: 'Call to ' + url + ' failed. GET returned: ' + status });
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.editSchedule = function(id) {
|
$scope.editSchedule = function(id) {
|
||||||
@@ -107,22 +86,7 @@ LoadDialogPartial) {
|
|||||||
|
|
||||||
$scope.addSchedule = function() {
|
$scope.addSchedule = function() {
|
||||||
var schedule = { };
|
var schedule = { };
|
||||||
switch(base) {
|
schedule.enabled = true;
|
||||||
case 'job_templates':
|
|
||||||
schedule.job_template = $routeParams.id;
|
|
||||||
schedule.job_type = 'playbook_run';
|
|
||||||
schedule.job_class = "ansible:playbook";
|
|
||||||
break;
|
|
||||||
case 'inventories':
|
|
||||||
schedule.inventory = $routeParams.id;
|
|
||||||
schedule.job_type = 'inventory_sync';
|
|
||||||
schedule.job_class = "inventory:sync";
|
|
||||||
break;
|
|
||||||
case 'projects':
|
|
||||||
schedule.project = $routeParams.id;
|
|
||||||
schedule.job_type = 'project_sync';
|
|
||||||
schedule.job_class = "project:sync";
|
|
||||||
}
|
|
||||||
AddSchedule({ scope: $scope, schedule: schedule, url: url });
|
AddSchedule({ scope: $scope, schedule: schedule, url: url });
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -163,7 +127,7 @@ LoadDialogPartial) {
|
|||||||
$scope.removeLoadParent = $scope.$on('LoadParent', function() {
|
$scope.removeLoadParent = $scope.$on('LoadParent', function() {
|
||||||
// Load the parent object
|
// Load the parent object
|
||||||
id = $routeParams.id;
|
id = $routeParams.id;
|
||||||
url = GetBasePath(base) + id;
|
url = GetBasePath(base) + id + '/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success(function(data) {
|
.success(function(data) {
|
||||||
|
|||||||
@@ -111,8 +111,8 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
|||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('EditSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest',
|
.factory('EditSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest', 'ToAPI', 'ProcessErrors',
|
||||||
function(SchedulerInit, ShowSchedulerModal, Wait, Rest) {
|
function(SchedulerInit, ShowSchedulerModal, Wait, Rest, ToAPI, ProcessErrors) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
schedule = params.schedule,
|
schedule = params.schedule,
|
||||||
@@ -128,7 +128,7 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
|||||||
scope.showRRuleDetail = false;
|
scope.showRRuleDetail = false;
|
||||||
|
|
||||||
if (!/DTSTART/.test(schedule.rrule)) {
|
if (!/DTSTART/.test(schedule.rrule)) {
|
||||||
schedule.rrule += ";DTSTART=" + schedule.dtstart;
|
schedule.rrule += ";DTSTART=" + schedule.dtstart.replace(/\.\d+Z$/,'Z');
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
@@ -141,22 +141,24 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
|||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
scope.saveSchedule = function() {
|
scope.saveSchedule = function() {
|
||||||
var newSchedule;
|
var newSchedule, rrule;
|
||||||
$('#scheduler-tabs a:first').tab('show');
|
$('#scheduler-tabs a:first').tab('show');
|
||||||
if (scheduler.isValid()) {
|
if (scheduler.isValid()) {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
newSchedule = scheduler.getValue();
|
newSchedule = scheduler.getValue();
|
||||||
|
rrule = scheduler.getRRule();
|
||||||
schedule.name = newSchedule.name;
|
schedule.name = newSchedule.name;
|
||||||
schedule.rrule = newSchedule.rrule;
|
schedule.rrule = ToAPI(rrule.toString());
|
||||||
|
schedule.description = (/error/.test(rrule.toText())) ? '' : rrule.toText();
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post(schedule)
|
Rest.post(schedule)
|
||||||
.success(function(){
|
.success(function(){
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$('#scheduler-modal-dialog').dialog('close');
|
$('#scheduler-modal-dialog').dialog('close');
|
||||||
})
|
})
|
||||||
.error(function(){
|
.error(function(data, status){
|
||||||
Wait('stop');
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||||
$('#scheduler-modal-dialog').dialog('close');
|
msg: 'POST to ' + url + ' returned: ' + status });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -171,8 +173,8 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
|||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('AddSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest',
|
.factory('AddSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest', 'ToAPI', 'ProcessErrors',
|
||||||
function(SchedulerInit, ShowSchedulerModal, Wait, Rest) {
|
function(SchedulerInit, ShowSchedulerModal, Wait, Rest, ToAPI, ProcessErrors) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
url = params.url,
|
url = params.url,
|
||||||
@@ -193,22 +195,24 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
|||||||
}, 300);
|
}, 300);
|
||||||
|
|
||||||
scope.saveSchedule = function() {
|
scope.saveSchedule = function() {
|
||||||
var newSchedule;
|
var newSchedule, rrule;
|
||||||
$('#scheduler-tabs a:first').tab('show');
|
$('#scheduler-tabs a:first').tab('show');
|
||||||
if (scheduler.isValid()) {
|
if (scheduler.isValid()) {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
newSchedule = scheduler.getValue();
|
newSchedule = scheduler.getValue();
|
||||||
|
rrule = scheduler.getRRule();
|
||||||
schedule.name = newSchedule.name;
|
schedule.name = newSchedule.name;
|
||||||
schedule.rrule = newSchedule.rrule;
|
schedule.rrule = ToAPI(rrule.toString());
|
||||||
|
schedule.description = (/error/.test(rrule.toText())) ? '' : rrule.toText();
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post(schedule)
|
Rest.post(schedule)
|
||||||
.success(function(){
|
.success(function(){
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$('#scheduler-modal-dialog').dialog('close');
|
$('#scheduler-modal-dialog').dialog('close');
|
||||||
})
|
})
|
||||||
.error(function(){
|
.error(function(data, status){
|
||||||
Wait('stop');
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||||
$('#scheduler-modal-dialog').dialog('close');
|
msg: 'POST to ' + url + ' returned: ' + status });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -242,7 +246,7 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
|||||||
scope.$emit(callback);
|
scope.$emit(callback);
|
||||||
})
|
})
|
||||||
.error(function(data, status) {
|
.error(function(data, status) {
|
||||||
ProcessErrors(scope, null, status, null, { hdr: 'Error!',
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||||
msg: 'Call to ' + url + ' failed. GET returned: ' + status });
|
msg: 'Call to ' + url + ' failed. GET returned: ' + status });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -348,6 +352,16 @@ angular.module('SchedulesHelper', ['Utilities', 'SchedulesHelper'])
|
|||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
}])
|
||||||
|
|
||||||
|
.factory('ToAPI', [ function() {
|
||||||
|
return function(rrule) {
|
||||||
|
var response;
|
||||||
|
response = rrule.replace(/(^.*(?=DTSTART))(DTSTART=.*?;)(.*$)/, function(str, p1, p2, p3) {
|
||||||
|
return p2.replace(/\;/,'').replace(/=/,':') + ' ' + 'RRULE:' + p1 + p3;
|
||||||
|
});
|
||||||
|
return response;
|
||||||
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,19 +26,23 @@ angular.module('SchedulesListDefinition', [])
|
|||||||
ngClick: "editSchedule(schedule.id)",
|
ngClick: "editSchedule(schedule.id)",
|
||||||
columnClass: "col-md-5 col-sm-3 col-xs-3"
|
columnClass: "col-md-5 col-sm-3 col-xs-3"
|
||||||
},
|
},
|
||||||
dtstart: {
|
next_run: {
|
||||||
label: 'Start',
|
label: 'Next Run',
|
||||||
|
filter: "date:'MM/dd/yy HH:mm:ss'",
|
||||||
searchable: false,
|
searchable: false,
|
||||||
columnClass: "col-md-2 col-sm-3 col-xs-3"
|
columnClass: "col-md-2 col-sm-3 col-xs-3"
|
||||||
},
|
},
|
||||||
next_run: {
|
dtstart: {
|
||||||
label: 'Next Run',
|
label: 'Start',
|
||||||
|
filter: "date:'MM/dd/yy HH:mm:ss'",
|
||||||
searchable: false,
|
searchable: false,
|
||||||
columnClass: "col-md-2 col-sm-3 col-xs-3"
|
columnClass: "col-md-2 col-sm-3 hidden-xs"
|
||||||
},
|
},
|
||||||
dtend: {
|
dtend: {
|
||||||
label: 'End',
|
label: 'End',
|
||||||
searchable: false
|
filter: "date:'MM/dd/yy HH:mm:ss'",
|
||||||
|
searchable: false,
|
||||||
|
columnClass: "col-md-2 col-sm-3 hidden-xs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user