zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cornead...@apache.org
Subject zeppelin git commit: [ZEPPELIN-869] Search notebook to handle empty result.
Date Wed, 15 Jun 2016 03:37:45 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/master 1587b8686 -> 70ebd328e


[ZEPPELIN-869] Search notebook to handle empty result.

### What is this PR for?
Search notebook to handle empty result.

### What type of PR is it?
Bug Fix
### Todos

### What is the Jira issue?
[ZEPPELIN-869](https://issues.apache.org/jira/browse/ZEPPELIN-869?jql=project%20%3D%20ZEPPELIN%20AND%20text%20~%20%22empty%22)

### How should this be tested?
1. Try to search something which should return empty result, you should get proper message
for that.
2. search box should get cleared when clicked on any other link.

### Screenshots (if appropriate)
Before:
![screen shot 2016-06-09 at 3 44 53 pm](https://cloud.githubusercontent.com/assets/7026661/15926338/25f8924e-2e59-11e6-8c10-2dd9542f5258.png)

After:
![screen shot 2016-06-09 at 3 34 47 pm](https://cloud.githubusercontent.com/assets/7026661/15926303/f1412d7c-2e58-11e6-9dd3-1ecccb938a26.png)
### Questions:
* Does the licenses files need update?No
* Is there breaking changes for older versions?No
* Does this needs documentation?No

Author: Ravi Ranjan <ranjanravi0308@gmail.com>

Closes #978 from ravicodder/ZEPPELIN-869 and squashes the following commits:

cab339d [Ravi Ranjan] Remove controller , add update  searchTerm, remove deregistration function
remove rootscope
7096781 [Ravi Ranjan] Merge branch 'master' of https://github.com/apache/incubator-zeppelin
into ZEPPELIN-869
6c3db2c [Ravi Ranjan] use searchServise in place of rootscope
d2f66a7 [Ravi Ranjan] Merge branch 'master' of https://github.com/apache/incubator-zeppelin
into ZEPPELIN-869
5d5a072 [Ravi Ranjan] add check on searchTerm and clan up scope
7315707 [Ravi Ranjan] Handle empty search


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/70ebd328
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/70ebd328
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/70ebd328

Branch: refs/heads/master
Commit: 70ebd328eebd17e0cdec9774bc86f481f457da58
Parents: 1587b86
Author: Ravi Ranjan <ranjanravi0308@gmail.com>
Authored: Tue Jun 14 14:15:32 2016 +0530
Committer: Damien CORNEAU <corneadoug@gmail.com>
Committed: Wed Jun 15 12:37:22 2016 +0900

----------------------------------------------------------------------
 zeppelin-web/src/app/search/result-list.controller.js  | 13 +++++++++++++
 zeppelin-web/src/app/search/result-list.html           |  8 ++++++--
 zeppelin-web/src/app/search/search.css                 |  9 +++++++++
 .../src/components/navbar/navbar.controller.js         |  6 +++++-
 zeppelin-web/src/components/navbar/navbar.html         | 10 ++++++----
 .../src/components/searchService/search.service.js     |  3 +++
 6 files changed, 42 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/70ebd328/zeppelin-web/src/app/search/result-list.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/search/result-list.controller.js b/zeppelin-web/src/app/search/result-list.controller.js
index bba88f0..2edf9f5 100644
--- a/zeppelin-web/src/app/search/result-list.controller.js
+++ b/zeppelin-web/src/app/search/result-list.controller.js
@@ -18,6 +18,8 @@ angular
   .module('zeppelinWebApp')
   .controller('SearchResultCtrl', function($scope, $routeParams, searchService) {
 
+  $scope.isResult = true ;
+  $scope.searchTerm = $routeParams.searchTerm;
   var results = searchService.search({'q': $routeParams.searchTerm}).query();
 
   results.$promise.then(function(result) {
@@ -34,6 +36,17 @@ angular
 
       return note;
     });
+    if ($scope.notes.length === 0) {
+      $scope.isResult = false;
+    } else {
+      $scope.isResult = true;
+    }
+
+  $scope.$on('$routeChangeStart', function (event, next, current) {
+      if (next.originalPath !== '/search/:searchTerm') {
+        searchService.searchTerm = '';
+      }
+    });
   });
 
   $scope.page = 0;

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/70ebd328/zeppelin-web/src/app/search/result-list.html
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/search/result-list.html b/zeppelin-web/src/app/search/result-list.html
index 87fce53..67b0d7c 100644
--- a/zeppelin-web/src/app/search/result-list.html
+++ b/zeppelin-web/src/app/search/result-list.html
@@ -11,8 +11,8 @@ 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 ng-controller="SearchResultCtrl" class="searchResults">
-  <div class="row">
+<div class="searchResults">
+    <div ng-if="isResult" class="row">
     <div class="col-sm-8" style="margin: 0 auto; float: none">
       <ul class="search-results">
         <li class="panel panel-default" ng-repeat="note in notes">
@@ -37,6 +37,10 @@ limitations under the License.
           </div>
           </div>
        </li>
+      </ul>
     </div>
   </div>
+  <div ng-if="!isResult" class="search-no-result-found">
+      <span class="glyphicon glyphicon-search"></span> We couldn’t find any
notebook matching <b>'{{searchTerm}}' </b>
+  </div>
 </div>

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/70ebd328/zeppelin-web/src/app/search/search.css
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/search/search.css b/zeppelin-web/src/app/search/search.css
index b06b4a9..90a7a3f 100644
--- a/zeppelin-web/src/app/search/search.css
+++ b/zeppelin-web/src/app/search/search.css
@@ -40,3 +40,12 @@
 .search-results .ace_invalid {
   background: none !important;
 }
+
+.search-no-result-found {
+  border: 1px solid;
+  margin: 150px 150px;
+  padding: 15px 10px 15px 0px;
+  color: #00529B;
+  text-align: center;
+  background-color: #f4f6f8;
+}

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/70ebd328/zeppelin-web/src/components/navbar/navbar.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/navbar/navbar.controller.js b/zeppelin-web/src/components/navbar/navbar.controller.js
index e0c242c..e2f40c8 100644
--- a/zeppelin-web/src/components/navbar/navbar.controller.js
+++ b/zeppelin-web/src/components/navbar/navbar.controller.js
@@ -53,7 +53,8 @@ angular.module('zeppelinWebApp')
   };
 })
 .controller('NavCtrl', function($scope, $rootScope, $http, $routeParams,
-    $location, notebookListDataFactory, baseUrlSrv, websocketMsgSrv, arrayOrderingSrv) {
+    $location, notebookListDataFactory, baseUrlSrv, websocketMsgSrv, arrayOrderingSrv, searchService)
{
+
   /** Current list of notes (ids) */
 
   $scope.showLoginWindow = function() {
@@ -62,11 +63,14 @@ angular.module('zeppelinWebApp')
     }, 500);
   };
 
+
   var vm = this;
   vm.notes = notebookListDataFactory;
   vm.connected = websocketMsgSrv.isConnected();
   vm.websocketMsgSrv = websocketMsgSrv;
   vm.arrayOrderingSrv = arrayOrderingSrv;
+  $scope.searchForm = searchService;
+
   if ($rootScope.ticket) {
     $rootScope.fullUsername = $rootScope.ticket.principal;
     $rootScope.truncatedUsername = $rootScope.ticket.principal;

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/70ebd328/zeppelin-web/src/components/navbar/navbar.html
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/navbar/navbar.html b/zeppelin-web/src/components/navbar/navbar.html
index c21be8c..5e7de3b 100644
--- a/zeppelin-web/src/components/navbar/navbar.html
+++ b/zeppelin-web/src/components/navbar/navbar.html
@@ -63,15 +63,17 @@ limitations under the License.
       <ul class="nav navbar-nav navbar-right" style="margin-right:5px;">
         <li ng-if="ticket" style="margin-top:10px;">
         <!--TODO(bzz): move to Typeahead https://angular-ui.github.io/bootstrap  -->
-          <form role="search"
+
+          <form role="search" data-ng-model="searchForm"
             style="display: inline-block; margin: 0px"
              class="navbar-form"
-             ng-submit="search(searchTerm)">
+             ng-submit="search(searchForm.searchTerm)">
             <div class="input-group">
               <input
                 type="text"
                 style="min-width:300px;"
-                ng-model="searchTerm"
+                ng-model="searchForm.searchTerm"
+                id="searchTermId"
                 ng-disabled="!navbar.connected"
                 class="form-control"
                 placeholder="Search your Notebooks"
@@ -80,7 +82,7 @@ limitations under the License.
                 <button
                   type="submit"
                   class="btn btn-default"
-                  ng-disabled="!navbar.connected"
+                  ng-disabled="!navbar.connected || !searchForm.searchTerm"
                 >
                   <i class="glyphicon glyphicon-search"></i>
                 </button>

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/70ebd328/zeppelin-web/src/components/searchService/search.service.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/searchService/search.service.js b/zeppelin-web/src/components/searchService/search.service.js
index 920b5e0..d026404 100644
--- a/zeppelin-web/src/components/searchService/search.service.js
+++ b/zeppelin-web/src/components/searchService/search.service.js
@@ -16,6 +16,7 @@
 angular.module('zeppelinWebApp').service('searchService', function($resource, baseUrlSrv)
{
 
   this.search = function(term) {
+    this.searchTerm = term.q;
      console.log('Searching for: %o', term.q);
     if (!term.q) { //TODO(bzz): empty string check
       return;
@@ -26,4 +27,6 @@ angular.module('zeppelinWebApp').service('searchService', function($resource,
ba
     });
   };
 
+  this.searchTerm = '';
+
 });


Mime
View raw message