You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by co...@apache.org on 2016/06/14 01:49:50 UTC

zeppelin git commit: filtering subdirectory names.

Repository: zeppelin
Updated Branches:
  refs/heads/master bda1cc561 -> aeb34fb34


filtering subdirectory names.

### What is this PR for?
It needs to filtering subdirectory names in navbar.

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

### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-886

### How should this be tested?
try filter the note name on navbar.

### Screenshots (if appropriate)
![gif](https://cloud.githubusercontent.com/assets/3348133/15806159/31026fc2-2b78-11e6-936c-562ae4cdddd6.gif)

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: astroshim <hs...@nflabs.com>

Closes #964 from astroshim/ZEPPELIN-886 and squashes the following commits:

7b7b260 [astroshim] code refatoring
d963af8 [astroshim] add space.
3337385 [astroshim] fix jshint error
1167d0d [astroshim] filtering subdirectory names.


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

Branch: refs/heads/master
Commit: aeb34fb342d025b5d9746a8e7b06d3f50f5f0245
Parents: bda1cc5
Author: astroshim <hs...@nflabs.com>
Authored: Sat Jun 11 00:58:35 2016 +0900
Committer: Damien CORNEAU <co...@gmail.com>
Committed: Tue Jun 14 10:49:37 2016 +0900

----------------------------------------------------------------------
 .../filterNoteNames/filter-note-names.html      |  2 +-
 .../src/components/navbar/navbar.controller.js  | 40 +++++++++++++++++++-
 zeppelin-web/src/components/navbar/navbar.html  |  3 +-
 3 files changed, 41 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/aeb34fb3/zeppelin-web/src/components/filterNoteNames/filter-note-names.html
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/filterNoteNames/filter-note-names.html b/zeppelin-web/src/components/filterNoteNames/filter-note-names.html
index a354cda..f8fd22f 100644
--- a/zeppelin-web/src/components/filterNoteNames/filter-note-names.html
+++ b/zeppelin-web/src/components/filterNoteNames/filter-note-names.html
@@ -11,4 +11,4 @@ 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.
 -->
-<input type="text" class="note-name-query form-control" ng-click="$event.stopPropagation()" placeholder="&#xf002 Filter" ng-model="$parent.query.name" />
+<input type="text" class="note-name-query form-control" ng-click="$event.stopPropagation()" placeholder="&#xf002 Filter" ng-model="$parent.query" />

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/aeb34fb3/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 e750162..e0c242c 100644
--- a/zeppelin-web/src/components/navbar/navbar.controller.js
+++ b/zeppelin-web/src/components/navbar/navbar.controller.js
@@ -14,7 +14,45 @@
 
 'use strict';
 
-angular.module('zeppelinWebApp').controller('NavCtrl', function($scope, $rootScope, $http, $routeParams,
+angular.module('zeppelinWebApp')
+.filter('notebookFilter', function() {
+  return function (notebooks, searchText)
+  {
+    if (!searchText) {
+      return notebooks;
+    }
+
+    var filteringNote = function(notebooks, filteredNotes) {
+      _.each(notebooks, function(notebook) {
+
+        if (notebook.name.toLowerCase().indexOf(searchText) !== -1) {
+          filteredNotes.push(notebook);
+          return notebook;
+        }
+
+        if (notebook.children) { 
+          filteringNote(notebook.children, filteredNotes);
+        }
+      });
+    };
+
+    return _.filter(notebooks, function(notebook) {
+      if (notebook.children) {
+        var filteredNotes = [];
+        filteringNote(notebook.children, filteredNotes);
+
+        if (filteredNotes.length > 0) {
+          return filteredNotes;
+        }
+      }
+
+      if (notebook.name.toLowerCase().indexOf(searchText) !== -1) {
+        return notebook;
+      }
+    });
+  };
+})
+.controller('NavCtrl', function($scope, $rootScope, $http, $routeParams,
     $location, notebookListDataFactory, baseUrlSrv, websocketMsgSrv, arrayOrderingSrv) {
   /** Current list of notes (ids) */
 

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/aeb34fb3/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 71868f2..c21be8c 100644
--- a/zeppelin-web/src/components/navbar/navbar.html
+++ b/zeppelin-web/src/components/navbar/navbar.html
@@ -44,8 +44,7 @@ limitations under the License.
             <li class="divider"></li>
             <div id="notebook-list" class="scrollbar-container">
               <li class="filter-names" ng-include="'components/filterNoteNames/filter-note-names.html'"></li>
-              <li ng-repeat="note in navbar.notes.root.children | filter:query track by $index" ng-class="{'active' : navbar.isActive(note.id)}" ng-include="'notebook_list_renderer.html'">
-              </li>
+              <li ng-repeat="note in navbar.notes.root.children |notebookFilter:query track by $index" ng-class="{'active' : navbar.isActive(note.id)}" ng-include="'notebook_list_renderer.html'"></li>
             </div>
           </ul>
         </li>