You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by kb...@apache.org on 2020/10/14 14:40:30 UTC

[atlas] branch branch-2.0 updated: ATLAS-3986: UI Allow user to update the date format from JAVA property file

This is an automated email from the ASF dual-hosted git repository.

kbhatt pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 3768c9d  ATLAS-3986: UI Allow user to update the date format from JAVA property file
3768c9d is described below

commit 3768c9dcd33eb045c834a8e6cebe4703ab0d933d
Author: kevalbhatt <kb...@apache.org>
AuthorDate: Wed Oct 14 20:00:28 2020 +0530

    ATLAS-3986: UI Allow user to update the date format from JAVA property file
    
    (cherry picked from commit 39892854ffb696df70ecbc0f3e965c5a8261f621)
---
 dashboardv2/public/js/main.js                      | 10 ++++++++
 dashboardv2/public/js/utils/Globals.js             |  8 +++---
 dashboardv2/public/js/utils/Utils.js               | 30 ++++++++++------------
 .../js/views/audit/CreateAuditTableLayoutView.js   |  7 +++++
 .../public/js/views/search/QueryBuilderView.js     |  4 +--
 dashboardv2/public/js/views/site/Statistics.js     |  2 +-
 dashboardv3/public/js/main.js                      | 10 ++++++++
 dashboardv3/public/js/utils/Globals.js             |  9 ++++---
 dashboardv3/public/js/utils/Utils.js               | 30 ++++++++++------------
 .../js/views/audit/CreateAuditTableLayoutView.js   |  7 +++++
 .../public/js/views/search/QueryBuilderView.js     |  4 +--
 dashboardv3/public/js/views/site/Statistics.js     |  2 +-
 12 files changed, 79 insertions(+), 44 deletions(-)

diff --git a/dashboardv2/public/js/main.js b/dashboardv2/public/js/main.js
index 7cee837..282c407 100644
--- a/dashboardv2/public/js/main.js
+++ b/dashboardv2/public/js/main.js
@@ -272,6 +272,16 @@ require(['App',
                 if (response['atlas.ui.default.version'] !== undefined) {
                     Globals.DEFAULT_UI = response['atlas.ui.default.version'];
                 }
+                if (response['atlas.ui.date.format'] !== undefined) {
+                    Globals.dateTimeFormat = response['atlas.ui.date.format'];
+                    var dateFormatSeperated = Globals.dateTimeFormat.split(' ');
+                    if (dateFormatSeperated[0]) {
+                        Globals.dateFormat = dateFormatSeperated[0]; //date
+                    }
+                }
+                if (response['atlas.ui.date.timezone'] !== undefined) {
+                    Globals.isDateTimeZone = response['atlas.ui.date.timezone'];
+                }
             }
             --that.asyncFetchCounter;
             startApp();
diff --git a/dashboardv2/public/js/utils/Globals.js b/dashboardv2/public/js/utils/Globals.js
index c92c8e1..0a4a050 100644
--- a/dashboardv2/public/js/utils/Globals.js
+++ b/dashboardv2/public/js/utils/Globals.js
@@ -40,9 +40,11 @@ define(["require"], function(require) {
     Globals.serviceTypeMap = {};
     Globals.entityImgPath = "/img/entity-icon/";
     Globals.DEFAULT_UI = "v2";
-    Globals.dateFormat = "YYYY/MM/DD";
-    Globals.dateTimeFormat = "YYYY/MM/DD HH:mm:ss";
-    Globals.meridiemFormat = "MM/DD/YYYY h:mm A z";
+
+    // Date Format
+    Globals.dateTimeFormat = "MM/DD/YYYY hh:mm:ss A";
+    Globals.dateFormat = "MM/DD/YYYY";
+    Globals.isDateTimeZone = true;
 
     return Globals;
 });
\ No newline at end of file
diff --git a/dashboardv2/public/js/utils/Utils.js b/dashboardv2/public/js/utils/Utils.js
index 2aab9c1..0fbe56a 100644
--- a/dashboardv2/public/js/utils/Utils.js
+++ b/dashboardv2/public/js/utils/Utils.js
@@ -917,19 +917,17 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
         var dateValue = null,
             dateFormat = Globals.dateTimeFormat,
             isValidDate = false;
-        if (options) {
-            if (options.dateFormat) {
-                dateFormat = options.dateFormat;
-            }
-            if (options.date) {
-                if (options.date === "-") {
+        if (options && options.date) {
+            dateValue = options.date;
+            if (dateValue !== "-") {
+                dateValue = parseInt(dateValue);
+                if (_.isNaN(dateValue)) {
                     dateValue = options.date;
-                } else {
-                    dateValue = moment(options.date)
-                    if (dateValue._isValid) {
-                        isValidDate = true;
-                        dateValue = dateValue.format(dateFormat);
-                    }
+                }
+                dateValue = moment(dateValue);
+                if (dateValue._isValid) {
+                    isValidDate = true;
+                    dateValue = dateValue.format(dateFormat);
                 }
             }
         }
@@ -937,12 +935,12 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
             if (isValidDate === false && options && options.defaultDate !== false) {
                 dateValue = moment().format(dateFormat);
             }
-
-            if (!options || options && options.zone !== false) {
-                dateValue += " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")";
+            if (Globals.isDateTimeZone) {
+                if (!options || options && options.zone !== false) {
+                    dateValue += " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")";
+                }
             }
         }
-
         return dateValue;
     }
     return Utils;
diff --git a/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js b/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
index ba6bfec..e7d5d8b 100644
--- a/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
+++ b/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
@@ -75,6 +75,13 @@ define(['require',
             createTableWithValues: function(tableDetails) {
                 var attrTable = CommonViewFunction.propertyTable({
                     scope: this,
+                    getValue: function(val, key) {
+                        if (key && key.toLowerCase().indexOf("time") > 0) {
+                            return Utils.formatDate({ date: val });
+                        } else {
+                            return val;
+                        }
+                    },
                     valueObject: tableDetails
                 });
                 return attrTable;
diff --git a/dashboardv2/public/js/views/search/QueryBuilderView.js b/dashboardv2/public/js/views/search/QueryBuilderView.js
index ba6cf0d..dd38cc7 100644
--- a/dashboardv2/public/js/views/search/QueryBuilderView.js
+++ b/dashboardv2/public/js/views/search/QueryBuilderView.js
@@ -359,8 +359,8 @@ define(['require',
                         }
                         obj.singleDatePicker = false;
                     } else {
-                        obj.startDate = moment(valueObj.value);
-                        obj.endDate = moment(valueObj.value);
+                        obj.startDate = moment(Date.parse(valueObj.value));
+                        obj.endDate = obj.startDate;
                         obj.singleDatePicker = true;
                     }
                 }
diff --git a/dashboardv2/public/js/views/site/Statistics.js b/dashboardv2/public/js/views/site/Statistics.js
index 8284129..32a6669 100644
--- a/dashboardv2/public/js/views/site/Statistics.js
+++ b/dashboardv2/public/js/views/site/Statistics.js
@@ -491,7 +491,7 @@ define(['require',
                 if (type == 'time') {
                     return Utils.millisecondsToTime(value);
                 } else if (type == 'day') {
-                    return Utils.formatDate({ date: value, dateFormat: Globals.meridiemFormat })
+                    return Utils.formatDate({ date: value })
                 } else if (type == 'number') {
                     return _.numberFormatWithComma(value);
                 } else if (type == 'millisecond') {
diff --git a/dashboardv3/public/js/main.js b/dashboardv3/public/js/main.js
index 3acfd87..a91cd97 100644
--- a/dashboardv3/public/js/main.js
+++ b/dashboardv3/public/js/main.js
@@ -301,6 +301,16 @@ require(['App',
                 if (response['atlas.ui.default.version'] !== undefined) {
                     Globals.DEFAULT_UI = response['atlas.ui.default.version'];
                 }
+                if (response['atlas.ui.date.format'] !== undefined) {
+                    Globals.dateTimeFormat = response['atlas.ui.date.format'];
+                    var dateFormatSeperated = Globals.dateTimeFormat.split(' ');
+                    if (dateFormatSeperated[0]) {
+                        Globals.dateFormat = dateFormatSeperated[0]; //date
+                    }
+                }
+                if (response['atlas.ui.date.timezone'] !== undefined) {
+                    Globals.isDateTimeZone = response['atlas.ui.date.timezone'];
+                }
             }
             --that.asyncFetchCounter;
             startApp();
diff --git a/dashboardv3/public/js/utils/Globals.js b/dashboardv3/public/js/utils/Globals.js
index f0efb99..0a4a050 100644
--- a/dashboardv3/public/js/utils/Globals.js
+++ b/dashboardv3/public/js/utils/Globals.js
@@ -40,8 +40,11 @@ define(["require"], function(require) {
     Globals.serviceTypeMap = {};
     Globals.entityImgPath = "/img/entity-icon/";
     Globals.DEFAULT_UI = "v2";
-    Globals.dateFormat = "YYYY/MM/DD";
-    Globals.dateTimeFormat = "YYYY/MM/DD HH:mm:ss";
-    Globals.meridiemFormat = "MM/DD/YYYY h:mm A z";
+
+    // Date Format
+    Globals.dateTimeFormat = "MM/DD/YYYY hh:mm:ss A";
+    Globals.dateFormat = "MM/DD/YYYY";
+    Globals.isDateTimeZone = true;
+
     return Globals;
 });
\ No newline at end of file
diff --git a/dashboardv3/public/js/utils/Utils.js b/dashboardv3/public/js/utils/Utils.js
index f7ccd0a..c8f7a0b 100644
--- a/dashboardv3/public/js/utils/Utils.js
+++ b/dashboardv3/public/js/utils/Utils.js
@@ -922,19 +922,17 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
         var dateValue = null,
             dateFormat = Globals.dateTimeFormat,
             isValidDate = false;
-        if (options) {
-            if (options.dateFormat) {
-                dateFormat = options.dateFormat;
-            }
-            if (options.date) {
-                if (options.date === "-") {
+        if (options && options.date) {
+            dateValue = options.date;
+            if (dateValue !== "-") {
+                dateValue = parseInt(dateValue);
+                if (_.isNaN(dateValue)) {
                     dateValue = options.date;
-                } else {
-                    dateValue = moment(options.date)
-                    if (dateValue._isValid) {
-                        isValidDate = true;
-                        dateValue = dateValue.format(dateFormat);
-                    }
+                }
+                dateValue = moment(dateValue);
+                if (dateValue._isValid) {
+                    isValidDate = true;
+                    dateValue = dateValue.format(dateFormat);
                 }
             }
         }
@@ -942,12 +940,12 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
             if (isValidDate === false && options && options.defaultDate !== false) {
                 dateValue = moment().format(dateFormat);
             }
-
-            if (!options || options && options.zone !== false) {
-                dateValue += " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")";
+            if (Globals.isDateTimeZone) {
+                if (!options || options && options.zone !== false) {
+                    dateValue += " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")";
+                }
             }
         }
-
         return dateValue;
     }
     return Utils;
diff --git a/dashboardv3/public/js/views/audit/CreateAuditTableLayoutView.js b/dashboardv3/public/js/views/audit/CreateAuditTableLayoutView.js
index ba6bfec..e7d5d8b 100644
--- a/dashboardv3/public/js/views/audit/CreateAuditTableLayoutView.js
+++ b/dashboardv3/public/js/views/audit/CreateAuditTableLayoutView.js
@@ -75,6 +75,13 @@ define(['require',
             createTableWithValues: function(tableDetails) {
                 var attrTable = CommonViewFunction.propertyTable({
                     scope: this,
+                    getValue: function(val, key) {
+                        if (key && key.toLowerCase().indexOf("time") > 0) {
+                            return Utils.formatDate({ date: val });
+                        } else {
+                            return val;
+                        }
+                    },
                     valueObject: tableDetails
                 });
                 return attrTable;
diff --git a/dashboardv3/public/js/views/search/QueryBuilderView.js b/dashboardv3/public/js/views/search/QueryBuilderView.js
index 06ecd01..9e14891 100644
--- a/dashboardv3/public/js/views/search/QueryBuilderView.js
+++ b/dashboardv3/public/js/views/search/QueryBuilderView.js
@@ -359,8 +359,8 @@ define(['require',
                         }
                         obj.singleDatePicker = false;
                     } else {
-                        obj.startDate = moment(valueObj.value);
-                        obj.endDate = moment(valueObj.value);
+                        obj.startDate = moment(Date.parse(valueObj.value));
+                        obj.endDate = obj.startDate;
                         obj.singleDatePicker = true;
                     }
                 }
diff --git a/dashboardv3/public/js/views/site/Statistics.js b/dashboardv3/public/js/views/site/Statistics.js
index cb2a655..9eb714d 100644
--- a/dashboardv3/public/js/views/site/Statistics.js
+++ b/dashboardv3/public/js/views/site/Statistics.js
@@ -398,7 +398,7 @@ define(['require',
                 if (type == 'time') {
                     return Utils.millisecondsToTime(value);
                 } else if (type == 'day') {
-                    return Utils.formatDate({ date: value, dateFormat: Globals.meridiemFormat })
+                    return Utils.formatDate({ date: value })
                 } else if (type == 'number') {
                     return _.numberFormatWithComma(value);
                 } else if (type == 'millisecond') {