This is an automated email from the ASF dual-hosted git repository. kbhatt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/atlas.git
commit cd177f83d24dbce0a992e3c2cf7c2f3001f0f806 Author: kevalbhatt <[email protected]> AuthorDate: Thu Feb 20 15:59:32 2020 +0530 ATLAS-3623 : Beta UI: Basic search improvement to search for namespace attribute --- .../public/js/views/search/QueryBuilderView.js | 25 +++++++++++++++++++++ .../js/views/search/SearchDefaultLayoutView.js | 21 ++++++++++++++--- .../js/views/search/SearchResultLayoutView.js | 26 ++++++++++++++++++++-- 3 files changed, 67 insertions(+), 5 deletions(-) diff --git a/dashboardv3/public/js/views/search/QueryBuilderView.js b/dashboardv3/public/js/views/search/QueryBuilderView.js index cca7992..20179bf 100644 --- a/dashboardv3/public/js/views/search/QueryBuilderView.js +++ b/dashboardv3/public/js/views/search/QueryBuilderView.js @@ -61,6 +61,7 @@ define(['require', 'entityDefCollection', 'enumDefCollection', 'classificationDefCollection', + 'nameSpaceCollection', 'tag', 'searchTableFilters', 'systemAttrArr')); @@ -364,6 +365,30 @@ define(['require', filters.push(returnObj); } }); + if (this.attrObj.length > 0) { + + var sortedNamespaceData = _.sortBy(this.nameSpaceCollection.models, function(obj) { + return obj.get('name') + }); + _.each(sortedNamespaceData, function(obj) { + var namespaceName = obj.get('name'); + + var sortedNamespaceAttr = _.sortBy(obj.attributes.attributeDefs, function(obj) { + return obj.name; + }); + _.each(sortedNamespaceAttr, function(attrDetails) { + if (attrDetails.options && attrDetails.options.applicableEntityTypes && that.options.applicableType && (JSON.parse(attrDetails.options.applicableEntityTypes).indexOf(that.options.applicableType) != -1)) { + var returnObj = that.getObjDef(attrDetails, rules_widgets, isGroupView, 'Select Namespace Attribute', true); + if (returnObj) { + returnObj.id = namespaceName + "." + returnObj.id; + returnObj.label = namespaceName + ": " + returnObj.label; + returnObj.data = { 'entityType': "namespace" }; + filters.push(returnObj); + } + } + }) + }); + } filters = _.uniq(filters, 'id'); if (filters && !_.isEmpty(filters)) { this.ui.builder.queryBuilder({ diff --git a/dashboardv3/public/js/views/search/SearchDefaultLayoutView.js b/dashboardv3/public/js/views/search/SearchDefaultLayoutView.js index 707ff14..4f5c434 100644 --- a/dashboardv3/public/js/views/search/SearchDefaultLayoutView.js +++ b/dashboardv3/public/js/views/search/SearchDefaultLayoutView.js @@ -57,9 +57,11 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa events["click " + this.ui.attrFilter] = function(e) { if (this.$('.attribute-filter-container').hasClass("hide")) { this.onClickAttrFilter(); + this.$('.attributeResultContainer').addClass("overlay"); + } else { + this.$('.attributeResultContainer').removeClass("overlay"); } this.$('.fa-angle-right').toggleClass('fa-angle-down'); - this.$('.attributeResultContainer').addClass("overlay"); this.$('.attribute-filter-container, .attr-filter-overlay').toggleClass('hide'); }; @@ -236,6 +238,7 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa enumDefCollection: that.options.enumDefCollection, typeHeaders: that.options.typeHeaders, classificationDefCollection: that.options.classificationDefCollection, + nameSpaceCollection: that.options.nameSpaceCollection, searchTableFilters: that.checkEntityFilter(that.options) }; if (that.options.value) { @@ -295,7 +298,8 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa this.renderQueryBuilder(_.extend({}, obj, { tag: false, type: true, - attrObj: attrTypeObj + attrObj: attrTypeObj, + applicableType: that.options.value ? that.options.value.type : null }), this.RQueryBuilderEntity); this.ui.entityName.html(that.options.value.type); @@ -362,13 +366,24 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa return col; }, updateFilterOptions: function(rule, filtertype, isTag) { - var ruleUrl = CommonViewFunction.attributeFilter.generateUrl({ value: rule, formatedDateToLong: true }); + var that = this, + ruleUrl = CommonViewFunction.attributeFilter.generateUrl({ value: rule, formatedDateToLong: true }); this.options.searchTableFilters[filtertype][isTag ? this.options.value.tag : this.options.value.type] = ruleUrl; if (!isTag && this.options.value && this.options.value.type && this.options.searchTableColumns) { if (!this.options.searchTableColumns[this.options.value.type]) { this.options.searchTableColumns[this.options.value.type] = ["selected", "name", "owner", "description", "tag", "typeName"]; } this.options.searchTableColumns[this.options.value.type] = _.sortBy(_.union(this.options.searchTableColumns[this.options.value.type], this.getIdFromRuleObj(rule))); + if (rule.rules) { + _.find(rule.rules, function(checkNamespace) { + if (checkNamespace.data && checkNamespace.data.entityType && checkNamespace.data.entityType == 'namespace') { + if (that.options.searchTableColumns[that.options.value.type].indexOf('namespace') == -1) { + that.options.searchTableColumns[that.options.value.type].push(checkNamespace.data.entityType); + } + return true; + } + }); + } } }, renderQueryBuilder: function(obj, rQueryBuilder) { diff --git a/dashboardv3/public/js/views/search/SearchResultLayoutView.js b/dashboardv3/public/js/views/search/SearchResultLayoutView.js index 01083ff..6d67bb6 100644 --- a/dashboardv3/public/js/views/search/SearchResultLayoutView.js +++ b/dashboardv3/public/js/views/search/SearchResultLayoutView.js @@ -641,12 +641,12 @@ define(['require', var that = this, nameCheck = 0, columnToShow = null, - col = {}; + col = {}, + namespaceRenderable = false; this.value = Utils.getUrlState.getQueryParams() || this.value; if (this.value && this.value.searchType === "basic" && this.searchTableColumns && (this.searchTableColumns[this.value.type] !== undefined)) { columnToShow = this.searchTableColumns[this.value.type] == null ? [] : this.searchTableColumns[this.value.type]; } - col['Check'] = { name: "selected", label: "Select", @@ -787,6 +787,28 @@ define(['require', } }) }; + col['Namespaces'] = { + label: "Namespaces", + cell: "Html", + editable: false, + resizeable: true, + orderable: true, + renderable: _.contains(columnToShow, 'namespace'), + formatter: _.extend({}, Backgrid.CellFormatter.prototype, { + fromRaw: function(rawValue, model) { + var obj = model.toJSON(), + namespaceStr = ''; + if (obj && obj.attributes) { + _.each(obj.attributes, function(namespaceValue, attributeName) { + if (attributeName.indexOf('.') != -1) { + namespaceStr += '<label class="btn btn-action btn-xs btn-blue no-pointer">' + attributeName + ': ' + namespaceValue + '</label>'; + } + }) + return namespaceStr; + } + } + }) + }; this.getTagCol({ 'col': col, 'columnToShow': columnToShow }); if ((!_.contains(["glossary"], this.fromView))) { this.getTermCol({ 'col': col, 'columnToShow': columnToShow });
