From f5116e6c99296eb918b1845a2256a675dc11d54d Mon Sep 17 00:00:00 2001 From: shazha Date: Fri, 22 Mar 2019 22:26:06 +0800 Subject: [PATCH 1/2] fix: Created Column now shows the correct time --- .../index_resources/index_resources.controller.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/pages/index_resources/index_resources.controller.js b/src/pages/index_resources/index_resources.controller.js index e2b24d2..9b3bfc5 100644 --- a/src/pages/index_resources/index_resources.controller.js +++ b/src/pages/index_resources/index_resources.controller.js @@ -5,9 +5,9 @@ .module('app') .controller('IndexResources', IndexResources); - IndexResources.$inject = ["resourceType", "resourceName", "Kong", "Alert", "parentType", "parent"]; + IndexResources.$inject = ["resourceType", "resourceName", "Kong", "env", "Alert", "parentType", "parent"]; - function IndexResources(resourceType, resourceName, Kong, Alert, parentType, parent) { + function IndexResources(resourceType, resourceName, Kong, env, Alert, parentType, parent) { var vm = this; vm.resources = null; @@ -156,8 +156,13 @@ nextPage = response.offset ? fetchEndpoint + '&offset=' + encodeURIComponent(response.offset) : null; nextPageLoading = false; + var isTimeInSeconds = isKong1xVersion(env.kong_version); + // appending related resources, if any. vm.resources.forEach(function(resource) { + if (resource.created_at && isTimeInSeconds) { + resource.created_at *= 1000; + } if (!resource.api && resource.api_id) { Kong.get('/apis/' + resource.api_id).then(function(api) { resource.api = api; @@ -226,5 +231,9 @@ }); }); }; + + function isKong1xVersion(versionStr) { + return versionStr >= "1.0.0" || versionStr.substring(0, 4) === "0.15" + } } })(); From 975390b593b83d2842fcffda6016e15084e6f4b0 Mon Sep 17 00:00:00 2001 From: shazha Date: Fri, 22 Mar 2019 22:46:29 +0800 Subject: [PATCH 2/2] timestamp in v0.14 is second-level numbers as well --- src/pages/index_resources/index_resources.controller.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/pages/index_resources/index_resources.controller.js b/src/pages/index_resources/index_resources.controller.js index 9b3bfc5..622066a 100644 --- a/src/pages/index_resources/index_resources.controller.js +++ b/src/pages/index_resources/index_resources.controller.js @@ -156,11 +156,11 @@ nextPage = response.offset ? fetchEndpoint + '&offset=' + encodeURIComponent(response.offset) : null; nextPageLoading = false; - var isTimeInSeconds = isKong1xVersion(env.kong_version); + var isTimestampInSeconds = env.kong_version >= "0.14"; // appending related resources, if any. vm.resources.forEach(function(resource) { - if (resource.created_at && isTimeInSeconds) { + if (isTimestampInSeconds && resource.created_at) { resource.created_at *= 1000; } if (!resource.api && resource.api_id) { @@ -231,9 +231,5 @@ }); }); }; - - function isKong1xVersion(versionStr) { - return versionStr >= "1.0.0" || versionStr.substring(0, 4) === "0.15" - } } })();