atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [2/2] incubator-atlas git commit: ATLAS-1760: UI update to render property value per attribute type in entity definition
Date Mon, 01 May 2017 07:44:58 GMT
ATLAS-1760: UI update to render property value per attribute type in entity definition

Signed-off-by: Madhan Neethiraj <madhan@apache.org>
(cherry picked from commit f6ea040aced9fe2f76785dc2e6cb171f33b10aec)


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/2fd12efc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/2fd12efc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/2fd12efc

Branch: refs/heads/0.8-incubating
Commit: 2fd12efc4fc723859b4b109128d0e65588455cc5
Parents: 5f67d2b
Author: kevalbhatt <kbhatt@apache.org>
Authored: Fri Apr 28 21:55:44 2017 +0530
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Mon May 1 00:44:52 2017 -0700

----------------------------------------------------------------------
 .../public/js/utils/CommonViewFunction.js       | 160 ++++++++-----------
 .../js/views/audit/AuditTableLayoutView.js      |   6 +-
 .../views/audit/CreateAuditTableLayoutView.js   |   4 +-
 .../views/detail_page/DetailPageLayoutView.js   |  14 +-
 .../views/entity/EntityDetailTableLayoutView.js |   4 +-
 5 files changed, 87 insertions(+), 101 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2fd12efc/dashboardv2/public/js/utils/CommonViewFunction.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/utils/CommonViewFunction.js b/dashboardv2/public/js/utils/CommonViewFunction.js
index ce12466..e49d2b7 100644
--- a/dashboardv2/public/js/utils/CommonViewFunction.js
+++ b/dashboardv2/public/js/utils/CommonViewFunction.js
@@ -88,13 +88,10 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
             }
         });
     }
-    CommonViewFunction.propertyTable = function(valueObject, scope, searchTable) {
+    CommonViewFunction.propertyTable = function(scope, valueObject, entityDef) {
         var table = "",
             fetchInputOutputValue = function(id) {
                 var that = this;
-                if (searchTable) {
-                    ++scope.fetchList
-                }
                 scope.entityModel.getEntity(id, {
                     success: function(serverData) {
                         var value = "",
@@ -118,113 +115,92 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages',
'utils/Enum
                             scope.$('td div[data-id="' + id + '"]').append(deleteButton);
                         }
                     },
-                    complete: function() {
-                        if (searchTable) {
-                            --scope.fetchList;
-                            scope.checkTableFetch();
-                        }
-                    }
+                    complete: function() {}
                 });
             }
         _.sortBy(_.keys(valueObject)).map(function(key) {
             key = _.escape(key)
             var keyValue = valueObject[key],
                 valueOfArray = [];
-            if (_.isObject(keyValue)) {
-                if (!_.isArray(keyValue) && _.isObject(keyValue)) {
-                    keyValue = [keyValue];
-                }
-                var subLink = "";
-                for (var i = 0; i < keyValue.length; i++) {
-                    var inputOutputField = keyValue[i],
-                        id = inputOutputField.guid || (_.isObject(inputOutputField.id) ?
inputOutputField.id.id : inputOutputField.id),
-                        tempLink = "",
-                        status = inputOutputField.status || (_.isObject(inputOutputField.id)
? inputOutputField.id.state : inputOutputField.state),
-                        readOnly = Enums.entityStateReadOnly[status];
-                    if (!inputOutputField.attributes && inputOutputField.values)
{
-                        inputOutputField['attributes'] = inputOutputField.values;
+            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)) {
+                        keyValue = [keyValue];
                     }
-                    if (_.isString(inputOutputField) || _.isBoolean(inputOutputField) ||
_.isNumber(inputOutputField)) {
-                        var tempVarfor$check = inputOutputField.toString();
-                        if (tempVarfor$check.indexOf("$") == -1) {
-                            valueOfArray.push('<span>' + _.escape(inputOutputField)
+ '</span>');
+                    var subLink = "";
+                    for (var i = 0; i < keyValue.length; i++) {
+                        var inputOutputField = keyValue[i],
+                            id = inputOutputField.guid || (_.isObject(inputOutputField.id)
? inputOutputField.id.id : inputOutputField.id),
+                            tempLink = "",
+                            status = inputOutputField.status || (_.isObject(inputOutputField.id)
? inputOutputField.id.state : inputOutputField.state),
+                            readOnly = Enums.entityStateReadOnly[status];
+                        if (!inputOutputField.attributes && inputOutputField.values)
{
+                            inputOutputField['attributes'] = inputOutputField.values;
                         }
-                    } else if (_.isObject(inputOutputField) && !id) {
-                        var attributesList = inputOutputField;
-                        if (scope.typeHeaders && inputOutputField.typeName) {
-                            var typeNameCategory = scope.typeHeaders.fullCollection.findWhere({
name: inputOutputField.typeName });
-                            if (attributesList.attributes && typeNameCategory &&
typeNameCategory.get('category') === 'STRUCT') {
-                                attributesList = attributesList.attributes;
-                            }
-                        }
-                        _.each(attributesList, function(objValue, objKey) {
-                            var value = objValue,
-                                tempVarfor$check = objKey.toString();
+                        if (_.isString(inputOutputField) || _.isBoolean(inputOutputField)
|| _.isNumber(inputOutputField)) {
+                            var tempVarfor$check = inputOutputField.toString();
                             if (tempVarfor$check.indexOf("$") == -1) {
-                                if (_.isObject(value)) {
-                                    value = JSON.stringify(value);
+                                valueOfArray.push('<span>' + _.escape(inputOutputField)
+ '</span>');
+                            }
+                        } else if (_.isObject(inputOutputField) && !id) {
+                            var attributesList = inputOutputField;
+                            if (scope.typeHeaders && inputOutputField.typeName) {
+                                var typeNameCategory = scope.typeHeaders.fullCollection.findWhere({
name: inputOutputField.typeName });
+                                if (attributesList.attributes && typeNameCategory
&& typeNameCategory.get('category') === 'STRUCT') {
+                                    attributesList = attributesList.attributes;
                                 }
-                                valueOfArray.push('<span>' + _.escape(objKey) + ':'
+ _.escape(value) + '</span>');
                             }
-                        });
-                    }
-
-                    if (id && inputOutputField) {
-                        var name = Utils.getName(inputOutputField);
-                        if (name === "-" || name === id) {
-                            var fetch = true;
-                            var fetchId = (_.isObject(id) ? id.id : id);
-                            fetchInputOutputValue(fetchId);
-                            tempLink += '<div data-id="' + fetchId + '"></div>';
-                        } else {
-                            tempLink += '<a href="#!/detailPage/' + id + '">' + name
+ '</a>'
-                        }
-                    }
-                    if (readOnly) {
-                        if (!fetch) {
-                            tempLink += '<button title="Deleted" class="btn btn-atlasAction
btn-atlas deleteBtn"><i class="fa fa-trash"></i></button>';
-                            subLink += '<div class="block readOnlyLink">' + tempLink
+ '</div>';
-                        } else {
-                            fetch = false;
-                            subLink += tempLink;
+                            _.each(attributesList, function(objValue, objKey) {
+                                var value = objValue,
+                                    tempVarfor$check = objKey.toString();
+                                if (tempVarfor$check.indexOf("$") == -1) {
+                                    if (_.isObject(value)) {
+                                        value = JSON.stringify(value);
+                                    }
+                                    valueOfArray.push('<span>' + _.escape(objKey) +
':' + _.escape(value) + '</span>');
+                                }
+                            });
                         }
 
-                    } else {
-                        if (tempLink.search('href') != -1) {
-                            subLink += '<div>' + tempLink + '</div>'
-                        } else if (tempLink.length) {
-                            subLink += tempLink
-                        }
-                    }
-                }
-                if (valueOfArray.length) {
-                    subLink = valueOfArray.join(', ');
-                }
-                if (searchTable) {
-                    table = subLink;
-                } else {
-                    table += '<tr><td>' + _.escape(key) + '</td><td>'
+ subLink + '</td></tr>';
-                }
-            } else {
-                var tempVarfor$check = key.toString();
-                if (tempVarfor$check.indexOf("$") == -1) {
-                    if (key.indexOf("Time") !== -1 || key == "retention") {
-                        if (searchTable) {
-                            table = new Date(valueObject[key]);
-                        } else {
-                            table += '<tr><td>' + _.escape(key) + '</td><td>'
+ new Date(valueObject[key]) + '</td></tr>';
+                        if (id && inputOutputField) {
+                            var name = Utils.getName(inputOutputField);
+                            if (name === "-" || name === id) {
+                                var fetch = true;
+                                var fetchId = (_.isObject(id) ? id.id : id);
+                                fetchInputOutputValue(fetchId);
+                                tempLink += '<div data-id="' + fetchId + '"></div>';
+                            } else {
+                                tempLink += '<a href="#!/detailPage/' + id + '">' +
name + '</a>'
+                            }
                         }
-                    } else {
-                        if (searchTable) {
-                            if (_.isBoolean(valueObject[key])) {
-                                table = valueObject[key].toString();
+                        if (readOnly) {
+                            if (!fetch) {
+                                tempLink += '<button title="Deleted" class="btn btn-atlasAction
btn-atlas deleteBtn"><i class="fa fa-trash"></i></button>';
+                                subLink += '<div class="block readOnlyLink">' + tempLink
+ '</div>';
                             } else {
-                                table = valueObject[key];
+                                fetch = false;
+                                subLink += tempLink;
                             }
+
                         } else {
-                            table += '<tr><td>' + _.escape(key) + '</td><td>'
+ _.escape(valueObject[key]) + '</td></tr>';
+                            if (tempLink.search('href') != -1) {
+                                subLink += '<div>' + tempLink + '</div>'
+                            } else if (tempLink.length) {
+                                subLink += tempLink
+                            }
                         }
                     }
+                    if (valueOfArray.length) {
+                        subLink = valueOfArray.join(', ');
+                    }
+                    table += '<tr><td>' + _.escape(key) + '</td><td>'
+ subLink + '</td></tr>';
+
+                } else {
+                    table += '<tr><td>' + _.escape(key) + '</td><td>'
+ _.escape(valueObject[key]) + '</td></tr>';
                 }
             }
         });

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2fd12efc/dashboardv2/public/js/views/audit/AuditTableLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/audit/AuditTableLayoutView.js b/dashboardv2/public/js/views/audit/AuditTableLayoutView.js
index 82206cb..0f068cc 100644
--- a/dashboardv2/public/js/views/audit/AuditTableLayoutView.js
+++ b/dashboardv2/public/js/views/audit/AuditTableLayoutView.js
@@ -57,7 +57,7 @@ define(['require',
              * @constructs
              */
             initialize: function(options) {
-                _.extend(this, _.pick(options, 'guid', 'entity', 'entityName'));
+                _.extend(this, _.pick(options, 'guid', 'entity', 'entityName', 'entityDef'));
                 this.entityCollection = new VEntityList();
                 this.count = 26;
                 this.entityCollection.url = UrlLinks.entityCollectionaudit(this.guid);
@@ -227,9 +227,9 @@ define(['require',
                     'views/audit/CreateAuditTableLayoutView',
                 ], function(Modal, CreateAuditTableLayoutView) {
                     that.action = $(e.target).data("action");
-                    var eventModel = that.entityCollection.findWhere({ 'eventKey': $(e.currentTarget).data('modalid')
}).toJSON(),
+                    var eventModel = that.entityCollection.fullCollection.findWhere({ 'eventKey':
$(e.currentTarget).data('modalid') }).toJSON(),
                         collectionModel = new that.entityCollection.model(eventModel),
-                        view = new CreateAuditTableLayoutView({ guid: that.guid, entityModel:
collectionModel, action: that.action, entity: that.entity, entityName: that.entityName });
+                        view = new CreateAuditTableLayoutView({ guid: that.guid, entityModel:
collectionModel, action: that.action, entity: that.entity, entityName: that.entityName, entityDef:
that.entityDef });
                     var modal = new Modal({
                         title: that.action,
                         content: view,

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2fd12efc/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js b/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
index cbf6a9f..3f6be02 100644
--- a/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
+++ b/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
@@ -54,7 +54,7 @@ define(['require',
              * @constructs
              */
             initialize: function(options) {
-                _.extend(this, _.pick(options, 'guid', 'entityModel', 'action', 'entity',
'entityName'));
+                _.extend(this, _.pick(options, 'guid', 'entityModel', 'action', 'entity',
'entityName', 'entityDef'));
             },
             bindEvents: function() {},
             onRender: function() {
@@ -85,7 +85,7 @@ define(['require',
                     } else if (parseDetailsObject && parseDetailsObject.values) {
                         this.ui.auditHeaderValue.html('<th>Key</th><th>New
Value</th>');
                         //CommonViewFunction.findAndmergeRefEntity(attributeObject, that.referredEntities);
-                        table = CommonViewFunction.propertyTable(values, this);
+                        table = CommonViewFunction.propertyTable(this, values, this.entityDef);
                         if (table.length) {
                             this.ui.noData.hide();
                             this.ui.tableAudit.show();

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2fd12efc/dashboardv2/public/js/views/detail_page/DetailPageLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/detail_page/DetailPageLayoutView.js b/dashboardv2/public/js/views/detail_page/DetailPageLayoutView.js
index 613064f..dc3ae4c 100644
--- a/dashboardv2/public/js/views/detail_page/DetailPageLayoutView.js
+++ b/dashboardv2/public/js/views/detail_page/DetailPageLayoutView.js
@@ -173,8 +173,7 @@ define(['require',
                         entityDefCollection: this.entityDefCollection,
                         fetchCollection: this.fetchCollection.bind(that)
                     }
-                    this.renderEntityDetailTableLayoutView(obj);
-                    this.renderAuditTableLayoutView(obj);
+                    this.getEntityDef(obj);
                     this.renderTagTableLayoutView(obj);
                     this.renderTermTableLayoutView(_.extend({}, obj, { term: true }));
                     // To render Schema check attribute "schemaElementsAttribute"
@@ -240,6 +239,17 @@ define(['require',
             fetchCollection: function() {
                 this.collection.fetch({ reset: true });
             },
+            getEntityDef: function(obj) {
+                var data = this.entityDefCollection.fullCollection.findWhere({ name: obj.entity.typeName
}).toJSON();
+                var entityDef = Utils.getNestedSuperTypeObj({
+                    data: data,
+                    attrMerge: true,
+                    collection: this.entityDefCollection
+                });
+                obj['entityDef'] = entityDef;
+                this.renderEntityDetailTableLayoutView(obj);
+                this.renderAuditTableLayoutView(obj);
+            },
             onClickTagCross: function(e) {
                 var tagName = $(e.currentTarget).parent().text(),
                     tagOrTerm = $(e.target).data("type"),

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2fd12efc/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js b/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js
index 651c1ce..480305e 100644
--- a/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js
+++ b/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js
@@ -48,7 +48,7 @@ define(['require',
              * @constructs
              */
             initialize: function(options) {
-                _.extend(this, _.pick(options, 'entity', 'referredEntities', 'typeHeaders'));
+                _.extend(this, _.pick(options, 'entity', 'referredEntities', 'typeHeaders',
'entityDef'));
                 this.entityModel = new VEntity({});
             },
             bindEvents: function() {},
@@ -65,7 +65,7 @@ define(['require',
                     });
                     attributeObject.columns = valueSorted;
                 }
-                var table = CommonViewFunction.propertyTable(attributeObject, this);
+                var table = CommonViewFunction.propertyTable(this, attributeObject, this.entityDef);
                 that.ui.detailValue.append(table);
             }
         });


Mime
View raw message