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/22 14:24:56 UTC
atlas git commit: ATLAS-2156: save-search UI to allow user to edit
name
Repository: atlas
Updated Branches:
refs/heads/master 454eb66a3 -> 20f2fba7e
ATLAS-2156: save-search UI to allow user to edit name
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/20f2fba7
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/20f2fba7
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/20f2fba7
Branch: refs/heads/master
Commit: 20f2fba7e3a79e1d3baacdb1b97d1b37acc39c95
Parents: 454eb66
Author: kevalbhatt <kb...@apache.org>
Authored: Fri Sep 22 19:10:32 2017 +0530
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Fri Sep 22 07:13:06 2017 -0700
----------------------------------------------------------------------
.../templates/search/SaveAsLayoutView_tmpl.html | 24 ----
.../search/SaveSearchItemView_tmpl.html | 28 ----
.../js/templates/search/SaveSearch_tmpl.html | 29 ----
.../search/save/SaveModalLayoutView_tmpl.html | 24 ++++
.../search/save/SaveSearchItemView_tmpl.html | 28 ++++
.../search/save/SaveSearchView_tmpl.html | 30 ++++
.../public/js/utils/CommonViewFunction.js | 8 +-
.../public/js/views/search/SaveAsLayoutView.js | 97 -------------
.../js/views/search/SaveSearchItemView.js | 127 ----------------
.../public/js/views/search/SaveSearchView.js | 143 -------------------
.../public/js/views/search/SearchLayoutView.js | 39 +++--
.../js/views/search/save/SaveModalLayoutView.js | 131 +++++++++++++++++
.../js/views/search/save/SaveSearchItemView.js | 139 ++++++++++++++++++
.../js/views/search/save/SaveSearchView.js | 130 +++++++++++++++++
14 files changed, 506 insertions(+), 471 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/atlas/blob/20f2fba7/dashboardv2/public/js/templates/search/SaveAsLayoutView_tmpl.html
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/templates/search/SaveAsLayoutView_tmpl.html b/dashboardv2/public/js/templates/search/SaveAsLayoutView_tmpl.html
deleted file mode 100644
index fd87d28..0000000
--- a/dashboardv2/public/js/templates/search/SaveAsLayoutView_tmpl.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
--->
-<form name="saveAsform" class="form-horizontal" data-id="">
- <div class="form-group">
- <label class="control-label col-sm-2 required" for="name">Name</label>
- <div class="col-sm-10">
- <input class="form-control" data-id="saveAsName" placeholder="Name(required)" autofocus/>
- </div>
- </div>
-</form>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/20f2fba7/dashboardv2/public/js/templates/search/SaveSearchItemView_tmpl.html
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/templates/search/SaveSearchItemView_tmpl.html b/dashboardv2/public/js/templates/search/SaveSearchItemView_tmpl.html
deleted file mode 100644
index d84a2ef..0000000
--- a/dashboardv2/public/js/templates/search/SaveSearchItemView_tmpl.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
--->
-<!-- <div class="row">
- <div class="col-md-10"><span>{{name}}</span></div>
- <div class="col-md-2">
- <button type="button" class="btn btn-danger btn-sm closeInput" data-id="close"><i class="fa fa-times"></i></button>
- </div>
-</div> -->
-<div data-id="{{guid}}" class="item">
- <div class="tools">
- <i class="fa fa-ellipsis-h tagPopover" data-original-title="" title="" data-id=""></i>
- </div>
- <a href="javascript:void(0)">{{name}}</a>
-</div>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/20f2fba7/dashboardv2/public/js/templates/search/SaveSearch_tmpl.html
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/templates/search/SaveSearch_tmpl.html b/dashboardv2/public/js/templates/search/SaveSearch_tmpl.html
deleted file mode 100644
index 0b20eb4..0000000
--- a/dashboardv2/public/js/templates/search/SaveSearch_tmpl.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
--->
-<div class="inline-content add-seperator">
- <div class="inline">
- <h4>Favorite Search</h4></div>
- <div class="pull-right">
- <button type="button" class="btn btn-action btn-sm" disabled="disabled" data-id="saveBtn">Save</button>
- <button type="button" class="btn btn-action btn-sm" data-id="saveAsBtn">Save As</button>
- </div>
-</div>
-<ul data-id="itemViewContent" class="tag-tree saveSearchList gray-text">
- <div class="fontLoader-relative" style="display: block;">
- <i class="fa fa-refresh fa-spin-custom"></i>
- </div>
-</ul>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/20f2fba7/dashboardv2/public/js/templates/search/save/SaveModalLayoutView_tmpl.html
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/templates/search/save/SaveModalLayoutView_tmpl.html b/dashboardv2/public/js/templates/search/save/SaveModalLayoutView_tmpl.html
new file mode 100644
index 0000000..49d6013
--- /dev/null
+++ b/dashboardv2/public/js/templates/search/save/SaveModalLayoutView_tmpl.html
@@ -0,0 +1,24 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<form name="saveAsform" class="form-horizontal" data-id="">
+ <div class="form-group">
+ <label class="control-label col-sm-2 required" for="name">Name</label>
+ <div class="col-sm-10">
+ <input class="form-control" data-id="saveAsName" placeholder="Name(required)" value="{{selectedModel.name}}" autofocus/>
+ </div>
+ </div>
+</form>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/20f2fba7/dashboardv2/public/js/templates/search/save/SaveSearchItemView_tmpl.html
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/templates/search/save/SaveSearchItemView_tmpl.html b/dashboardv2/public/js/templates/search/save/SaveSearchItemView_tmpl.html
new file mode 100644
index 0000000..d84a2ef
--- /dev/null
+++ b/dashboardv2/public/js/templates/search/save/SaveSearchItemView_tmpl.html
@@ -0,0 +1,28 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<!-- <div class="row">
+ <div class="col-md-10"><span>{{name}}</span></div>
+ <div class="col-md-2">
+ <button type="button" class="btn btn-danger btn-sm closeInput" data-id="close"><i class="fa fa-times"></i></button>
+ </div>
+</div> -->
+<div data-id="{{guid}}" class="item">
+ <div class="tools">
+ <i class="fa fa-ellipsis-h tagPopover" data-original-title="" title="" data-id=""></i>
+ </div>
+ <a href="javascript:void(0)">{{name}}</a>
+</div>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/20f2fba7/dashboardv2/public/js/templates/search/save/SaveSearchView_tmpl.html
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/templates/search/save/SaveSearchView_tmpl.html b/dashboardv2/public/js/templates/search/save/SaveSearchView_tmpl.html
new file mode 100644
index 0000000..3212eb6
--- /dev/null
+++ b/dashboardv2/public/js/templates/search/save/SaveSearchView_tmpl.html
@@ -0,0 +1,30 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<div class="inline-content add-seperator">
+ <div class="inline">
+ <h4>Favorite Search</h4></div>
+ <div class="pull-right">
+ <button type="button" class="btn btn-action btn-sm" disabled="disabled" data-id="saveBtn">Save</button>
+ <button type="button" class="btn btn-action btn-sm" data-id="saveAsBtn">Save As</button>
+ </div>
+</div>
+<span class="gray-text noFavoriteSearch">You don't have any favorite search.</span>
+<ul data-id="itemViewContent" class="tag-tree saveSearchList">
+ <div class="fontLoader-relative" style="display: block;">
+ <i class="fa fa-refresh fa-spin-custom"></i>
+ </div>
+</ul>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/20f2fba7/dashboardv2/public/js/utils/CommonViewFunction.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/utils/CommonViewFunction.js b/dashboardv2/public/js/utils/CommonViewFunction.js
index de5856c..fc20b02 100644
--- a/dashboardv2/public/js/utils/CommonViewFunction.js
+++ b/dashboardv2/public/js/utils/CommonViewFunction.js
@@ -447,9 +447,8 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
CommonViewFunction.generateObjectForSaveSearchApi = function(options) {
var obj = {
name: options.name,
- searchParameters: {
- excludeDeletedEntities: true
- }
+ guid: options.guid,
+ searchParameters: {}
};
var value = options.value;
if (value) {
@@ -470,6 +469,9 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
}
}
}
+ if (k == "includeDE") {
+ val = _.isUndefinedNull(val) ? true : val;
+ }
obj.searchParameters[v] = val;
});
return obj;
http://git-wip-us.apache.org/repos/asf/atlas/blob/20f2fba7/dashboardv2/public/js/views/search/SaveAsLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/search/SaveAsLayoutView.js b/dashboardv2/public/js/views/search/SaveAsLayoutView.js
deleted file mode 100644
index f4f4c68..0000000
--- a/dashboardv2/public/js/views/search/SaveAsLayoutView.js
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-define(['require',
- 'backbone',
- 'hbs!tmpl/search/SaveAsLayoutView_tmpl',
- 'utils/Utils',
- 'modules/Modal',
- 'utils/UrlLinks',
- 'platform',
- 'models/VSearch',
- 'utils/CommonViewFunction',
- 'utils/Messages'
-], function(require, Backbone, SaveAsLayoutViewTmpl, Utils, Modal, UrlLinks, platform, VSearch, CommonViewFunction, Messages) {
-
-
- var SaveAsLayoutView = Backbone.Marionette.LayoutView.extend({
- _viewName: 'SaveAsLayoutView',
- template: SaveAsLayoutViewTmpl,
- regions: {},
- ui: {
- saveAsName: "[data-id='saveAsName']"
- },
- events: function() {
- var events = {};
- return events;
- },
- initialize: function(options) {
- var that = this;
- _.extend(this, _.pick(options, 'value', 'collection', 'searchVent', 'typeHeaders', 'fetchFavioriteCollection', 'getValue', 'isBasic'));
-
- this.model = new VSearch();
- var modal = new Modal({
- title: 'Enter your search name',
- content: this,
- cancelText: "Cancel",
- okCloses: false,
- okText: 'Create',
- allowCancel: true
- }).open();
- modal.$el.find('button.ok').attr("disabled", "true");
- this.ui.saveAsName.on('keyup', function(e) {
- modal.$el.find('button.ok').removeAttr("disabled");
- });
- this.ui.saveAsName.on('keyup', function(e) {
- if ((e.keyCode == 8 || e.keyCode == 32 || e.keyCode == 46) && e.currentTarget.value.trim() == "") {
- modal.$el.find('button.ok').attr("disabled", "true");
- }
- });
- modal.on('ok', function() {
- modal.$el.find('button.ok').attr("disabled", "true");
- that.onCreateButton(modal);
- });
- modal.on('closeModal', function() {
- modal.trigger('cancel');
- });
- },
- onCreateButton: function(modal) {
- var that = this,
- obj = { value: this.getValue(), name: this.ui.saveAsName.val() },
- saveObj = CommonViewFunction.generateObjectForSaveSearchApi(obj);
- if (this.isBasic) {
- saveObj['searchType'] = "BASIC";
- } else {
- saveObj['searchType'] = "ADVANCED";
- }
- that.model.urlRoot = UrlLinks.saveSearchApiUrl();
- that.model.save(saveObj, {
- success: function(model, data) {
- if (that.collection) {
- that.collection.add(data);
- }
- Utils.notifySuccess({
- content: obj.name + Messages.addSuccessMessage
- });
- }
- });
- modal.trigger('cancel');
- }
- });
- return SaveAsLayoutView;
-});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/20f2fba7/dashboardv2/public/js/views/search/SaveSearchItemView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/search/SaveSearchItemView.js b/dashboardv2/public/js/views/search/SaveSearchItemView.js
deleted file mode 100644
index 46704a9..0000000
--- a/dashboardv2/public/js/views/search/SaveSearchItemView.js
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-define(['require',
- 'backbone',
- 'hbs!tmpl/search/SaveSearchItemView_tmpl',
- 'utils/UrlLinks',
- 'utils/Utils',
- 'utils/CommonViewFunction',
- 'utils/Messages'
-], function(require, Backbone, SaveSearchItemView_tmpl, UrlLinks, Utils, CommonViewFunction, Messages) {
- 'use strict';
- return Backbone.Marionette.ItemView.extend({
- template: SaveSearchItemView_tmpl,
- tagName: 'li',
- className: 'parent-node',
- ui: {
- stateChange: '.item',
- tools: '.tools'
- },
- events: function() {
- var events = {};
- events['click ' + this.ui.stateChange] = 'stateChange';
- events['click ' + this.ui.tools] = function(e) {
- e.stopPropagation();
- };
- return events;
- },
- initialize: function(options) {
- _.extend(this, _.pick(options, 'collection', 'typeHeaders', 'applyValue', 'fetchFavioriteCollection', 'isBasic', 'classificationDefCollection', 'entityDefCollection'));
- this.model.id = this.model.get('guid');
- this.model.idAttribute = 'guid';
- this.searchTypeObj = {
- 'searchType': 'dsl',
- 'dslChecked': 'true'
- }
- if (this.isBasic) {
- this.searchTypeObj.dslChecked = false;
- this.searchTypeObj.searchType = 'basic';
- }
- },
- onRender: function() {
- this.showToolTip();
- },
- stateChange: function() {
- this.applyValue(this.model, this.searchTypeObj);
- this.trigger('item:clicked');
- this.ui.stateChange.parent('li').addClass('active').siblings().removeClass('active');
- },
- showToolTip: function(e) {
- var that = this;
- Utils.generatePopover({
- el: this.$('.tagPopover'),
- container: this.$el,
- popoverOptions: {
- content: function() {
- return "<ul class='saveSearchPopoverList'>" +
- "<li class='th' ><i class='fa fa-search'></i> <a href='javascript:void(0)' data-fn='onSearch'>Search </a></li>" +
- "<li class='listTerm' ><i class='fa fa-trash-o'></i> <a href='javascript:void(0)' data-fn='onDelete'>Delete</a></li>" +
- "</ul>";
- }
- }
- }).parent('div.tools').on('click', 'li', function(e) {
- e.stopPropagation();
- that.$('.tagPopover').popover('hide');
- that[$(this).find('a').data('fn')](e)
- });
- },
- onSearch: function() {
- var searchParameters = this.model.toJSON().searchParameters,
- params = CommonViewFunction.generateUrlFromSaveSearchObject({
- value: searchParameters,
- classificationDefCollection: this.classificationDefCollection,
- entityDefCollection: this.entityDefCollection
- });
- Utils.setUrl({
- url: '#!/search/searchResult',
- urlParams: _.extend(params, this.searchTypeObj),
- mergeBrowserUrl: false,
- trigger: true,
- updateTabState: true
- });
- },
- onDelete: function() {
- var that = this;
- var notifyObj = {
- modal: true,
- html: true,
- text: Messages.conformation.deleteMessage + "<b>" + this.model.get('name') + "</b>" + " ?",
- ok: function(argument) {
- that.onDeleteNotifyOk();
- },
- cancel: function(argument) {}
- }
- Utils.notifyConfirm(notifyObj);
- },
- onDeleteNotifyOk: function() {
- var that = this;
- this.model.urlRoot = UrlLinks.saveSearchApiUrl();
- this.model.destroy({
- wait: true,
- success: function(model, data) {
- if (that.collection) {
- that.collection.remove(data);
- }
- Utils.notifySuccess({
- content: that.model.get('name') + Messages.deleteSuccessMessage
- });
- }
- });
- }
- });
-});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/20f2fba7/dashboardv2/public/js/views/search/SaveSearchView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/search/SaveSearchView.js b/dashboardv2/public/js/views/search/SaveSearchView.js
deleted file mode 100644
index aed8714..0000000
--- a/dashboardv2/public/js/views/search/SaveSearchView.js
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-define(['require',
- 'backbone',
- 'hbs!tmpl/search/SaveSearch_tmpl',
- 'views/search/SaveSearchItemView',
- 'collection/VSearchList',
- 'utils/Utils',
- 'utils/UrlLinks',
- 'utils/CommonViewFunction',
- 'utils/Messages'
-], function(require, Backbone, SaveSearch_Tmpl, SaveSearchItemView, VSearchList, Utils, UrlLinks, CommonViewFunction, Messages) {
- 'use strict';
-
- return Backbone.Marionette.CompositeView.extend({
- template: SaveSearch_Tmpl,
- childView: SaveSearchItemView,
- childViewContainer: "[data-id='itemViewContent']",
- ui: {
- saveAs: "[data-id='saveAsBtn']",
- save: "[data-id='saveBtn']"
- },
- childViewOptions: function() {
- return {
- collection: this.collection,
- typeHeaders: this.typeHeaders,
- applyValue: this.applyValue,
- isBasic: this.isBasic,
- classificationDefCollection: this.classificationDefCollection,
- entityDefCollection: this.entityDefCollection,
- fetchFavioriteCollection: this.fetchCollection.bind(this)
- };
- },
- childEvents: function() {
- return {
- "item:clicked": function() {
- this.ui.save.attr('disabled', false);
- }
- }
- },
- events: function() {
- var events = {};
- events['click ' + this.ui.saveAs] = "saveAs";
- events['click ' + this.ui.save] = "save";
- return events;
- },
- initialize: function(options) {
- var that = this;
- _.extend(this, _.pick(options, 'collection', 'value', 'searchVent', 'typeHeaders', 'applyValue', 'getValue', 'isBasic', 'fetchCollection', 'classificationDefCollection', 'entityDefCollection'));
- },
- onRender: function() {
- this.bindEvents();
- },
- bindEvents: function() {
- this.listenTo(this.collection, "reset error", function(model, response) {
- this.$('.fontLoader-relative').hide();
- if (model && model.length) {
- this.$("[data-id='itemViewContent']").text("");
- } else {
- this.$("[data-id='itemViewContent']").text("You don't have any favorite search.")
- }
- }, this);
- },
- saveAs: function(e) {
- var that = this,
- value = this.getValue();
- if (value && (value.type || value.tag || value.query)) {
- require([
- 'views/search/SaveAsLayoutView'
- ], function(SaveAsLayoutView) {
- new SaveAsLayoutView({ 'value': that.value, 'searchVent': that.searchVent, 'collection': that.collection, 'getValue': that.getValue, 'isBasic': that.isBasic });
- });
- } else {
- Utils.notifyInfo({
- content: Messages.search.favoriteSearch.notSelectedSearchFilter
- })
- }
- },
- save: function() {
- var that = this,
- obj = {},
- notifyObj = {
- modal: true,
- html: true,
- ok: function(argument) {
- that.onSaveNotifyOk(obj);
- },
- cancel: function(argument) {}
- },
- selectedEl = this.$('.saveSearchList li.active').find('div.item');
- obj.name = selectedEl.find('a').text();
- obj.id = selectedEl.data('id');
- if (selectedEl && selectedEl.length) {
- notifyObj['text'] = Messages.search.favoriteSearch.save + " <b>" + obj.name + "</b> ?";
- Utils.notifyConfirm(notifyObj);
- } else {
- Utils.notifyInfo({
- content: Messages.search.favoriteSearch.notSelectedElement
- })
- }
- },
- onSaveNotifyOk: function(obj) {
- var that = this
- if (obj && obj.id) {
- var model = new this.collection.model();
- obj.value = this.getValue();
- var saveObj = CommonViewFunction.generateObjectForSaveSearchApi(obj);
- saveObj['guid'] = obj.id;
- model.urlRoot = UrlLinks.saveSearchApiUrl();
- model.save(saveObj, {
- type: 'PUT',
- success: function(model, data) {
- if (that.collection) {
- var collectionRef = that.collection.find({ guid: data.guid });
- if (collectionRef) {
- collectionRef.set(data);
- }
- }
- Utils.notifySuccess({
- content: obj.name + Messages.editSuccessMessage
- });
- }
- });
- }
- }
- });
-});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/20f2fba7/dashboardv2/public/js/views/search/SearchLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/search/SearchLayoutView.js b/dashboardv2/public/js/views/search/SearchLayoutView.js
index 4fbeaaf..b032ea9 100644
--- a/dashboardv2/public/js/views/search/SearchLayoutView.js
+++ b/dashboardv2/public/js/views/search/SearchLayoutView.js
@@ -102,8 +102,10 @@ define(['require',
type: null,
tag: null,
attributes: null,
+ tagFilters: null,
pageOffset: null,
pageLimit: null,
+ entityFilters: null,
includeDE: null
}
};
@@ -119,7 +121,7 @@ define(['require',
},
renderSaveSearch: function() {
var that = this;
- require(['views/search/SaveSearchView'], function(SaveSearchView) {
+ require(['views/search/save/SaveSearchView'], function(SaveSearchView) {
var saveSearchBaiscCollection = new VSearchList(),
saveSearchAdvanceCollection = new VSearchList(),
saveSearchCollection = new VSearchList();
@@ -137,6 +139,7 @@ define(['require',
tagObj = that.searchTableFilters['tagFilters'],
urlObj = Utils.getUrlState.getQueryParams();
if (urlObj) {
+ // includeDE value in because we need to send "true","false" to the server.
if (urlObj.includeDE == "true") {
urlObj.includeDE = true;
} else {
@@ -329,8 +332,10 @@ define(['require',
type: null,
tag: null,
attributes: null,
+ tagFilters: null,
pageOffset: null,
pageLimit: null,
+ entityFilters: null,
includeDE: null
}), param);
},
@@ -439,6 +444,7 @@ define(['require',
this.value = paramObj;
}
if (this.value) {
+ this.ui.searchInput.val(this.value.query || "");
if (this.value.dslChecked == "true") {
if (!this.ui.searchType.prop("checked")) {
this.ui.searchType.prop("checked", true).trigger("change");
@@ -470,7 +476,6 @@ define(['require',
}
}
}
- this.ui.searchInput.val(this.value.query || "");
setTimeout(function() {
that.ui.searchInput.focus();
}, 0);
@@ -482,15 +487,11 @@ define(['require',
triggerSearch: function(value) {
var params = {
searchType: this.type,
- dslChecked: this.ui.searchType.is(':checked'),
- tagFilters: null,
- entityFilters: null,
- attributes: null,
- includeDE: null
+ dslChecked: this.ui.searchType.is(':checked')
}
- this.query[this.type].type = this.ui.typeLov.select2('val') || null;
+ params['type'] = this.ui.typeLov.select2('val') || null;
if (!this.dsl) {
- this.query[this.type].tag = this.ui.tagLov.select2('val') || null;
+ params['tag'] = this.ui.tagLov.select2('val') || null;
var entityFilterObj = this.searchTableFilters['entityFilters'],
tagFilterObj = this.searchTableFilters['tagFilters'];
if (this.value.tag) {
@@ -503,25 +504,27 @@ define(['require',
if (columnList) {
params['attributes'] = columnList.join(',');
}
- if (this.value.includeDE) {
+ if (_.isUndefinedNull(this.value.includeDE)) {
+ params['includeDE'] = false;
+ } else {
params['includeDE'] = this.value.includeDE;
}
}
if (this.value.pageLimit) {
- this.query[this.type].pageLimit = this.value.pageLimit;
+ params['pageLimit'] = this.value.pageLimit;
}
if (this.value.pageOffset) {
if (this.query[this.type].query && this.query[this.type].query != value) {
- this.query[this.type].pageOffset = 0;
+ params['pageOffset'] = 0;
} else {
- this.query[this.type].pageOffset = this.value.pageOffset;
+ params['pageOffset'] = this.value.pageOffset;
}
}
- this.query[this.type].query = value || null;
-
+ params['query'] = value || null;
+ _.extend(this.query[this.type], params);
Utils.setUrl({
url: '#!/search/searchResult',
- urlParams: _.extend({}, this.query[this.type], params),
+ urlParams: _.extend({}, this.query[this.type]),
mergeBrowserUrl: false,
trigger: true,
updateTabState: true
@@ -555,10 +558,6 @@ define(['require',
this.$('.searchText').text('Search By Text');
this.ui.searchInput.attr("placeholder", "Search By Text");
}
- if (paramObj && this.type == "basic") {
- this.query[this.type].attributes = paramObj.attributes ? paramObj.attributes : null;
- this.query[this.type].includeDE = this.value.includeDE;
- }
if (Utils.getUrlState.isSearchTab()) {
Utils.setUrl({
url: '#!/search/searchResult',
http://git-wip-us.apache.org/repos/asf/atlas/blob/20f2fba7/dashboardv2/public/js/views/search/save/SaveModalLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/search/save/SaveModalLayoutView.js b/dashboardv2/public/js/views/search/save/SaveModalLayoutView.js
new file mode 100644
index 0000000..107e2dd
--- /dev/null
+++ b/dashboardv2/public/js/views/search/save/SaveModalLayoutView.js
@@ -0,0 +1,131 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+define(['require',
+ 'backbone',
+ 'hbs!tmpl/search/save/SaveModalLayoutView_tmpl',
+ 'utils/Utils',
+ 'modules/Modal',
+ 'utils/UrlLinks',
+ 'platform',
+ 'models/VSearch',
+ 'utils/CommonViewFunction',
+ 'utils/Messages'
+], function(require, Backbone, SaveModalLayoutViewTmpl, Utils, Modal, UrlLinks, platform, VSearch, CommonViewFunction, Messages) {
+
+
+ var SaveModalLayoutView = Backbone.Marionette.LayoutView.extend({
+ _viewName: 'SaveModalLayoutView',
+ template: SaveModalLayoutViewTmpl,
+ regions: {},
+ ui: {
+ saveAsName: "[data-id='saveAsName']"
+ },
+ templateHelpers: function() {
+ return {
+ selectedModel: this.selectedModel ? this.selectedModel.toJSON() : null
+ };
+ },
+ events: function() {
+ var events = {};
+ return events;
+ },
+ initialize: function(options) {
+ var that = this;
+ _.extend(this, _.pick(options, 'selectedModel', 'collection', 'getValue', 'isBasic', 'saveObj'));
+
+ this.model = new VSearch();
+ if (this.saveObj) {
+ this.onCreateButton();
+ } else {
+ var modal = new Modal({
+ title: (this.selectedModel ? 'Update' : 'Create') + ' your favorite search ' + (this.selectedModel ? 'name' : ''),
+ content: this,
+ cancelText: "Cancel",
+ okCloses: false,
+ okText: this.selectedModel ? 'Update' : 'Create',
+ allowCancel: true
+ }).open();
+ modal.$el.find('button.ok').attr("disabled", "true");
+ this.ui.saveAsName.on('keyup', function(e) {
+ modal.$el.find('button.ok').removeAttr("disabled");
+ });
+ this.ui.saveAsName.on('keyup', function(e) {
+ if ((e.keyCode == 8 || e.keyCode == 32 || e.keyCode == 46) && e.currentTarget.value.trim() == "") {
+ modal.$el.find('button.ok').attr("disabled", "true");
+ }
+ });
+ modal.on('ok', function() {
+ modal.$el.find('button.ok').attr("disabled", "true");
+ that.onCreateButton(modal);
+ });
+ modal.on('closeModal', function() {
+ modal.trigger('cancel');
+ });
+ }
+ },
+ onCreateButton: function(modal) {
+ var that = this,
+ obj = { name: this.ui.saveAsName.val ? this.ui.saveAsName.val() : null };
+ if (this.selectedModel) {
+ // Update Name only.
+ var saveObj = this.selectedModel.toJSON();
+ saveObj.name = obj.name;
+ } else {
+ obj.value = this.getValue();
+ if (this.saveObj) {
+ // Save search Filter
+ _.extend(obj, this.saveObj);
+ }
+ var saveObj = CommonViewFunction.generateObjectForSaveSearchApi(obj);
+ if (this.isBasic) {
+ saveObj['searchType'] = "BASIC";
+ } else {
+ saveObj['searchType'] = "ADVANCED";
+ }
+ }
+ this.model.urlRoot = UrlLinks.saveSearchApiUrl();
+ this.model.save(saveObj, {
+ type: (saveObj.guid ? 'PUT' : 'POST'),
+ success: function(model, data) {
+ if (that.collection) {
+ if (saveObj.guid) {
+ var collectionRef = that.collection.find({ guid: data.guid });
+ if (collectionRef) {
+ collectionRef.set(data);
+ }
+ Utils.notifySuccess({
+ content: obj.name + Messages.editSuccessMessage
+ });
+ } else {
+ that.collection.add(data);
+ Utils.notifySuccess({
+ content: obj.name + Messages.addSuccessMessage
+ });
+ }
+ }
+
+ }
+ });
+ if (modal) {
+ modal.trigger('cancel');
+ }
+ }
+ });
+ return SaveModalLayoutView;
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/20f2fba7/dashboardv2/public/js/views/search/save/SaveSearchItemView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/search/save/SaveSearchItemView.js b/dashboardv2/public/js/views/search/save/SaveSearchItemView.js
new file mode 100644
index 0000000..07d8df7
--- /dev/null
+++ b/dashboardv2/public/js/views/search/save/SaveSearchItemView.js
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+define(['require',
+ 'backbone',
+ 'hbs!tmpl/search/save/SaveSearchItemView_tmpl',
+ 'utils/UrlLinks',
+ 'utils/Utils',
+ 'utils/CommonViewFunction',
+ 'utils/Messages'
+], function(require, Backbone, SaveSearchItemViewTmpl, UrlLinks, Utils, CommonViewFunction, Messages) {
+ 'use strict';
+ return Backbone.Marionette.ItemView.extend({
+ template: SaveSearchItemViewTmpl,
+ tagName: 'li',
+ className: 'parent-node',
+ ui: {
+ stateChange: '.item',
+ tools: '.tools'
+ },
+ events: function() {
+ var events = {};
+ events['click ' + this.ui.stateChange] = 'stateChange';
+ events['click ' + this.ui.tools] = function(e) {
+ e.stopPropagation();
+ };
+ return events;
+ },
+ initialize: function(options) {
+ _.extend(this, _.pick(options, 'collection', 'typeHeaders', 'applyValue', 'fetchFavioriteCollection', 'isBasic', 'classificationDefCollection', 'entityDefCollection'));
+ this.model.id = this.model.get('guid');
+ this.model.idAttribute = 'guid';
+ this.searchTypeObj = {
+ 'searchType': 'dsl',
+ 'dslChecked': 'true'
+ }
+ if (this.isBasic) {
+ this.searchTypeObj.dslChecked = false;
+ this.searchTypeObj.searchType = 'basic';
+ }
+ },
+ onRender: function() {
+ this.showToolTip();
+ },
+ stateChange: function() {
+ this.applyValue(this.model, this.searchTypeObj);
+ this.trigger('item:clicked');
+ this.ui.stateChange.parent('li').addClass('active').siblings().removeClass('active');
+ },
+ modelEvents: {
+ 'change': 'render'
+ },
+ showToolTip: function(e) {
+ var that = this;
+ Utils.generatePopover({
+ el: this.$('.tagPopover'),
+ container: this.$el,
+ popoverOptions: {
+ content: function() {
+ return "<ul class='saveSearchPopoverList'>" +
+ "<li class='listTerm' ><i class='fa fa-search'></i> <a href='javascript:void(0)' data-fn='onSearch'>Search </a></li>" +
+ "<li class='listTerm' ><i class='fa fa-pencil'></i> <a href='javascript:void(0)' data-fn='onRename'>Rename</a></li>" +
+ "<li class='listTerm' ><i class='fa fa-trash-o'></i> <a href='javascript:void(0)' data-fn='onDelete'>Delete</a></li>" +
+ "</ul>";
+ }
+ }
+ }).parent('div.tools').on('click', 'li', function(e) {
+ e.stopPropagation();
+ that.$('.tagPopover').popover('hide');
+ that[$(this).find('a').data('fn')](e)
+ });
+ },
+ onSearch: function() {
+ var searchParameters = this.model.toJSON().searchParameters,
+ params = CommonViewFunction.generateUrlFromSaveSearchObject({
+ value: searchParameters,
+ classificationDefCollection: this.classificationDefCollection,
+ entityDefCollection: this.entityDefCollection
+ });
+ Utils.setUrl({
+ url: '#!/search/searchResult',
+ urlParams: _.extend(params, this.searchTypeObj),
+ mergeBrowserUrl: false,
+ trigger: true,
+ updateTabState: true
+ });
+ },
+ onRename: function() {
+ var that = this;
+ require([
+ 'views/search/save/SaveModalLayoutView'
+ ], function(SaveModalLayoutView) {
+ new SaveModalLayoutView({ 'selectedModel': that.model, 'collection': that.collection, 'getValue': that.getValue, 'isBasic': that.isBasic });
+ });
+ },
+ onDelete: function() {
+ var that = this;
+ var notifyObj = {
+ modal: true,
+ html: true,
+ text: Messages.conformation.deleteMessage + "<b>" + this.model.get('name') + "</b>" + " ?",
+ ok: function(argument) {
+ that.onDeleteNotifyOk();
+ },
+ cancel: function(argument) {}
+ }
+ Utils.notifyConfirm(notifyObj);
+ },
+ onDeleteNotifyOk: function() {
+ var that = this;
+ this.model.urlRoot = UrlLinks.saveSearchApiUrl();
+ this.model.destroy({
+ wait: true,
+ success: function(model, data) {
+ if (that.collection) {
+ that.collection.remove(data);
+ }
+ Utils.notifySuccess({
+ content: that.model.get('name') + Messages.deleteSuccessMessage
+ });
+ }
+ });
+ }
+ });
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/20f2fba7/dashboardv2/public/js/views/search/save/SaveSearchView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/search/save/SaveSearchView.js b/dashboardv2/public/js/views/search/save/SaveSearchView.js
new file mode 100644
index 0000000..4ca5c5a
--- /dev/null
+++ b/dashboardv2/public/js/views/search/save/SaveSearchView.js
@@ -0,0 +1,130 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+define(['require',
+ 'backbone',
+ 'hbs!tmpl/search/save/SaveSearchView_tmpl',
+ 'views/search/save/SaveSearchItemView',
+ 'collection/VSearchList',
+ 'utils/Utils',
+ 'utils/UrlLinks',
+ 'utils/CommonViewFunction',
+ 'utils/Messages'
+], function(require, Backbone, SaveSearchViewTmpl, SaveSearchItemView, VSearchList, Utils, UrlLinks, CommonViewFunction, Messages) {
+ 'use strict';
+
+ return Backbone.Marionette.CompositeView.extend({
+ template: SaveSearchViewTmpl,
+ childView: SaveSearchItemView,
+ childViewContainer: "[data-id='itemViewContent']",
+ ui: {
+ saveAs: "[data-id='saveAsBtn']",
+ save: "[data-id='saveBtn']"
+ },
+ childViewOptions: function() {
+ return {
+ collection: this.collection,
+ typeHeaders: this.typeHeaders,
+ applyValue: this.applyValue,
+ isBasic: this.isBasic,
+ classificationDefCollection: this.classificationDefCollection,
+ entityDefCollection: this.entityDefCollection,
+ fetchFavioriteCollection: this.fetchCollection.bind(this)
+ };
+ },
+ childEvents: function() {
+ return {
+ "item:clicked": function() {
+ this.ui.save.attr('disabled', false);
+ }
+ }
+ },
+ events: function() {
+ var events = {};
+ events['click ' + this.ui.saveAs] = "saveAs";
+ events['click ' + this.ui.save] = "save";
+ return events;
+ },
+ initialize: function(options) {
+ var that = this;
+ _.extend(this, _.pick(options, 'collection', 'value', 'searchVent', 'typeHeaders', 'applyValue', 'getValue', 'isBasic', 'fetchCollection', 'classificationDefCollection', 'entityDefCollection'));
+ },
+ onRender: function() {
+ this.bindEvents();
+ },
+ bindEvents: function() {
+ this.listenTo(this.collection, "add reset error", function(model, collection) {
+ this.$('.fontLoader-relative').hide();
+ if (this.collection && this.collection.length) {
+ this.$(".noFavoriteSearch").hide();
+ } else {
+ this.$(".noFavoriteSearch").show();
+ }
+ }, this);
+ },
+ saveAs: function(e) {
+ var value = this.getValue();
+ if (value && (value.type || value.tag || value.query)) {
+ this.callSaveModalLayoutView({
+ 'collection': this.collection,
+ 'getValue': this.getValue,
+ 'isBasic': this.isBasic
+ });
+ } else {
+ Utils.notifyInfo({
+ content: Messages.search.favoriteSearch.notSelectedSearchFilter
+ })
+ }
+ },
+ save: function() {
+ var that = this,
+ obj = {},
+ notifyObj = {
+ modal: true,
+ html: true,
+ ok: function(argument) {
+ that.callSaveModalLayoutView({
+ 'saveObj': obj,
+ 'collection': that.collection,
+ 'getValue': that.getValue,
+ 'isBasic': that.isBasic
+ })
+ },
+ cancel: function(argument) {}
+ },
+ selectedEl = this.$('.saveSearchList li.active').find('div.item');
+ obj.name = selectedEl.find('a').text();
+ obj.guid = selectedEl.data('id');
+ if (selectedEl && selectedEl.length) {
+ notifyObj['text'] = Messages.search.favoriteSearch.save + " <b>" + obj.name + "</b> ?";
+ Utils.notifyConfirm(notifyObj);
+ } else {
+ Utils.notifyInfo({
+ content: Messages.search.favoriteSearch.notSelectedFavoriteElement
+ })
+ }
+ },
+ callSaveModalLayoutView: function(options) {
+ require([
+ 'views/search/save/SaveModalLayoutView'
+ ], function(SaveModalLayoutView) {
+ new SaveModalLayoutView(options);
+ });
+ }
+ });
+});
\ No newline at end of file