Commit 38fd4f35 by Keval Bhatt

ATLAS-1091 : Improvement in DSL search functionality.(kevalbhatt)

parent 81ceabbd
......@@ -25,6 +25,7 @@ $action_gray:#999999;
$color_keppel_approx: #37bb9b;
$color_gallery_approx: #eee;
$gray: #808080;
$dark_gray:#666;
$color_tuna_approx: #323544;
$color_celeste_approx: #ccc;
$color_cornflower_blue_approx: #66afe9;
......@@ -38,7 +39,7 @@ $color_ironside_gray_approx: #686868;
$color_mercury_approx: #e6e6e6;
$color_whisper_approx: #f6f7fa;
$color_bombay_approx: #b5b9bc;
$red: red;
$red: #f00;
//theme color
//colors
$color_white_lilac_approx: #f6f7fb;
......@@ -100,7 +101,6 @@ $black_80: rgba(0, 0, 0, 0.8);
$color_bright_turquoise_approx: #00ffd0;
$color_mountain_mist_approx: #999;
$color_suva_gray_approx: #868686;
// $tag_color:#9599a0;
$tag_color:#4A90E2;
$delete_link:#BB5838;
//urls
......
......@@ -132,10 +132,49 @@
}
}
.select2-container .select2-selection--single {
height: 34px;
.select2-selection__rendered {
padding-left: 12px;
.select2-container {
.select2-selection--single,
.select2-selection--multiple {
min-height: 34px;
.select2-selection__rendered {
padding-left: 12px;
}
}
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
background-color: $white;
color: $color_mountain_mist_approx;
border: 1px solid $tag_color;
}
.select2-container--default .select2-search--inline .select2-search__field {
color: #555;
}
.typeLOV {
.select2-container--default {
.select2-selection--multiple {
.select2-selection__rendered {
padding-right: 13px;
.select2-selection__choice {
font-size: 14px;
color: $color_mountain_mist_approx;
border: 1px solid $color_mountain_mist_approx;
}
.select2-search__field {
font-size: 14px;
}
}
.select2-selection__clear {
position: absolute;
float: none;
margin: 0px;
right: 4px;
top: 5px;
color: $color_mountain_mist_approx;
}
}
}
}
......@@ -182,3 +221,16 @@
.backgrid-paginator ul > .disabled > a:hover {
cursor: pointer;
}
.popover-content {
ul {
color: $dark_gray;
padding: 0px 5px;
margin-bottom: 0px;
cursor: pointer;
a {
color: $dark_gray;
padding: 5px;
}
}
}
......@@ -105,16 +105,6 @@
margin: 15px 0px;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
background-color: #fff;
color: #9599a0;
border: 1px solid $tag_color;
}
.select2-container--default .select2-search--inline .select2-search__field {
color: #555;
}
.inputTag {
display: inline-block;
border: 1px $tag_color solid;
......@@ -325,6 +315,14 @@ form-control .tagInpput {
float: right;
}
.multiSelectTag {
float: right;
}
.inputAssignTag.multiSelectTag {
margin-right: 10px;
}
.popover.popoverTag {
display: block;
}
......
......@@ -104,36 +104,12 @@
}
}
.termPopoverList {
color: #666;
padding: 0px 5px;
margin-bottom: 0px;
a {
color: #666;
padding: 5px;
}
}
.termPopover {
cursor: pointer;
}
.termMoveDiv {
width: 550px;
height: 200px;
margin: 10px;
}
.tagPopoverList {
color: #666;
padding: 0px 5px;
margin-bottom: 0px;
a {
color: #666;
padding: 5px;
}
}
.toggleArrow {
position: absolute;
left: 0px;
......@@ -141,12 +117,12 @@
cursor: pointer;
}
.addTermDiable {
border-color: #FF0000 !important;
.addTermDisable {
border-color: $red !important;
}
.alertTerm {
color: #FF0000 !important;
color: $red !important;
}
......
......@@ -33,7 +33,23 @@ define(['require',
this.modelName = 'VSearch';
this.modelAttrName = 'results';
this.bindErrorEvents();
}
},
parseRecords: function(resp, options) {
this.responseData = {
dataType: resp.dataType,
query: resp.query,
queryType: resp.queryType,
requestId: resp.requestId
};
try {
if (!this.modelAttrName) {
throw new Error("this.modelAttrName not defined for " + this);
}
return _.reject(resp[this.modelAttrName], _.isNull);
} catch (e) {
console.log(e);
}
},
},
//Static Class Members
{
......
......@@ -20,7 +20,7 @@
<button class="btn btn-atlasAction btn-atlas pull-right" onclick="this.blur();" title="Refresh" data-id="refreshTaxanomy"><i class="fa fa-refresh"></i></button>
</div>
<div>
<select type="text" class="form-control" data-id="searchTermInput" placeholder="Search term"></select>
<select type="text" class="form-control" data-id="searchTermInput"></select>
</div>
<div class="">
<ul class="taxonomyTree">
......
......@@ -29,18 +29,12 @@
</div>
<div class="col-sm-12">
<div class="form-group">
<input type="text" class="form-control" data-id="searchInput" placeholder="Search using a query string: e.g. sales_fact">
</div>
<!-- <div data-id="advanceSearchContainer">
<div class="form-group">
<select type="text" class="col-md-12 form-control tagListSelect" data-id="tagListInput" multiple></select>
</div>
<div class="form-group">
<select type="text" class="col-md-12 form-control" data-id="termListInput" multiple></select>
<div class="typeLOV">
<select data-id="typeLOV"></select>
</div>
</div> -->
<input type="text" class="form-control" data-id="searchInput" placeholder="Search using a query string: e.g. sales_fact" style="margin-top: 5px;">
</div>
<div class="clearAdvanceSearch" data-id="clearSearch">Clear</div>
<button class="btn btn-atlas advanceSearchBtn" data-id="searchBtn">Search</button>
<button class="btn btn-atlas advanceSearchBtn" data-id="searchBtn" disabled="disabled">Search</button>
</div>
</div>
<div id="searchResult"></div>
<div id="searchResult"></div>
......@@ -315,11 +315,13 @@ define(['require',
termSearchData: function() {
var that = this;
var str = '<option></option>';
for (var j = 0; j < this.termCollection.models.length; j++) {
var terms = this.termCollection.models[j].attributes.name;
str += '<option>' + terms + '</option>';
this.ui.searchTermInput.html(str);
this.termCollection.fullCollection.comparator = function(model) {
return model.get('name');
}
this.termCollection.fullCollection.sort().each(function(model) {
str += '<option>' + model.get('name') + '</option>';
});
this.ui.searchTermInput.html(str);
// this.ui.searchTermInput.setAttribute('data-href' : that.termCollection.url);
this.ui.searchTermInput.select2({
placeholder: "Search Term",
......@@ -480,11 +482,11 @@ define(['require',
view.ui.termName.on('keyup', function() {
if (this.value.indexOf(' ') >= 0) {
modal.$el.find('button.ok').prop('disabled', true);
view.ui.termName.addClass("addTermDiable");
view.ui.termName.addClass("addTermDisable");
view.$('.alertTerm').show();
} else {
modal.$el.find('button.ok').prop('disabled', false);
view.ui.termName.removeClass("addTermDiable");
view.ui.termName.removeClass("addTermDisable");
view.$('.alertTerm').hide();
}
});
......@@ -626,11 +628,11 @@ define(['require',
view.ui.termName.on('keyup', function() {
if (this.value.indexOf(' ') >= 0) {
modal.$el.find('button.ok').prop('disabled', true);
view.ui.termName.addClass("addTermDiable");
view.ui.termName.addClass("addTermDisable");
view.$('.alertTerm').show();
} else {
modal.$el.find('button.ok').prop('disabled', false);
view.ui.termName.removeClass("addTermDiable");
view.ui.termName.removeClass("addTermDisable");
view.$('.alertTerm').hide();
}
});
......
......@@ -19,10 +19,9 @@
define(['require',
'backbone',
'hbs!tmpl/search/SearchLayoutView_tmpl',
'collection/VSearchList',
'collection/VTagList',
'utils/Utils',
'collection/VTagList'
], function(require, Backbone, SearchLayoutViewTmpl, VSearchList, Utils, VTagList) {
], function(require, Backbone, SearchLayoutViewTmpl, VTagList, Utils) {
'use strict';
var SearchLayoutView = Backbone.Marionette.LayoutView.extend(
......@@ -37,33 +36,30 @@ define(['require',
/** ui selector cache */
ui: {
searchButton: '[data-id="searchButton"]',
searchInput: '[data-id="searchInput"]',
searchType: 'input[name="queryType"]',
advanceSearch: '[data-id="advanceSearch"]',
tagList: '[data-id="tagList"]',
tagListInput: '[data-id="tagListInput"]',
termListInput: '[data-id="termListInput"]',
searchBtn: '[data-id="searchBtn"]',
clearSearch: '[data-id="clearSearch"]'
clearSearch: '[data-id="clearSearch"]',
typeLov: '[data-id="typeLOV"]'
},
/** ui events hash */
events: function() {
var events = {},
that = this;
events["keyup " + this.ui.searchInput] = function(e) {
this.ui.searchBtn.removeAttr("disabled");
var code = e.which;
this.ui.searchBtn.removeAttr("disabled");
if (code == 13) {
that.findSearchResult();
}
if (code == 8 && this.ui.searchInput.val() == "") {
if (code == 8 && this.ui.searchInput.val() == "" && this.ui.typeLov.val() == "") {
this.ui.searchBtn.attr("disabled", "true");
}
};
events["change " + this.ui.searchType] = 'dslFulltextToggle';
events["click " + this.ui.searchBtn] = 'findSearchResult';
events["click " + this.ui.clearSearch] = 'clearSearchData';
events["change " + this.ui.typeLov] = 'onChangeTypeList';
return events;
},
/**
......@@ -72,44 +68,98 @@ define(['require',
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'value'));
this.searchCollection = new VSearchList([], {
state: {
firstPage: 0,
pageSize: 10
}
});
this.typecollection = new VTagList([], {});
this.type = "fulltext";
var param = Utils.getUrlState.getQueryParams();
this.query = {
dsl: {
query: ""
},
fulltext: {
query: ""
}
};
this.dsl = false;
if (param && param.query && param.searchType) {
this.query[param.searchType].query = param.query;
}
this.bindEvents();
},
bindEvents: function(param) {
this.listenTo(this.searchCollection, "reset", function(value) {
this.renderTree();
this.listenTo(this.typecollection, "reset", function(value) {
this.renderTypeList();
this.setValues();
this.ui.typeLov.select2({
placeholder: "Search For",
allowClear: true
});
}, this);
},
onRender: function() {
// array of tags which is coming from url
this.$('.typeLOV').hide();
this.fetchCollection();
this.ui.searchBtn.attr("disabled", "true");
this.setValues();
},
fetchCollection: function(value) {
$.extend(this.typecollection.queryParams, { type: 'CLASS' });
this.typecollection.fetch({ reset: true });
},
manualRender: function(paramObj) {
this.setValues(paramObj);
},
renderTypeList: function() {
var that = this;
this.ui.typeLov.empty();
var str = '<option></option>';
this.typecollection.fullCollection.comparator = function(model) {
return model.get('tags');
}
this.typecollection.fullCollection.sort().each(function(model) {
str += '<option>' + model.get("tags") + '</option>';
});
that.ui.typeLov.html(str);
},
onChangeTypeList: function(e) {
if (this.ui.typeLov.select2('val') !== "") {
this.ui.searchBtn.removeAttr("disabled");
} else if (this.ui.searchInput.val() === "") {
this.ui.searchBtn.attr("disabled", "true");
}
},
setValues: function(paramObj) {
var arr = [];
var arr = [],
that = this;
if (paramObj) {
this.value = paramObj;
}
if (this.value) {
if (this.value.query.length) {
// get only search value and append it to input box
this.ui.searchInput.val(this.value.query);
this.ui.searchBtn.removeAttr("disabled");
}
if (this.value.dslChecked == "true") {
if (this.value.dslChecked == "true" && this.dsl == false) {
this.ui.searchType.prop("checked", true).trigger("change");
} else {
} else if (this.value.dslChecked == "false" && this.dsl == true) {
this.ui.searchType.prop("checked", false).trigger("change");
}
if (this.value.query !== undefined) {
// get only search value and append it to input box
if (this.dsl) {
var query = this.value.query.split(" ");
if (query.length > 1) {
var typeList = query.shift();
} else {
var typeList = "";
}
if (this.ui.typeLov.data('select2')) {
this.ui.typeLov.val(typeList).trigger('change');
} else {
this.ui.typeLov.val(typeList);
}
this.ui.searchInput.val(query.join(" "));
} else {
this.ui.searchInput.val(this.value.query);
}
this.ui.searchBtn.removeAttr("disabled");
}
}
this.bindEvents(arr);
},
......@@ -117,18 +167,20 @@ define(['require',
this.triggerSearch(this.ui.searchInput.val());
},
triggerSearch: function(value) {
if (!this.ui.searchType.is(':checked')) {
if (this.ui.searchType.is(':checked')) {
this.type = "dsl";
} else if (!this.ui.searchType.is(':checked')) {
this.type = "fulltext";
}
var advancedSearchValue = value;
this.type = "fulltext";
if (this.ui.typeLov.select2('val') !== null && this.dsl === true) {
this.query[this.type].query = this.ui.typeLov.select2('val') + ' ' + value;
} else {
this.query[this.type].query = value
}
Utils.setUrl({
url: '#!/search/searchResult',
urlParams: {
query: advancedSearchValue,
query: this.query[this.type].query,
searchType: this.type,
dslChecked: this.ui.searchType.is(':checked')
},
......@@ -139,38 +191,35 @@ define(['require',
trigger: true
});
},
fetchCollection: function(value) {
if (value) {
this.searchCollection.url = "/api/atlas/discovery/search/" + this.type;
$.extend(this.searchCollection.queryParams, { 'query': value });
}
this.searchCollection.fetch({ reset: true });
},
dslFulltextToggle: function(e) {
var paramQuery = "";
if (e.currentTarget.checked) {
this.type = "dsl";
this.dsl = true;
this.$('.typeLOV').show();
} else {
this.dsl = false;
this.$('.typeLOV').hide();
this.type = "fulltext";
}
if (this.ui.searchInput.val() !== "") {
Utils.setUrl({
url: '#!/search/searchResult',
urlParams: {
query: this.ui.searchInput.val(),
searchType: this.type,
dslChecked: this.ui.searchType.is(':checked')
},
updateTabState: function() {
return { searchUrl: this.url, stateChanged: true };
},
mergeBrowserUrl: false,
trigger: true
});
//this.findSearchResult();
}
this.ui.searchInput.attr("placeholder", this.type == "dsl" ? 'Search using a DSL query: e.g. DataSet where name="sales_fact "' : 'Search using a query string: e.g. sales_fact');
Utils.setUrl({
url: '#!/search/searchResult',
urlParams: {
query: this.query[this.type].query,
searchType: this.type,
dslChecked: this.ui.searchType.is(':checked')
},
updateTabState: function() {
return { searchUrl: this.url, stateChanged: true };
},
mergeBrowserUrl: false,
trigger: true
});
this.ui.searchInput.attr("placeholder", this.type == "dsl" ? 'Optional conditions' : 'Search using a query string: e.g. sales_fact');
},
clearSearchData: function() {
this.query[this.type].query = "";
this.ui.typeLov.val("").trigger("change");
this.ui.searchInput.val("");
this.ui.searchBtn.attr("disabled", "true");
Utils.setUrl({
......
......@@ -195,9 +195,12 @@ define(['require',
},
fetchCollection: function(value) {
var that = this;
if (value && (value.query === undefined || value.query === "")) {
return;
}
this.$('.fontLoader').show();
this.$('.searchTable').hide();
that.$('.searchResult').hide();
this.$('.searchResult').hide();
if (Globals.searchApiCallRef) {
Globals.searchApiCallRef.abort();
}
......@@ -208,7 +211,10 @@ define(['require',
$.extend(this.searchCollection.queryParams, { limit: this.limit });
this.offset = 0;
}
_.extend(this.searchCollection.queryParams, { 'query': value.query });
if (Utils.getUrlState.isTagTab()) {
this.searchCollection.url = "/api/atlas/discovery/search/dsl";
}
_.extend(this.searchCollection.queryParams, { 'query': value.query.trim() });
}
Globals.searchApiCallRef = this.searchCollection.fetch({
success: function() {
......@@ -239,7 +245,7 @@ define(['require',
that.checkTableFetch();
that.offset = that.offset - that.limit;
if (that.firstFetch) {
that.renderTableLayoutView();
that.startRenderTableProcess();
}
}
if (that.firstFetch) {
......@@ -250,7 +256,7 @@ define(['require',
}
// checking length for not rendering the table
if (that.searchCollection.models.length) {
that.renderTableLayoutView();
that.startRenderTableProcess();
}
var resultData = 'Results for <b>' + that.searchCollection.queryParams.query + '</b>'
var multiAssignData = '<a href="javascript:void(0)" class="inputAssignTag multiSelect" style="display:none" data-id="addTerm"><i class="fa fa-folder-o"></i>' + " " + 'Assign Term</a>'
......@@ -259,11 +265,14 @@ define(['require',
silent: true
});
},
renderTableLayoutView: function() {
startRenderTableProcess: function() {
this.getEntityTableColumns();
},
renderTableLayoutView: function(col) {
var that = this,
count = 5;
require(['utils/TableLayout'], function(TableLayout) {
var columns = new Backgrid.Columns(that.getEntityTableColumns());
var columns = new Backgrid.Columns(col);
that.REntityTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, {
globalVent: that.globalVent,
columns: columns
......@@ -295,9 +304,10 @@ define(['require',
var responseData = this.searchCollection.responseData;
if (this.searchCollection.responseData) {
if (responseData.dataType && responseData.dataType.typeName.indexOf('_temp') == -1) {
return this.getFixedDslColumn();
that.renderTableLayoutView(that.getFixedDslColumn())
} else {
var idFound = false;
var idFound = false,
fetchResultCount = 0;
_.each(this.searchCollection.models, function(model) {
var modelJSON = model.toJSON();
var guid = "";
......@@ -320,26 +330,36 @@ define(['require',
});
if (guid.length) {
idFound = true;
++fetchResultCount;
model.getEntity(guid, {
async: false,
success: function(data) {
if (data.definition) {
if (data.definition.id && data.definition.values) {
that.searchCollection.get(data.definition.id).set(data.definition.values);
that.searchCollection.get(data.definition.id).set('$id$', data.definition.id);
that.searchCollection.get(data.definition.id).set('$traits$', data.definition.traits);
var id = "";
if (_.isObject(data.definition.id) && data.definition.id.id) {
id = data.definition.id.id;
} else {
id = data.definition.id;
}
that.searchCollection.get(id).set(data.definition.values);
that.searchCollection.get(id).set('$id$', data.definition.id);
that.searchCollection.get(id).set('$traits$', data.definition.traits);
}
}
},
error: function(error, data, status) {},
complete: function() {}
complete: function() {
--fetchResultCount;
if (fetchResultCount === 0) {
that.renderTableLayoutView(that.getFixedDslColumn())
}
}
});
}
});
if (idFound) {
return this.getFixedDslColumn();
} else {
return this.getDaynamicColumn();
if (idFound === false) {
that.renderTableLayoutView(this.getDaynamicColumn())
}
}
}
......@@ -371,11 +391,16 @@ define(['require',
var that = this,
nameCheck = 0,
col = {};
this.searchCollection.each(function(model) {
if (model.get('name') || model.get('qualifiedName')) {
for (var i = 0; i < this.searchCollection.models.length; i++) {
var model = this.searchCollection.models[i];
if (model && (model.get('name') || model.get('qualifiedName'))) {
++nameCheck
}
});
if (model && model.get('$id$') === undefined) {
i = i - 1;
that.searchCollection.remove(model);
}
}
if (Globals.taxonomy) {
col['Check'] = {
name: "selected",
......@@ -542,7 +567,7 @@ define(['require',
var view = new AddTermToEntityLayoutView({
guid: guid,
multiple: multiple,
callback: function(termName) {
callback: function() {
that.fetchCollection();
that.arr = [];
},
......
......@@ -77,7 +77,7 @@ define(['require',
var str = '',
that = this;
this.ui.parentTag.empty();
this.tagCollection.each(function(val) {
this.tagCollection.fullCollection.each(function(val) {
str += '<option>' + val.get("tags") + '</option>';
});
that.ui.parentTag.html(str);
......
......@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES:
ALL CHANGES:
ATLAS-1091 Improvement in DSL search functionality. (kevalbhatt)
ATLAS-1080 Regression - UI - hive_storagedesc is shown as "undefined" in UI.(kevalbhatt)
ATLAS-1089 Storm hook should handle cyclic references in topology object (mneethiraj via sumasai)
ATLAS-1086 Build failure in hive-bridge after security fixes in ATLAS-762 (sumasai)
......
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