mirror of
https://github.com/ansible/awx.git
synced 2026-05-13 12:27:37 -02:30
Add support for TZID in schedule rrules
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
export default
|
export default
|
||||||
function RRuleToAPI() {
|
function RRuleToAPI() {
|
||||||
return function(rrule) {
|
return function(rrule, scope) {
|
||||||
var response;
|
let localTime = scope.schedulerLocalTime;
|
||||||
response = rrule.replace(/(^.*(?=DTSTART))(DTSTART=.*?;)(.*$)/, function(str, p1, p2, p3) {
|
let timeZone = scope.schedulerTimeZone.name;
|
||||||
return p2.replace(/\;/,'').replace(/=/,':') + ' ' + 'RRULE:' + p1 + p3;
|
|
||||||
|
let response = rrule.replace(/(^.*(?=DTSTART))(DTSTART.*?)(=.*?;)(.*$)/, (str, p1, p2, p3, p4) => {
|
||||||
|
return p2 + ';TZID=' + timeZone + ':' + localTime + ' ' + 'RRULE:' + p4;
|
||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export default
|
|||||||
newSchedule = scheduler.getValue();
|
newSchedule = scheduler.getValue();
|
||||||
rrule = scheduler.getRRule();
|
rrule = scheduler.getRRule();
|
||||||
schedule.name = newSchedule.name;
|
schedule.name = newSchedule.name;
|
||||||
schedule.rrule = RRuleToAPI(rrule.toString());
|
schedule.rrule = RRuleToAPI(rrule.toString(), scope);
|
||||||
schedule.description = (/error/.test(rrule.toText())) ? '' : rrule.toText();
|
schedule.description = (/error/.test(rrule.toText())) ? '' : rrule.toText();
|
||||||
|
|
||||||
if (scope.isFactCleanup) {
|
if (scope.isFactCleanup) {
|
||||||
|
|||||||
@@ -4,14 +4,14 @@
|
|||||||
* All Rights Reserved
|
* All Rights Reserved
|
||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
export default ['$filter', '$state', '$stateParams', 'Wait',
|
export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
|
||||||
'$scope', '$rootScope', 'CreateSelect2', 'ParseTypeChange', 'GetBasePath',
|
'$scope', '$rootScope', 'CreateSelect2', 'ParseTypeChange', 'GetBasePath',
|
||||||
'Rest', 'ParentObject', 'JobTemplateModel', '$q', 'Empty', 'SchedulePost',
|
'Rest', 'ParentObject', 'JobTemplateModel', '$q', 'Empty', 'SchedulePost',
|
||||||
'ProcessErrors', 'SchedulerInit', '$location', 'PromptService',
|
'ProcessErrors', 'SchedulerInit', '$location', 'PromptService', 'RRuleToAPI',
|
||||||
function($filter, $state, $stateParams, Wait,
|
function($filter, $state, $stateParams, $http, Wait,
|
||||||
$scope, $rootScope, CreateSelect2, ParseTypeChange, GetBasePath,
|
$scope, $rootScope, CreateSelect2, ParseTypeChange, GetBasePath,
|
||||||
Rest, ParentObject, JobTemplate, $q, Empty, SchedulePost,
|
Rest, ParentObject, JobTemplate, $q, Empty, SchedulePost,
|
||||||
ProcessErrors, SchedulerInit, $location, PromptService) {
|
ProcessErrors, SchedulerInit, $location, PromptService, RRuleToAPI) {
|
||||||
|
|
||||||
var base = $scope.base || $location.path().replace(/^\//, '').split('/')[0],
|
var base = $scope.base || $location.path().replace(/^\//, '').split('/')[0],
|
||||||
scheduler,
|
scheduler,
|
||||||
@@ -283,6 +283,16 @@ export default ['$filter', '$state', '$stateParams', 'Wait',
|
|||||||
Wait('start');
|
Wait('start');
|
||||||
$('#form-container').empty();
|
$('#form-container').empty();
|
||||||
scheduler = SchedulerInit({ scope: $scope, requireFutureStartTime: false });
|
scheduler = SchedulerInit({ scope: $scope, requireFutureStartTime: false });
|
||||||
|
let timeZonesAPI = () => {
|
||||||
|
return $http.get(`/api/v2/schedules/zoneinfo/`);
|
||||||
|
};
|
||||||
|
// set API timezones to scheduler object
|
||||||
|
timeZonesAPI().then(({data}) => {
|
||||||
|
scheduler.scope.timeZones = data;
|
||||||
|
scheduler.scope.schedulerTimeZone = _.find(data, (zone) => {
|
||||||
|
return zone.name === scheduler.scope.current_timezone.name;
|
||||||
|
});
|
||||||
|
});
|
||||||
if($scope.schedulerUTCTime) {
|
if($scope.schedulerUTCTime) {
|
||||||
// The UTC time is already set
|
// The UTC time is already set
|
||||||
processSchedulerEndDt();
|
processSchedulerEndDt();
|
||||||
@@ -306,7 +316,22 @@ export default ['$filter', '$state', '$stateParams', 'Wait',
|
|||||||
$scope.$on("formUpdated", function() {
|
$scope.$on("formUpdated", function() {
|
||||||
$rootScope.$broadcast("loadSchedulerDetailPane");
|
$rootScope.$broadcast("loadSchedulerDetailPane");
|
||||||
});
|
});
|
||||||
|
$scope.$on("setPreviewPane", (event) => {
|
||||||
|
let rrule = event.currentScope.rrule.toString();
|
||||||
|
let req = RRuleToAPI(rrule, $scope);
|
||||||
|
|
||||||
|
$http.post('/api/v2/schedules/preview/', {'rrule': req})
|
||||||
|
.then(({data}) => {
|
||||||
|
|
||||||
|
$scope.preview_list = data;
|
||||||
|
for (let tz in data) {
|
||||||
|
$scope.preview_list.isEmpty = data[tz].length === 0;
|
||||||
|
$scope.preview_list[tz] = data[tz].map(function(date) {
|
||||||
|
return date.replace(/Z/, '');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
$scope.$watchGroup(["schedulerName",
|
$scope.$watchGroup(["schedulerName",
|
||||||
"schedulerStartDt",
|
"schedulerStartDt",
|
||||||
"schedulerStartHour",
|
"schedulerStartHour",
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
export default ['$filter', '$state', '$stateParams', 'Wait', '$scope',
|
export default ['$filter', '$state', '$stateParams', 'Wait', '$scope',
|
||||||
'$rootScope', 'CreateSelect2', 'ParseTypeChange', 'ParentObject', 'ProcessErrors', 'Rest',
|
'$rootScope', '$http', 'CreateSelect2', 'ParseTypeChange', 'ParentObject', 'ProcessErrors', 'Rest',
|
||||||
'GetBasePath', 'SchedulerInit', 'SchedulePost', 'JobTemplateModel', '$q', 'Empty', 'PromptService',
|
'GetBasePath', 'SchedulerInit', 'SchedulePost', 'JobTemplateModel', '$q', 'Empty', 'PromptService', 'RRuleToAPI',
|
||||||
function($filter, $state, $stateParams, Wait, $scope,
|
function($filter, $state, $stateParams, Wait, $scope,
|
||||||
$rootScope, CreateSelect2, ParseTypeChange, ParentObject, ProcessErrors, Rest,
|
$rootScope, $http, CreateSelect2, ParseTypeChange, ParentObject, ProcessErrors, Rest,
|
||||||
GetBasePath, SchedulerInit, SchedulePost, JobTemplate, $q, Empty, PromptService) {
|
GetBasePath, SchedulerInit, SchedulePost, JobTemplate, $q, Empty, PromptService, RRuleToAPI) {
|
||||||
|
|
||||||
let schedule, scheduler;
|
let schedule, scheduler;
|
||||||
|
|
||||||
@@ -85,6 +85,22 @@ function($filter, $state, $stateParams, Wait, $scope,
|
|||||||
callSelect2();
|
callSelect2();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$scope.$on("setPreviewPane", (event) => {
|
||||||
|
let rrule = event.currentScope.rrule.toString();
|
||||||
|
let req = RRuleToAPI(rrule, $scope);
|
||||||
|
|
||||||
|
$http.post('/api/v2/schedules/preview/', {'rrule': req})
|
||||||
|
.then(({data}) => {
|
||||||
|
$scope.preview_list = data;
|
||||||
|
for (let tz in data) {
|
||||||
|
$scope.preview_list.isEmpty = data[tz].length === 0;
|
||||||
|
$scope.preview_list[tz] = data[tz].map(function(date) {
|
||||||
|
return date.replace(/Z/, '');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
|
|
||||||
// Get the existing record
|
// Get the existing record
|
||||||
@@ -111,6 +127,13 @@ function($filter, $state, $stateParams, Wait, $scope,
|
|||||||
|
|
||||||
$('#form-container').empty();
|
$('#form-container').empty();
|
||||||
scheduler = SchedulerInit({ scope: $scope, requireFutureStartTime: false });
|
scheduler = SchedulerInit({ scope: $scope, requireFutureStartTime: false });
|
||||||
|
|
||||||
|
$http.get('/api/v2/schedules/zoneinfo/').then(({data}) => {
|
||||||
|
scheduler.scope.timeZones = data;
|
||||||
|
scheduler.scope.schedulerTimeZone = _.find(data, (zone) => {
|
||||||
|
return zone.name === scheduler.scope.current_timezone.name;
|
||||||
|
});
|
||||||
|
});
|
||||||
scheduler.inject('form-container', false);
|
scheduler.inject('form-container', false);
|
||||||
scheduler.injectDetail('occurrences', false);
|
scheduler.injectDetail('occurrences', false);
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,12 @@
|
|||||||
name="schedulerName"
|
name="schedulerName"
|
||||||
id="schedulerName"
|
id="schedulerName"
|
||||||
ng-model="schedulerName" required
|
ng-model="schedulerName" required
|
||||||
|
ng-model-options="{
|
||||||
|
'updateOn': 'default blur',
|
||||||
|
'debounce': {
|
||||||
|
'default': 300,
|
||||||
|
'blur': 0
|
||||||
|
}}"
|
||||||
ng-disabled="!(schedule_obj.summary_fields.user_capabilities.edit || canAdd)"
|
ng-disabled="!(schedule_obj.summary_fields.user_capabilities.edit || canAdd)"
|
||||||
placeholder="Schedule name">
|
placeholder="Schedule name">
|
||||||
<div class="error"
|
<div class="error"
|
||||||
@@ -578,7 +584,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="SchedulerFormDetail-container"
|
<div class="SchedulerFormDetail-container"
|
||||||
ng-show="schedulerIsValid">
|
ng-show="schedulerIsValid && !preview_list.isEmpty">
|
||||||
<label class="SchedulerFormDetail-label">
|
<label class="SchedulerFormDetail-label">
|
||||||
Schedule Description
|
Schedule Description
|
||||||
</label>
|
</label>
|
||||||
@@ -623,15 +629,15 @@
|
|||||||
<ul class="occurrence-list mono-space
|
<ul class="occurrence-list mono-space
|
||||||
SchedulerFormDetail-occurrenceList"
|
SchedulerFormDetail-occurrenceList"
|
||||||
ng-show="dateChoice == 'utc'">
|
ng-show="dateChoice == 'utc'">
|
||||||
<li ng-repeat="occurrence in occurrence_list">
|
<li ng-repeat="occurrence in preview_list.utc">
|
||||||
{{ occurrence.utc }}
|
{{ occurrence | date:'MM-dd-yyyy HH:mm:ss'}} UTC
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="occurrence-list mono-space
|
<ul class="occurrence-list mono-space
|
||||||
SchedulerFormDetail-occurrenceList"
|
SchedulerFormDetail-occurrenceList"
|
||||||
ng-show="dateChoice == 'local'">
|
ng-show="dateChoice == 'local'">
|
||||||
<li ng-repeat="occurrence in occurrence_list">
|
<li ng-repeat="occurrence in preview_list.local">
|
||||||
{{ occurrence.local }}
|
{{ occurrence | date:'MM-dd-yyyy HH:mm:ss'}}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user