ATLAS-3827: UI: Use moment date format instead of default date format.
Signed-off-by: Nikhil Bonte <nbonte@apache.org>
diff --git a/dashboardv2/public/css/scss/business-metadata.scss b/dashboardv2/public/css/scss/business-metadata.scss
index 1d4d737..fc11f18 100644
--- a/dashboardv2/public/css/scss/business-metadata.scss
+++ b/dashboardv2/public/css/scss/business-metadata.scss
@@ -120,6 +120,16 @@
margin-left: 20px;
width: calc(100% - 27px);
}
+
+ .import-export .admin-audit-details {
+ display: table;
+ border: 1px solid #ddd;
+ border-radius: 4px;
+
+ tr>td:nth-child(2) {
+ text-align: right;
+ }
+ }
}
.admin-details .expandable .admin-audit-details .attr-type-container {
@@ -174,7 +184,7 @@
.business-metadata-attr-tableOverlay {
position: absolute;
- width: 100%;
+ width: calc(100% - 40px);
height: 100%;
background: #808080;
z-index: 99;
diff --git a/dashboardv2/public/js/utils/CommonViewFunction.js b/dashboardv2/public/js/utils/CommonViewFunction.js
index 84728f7..2452ff2 100644
--- a/dashboardv2/public/js/utils/CommonViewFunction.js
+++ b/dashboardv2/public/js/utils/CommonViewFunction.js
@@ -101,7 +101,13 @@
return resultStr;
}
},
- getValue = function(val) {
+ getEmptyString = function(key) {
+ if (options.getEmptyString) {
+ return options.getEmptyString(key);
+ }
+ return "N/A";
+ },
+ getValue = function(val, key) {
if (!_.isUndefined(val) && !_.isNull(val)) {
if ((_.isNumber(val) || !_.isNaN(parseInt(val))) && formatIntVal) {
return numberFormat(val);
@@ -118,7 +124,7 @@
return getHighlightedString(_.escape(newVal));
}
} else {
- return "N/A";
+ return getEmptyString(key);
}
},
fetchInputOutputValue = function(id, defEntity) {
@@ -137,7 +143,7 @@
id = data.guid;
}
if (value.length > 0) {
- scope.$('td div[data-id="' + id + '"]').html('<a href="#!/detailPage/' + id + '">' + getValue(value) + '</a>');
+ scope.$('td div[data-id="' + id + '"]').html('<a href="#!/detailPage/' + id + '">' + getValue(value, key) + '</a>');
} else {
scope.$('td div[data-id="' + id + '"]').html('<a href="#!/detailPage/' + id + '">' + _.escape(id) + '</a>');
}
@@ -179,7 +185,7 @@
if (_.isString(inputOutputField) || _.isBoolean(inputOutputField) || _.isNumber(inputOutputField)) {
var tempVarfor$check = inputOutputField.toString();
if (tempVarfor$check.indexOf("$") == -1) {
- valueOfArray.push('<span class="json-string">' + getValue(inputOutputField) + '</span>');
+ valueOfArray.push('<span class="json-string">' + getValue(inputOutputField, key) + '</span>');
}
} else if (_.isObject(inputOutputField) && !id) {
var attributesList = inputOutputField;
@@ -247,7 +253,7 @@
if (valueOfArray.length) {
subLink = valueOfArray.join(', ');
}
- return subLink === "" ? "N/A" : subLink;
+ return subLink === "" ? getEmptyString(key) : subLink;
}
var valueObjectKeysList = _.keys(valueObject);
if (_.isUndefined(sortBy) || sortBy == true) {
@@ -263,7 +269,7 @@
if (defEntity && defEntity.typeName) {
var defEntityType = defEntity.typeName.toLocaleLowerCase();
if (defEntityType === 'date') {
- keyValue = keyValue > 0 ? new Date(keyValue) : null;
+ keyValue = keyValue > 0 ? Utils.formatDate({ date: keyValue }) : null;
} else if (_.isObject(keyValue)) {
keyValue = extractObject({ "keyValue": keyValue, "key": key, 'defEntity': defEntity });
}
@@ -276,13 +282,13 @@
if (_.isObject(valueObject[key])) {
val = keyValue
} else if (key === 'guid' || key === "__guid") {
- if (options.fromAdminAudit) {
- val = getValue(keyValue);
+ if (options.guidHyperLink === false) {
+ val = getValue(keyValue, key);
} else {
- val = '<a title="' + key + '" href="#!/detailPage/' + _.escape(keyValue) + '">' + getValue(keyValue) + '</a>';
+ val = '<a title="' + key + '" href="#!/detailPage/' + _.escape(keyValue) + '">' + getValue(keyValue, key) + '</a>';
}
} else {
- val = getValue(keyValue);
+ val = getValue(keyValue, key);
}
if (isTable) {
var value = val,
@@ -387,12 +393,16 @@
function objToString(filterObj) {
var generatedQuery = _.map(filterObj.rules, function(obj, key) {
- var obj = $.extend(true, {}, obj); // not to update the timezone abbr on original obj , copy of obj is used
+ var obj = $.extend(true, {}, obj); // not to update the timezone abbr on original obj , copy of obj is used
if (_.has(obj, 'condition')) {
return ' <span class="operator">' + obj.condition + '</span> ' + '(' + objToString(obj) + ')';
} else {
if (obj.type === "date") {
- obj.value = obj.value + " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")";
+ if (Enums.queryBuilderDateRangeUIValueToAPI[obj.value]) {
+ obj.value = Enums.queryBuilderDateRangeUIValueToAPI[obj.value];
+ } else {
+ obj.value = obj.value + " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")";
+ }
}
return '<span class="key">' + (Enums.systemAttributes[obj.id] ? Enums.systemAttributes[obj.id] : _.escape(obj.id)) + '</span> <span class="operator">' + _.escape(obj.operator) + '</span> <span class="value">' + (Enums[obj.id] ? Enums[obj.id][obj.value] : _.escape(obj.value)) + "</span>";
}
@@ -612,7 +622,7 @@
rule = {};
if (apiObj) {
rule = { attributeName: temp[0], operator: mapUiOperatorToAPI(temp[1]), attributeValue: _.trim(temp[2]) }
- rule.attributeValue = rule.type === 'date' && formatDate && rule.attributeValue.length ? moment(parseInt(rule.attributeValue)).format(Globals.dateTimeFormat) : rule.attributeValue;
+ rule.attributeValue = rule.type === 'date' && formatDate && rule.attributeValue.length ? Utils.formatDate({ date: parseInt(rule.attributeValue), zone: false }) : rule.attributeValue;
} else {
rule = { id: temp[0], operator: temp[1], value: _.trim(temp[2]) }
if (temp[3]) {
@@ -621,13 +631,13 @@
if (rule.operator === "TIME_RANGE") {
if (temp[2].indexOf(",") > -1) {
rule.value = temp[2].split(",").map(function(udKey) {
- return moment(parseInt(udKey.trim())).format(Globals.dateTimeFormat)
+ return Utils.formatDate({ date: parseInt(udKey.trim()), zone: false })
}).join(" - ")
} else {
rule.value = Enums.queryBuilderDateRangeAPIValueToUI[_.trim(rule.value)] || rule.value;
}
} else if (rule.type === 'date' && formatDate && rule.value.length) {
- rule.value = moment(parseInt(rule.value)).format(Globals.dateTimeFormat)
+ rule.value = Utils.formatDate({ date: parseInt(rule.value), zone: false })
}
}
return rule;
diff --git a/dashboardv2/public/js/utils/Globals.js b/dashboardv2/public/js/utils/Globals.js
index 3ab33a5..c92c8e1 100644
--- a/dashboardv2/public/js/utils/Globals.js
+++ b/dashboardv2/public/js/utils/Globals.js
@@ -42,5 +42,7 @@
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";
+
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 7c6fbfc..2aab9c1 100644
--- a/dashboardv2/public/js/utils/Utils.js
+++ b/dashboardv2/public/js/utils/Utils.js
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums', 'pnotify.buttons', 'pnotify.confirm'], function(require, Globals, pnotify, Messages, Enums) {
+define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums', 'moment', 'moment-timezone', 'pnotify.buttons', 'pnotify.confirm'], function(require, Globals, pnotify, Messages, Enums, moment) {
'use strict';
var Utils = {};
@@ -913,5 +913,37 @@
$(this).removeClass('button-loader').removeAttr("disabled");
$(this).siblings("button.cancel").prop("disabled", false);
}
+ Utils.formatDate = function(options) {
+ var dateValue = null,
+ dateFormat = Globals.dateTimeFormat,
+ isValidDate = false;
+ if (options) {
+ if (options.dateFormat) {
+ dateFormat = options.dateFormat;
+ }
+ if (options.date) {
+ if (options.date === "-") {
+ dateValue = options.date;
+ } else {
+ dateValue = moment(options.date)
+ if (dateValue._isValid) {
+ isValidDate = true;
+ dateValue = dateValue.format(dateFormat);
+ }
+ }
+ }
+ }
+ if (dateValue !== "-") {
+ if (isValidDate === false && options && options.defaultDate !== false) {
+ dateValue = moment().format(dateFormat);
+ }
+
+ if (!options || options && options.zone !== false) {
+ dateValue += " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")";
+ }
+ }
+
+ return dateValue;
+ }
return Utils;
});
\ No newline at end of file
diff --git a/dashboardv2/public/js/views/audit/AuditTableLayoutView.js b/dashboardv2/public/js/views/audit/AuditTableLayoutView.js
index be911d2..c8cf475 100644
--- a/dashboardv2/public/js/views/audit/AuditTableLayoutView.js
+++ b/dashboardv2/public/js/views/audit/AuditTableLayoutView.js
@@ -20,9 +20,10 @@
'backbone',
'hbs!tmpl/audit/AuditTableLayoutView_tmpl',
'collection/VEntityList',
+ 'utils/Utils',
'utils/Enums',
'utils/UrlLinks'
-], function(require, Backbone, AuditTableLayoutView_tmpl, VEntityList, Enums, UrlLinks) {
+], function(require, Backbone, AuditTableLayoutView_tmpl, VEntityList, Utils, Enums, UrlLinks) {
'use strict';
var AuditTableLayoutView = Backbone.Marionette.LayoutView.extend(
@@ -214,7 +215,7 @@
editable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
- return new Date(rawValue);
+ return Utils.formatDate({ date: rawValue });
}
})
},
diff --git a/dashboardv2/public/js/views/audit/ReplicationAuditTableLayoutView.js b/dashboardv2/public/js/views/audit/ReplicationAuditTableLayoutView.js
index f48470b..095d3b7 100644
--- a/dashboardv2/public/js/views/audit/ReplicationAuditTableLayoutView.js
+++ b/dashboardv2/public/js/views/audit/ReplicationAuditTableLayoutView.js
@@ -166,7 +166,7 @@
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
if (rawValue) {
- return new Date(rawValue);
+ return Utils.formatDate({ date: rawValue });
} else {
return '-';
}
@@ -181,7 +181,7 @@
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
if (rawValue) {
- return new Date(rawValue);
+ return Utils.formatDate({ date: rawValue });
} else {
return '-';
}
diff --git a/dashboardv2/public/js/views/business_metadata/BusinessMetadataTableLayoutView.js b/dashboardv2/public/js/views/business_metadata/BusinessMetadataTableLayoutView.js
index ce1c892..6527eeb 100644
--- a/dashboardv2/public/js/views/business_metadata/BusinessMetadataTableLayoutView.js
+++ b/dashboardv2/public/js/views/business_metadata/BusinessMetadataTableLayoutView.js
@@ -318,7 +318,7 @@
editable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
- return new Date(model.get('createTime'));
+ return Utils.formatDate({ date: model.get('createTime') });
}
})
},
@@ -340,7 +340,7 @@
editable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
- return new Date(model.get('updateTime'));
+ return Utils.formatDate({ date: model.get('updateTime') });
}
})
},
diff --git a/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js b/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js
index 8239ab8..1710fb0 100644
--- a/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js
+++ b/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js
@@ -439,11 +439,12 @@
var dateObj = {
"singleDatePicker": true,
"showDropdowns": true,
+ "startDate": new Date(),
locale: {
format: Globals.dateFormat
}
};
- if (that.guid) {
+ if (that.guid && this.value.length) {
dateObj["startDate"] = new Date(Number(this.value));
}
$(this).daterangepicker(dateObj);
@@ -606,7 +607,7 @@
if (dataValue) {
entityValue = moment(dataValue);
} else {
- entityValue = moment().format(Globals.dateFormat);
+ entityValue = Utils.formatDate({ zone: false, dateFormat: Globals.dateFormat });
}
}
}
diff --git a/dashboardv2/public/js/views/entity/EntityBusinessMetaDataItemView.js b/dashboardv2/public/js/views/entity/EntityBusinessMetaDataItemView.js
index 1d030d8..f641546 100644
--- a/dashboardv2/public/js/views/entity/EntityBusinessMetaDataItemView.js
+++ b/dashboardv2/public/js/views/entity/EntityBusinessMetaDataItemView.js
@@ -17,11 +17,12 @@
*/
define(['require',
'backbone',
+ 'utils/Utils',
'hbs!tmpl/entity/EntityBusinessMetaDataItemView_tmpl',
'moment',
'utils/Globals',
'daterangepicker'
-], function(require, Backbone, EntityBusinessMetaDataItemViewTmpl, moment, Globals) {
+], function(require, Backbone, Utils, EntityBusinessMetaDataItemViewTmpl, moment, Globals) {
'use strict';
return Backbone.Marionette.ItemView.extend({
@@ -167,12 +168,12 @@
var dateStr = [];
_.each(val, function(selectedDate) {
selectedDate = parseInt(selectedDate);
- dateStr.push(moment(selectedDate).format(Globals.dateFormat));
+ dateStr.push(Utils.formatDate({ date: selectedDate, zone: false, dateFormat: Globals.dateFormat }));
});
val = dateStr.join(',');
} else if (!isMultiValued && val) {
val = parseInt(val);
- val = moment(val).format(Globals.dateFormat);
+ val = Utils.formatDate({ date: val, zone: false, dateFormat: Globals.dateFormat });
}
}
if (typeName === "string" || typeName === "array<string>") {
@@ -182,7 +183,7 @@
} else if (typeName === "date" || typeName === "array<date>") {
returnEL = '<' + (isMultiValued ? "textarea" : "input") + ' type="text" data-key="' + key + '" data-businessMetadata="' + businessMetadata + '" data-typename="' + typeName + '"data-multi="' + isMultiValued + '" data-type="date" class="form-control" ' + (isMultiValued === false && !_.isUndefinedNull(val) ? 'value="' + val + '"' : "") + '>' + (isMultiValued === true && !_.isUndefinedNull(val) ? val : "") + (isMultiValued ? "</textarea>" : "");
setTimeout(function() {
- var dateObj = { singleDatePicker: true, showDropdowns: true, autoUpdateInput: isMultiValued ? false : true },
+ var dateObj = { singleDatePicker: true, showDropdowns: true, autoUpdateInput: isMultiValued ? false : true, locale: { format: Globals.dateFormat } },
dateEl = that.$el.find('[data-type="date"][data-key="' + key + '"]').daterangepicker(dateObj);
if (isMultiValued) {
dateEl.on("apply.daterangepicker", function(ev, picker) {
@@ -190,7 +191,7 @@
if (val !== "") {
val += ", ";
}
- picker.element.val(val += picker.startDate.format(Globals.dateFormat));
+ picker.element.val(val += Utils.formatDate({ date: picker.startDate, zone: false, dateFormat: Globals.dateFormat }));
that.$el.find(".custom-col-1[data-id='value']>[data-key]").trigger('change');
});
}
@@ -267,7 +268,7 @@
var typeName = value.typeName,
value = value.value;
if (typeName === "date") {
- return moment(value).format(Globals.dateFormat);
+ return Utils.formatDate({ date: value, zone: false, dateFormat: Globals.dateFormat });
} else {
return value;
}
diff --git a/dashboardv2/public/js/views/entity/EntityBusinessMetaDataView.js b/dashboardv2/public/js/views/entity/EntityBusinessMetaDataView.js
index 2b4ec8f..a61772f 100644
--- a/dashboardv2/public/js/views/entity/EntityBusinessMetaDataView.js
+++ b/dashboardv2/public/js/views/entity/EntityBusinessMetaDataView.js
@@ -236,13 +236,12 @@
newVal = val.value;
if (newVal.length > 0 && val.typeName.indexOf("date") > -1) {
newVal = _.map(newVal, function(dates) {
- return moment(dates).format(Globals.dateFormat);
+ return Utils.formatDate({ date: dates, zone: false, dateFormat: Globals.dateFormat });
});
}
if (val.typeName === "date") {
- newVal = moment(newVal).format(Globals.dateFormat);
+ newVal = Utils.formatDate({ date: newVal, zone: false, dateFormat: Globals.dateFormat });
}
-
}
attrLi += "<tr><td class='business-metadata-detail-attr-key'>" + _.escape(key) + " (" + _.escape(val.typeName) + ")</td><td>" + _.escape(newVal) + "</td></tr>";
}
diff --git a/dashboardv2/public/js/views/search/SearchResultLayoutView.js b/dashboardv2/public/js/views/search/SearchResultLayoutView.js
index a51bbdb..8fb100f 100644
--- a/dashboardv2/public/js/views/search/SearchResultLayoutView.js
+++ b/dashboardv2/public/js/views/search/SearchResultLayoutView.js
@@ -744,7 +744,7 @@
fromRaw: function(rawValue, model) {
var obj = model.toJSON();
if (obj && obj.attributes && obj.attributes.createTime) {
- return new Date(obj.attributes.createTime);
+ return Utils.formatDate({ date: obj.attributes.createTime });
} else {
return '-'
}
diff --git a/dashboardv2/public/js/views/site/Statistics.js b/dashboardv2/public/js/views/site/Statistics.js
index db8c92f..d469fe8 100644
--- a/dashboardv2/public/js/views/site/Statistics.js
+++ b/dashboardv2/public/js/views/site/Statistics.js
@@ -31,8 +31,9 @@
'utils/MigrationEnums',
'moment',
'utils/Utils',
+ 'utils/Globals',
'moment-timezone'
-], function(require, Backbone, StatTmpl, StatsNotiTable, TopicOffsetTable, EntityTable, Modal, VCommon, UrlLinks, VTagList, CommonViewFunction, Enums, MigrationEnums, moment, Utils) {
+], function(require, Backbone, StatTmpl, StatsNotiTable, TopicOffsetTable, EntityTable, Modal, VCommon, UrlLinks, VTagList, CommonViewFunction, Enums, MigrationEnums, moment, Utils, Globals) {
'use strict';
var StatisticsView = Backbone.Marionette.LayoutView.extend(
@@ -490,7 +491,7 @@
if (type == 'time') {
return Utils.millisecondsToTime(value);
} else if (type == 'day') {
- return moment.tz(value, moment.tz.guess()).format("MM/DD/YYYY h:mm A z");
+ return Utils.formatDate({ date: value, dateFormat: Globals.meridiemFormat })
} else if (type == 'number') {
return _.numberFormatWithComa(value);
} else if (type == 'millisecond') {
diff --git a/dashboardv2/public/js/views/tag/AddTagModalView.js b/dashboardv2/public/js/views/tag/AddTagModalView.js
index 2e3df3f..3da33e5 100644
--- a/dashboardv2/public/js/views/tag/AddTagModalView.js
+++ b/dashboardv2/public/js/views/tag/AddTagModalView.js
@@ -372,13 +372,16 @@
"singleDatePicker": true,
"showDropdowns": true,
"timePicker": true,
+ startDate: new Date(),
locale: {
format: Globals.dateTimeFormat
}
};
if (that.tagModel) {
- var formatDate = Number(this.value);
- dateObj["startDate"] = new Date(formatDate);
+ if (this.value.length) {
+ var formatDate = Number(this.value);
+ dateObj["startDate"] = new Date(formatDate);
+ }
}
$(this).daterangepicker(dateObj);
}
diff --git a/dashboardv2/public/js/views/tag/AddTimezoneItemView.js b/dashboardv2/public/js/views/tag/AddTimezoneItemView.js
index e16e520..f6899aa 100644
--- a/dashboardv2/public/js/views/tag/AddTimezoneItemView.js
+++ b/dashboardv2/public/js/views/tag/AddTimezoneItemView.js
@@ -19,10 +19,11 @@
'backbone',
'hbs!tmpl/tag/AddTimezoneView_tmpl',
'moment',
+ 'utils/Utils',
'utils/Globals',
'moment-timezone',
'daterangepicker'
-], function(require, Backbone, AddTimezoneViewTmpl, moment, Globals) {
+], function(require, Backbone, AddTimezoneViewTmpl, moment, Utils, Globals) {
'use strict';
return Backbone.Marionette.ItemView.extend(
@@ -116,7 +117,7 @@
this.model.set('endTime', that.ui.endTime.val());
}
this.ui.startTime.daterangepicker(startDateObj).on('apply.daterangepicker', function(ev, picker) {
- that.ui.startTime.val(picker.startDate.format(Globals.dateTimeFormat));
+ that.ui.startTime.val(Utils.formatDate({ date: picker.startDate, zone: false }));
_.extend(endDateObj, { "minDate": that.ui.startTime.val() })
that.endDateInitialize(endDateObj);
that.model.set('startTime', that.ui.startTime.val());
@@ -152,7 +153,7 @@
endDateInitialize: function(option) {
var that = this;
this.ui.endTime.daterangepicker(option).on('apply.daterangepicker', function(ev, picker) {
- that.ui.endTime.val(picker.startDate.format(Globals.dateTimeFormat));
+ that.ui.endTime.val(Utils.formatDate({ date: picker.startDate, zone: false }));
that.model.set('endTime', that.ui.endTime.val());
that.buttonActive({ isButtonActive: true });
}).on('cancel.daterangepicker', function(ev, picker) {
diff --git a/dashboardv2/public/js/views/tag/TagDetailTableLayoutView.js b/dashboardv2/public/js/views/tag/TagDetailTableLayoutView.js
index 6771182..04a941b 100644
--- a/dashboardv2/public/js/views/tag/TagDetailTableLayoutView.js
+++ b/dashboardv2/public/js/views/tag/TagDetailTableLayoutView.js
@@ -239,7 +239,7 @@
val = JSON.stringify(val);
}
if (sortedObj.typeName === "date") {
- val = new Date(val)
+ val = Utils.formatDate({ date: val });
}
stringValue += "<tr><td class='html-cell string-cell renderable'>" + _.escape(key) + "</td><td class='html-cell string-cell renderable' data-type='" + sortedObj.typeName + "'>" + _.escape(val) + "</td>";
});
diff --git a/dashboardv3/public/css/scss/business-metadata.scss b/dashboardv3/public/css/scss/business-metadata.scss
index 444541b..b526977 100644
--- a/dashboardv3/public/css/scss/business-metadata.scss
+++ b/dashboardv3/public/css/scss/business-metadata.scss
@@ -120,6 +120,16 @@
margin-left: 20px;
width: calc(100% - 27px);
}
+
+ .import-export .admin-audit-details {
+ display: table;
+ border: 1px solid #ddd;
+ border-radius: 4px;
+
+ tr>td:nth-child(2) {
+ text-align: right;
+ }
+ }
}
.admin-details .expandable .admin-audit-details .attr-type-container {
@@ -174,7 +184,7 @@
.business-metadata-attr-tableOverlay {
position: absolute;
- width: 100%;
+ width: calc(100% - 40px);
height: 100%;
background: #808080;
z-index: 99;
diff --git a/dashboardv3/public/js/utils/CommonViewFunction.js b/dashboardv3/public/js/utils/CommonViewFunction.js
index 9d75a27..a821755 100644
--- a/dashboardv3/public/js/utils/CommonViewFunction.js
+++ b/dashboardv3/public/js/utils/CommonViewFunction.js
@@ -101,7 +101,13 @@
return resultStr;
}
},
- getValue = function(val) {
+ getEmptyString = function(key) {
+ if (options.getEmptyString) {
+ return options.getEmptyString(key);
+ }
+ return "N/A";
+ },
+ getValue = function(val, key) {
if (!_.isUndefined(val) && !_.isNull(val)) {
if ((_.isNumber(val) || !_.isNaN(parseInt(val))) && formatIntVal) {
return numberFormat(val);
@@ -118,7 +124,7 @@
return getHighlightedString(_.escape(newVal));
}
} else {
- return "N/A";
+ return getEmptyString(key);
}
},
fetchInputOutputValue = function(id, defEntity) {
@@ -137,7 +143,7 @@
id = data.guid;
}
if (value.length > 0) {
- scope.$('td div[data-id="' + id + '"]').html('<a href="#!/detailPage/' + id + '">' + getValue(value) + '</a>');
+ scope.$('td div[data-id="' + id + '"]').html('<a href="#!/detailPage/' + id + '">' + getValue(value, key) + '</a>');
} else {
scope.$('td div[data-id="' + id + '"]').html('<a href="#!/detailPage/' + id + '">' + _.escape(id) + '</a>');
}
@@ -179,7 +185,7 @@
if (_.isString(inputOutputField) || _.isBoolean(inputOutputField) || _.isNumber(inputOutputField)) {
var tempVarfor$check = inputOutputField.toString();
if (tempVarfor$check.indexOf("$") == -1) {
- valueOfArray.push('<span class="json-string">' + getValue(inputOutputField) + '</span>');
+ valueOfArray.push('<span class="json-string">' + getValue(inputOutputField, key) + '</span>');
}
} else if (_.isObject(inputOutputField) && !id) {
var attributesList = inputOutputField;
@@ -247,7 +253,7 @@
if (valueOfArray.length) {
subLink = valueOfArray.join(', ');
}
- return subLink === "" ? "N/A" : subLink;
+ return subLink === "" ? getEmptyString(key) : subLink;
}
var valueObjectKeysList = _.keys(valueObject);
if (_.isUndefined(sortBy) || sortBy == true) {
@@ -263,7 +269,7 @@
if (defEntity && defEntity.typeName) {
var defEntityType = defEntity.typeName.toLocaleLowerCase();
if (defEntityType === 'date') {
- keyValue = keyValue > 0 ? new Date(keyValue) : null;
+ keyValue = keyValue > 0 ? Utils.formatDate({ date: keyValue }) : null;
} else if (_.isObject(keyValue)) {
keyValue = extractObject({ "keyValue": keyValue, "key": key, 'defEntity': defEntity });
}
@@ -276,13 +282,13 @@
if (_.isObject(valueObject[key])) {
val = keyValue
} else if (key === 'guid' || key === "__guid") {
- if (options.fromAdminAudit) {
- val = getValue(keyValue);
+ if (options.guidHyperLink === false) {
+ val = getValue(keyValue, key);
} else {
- val = '<a title="' + key + '" href="#!/detailPage/' + _.escape(keyValue) + '">' + getValue(keyValue) + '</a>';
+ val = '<a title="' + key + '" href="#!/detailPage/' + _.escape(keyValue) + '">' + getValue(keyValue, key) + '</a>';
}
} else {
- val = getValue(keyValue);
+ val = getValue(keyValue, key);
}
if (isTable) {
var value = val,
@@ -393,7 +399,11 @@
} else {
if (isCapsuleView) {
if (obj.type === "date") {
- obj.value = obj.value + " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")";
+ if (Enums.queryBuilderDateRangeUIValueToAPI[obj.value]) {
+ obj.value = Enums.queryBuilderDateRangeUIValueToAPI[obj.value];
+ } else {
+ obj.value = obj.value + " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")";
+ }
}
return '<div class="capsuleView"><span class="key">' + (Enums.systemAttributes[obj.id] ? Enums.systemAttributes[obj.id] : _.escape(obj.id)) + '</span><span class="operator">' + _.escape(obj.operator) + '</span><span class="value">' + (Enums[obj.id] ? Enums[obj.id][obj.value] : _.escape(obj.value)) + "</span><div class='fa fa-close clear-attr' data-type=" + type + " data-id=" + _.escape(obj.id) + "></div></div>";
}
@@ -632,7 +642,7 @@
rule = {};
if (apiObj) {
rule = { attributeName: temp[0], operator: mapUiOperatorToAPI(temp[1]), attributeValue: _.trim(temp[2]) }
- rule.attributeValue = rule.type === 'date' && formatDate && rule.attributeValue.length ? moment(parseInt(rule.attributeValue)).format(Globals.dateTimeFormat) : rule.attributeValue;
+ rule.attributeValue = rule.type === 'date' && formatDate && rule.attributeValue.length ? Utils.formatDate({ date: parseInt(rule.attributeValue), zone: false }) : rule.attributeValue;
} else {
rule = { id: temp[0], operator: temp[1], value: _.trim(temp[2]) }
if (temp[3]) {
@@ -641,13 +651,13 @@
if (rule.operator === "TIME_RANGE") {
if (temp[2].indexOf(",") > -1) {
rule.value = temp[2].split(",").map(function(udKey) {
- return moment(parseInt(udKey.trim())).format(Globals.dateTimeFormat)
+ return Utils.formatDate({ date: parseInt(udKey.trim()), zone: false })
}).join(" - ")
} else {
rule.value = Enums.queryBuilderDateRangeAPIValueToUI[_.trim(rule.value)] || rule.value;
}
} else if (rule.type === 'date' && formatDate && rule.value.length) {
- rule.value = moment(parseInt(rule.value)).format(Globals.dateTimeFormat)
+ rule.value = Utils.formatDate({ date: parseInt(rule.value), zone: false })
}
}
return rule;
diff --git a/dashboardv3/public/js/utils/Globals.js b/dashboardv3/public/js/utils/Globals.js
index 3ab33a5..f0efb99 100644
--- a/dashboardv3/public/js/utils/Globals.js
+++ b/dashboardv3/public/js/utils/Globals.js
@@ -42,5 +42,6 @@
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";
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 70fd6af..f7ccd0a 100644
--- a/dashboardv3/public/js/utils/Utils.js
+++ b/dashboardv3/public/js/utils/Utils.js
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums', 'pnotify.buttons', 'pnotify.confirm'], function(require, Globals, pnotify, Messages, Enums) {
+define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums', 'moment', 'moment-timezone', 'pnotify.buttons', 'pnotify.confirm'], function(require, Globals, pnotify, Messages, Enums, moment) {
'use strict';
var Utils = {};
@@ -918,5 +918,37 @@
$(this).removeClass('button-loader').removeAttr("disabled");
$(this).siblings("button.cancel").prop("disabled", false);
}
+ Utils.formatDate = function(options) {
+ var dateValue = null,
+ dateFormat = Globals.dateTimeFormat,
+ isValidDate = false;
+ if (options) {
+ if (options.dateFormat) {
+ dateFormat = options.dateFormat;
+ }
+ if (options.date) {
+ if (options.date === "-") {
+ dateValue = options.date;
+ } else {
+ dateValue = moment(options.date)
+ if (dateValue._isValid) {
+ isValidDate = true;
+ dateValue = dateValue.format(dateFormat);
+ }
+ }
+ }
+ }
+ if (dateValue !== "-") {
+ if (isValidDate === false && options && options.defaultDate !== false) {
+ dateValue = moment().format(dateFormat);
+ }
+
+ if (!options || options && options.zone !== false) {
+ dateValue += " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")";
+ }
+ }
+
+ return dateValue;
+ }
return Utils;
});
\ No newline at end of file
diff --git a/dashboardv3/public/js/views/audit/AuditTableLayoutView.js b/dashboardv3/public/js/views/audit/AuditTableLayoutView.js
index be911d2..6b79f9e 100644
--- a/dashboardv3/public/js/views/audit/AuditTableLayoutView.js
+++ b/dashboardv3/public/js/views/audit/AuditTableLayoutView.js
@@ -20,9 +20,10 @@
'backbone',
'hbs!tmpl/audit/AuditTableLayoutView_tmpl',
'collection/VEntityList',
+ 'utils/Utils',
'utils/Enums',
'utils/UrlLinks'
-], function(require, Backbone, AuditTableLayoutView_tmpl, VEntityList, Enums, UrlLinks) {
+], function(require, Backbone, AuditTableLayoutView_tmpl, VEntityList, Utils, Enums, UrlLinks) {
'use strict';
var AuditTableLayoutView = Backbone.Marionette.LayoutView.extend(
@@ -200,7 +201,6 @@
view.render();
$(el).append($('<div>').html(view.$el));
});
-
}
},
user: {
@@ -214,7 +214,7 @@
editable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
- return new Date(rawValue);
+ return Utils.formatDate({ date: rawValue });
}
})
},
diff --git a/dashboardv3/public/js/views/audit/ReplicationAuditTableLayoutView.js b/dashboardv3/public/js/views/audit/ReplicationAuditTableLayoutView.js
index f48470b..095d3b7 100644
--- a/dashboardv3/public/js/views/audit/ReplicationAuditTableLayoutView.js
+++ b/dashboardv3/public/js/views/audit/ReplicationAuditTableLayoutView.js
@@ -166,7 +166,7 @@
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
if (rawValue) {
- return new Date(rawValue);
+ return Utils.formatDate({ date: rawValue });
} else {
return '-';
}
@@ -181,7 +181,7 @@
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
if (rawValue) {
- return new Date(rawValue);
+ return Utils.formatDate({ date: rawValue });
} else {
return '-';
}
diff --git a/dashboardv3/public/js/views/business_metadata/BusinessMetadataTableLayoutView.js b/dashboardv3/public/js/views/business_metadata/BusinessMetadataTableLayoutView.js
index 0bd8d67..80932ce 100644
--- a/dashboardv3/public/js/views/business_metadata/BusinessMetadataTableLayoutView.js
+++ b/dashboardv3/public/js/views/business_metadata/BusinessMetadataTableLayoutView.js
@@ -318,7 +318,7 @@
editable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
- return new Date(model.get('createTime'));
+ return Utils.formatDate({ date: model.get('createTime') });
}
})
},
@@ -340,7 +340,7 @@
editable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
- return new Date(model.get('updateTime'));
+ return Utils.formatDate({ date: model.get('updateTime') });
}
})
},
diff --git a/dashboardv3/public/js/views/entity/CreateEntityLayoutView.js b/dashboardv3/public/js/views/entity/CreateEntityLayoutView.js
index 11d3cda..16d68a1 100644
--- a/dashboardv3/public/js/views/entity/CreateEntityLayoutView.js
+++ b/dashboardv3/public/js/views/entity/CreateEntityLayoutView.js
@@ -442,11 +442,12 @@
var dateObj = {
"singleDatePicker": true,
"showDropdowns": true,
+ "startDate": new Date(),
locale: {
format: Globals.dateFormat
}
};
- if (that.guid) {
+ if (that.guid && this.value.length) {
dateObj["startDate"] = new Date(Number(this.value));
}
$(this).daterangepicker(dateObj);
@@ -609,7 +610,8 @@
if (dataValue) {
entityValue = moment(dataValue);
} else {
- entityValue = moment().format(Globals.dateFormat);
+ entityValue = Utils.formatDate({ zone: false, dateFormat: Globals.dateFormat });
+
}
}
}
diff --git a/dashboardv3/public/js/views/entity/EntityBusinessMetaDataItemView.js b/dashboardv3/public/js/views/entity/EntityBusinessMetaDataItemView.js
index 1d030d8..1cec55f 100644
--- a/dashboardv3/public/js/views/entity/EntityBusinessMetaDataItemView.js
+++ b/dashboardv3/public/js/views/entity/EntityBusinessMetaDataItemView.js
@@ -17,11 +17,12 @@
*/
define(['require',
'backbone',
+ 'utils/Utils',
'hbs!tmpl/entity/EntityBusinessMetaDataItemView_tmpl',
'moment',
'utils/Globals',
'daterangepicker'
-], function(require, Backbone, EntityBusinessMetaDataItemViewTmpl, moment, Globals) {
+], function(require, Backbone, Utils, EntityBusinessMetaDataItemViewTmpl, moment, Globals) {
'use strict';
return Backbone.Marionette.ItemView.extend({
@@ -167,12 +168,13 @@
var dateStr = [];
_.each(val, function(selectedDate) {
selectedDate = parseInt(selectedDate);
- dateStr.push(moment(selectedDate).format(Globals.dateFormat));
+ dateStr.push(Utils.formatDate({ date: selectedDate, zone: false, dateFormat: Globals.dateFormat }));
});
val = dateStr.join(',');
} else if (!isMultiValued && val) {
val = parseInt(val);
- val = moment(val).format(Globals.dateFormat);
+ val = Utils.formatDate({ date: val, zone: false, dateFormat: Globals.dateFormat });
+
}
}
if (typeName === "string" || typeName === "array<string>") {
@@ -182,7 +184,7 @@
} else if (typeName === "date" || typeName === "array<date>") {
returnEL = '<' + (isMultiValued ? "textarea" : "input") + ' type="text" data-key="' + key + '" data-businessMetadata="' + businessMetadata + '" data-typename="' + typeName + '"data-multi="' + isMultiValued + '" data-type="date" class="form-control" ' + (isMultiValued === false && !_.isUndefinedNull(val) ? 'value="' + val + '"' : "") + '>' + (isMultiValued === true && !_.isUndefinedNull(val) ? val : "") + (isMultiValued ? "</textarea>" : "");
setTimeout(function() {
- var dateObj = { singleDatePicker: true, showDropdowns: true, autoUpdateInput: isMultiValued ? false : true },
+ var dateObj = { singleDatePicker: true, showDropdowns: true, autoUpdateInput: isMultiValued ? false : true, locale: { format: Globals.dateFormat } },
dateEl = that.$el.find('[data-type="date"][data-key="' + key + '"]').daterangepicker(dateObj);
if (isMultiValued) {
dateEl.on("apply.daterangepicker", function(ev, picker) {
@@ -190,7 +192,7 @@
if (val !== "") {
val += ", ";
}
- picker.element.val(val += picker.startDate.format(Globals.dateFormat));
+ picker.element.val(val += Utils.formatDate({ date: picker.startDate, zone: false, dateFormat: Globals.dateFormat }));
that.$el.find(".custom-col-1[data-id='value']>[data-key]").trigger('change');
});
}
@@ -267,7 +269,8 @@
var typeName = value.typeName,
value = value.value;
if (typeName === "date") {
- return moment(value).format(Globals.dateFormat);
+ return Utils.formatDate({ date: value, zone: false, dateFormat: Globals.dateFormat });
+
} else {
return value;
}
diff --git a/dashboardv3/public/js/views/entity/EntityBusinessMetaDataView.js b/dashboardv3/public/js/views/entity/EntityBusinessMetaDataView.js
index 2b4ec8f..cbc0320 100644
--- a/dashboardv3/public/js/views/entity/EntityBusinessMetaDataView.js
+++ b/dashboardv3/public/js/views/entity/EntityBusinessMetaDataView.js
@@ -236,11 +236,11 @@
newVal = val.value;
if (newVal.length > 0 && val.typeName.indexOf("date") > -1) {
newVal = _.map(newVal, function(dates) {
- return moment(dates).format(Globals.dateFormat);
+ return Utils.formatDate({ date: dates, zone: false, dateFormat: Globals.dateFormat });
});
}
if (val.typeName === "date") {
- newVal = moment(newVal).format(Globals.dateFormat);
+ newVal = Utils.formatDate({ date: newVal, zone: false, dateFormat: Globals.dateFormat });
}
}
diff --git a/dashboardv3/public/js/views/search/SearchResultLayoutView.js b/dashboardv3/public/js/views/search/SearchResultLayoutView.js
index 1a904d7..1a47727 100644
--- a/dashboardv3/public/js/views/search/SearchResultLayoutView.js
+++ b/dashboardv3/public/js/views/search/SearchResultLayoutView.js
@@ -756,7 +756,7 @@
fromRaw: function(rawValue, model) {
var obj = model.toJSON();
if (obj && obj.attributes && obj.attributes.createTime) {
- return new Date(obj.attributes.createTime);
+ return Utils.formatDate({ date: obj.attributes.createTime });
} else {
return '-'
}
diff --git a/dashboardv3/public/js/views/site/Statistics.js b/dashboardv3/public/js/views/site/Statistics.js
index 75e11b0..52c2a53 100644
--- a/dashboardv3/public/js/views/site/Statistics.js
+++ b/dashboardv3/public/js/views/site/Statistics.js
@@ -30,8 +30,9 @@
'utils/Enums',
'moment',
'utils/Utils',
+ 'utils/Globals',
'moment-timezone'
-], function(require, Backbone, StatTmpl, StatsNotiTable, TopicOffsetTable, EntityTable, Modal, VCommon, UrlLinks, VTagList, CommonViewFunction, Enums, moment, Utils) {
+], function(require, Backbone, StatTmpl, StatsNotiTable, TopicOffsetTable, EntityTable, Modal, VCommon, UrlLinks, VTagList, CommonViewFunction, Enums, moment, Utils, Globals) {
'use strict';
var StatisticsView = Backbone.Marionette.LayoutView.extend(
@@ -397,7 +398,7 @@
if (type == 'time') {
return Utils.millisecondsToTime(value);
} else if (type == 'day') {
- return moment.tz(value, moment.tz.guess()).format("MM/DD/YYYY h:mm A z");
+ return Utils.formatDate({ date: value, dateFormat: Globals.meridiemFormat })
} else if (type == 'number') {
return _.numberFormatWithComa(value);
} else if (type == 'millisecond') {
diff --git a/dashboardv3/public/js/views/tag/AddTagModalView.js b/dashboardv3/public/js/views/tag/AddTagModalView.js
index 2e3df3f..3da33e5 100644
--- a/dashboardv3/public/js/views/tag/AddTagModalView.js
+++ b/dashboardv3/public/js/views/tag/AddTagModalView.js
@@ -372,13 +372,16 @@
"singleDatePicker": true,
"showDropdowns": true,
"timePicker": true,
+ startDate: new Date(),
locale: {
format: Globals.dateTimeFormat
}
};
if (that.tagModel) {
- var formatDate = Number(this.value);
- dateObj["startDate"] = new Date(formatDate);
+ if (this.value.length) {
+ var formatDate = Number(this.value);
+ dateObj["startDate"] = new Date(formatDate);
+ }
}
$(this).daterangepicker(dateObj);
}
diff --git a/dashboardv3/public/js/views/tag/AddTimezoneItemView.js b/dashboardv3/public/js/views/tag/AddTimezoneItemView.js
index e16e520..f6899aa 100644
--- a/dashboardv3/public/js/views/tag/AddTimezoneItemView.js
+++ b/dashboardv3/public/js/views/tag/AddTimezoneItemView.js
@@ -19,10 +19,11 @@
'backbone',
'hbs!tmpl/tag/AddTimezoneView_tmpl',
'moment',
+ 'utils/Utils',
'utils/Globals',
'moment-timezone',
'daterangepicker'
-], function(require, Backbone, AddTimezoneViewTmpl, moment, Globals) {
+], function(require, Backbone, AddTimezoneViewTmpl, moment, Utils, Globals) {
'use strict';
return Backbone.Marionette.ItemView.extend(
@@ -116,7 +117,7 @@
this.model.set('endTime', that.ui.endTime.val());
}
this.ui.startTime.daterangepicker(startDateObj).on('apply.daterangepicker', function(ev, picker) {
- that.ui.startTime.val(picker.startDate.format(Globals.dateTimeFormat));
+ that.ui.startTime.val(Utils.formatDate({ date: picker.startDate, zone: false }));
_.extend(endDateObj, { "minDate": that.ui.startTime.val() })
that.endDateInitialize(endDateObj);
that.model.set('startTime', that.ui.startTime.val());
@@ -152,7 +153,7 @@
endDateInitialize: function(option) {
var that = this;
this.ui.endTime.daterangepicker(option).on('apply.daterangepicker', function(ev, picker) {
- that.ui.endTime.val(picker.startDate.format(Globals.dateTimeFormat));
+ that.ui.endTime.val(Utils.formatDate({ date: picker.startDate, zone: false }));
that.model.set('endTime', that.ui.endTime.val());
that.buttonActive({ isButtonActive: true });
}).on('cancel.daterangepicker', function(ev, picker) {
diff --git a/dashboardv3/public/js/views/tag/TagDetailTableLayoutView.js b/dashboardv3/public/js/views/tag/TagDetailTableLayoutView.js
index c396338..7a56206 100644
--- a/dashboardv3/public/js/views/tag/TagDetailTableLayoutView.js
+++ b/dashboardv3/public/js/views/tag/TagDetailTableLayoutView.js
@@ -239,7 +239,7 @@
val = JSON.stringify(val);
}
if (sortedObj.typeName === "date") {
- val = new Date(val)
+ val = Utils.formatDate({ date: val });
}
stringValue += "<tr><td class='html-cell string-cell renderable'>" + _.escape(key) + "</td><td class='html-cell string-cell renderable' data-type='" + sortedObj.typeName + "'>" + _.escape(val) + "</td>";
});