You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2017/09/29 06:59:42 UTC

atlas git commit: ATLAS-2111 : UI: Select query is not able to render the search table in Advance search

Repository: atlas
Updated Branches:
  refs/heads/branch-0.8 9bef8225c -> 1aba32ba0


ATLAS-2111 : UI: Select query is not able to render the search table in Advance search

Signed-off-by: Madhan Neethiraj <ma...@apache.org>


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

Branch: refs/heads/branch-0.8
Commit: 1aba32ba0ff17ce31b0e14b5b0d544d3535b6651
Parents: 9bef822
Author: kevalbhatt <kb...@apache.org>
Authored: Thu Sep 28 11:32:01 2017 +0530
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Thu Sep 28 23:49:49 2017 -0700

----------------------------------------------------------------------
 dashboardv2/public/js/collection/VSearchList.js |  22 ++-
 .../js/views/search/SearchResultLayoutView.js   | 149 +++++++++++++------
 2 files changed, 124 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/1aba32ba/dashboardv2/public/js/collection/VSearchList.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/collection/VSearchList.js b/dashboardv2/public/js/collection/VSearchList.js
index 0a7b713..28c246f 100644
--- a/dashboardv2/public/js/collection/VSearchList.js
+++ b/dashboardv2/public/js/collection/VSearchList.js
@@ -31,14 +31,32 @@ define(['require',
             model: VSearch,
 
             initialize: function() {
-                this.modelName = 'VSearch';
+                this.modelName = 'VSearchList';
                 this.modelAttrName = '';
             },
             parseRecords: function(resp, options) {
                 this.queryType = resp.queryType;
                 this.queryText = resp.queryText;
                 this.referredEntities = resp.referredEntities;
-                return resp.entities ? resp.entities : [];
+                if (resp.attributes) {
+                    this.dynamicTable = true;
+                    var entities = [];
+                    _.each(resp.attributes.values, function(obj) {
+                        var temp = {};
+                        _.each(obj, function(val, index) {
+                            var key = resp.attributes.name[index];
+                            if (key == "__guid") {
+                                key = "guid"
+                            }
+                            temp[key] = val;
+                        });
+                        entities.push(temp);
+                    });
+                    return entities;
+                } else {
+                    this.dynamicTable = false;
+                    return resp.entities ? resp.entities : [];
+                }
             },
             getBasicRearchResult: function(options) {
                 var url = UrlLinks.searchApiUrl('basic');

http://git-wip-us.apache.org/repos/asf/atlas/blob/1aba32ba/dashboardv2/public/js/views/search/SearchResultLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/search/SearchResultLayoutView.js b/dashboardv2/public/js/views/search/SearchResultLayoutView.js
index fbcd352..e8151fd 100644
--- a/dashboardv2/public/js/views/search/SearchResultLayoutView.js
+++ b/dashboardv2/public/js/views/search/SearchResultLayoutView.js
@@ -525,7 +525,8 @@ define(['require',
                             return this;
                         }
                     });
-                    var columns = new columnCollection(that.getFixedDslColumn());
+                    that.bradCrumbList = [];
+                    var columns = new columnCollection((that.searchCollection.dynamicTable ? that.getDaynamicColumns(that.searchCollection.toJSON()) : that.getFixedDslColumn()));
                     columns.setPositions().sort();
                     that.REntityTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, {
                         columns: columns
@@ -679,7 +680,109 @@ define(['require',
                             }
                         })
                     };
+                    this.getTagTermCol({ 'col': col, 'columnToShow': columnToShow });
 
+                    if (this.value && this.value.searchType === "basic") {
+                        var def = this.entityDefCollection.fullCollection.find({ name: this.value.type });
+                        if (def) {
+                            var attrObj = Utils.getNestedSuperTypeObj({ data: def.toJSON(), collection: this.entityDefCollection, attrMerge: true });
+                            _.each(attrObj, function(obj, key) {
+                                var key = obj.name,
+                                    isRenderable = _.contains(columnToShow, key)
+                                if (key == "name" || key == "description" || key == "owner") {
+                                    if (columnToShow) {
+                                        col[key].renderable = isRenderable;
+                                    }
+                                    return;
+                                }
+                                col[obj.name] = {
+                                    label: obj.name.capitalize(),
+                                    cell: "Html",
+                                    editable: false,
+                                    sortable: false,
+                                    resizeable: true,
+                                    orderable: true,
+                                    renderable: isRenderable,
+                                    formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+                                        fromRaw: function(rawValue, model) {
+                                            var modelObj = model.toJSON();
+
+                                            if (modelObj && modelObj.attributes && !_.isUndefined(modelObj.attributes[key])) {
+                                                var tempObj = {
+                                                    'scope': that,
+                                                    'attributeDefs': [obj],
+                                                    'valueObject': {},
+                                                    'isTable': false
+                                                }
+
+                                                tempObj.valueObject[key] = modelObj.attributes[key]
+                                                Utils.findAndMergeRefEntity(tempObj.valueObject, that.searchCollection.referredEntities);
+                                                return CommonViewFunction.propertyTable(tempObj);
+                                            }
+                                        }
+                                    })
+                                };
+                            });
+                        }
+                    }
+                }
+                return this.searchCollection.constructor.getTableCols(col, this.searchCollection);
+            },
+            getDaynamicColumns: function(valueObj) {
+                var that = this,
+                    col = {};
+                if (valueObj && valueObj.length) {
+                    var firstObj = _.first(valueObj);
+                    _.each(_.keys(firstObj), function(key) {
+                        if (key !== 'guid') {
+                            col[key] = {
+                                label: key.capitalize(),
+                                cell: "Html",
+                                editable: false,
+                                sortable: false,
+                                resizeable: true,
+                                orderable: true,
+                                formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+                                    fromRaw: function(rawValue, model) {
+                                        var modelObj = model.toJSON();
+                                        if (key == "name") {
+                                            var nameHtml = "",
+                                                name = modelObj[key];
+                                            if (modelObj.guid) {
+                                                nameHtml = '<a title="' + name + '" href="#!/detailPage/' + modelObj.guid + '">' + name + '</a>';
+                                            } else {
+                                                nameHtml = '<span title="' + name + '">' + name + '</span>';
+                                            }
+                                            if (modelObj.status && Enums.entityStateReadOnly[modelObj.status]) {
+                                                nameHtml += '<button type="button" title="Deleted" class="btn btn-action btn-md deleteBtn"><i class="fa fa-trash"></i></button>';
+                                                return '<div class="readOnly readOnlyLink">' + nameHtml + '</div>';
+                                            }
+                                            return nameHtml;
+                                        } else if (modelObj && !_.isUndefined(modelObj[key])) {
+                                            var tempObj = {
+                                                'scope': that,
+                                                // 'attributeDefs':
+                                                'valueObject': {},
+                                                'isTable': false
+                                            }
+
+                                            tempObj.valueObject[key] = modelObj[key]
+                                            Utils.findAndMergeRefEntity(tempObj.valueObject, that.searchCollection.referredEntities);
+                                            return CommonViewFunction.propertyTable(tempObj);
+                                        }
+                                    }
+                                })
+                            };
+                        }
+                    });
+                }
+                return this.searchCollection.constructor.getTableCols(col, this.searchCollection);
+            },
+            getTagTermCol: function(options) {
+                var that = this,
+                    columnToShow = options.columnToShow,
+                    col = options.col;
+                if (col) {
                     col['tag'] = {
                         label: "Tags",
                         cell: "Html",
@@ -727,51 +830,7 @@ define(['require',
                             })
                         };
                     }
-                    if (this.value && this.value.searchType === "basic") {
-                        var def = this.entityDefCollection.fullCollection.find({ name: this.value.type });
-                        if (def) {
-                            var attrObj = Utils.getNestedSuperTypeObj({ data: def.toJSON(), collection: this.entityDefCollection, attrMerge: true });
-                            _.each(attrObj, function(obj, key) {
-                                var key = obj.name,
-                                    isRenderable = _.contains(columnToShow, key)
-                                if (key == "name" || key == "description" || key == "owner") {
-                                    if (columnToShow) {
-                                        col[key].renderable = isRenderable;
-                                    }
-                                    return;
-                                }
-                                col[obj.name] = {
-                                    label: obj.name.capitalize(),
-                                    cell: "Html",
-                                    editable: false,
-                                    sortable: false,
-                                    resizeable: true,
-                                    orderable: true,
-                                    renderable: isRenderable,
-                                    formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
-                                        fromRaw: function(rawValue, model) {
-                                            var modelObj = model.toJSON();
-
-                                            if (modelObj && modelObj.attributes && !_.isUndefined(modelObj.attributes[key])) {
-                                                var tempObj = {
-                                                    'scope': that,
-                                                    'attributeDefs': [obj],
-                                                    'valueObject': {},
-                                                    'isTable': false
-                                                }
-
-                                                tempObj.valueObject[key] = modelObj.attributes[key]
-                                                Utils.findAndMergeRefEntity(tempObj.valueObject, that.searchCollection.referredEntities);
-                                                return CommonViewFunction.propertyTable(tempObj);
-                                            }
-                                        }
-                                    })
-                                };
-                            });
-                        }
-                    }
                 }
-                return this.searchCollection.constructor.getTableCols(col, this.searchCollection);
             },
             addTagModalView: function(guid, multiple) {
                 var that = this;