Search: form added to navbar in frontend

This commit is contained in:
Alexander Bezzubov 2015-11-19 18:39:46 +09:00
parent 42100550f3
commit c5928f9fa1
4 changed files with 58 additions and 2 deletions

View file

@ -15,8 +15,7 @@
'use strict';
angular.module('zeppelinWebApp').controller('NavCtrl', function($scope, $rootScope, $routeParams,
notebookListDataFactory, websocketMsgSrv,
arrayOrderingSrv) {
notebookListDataFactory, websocketMsgSrv,arrayOrderingSrv, searchService) {
/** Current list of notes (ids) */
var vm = this;
@ -35,6 +34,13 @@ angular.module('zeppelinWebApp').controller('NavCtrl', function($scope, $rootSco
vm.connected = param;
});
$scope.search = function() {
$scope.page = 0;
$scope.recipes = [];
$scope.allResults = false;
searchService.search({'q': $scope.searchTerm});
};
function loadNotes() {
websocketMsgSrv.getNotebookList();
}

View file

@ -43,6 +43,21 @@ limitations under the License.
<a href="#/interpreter">Interpreter</a>
</li>
</ul>
<!--TODO(bzz): move to Typeahead https://angular-ui.github.io/bootstrap -->
<form role="search"
class="navbar-form navbar-left navbar-input-group"
ng-submit="search()">
<div class="form-group">
<input type="text" ng-model="searchTerm"
class="form-control" placeholder="Search your notebooks">
</div>
<button type="submit" class="btn btn-default">
Search
</button>
</form>
<ul class="nav navbar-nav navbar-right" style="margin-top:10px; margin-right:5px;">
<li class="server-status">
<i class="fa fa-circle" ng-class="{'server-connected':navbar.connected, 'server-disconnected':!navbar.connected}"></i>

View file

@ -0,0 +1,34 @@
/*
* Licensed 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.
*/
'use strict';
angular.module('zeppelinWebApp').service('searchService', function($http, baseUrlSrv) {
this.search = function(term) {
if (!term.q) { //TODO(bzz): empty string check
return;
}
console.log('Searching for %o', term.q);
var encQuery = window.encodeURIComponent(term.q);
$http
.get(baseUrlSrv.getRestApiBase() + '/notebook/search?q=' + encQuery)
.then(function successCallback(response) {
console.log('Found: %o', response);
//TODO(bzz): navigate to SearchResult page/controller
}, function errorCallback(response) {
console.log('Error: %o', response);
});
};
});

View file

@ -147,6 +147,7 @@ limitations under the License.
<script src="components/baseUrl/baseUrl.service.js"></script>
<script src="components/browser-detect/browserDetect.service.js"></script>
<script src="components/saveAs/saveAs.service.js"></script>
<script src="components/searchService/search.service.js"></script>
<!-- endbuild -->
</body>
</html>