fix(ui): add local time to time-restricted-access-policy
fixing DateTime issues that where caused by previous library replacement of moment
adding local time along utc time view in table
changing some functions to anonymous functions to avoid unexpected behaviour
MODIFY
manager/ui/war/plugins/api-manager/html/policyForms/time-restricted-access.include
manager/ui/war/plugins/api-manager/html/policyForms/time-restricted-access.include
<table class="table table-striped table-bordered">
<thead>
<tr>
- <th width="50%" apiman-i18n-key="path">Path</th>
- <th width="50%" apiman-i18n-key="accessible-utc">Accessible (UTC)</th>
- <th width="1%"></th>
+ <th width="33%" apiman-i18n-key="path">Path</th>
+ <th width="33%" apiman-i18n-key="accessible-local-time">Accessible (Local Time <strong>{{offsetName}}</strong>)</th>
+ <th width="33%" apiman-i18n-key="accessible-utc">Accessible (<strong>UTC</strong>)</th>
+ <th width="1%">Remove</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in config.rules | orderBy: 'pathPattern'">
<td>{{ item.pathPattern }}</td>
+ <td> {{formatToLocalTime(item.timeStart)}}-{{formatToLocalTime(item.timeEnd)}}
+ from {{getDayForIndex(item.dayStart)}} to {{getDayForIndex(item.dayEnd)}}
+ </td>
<td> {{formatToTime(item.timeStart)}}-{{formatToTime(item.timeEnd)}}
from {{getDayForIndex(item.dayStart)}} to {{getDayForIndex(item.dayEnd)}}
</td>
</tr>
</tbody>
</table>
-
</div>

MODIFY
manager/ui/war/plugins/api-manager/ts/policies.ts
manager/ui/war/plugins/api-manager/ts/policies.ts
@@ -17,7 +17,7 @@ export var isRegexpValid = function(v) {
_module.controller('Apiman.DefaultPolicyConfigFormController',
['$scope', 'Logger', 'EntityStatusSvc',
- ($scope, Logger, EntityStatusSvc) => {
+ function ($scope, Logger, EntityStatusSvc) {
var validateRaw = function(config) {
var valid = true;
try {
@@ -41,7 +41,7 @@ _module.controller('Apiman.DefaultPolicyConfigFormController',
_module.controller('Apiman.JsonSchemaPolicyConfigFormController',
['$scope', 'Logger', 'PluginSvcs', 'EntityStatusSvc',
- ($scope, Logger, PluginSvcs, EntityStatusSvc) => {
+ function ($scope, Logger, PluginSvcs, EntityStatusSvc) {
$scope.isEntityDisabled = EntityStatusSvc.isEntityDisabled;
var initEditor = function(schema) {
@@ -132,7 +132,7 @@ _module.controller('Apiman.JsonSchemaPolicyConfigFormController',
_module.controller('Apiman.RateLimitingFormController',
['$scope', 'Logger', 'EntityStatusSvc',
- ($scope, Logger, EntityStatusSvc) => {
+ function ($scope, Logger, EntityStatusSvc) {
var validate = function(config) {
var valid = true;
@@ -170,7 +170,7 @@ _module.controller('Apiman.RateLimitingFormController',
_module.controller('Apiman.QuotaFormController',
['$scope', 'Logger', 'EntityStatusSvc',
- ($scope, Logger, EntityStatusSvc) => {
+ function ($scope, Logger, EntityStatusSvc) {
var validate = function(config) {
var valid = true;
if (config.limit) {
@@ -207,7 +207,7 @@ export var GB = 1024 * 1024 * 1024;
_module.controller('Apiman.TransferQuotaFormController',
['$scope', 'Logger', 'EntityStatusSvc',
- ($scope, Logger, EntityStatusSvc) => {
+ function ($scope, Logger, EntityStatusSvc) {
$scope.limitDenomination = 'B';
if ($scope.config && $scope.config.limit) {
@@ -291,7 +291,7 @@ _module.controller('Apiman.TransferQuotaFormController',
_module.controller('Apiman.IPListFormController',
['$scope', 'Logger', 'EntityStatusSvc',
- ($scope, Logger, EntityStatusSvc) => {
+ function ($scope, Logger, EntityStatusSvc) {
var validate = function(config) {
var valid = true;
$scope.setValid(valid);
@@ -343,7 +343,7 @@ _module.controller('Apiman.IPListFormController',
_module.controller('Apiman.IgnoredResourcesFormController',
['$scope', 'Logger', 'EntityStatusSvc',
- ($scope, Logger, EntityStatusSvc) => {
+ function ($scope, Logger, EntityStatusSvc) {
var validate = function(config) {
var valid = config.rules && config.rules.length > 0;
$scope.setValid(valid);
@@ -389,7 +389,7 @@ _module.controller('Apiman.IgnoredResourcesFormController',
_module.controller('Apiman.BasicAuthFormController',
['$scope', 'Logger', 'EntityStatusSvc',
- ($scope, Logger, EntityStatusSvc) => {
+ function ($scope, Logger, EntityStatusSvc) {
var validate = function(config) {
if (!config) {
return;
@@ -574,7 +574,7 @@ _module.controller('Apiman.BasicAuthFormController',
_module.controller('Apiman.AuthorizationFormController',
['$scope', 'Logger', 'EntityStatusSvc',
- ($scope, Logger, EntityStatusSvc) => {
+ function ($scope, Logger, EntityStatusSvc) {
var validate = function(config) {
var valid = config.rules && config.rules.length > 0;
@@ -637,7 +637,7 @@ _module.controller('Apiman.AuthorizationFormController',
_module.controller('Apiman.CachingFormController',
['$scope', 'Logger', 'EntityStatusSvc',
- ($scope, Logger, EntityStatusSvc) => {
+ function ($scope, Logger, EntityStatusSvc) {
var validate = function(config) {
var valid = false;
@@ -689,7 +689,7 @@ _module.controller('Apiman.CachingFormController',
_module.controller('Apiman.CachingResourcesFormController',
['$scope', 'EntityStatusSvc',
- ($scope, EntityStatusSvc) => {
+ function ($scope, EntityStatusSvc) {
let validate = function(config) {
let valid = false;
@@ -743,7 +743,7 @@ _module.controller('Apiman.CachingResourcesFormController',
_module.controller('Apiman.URLRewritingFormController',
['$scope', 'Logger', 'EntityStatusSvc',
- ($scope, Logger, EntityStatusSvc) => {
+ function ($scope, Logger, EntityStatusSvc) {
var validate = function(config) {
var valid = true;
@@ -776,10 +776,11 @@ _module.controller('Apiman.URLRewritingFormController',
}]);
-
+// used in time-restricted-access.include
_module.controller('Apiman.TimeRestrictedAccessFormController',
['$window','$scope', 'Logger', 'EntityStatusSvc',
- ($window, $scope, Logger, EntityStatusSvc) => {
+ function ($window, $scope, Logger, EntityStatusSvc) {
+ $scope.offsetName = DateTime.local().offsetNameShort;
var isoTimeFormat="HH:mm:ss";
var validate = function(config) {
var valid = config.rules && config.rules.length > 0;
@@ -796,8 +797,8 @@ _module.controller('Apiman.TimeRestrictedAccessFormController',
if (!$scope.config.rules) {
$scope.config.rules = [];
}
- const timeStart = DateTime.fromISO($scope.timeStart).toUTC().toFormat(isoTimeFormat);
- const timeEnd = DateTime.fromISO($scope.timeEnd).toUTC().toFormat(isoTimeFormat)
+ const timeStart = DateTime.fromJSDate($scope.timeStart).toUTC().toFormat(isoTimeFormat);
+ const timeEnd = DateTime.fromJSDate($scope.timeEnd).toUTC().toFormat(isoTimeFormat)
var rule = {
'timeStart' : timeStart,
'timeEnd' : timeEnd,
@@ -821,15 +822,18 @@ _module.controller('Apiman.TimeRestrictedAccessFormController',
}
};
$scope.resetModel = function() {
- $scope.timeStart = DateTime.fromObject({ hour: 8 }).toFormat("hh:mm");
- $scope.timeEnd = DateTime.fromObject({ hour: 16 }).toFormat("hh:mm");
+ $scope.timeStart = DateTime.fromObject({ hour: 8 }).toJSDate();
+ $scope.timeEnd = DateTime.fromObject({ hour: 16 }).toJSDate();
$scope.dayStart = $scope.weekdays[0];
$scope.dayEnd = $scope.weekdays[4];
$scope.selectedPath = undefined;
};
$scope.resetModel();
- $scope.formatToTime = function(time){
- return DateTime.fromISO(time).toLocal().toFormat("HH:mm");
+ $scope.formatToTime = function(utcTime){
+ return DateTime.fromISO(utcTime, {zone: 'utc'}).toFormat("HH:mm");
+ };
+ $scope.formatToLocalTime = function(utcTime){
+ return DateTime.fromISO(utcTime, {zone: 'utc'}).toLocal().toFormat("HH:mm");
};
$scope.getDayIndex = function(day){
return $scope.weekdays.indexOf(day)+1;

MODIFY
manager/ui/war/src/main/resources/io/apiman/manager/ui/server/i18n/template_messages.properties
manager/ui/war/src/main/resources/io/apiman/manager/ui/server/i18n/template_messages.properties
@@ -8,6 +8,7 @@ about.project-site=Project Site:
about.source-code=Source Code:
about.user-guide=User Guide:
about.version=Version:
+accessible-local-time=Accessible Local Time()
accessible-utc=Accessible (UTC)
actions=Actions
actions.browse-importable-apis=Browse available/importable APIs

fix(ui): add local time to time-restricted-access-policy

- fixing DateTime issues that where caused by previous library replacement of moment
- adding local time along utc time view in table
- changing some functions to anonymous functions to avoid unexpected behaviour