Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion zeppelin-web/src/components/navbar/navbar.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) */

Expand Down
5 changes: 2 additions & 3 deletions zeppelin-web/src/components/navbar/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@
<li><a href="" data-toggle="modal" data-target="#noteNameModal"><i class="fa fa-plus"></i> Create new note</a></li>
<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 class="filter-names"><input type="text" class="note-name-query form-control" ng-click="$event.stopPropagation()" placeholder="&#xf002 Filter" ng-model="searchQuery"> </li>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make keep that line, and modify filter-note-names.html to have ng-model="$parent.query"

<li ng-repeat="note in navbar.notes.root.children |notebookFilter:searchQuery track by $index" ng-class="{'active' : navbar.isActive(note.id)}" ng-include="'notebook_list_renderer.html'"></li>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After previous comment, we should have | notebookFilter:query instead of |notebookFilter:searchQuery

@astroshim astroshim Jun 10, 2016

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review. I'll update the name.

</div>
</ul>
</li>
Expand Down