Commit e483712b by Kalyani Committed by nixonrodrigues

ATLAS-1810 : UI : Audit details of any tag event (Added,Updated) has only tag name and event.

parent d0e48cfd
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
--> -->
<h4>Name: <span data-id="tagHeader"></span></h4>
<table class="table table-bordered table-striped" data-id="tableAudit"> <table class="table table-bordered table-striped" data-id="tableAudit">
<thead> <thead>
<tr data-id="auditHeaderValue"> <tr data-id="auditHeaderValue">
......
...@@ -88,7 +88,12 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -88,7 +88,12 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
} }
}); });
} }
CommonViewFunction.propertyTable = function(scope, valueObject, entityDef) { CommonViewFunction.propertyTable = function(options) {
var scope = options.scope,
valueObject = options.valueObject,
extractJSON = options.extractJSON,
entityDef = options.entityDef;
var table = "", var table = "",
fetchInputOutputValue = function(id) { fetchInputOutputValue = function(id) {
var that = this; var that = this;
...@@ -117,17 +122,9 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -117,17 +122,9 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
}, },
complete: function() {} complete: function() {}
}); });
} },
_.sortBy(_.keys(valueObject)).map(function(key) { extractObject = function(keyValue) {
key = _.escape(key) var valueOfArray = [];
var keyValue = valueObject[key],
valueOfArray = [];
var defEntity = _.find(entityDef, { name: key });
if (defEntity) {
var defEntityType = defEntity.typeName.toLocaleLowerCase();
if (defEntityType === 'date' || defEntityType === 'time') {
table += '<tr><td>' + _.escape(key) + '</td><td>' + new Date(keyValue) + '</td></tr>';
} else if (_.isObject(keyValue)) {
if (!_.isArray(keyValue) && _.isObject(keyValue)) { if (!_.isArray(keyValue) && _.isObject(keyValue)) {
keyValue = [keyValue]; keyValue = [keyValue];
} }
...@@ -161,11 +158,24 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -161,11 +158,24 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
if (_.isObject(value)) { if (_.isObject(value)) {
value = JSON.stringify(value); value = JSON.stringify(value);
} }
if (extractJSON) {
if (extractJSON && extractJSON.extractKey) {
if (_.isObject(extractJSON.extractKey)) {
_.each(extractJSON.extractKey, function(extractKey) {
if (objKey === extractKey) {
valueOfArray.push('<span>' + _.escape(objKey) + ':' + _.escape(value) + '</span>'); valueOfArray.push('<span>' + _.escape(objKey) + ':' + _.escape(value) + '</span>');
} }
}); });
} else if (_.isString(extractJSON.extractKey) && extractJSON.extractKey === objKey) {
valueOfArray.push(_.escape(value));
}
}
} else {
valueOfArray.push('<span>' + _.escape(objKey) + ':' + _.escape(value) + '</span>');
}
}
});
} }
if (id && inputOutputField) { if (id && inputOutputField) {
var name = Utils.getName(inputOutputField); var name = Utils.getName(inputOutputField);
if (name === "-" || name === id) { if (name === "-" || name === id) {
...@@ -197,12 +207,25 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -197,12 +207,25 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
if (valueOfArray.length) { if (valueOfArray.length) {
subLink = valueOfArray.join(', '); subLink = valueOfArray.join(', ');
} }
table += '<tr><td>' + _.escape(key) + '</td><td>' + subLink + '</td></tr>'; return subLink;
}
_.sortBy(_.keys(valueObject)).map(function(key) {
key = _.escape(key);
var keyValue = valueObject[key];
var defEntity = _.find(entityDef, { name: key });
if (defEntity && defEntity.typeName) {
var defEntityType = defEntity.typeName.toLocaleLowerCase();
if (defEntityType === 'date' || defEntityType === 'time') {
keyValue = new Date(keyValue);
} else if (_.isObject(keyValue)) {
keyValue = extractObject(keyValue);
}
} else { } else {
table += '<tr><td>' + _.escape(key) + '</td><td>' + _.escape(valueObject[key]) + '</td></tr>'; if (_.isObject(keyValue)) {
keyValue = extractObject(keyValue)
} }
} }
table += '<tr><td>' + _.escape(key) + '</td><td>' + (_.isObject(valueObject[key]) ? keyValue : _.escape(keyValue)) + '</td></tr>';
}); });
return table; return table;
} }
......
...@@ -401,7 +401,13 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'pnotify.button ...@@ -401,7 +401,13 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'pnotify.button
return returnObj; return returnObj;
} }
if (collectionJSON.attributes.id) { if (collectionJSON.attributes.id) {
if (_.isObject(collectionJSON.attributes.id)) {
if (collectionJSON.id.id) {
returnObj.name = _.escape(collectionJSON.attributes.id.id);
}
} else {
returnObj.name = _.escape(collectionJSON.attributes.id); returnObj.name = _.escape(collectionJSON.attributes.id);
}
returnObj.key = 'id'; returnObj.key = 'id';
return returnObj; return returnObj;
} }
...@@ -427,7 +433,13 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'pnotify.button ...@@ -427,7 +433,13 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'pnotify.button
return returnObj; return returnObj;
} }
if (collectionJSON.id) { if (collectionJSON.id) {
if (_.isObject(collectionJSON.id)) {
if (collectionJSON.id.id) {
returnObj.name = _.escape(collectionJSON.id.id);
}
} else {
returnObj.name = _.escape(collectionJSON.id); returnObj.name = _.escape(collectionJSON.id);
}
returnObj.key = 'id'; returnObj.key = 'id';
return returnObj; return returnObj;
} }
......
...@@ -41,7 +41,8 @@ define(['require', ...@@ -41,7 +41,8 @@ define(['require',
auditCreate: "[data-id='auditCreate']", auditCreate: "[data-id='auditCreate']",
noData: "[data-id='noData']", noData: "[data-id='noData']",
tableAudit: "[data-id='tableAudit']", tableAudit: "[data-id='tableAudit']",
auditHeaderValue: "[data-id='auditHeaderValue']" auditHeaderValue: "[data-id='auditHeaderValue']",
tagHeader: "[data-id='tagHeader']"
}, },
/** ui events hash */ /** ui events hash */
events: function() { events: function() {
...@@ -79,13 +80,11 @@ define(['require', ...@@ -79,13 +80,11 @@ define(['require',
} }
} }
var values = parseDetailsObject.values; var values = parseDetailsObject.values;
if (this.action && (Enums.auditAction.ENTITY_CREATE !== this.action && Enums.auditAction.ENTITY_UPDATE !== this.action) && name) { if (parseDetailsObject && parseDetailsObject.values) {
this.ui.auditHeaderValue.html('<th>' + this.action + '</th>'); var tagHeader = ((name ? name : this.entityName));
this.ui.auditValue.html("<tr><td>" + (name ? name : this.entityName) + "</td></tr>"); this.ui.tagHeader.append(tagHeader);
} else if (parseDetailsObject && parseDetailsObject.values) {
this.ui.auditHeaderValue.html('<th>Key</th><th>New Value</th>'); this.ui.auditHeaderValue.html('<th>Key</th><th>New Value</th>');
//CommonViewFunction.findAndmergeRefEntity(attributeObject, that.referredEntities); table = CommonViewFunction.propertyTable({ scope: this, valueObject: values, entityDef: this.entityDef, extractJSON: { extractKey: 'value' } });
table = CommonViewFunction.propertyTable(this, values, this.entityDef);
if (table.length) { if (table.length) {
this.ui.noData.hide(); this.ui.noData.hide();
this.ui.tableAudit.show(); this.ui.tableAudit.show();
...@@ -94,9 +93,7 @@ define(['require', ...@@ -94,9 +93,7 @@ define(['require',
this.ui.noData.show(); this.ui.noData.show();
this.ui.tableAudit.hide(); this.ui.tableAudit.hide();
} }
}
} else { } else {
if (Enums.auditAction.ENTITY_DELETE === this.action) {
this.ui.auditHeaderValue.html('<th>' + this.action + '</th>'); this.ui.auditHeaderValue.html('<th>' + this.action + '</th>');
this.ui.auditValue.html("<tr><td>" + (name ? name : this.entityName) + "</td></tr>"); this.ui.auditValue.html("<tr><td>" + (name ? name : this.entityName) + "</td></tr>");
} }
......
...@@ -65,7 +65,7 @@ define(['require', ...@@ -65,7 +65,7 @@ define(['require',
}); });
attributeObject.columns = valueSorted; attributeObject.columns = valueSorted;
} }
var table = CommonViewFunction.propertyTable(this, attributeObject, this.entityDef); var table = CommonViewFunction.propertyTable({ scope: this, valueObject: attributeObject, entityDef: this.entityDef });
that.ui.detailValue.append(table); that.ui.detailValue.append(table);
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment