Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
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" />
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
3 changes: 1 addition & 2 deletions zeppelin-web/src/components/navbar/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
<li class="divider"></li>
<div id="notebook-list" class="scrollbar-container">
<li class="filter-names" ng-include="'components/filterNoteNames/filter-note-names.html'"></li>
Copy link
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 | 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>
Expand Down