mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Search: add search/result-list and switch to
This commit is contained in:
parent
bc2458a24d
commit
163a465e17
8 changed files with 73 additions and 16 deletions
|
|
@ -11,6 +11,7 @@
|
|||
"angular-animate": "1.3.8",
|
||||
"angular-touch": "1.3.8",
|
||||
"angular-route": "1.3.8",
|
||||
"angular-resource": "1.3.8",
|
||||
"angular-bootstrap": "~0.13.0",
|
||||
"angular-websocket": "~1.0.13",
|
||||
"ace-builds": "1.1.9",
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ angular.module('zeppelinWebApp', [
|
|||
'puElasticInput',
|
||||
'xeditable',
|
||||
'ngToast',
|
||||
'focus-if'
|
||||
'focus-if',
|
||||
'ngResource'
|
||||
])
|
||||
.filter('breakFilter', function() {
|
||||
return function (text) {
|
||||
|
|
@ -58,6 +59,10 @@ angular.module('zeppelinWebApp', [
|
|||
templateUrl: 'app/interpreter/interpreter.html',
|
||||
controller: 'InterpreterCtrl'
|
||||
})
|
||||
.when('/search/:searchTerm', {
|
||||
templateUrl: 'app/search/result-list.html',
|
||||
controller: 'SearchResultCtrl'
|
||||
})
|
||||
.otherwise({
|
||||
redirectTo: '/'
|
||||
});
|
||||
|
|
|
|||
29
zeppelin-web/src/app/search/result-list.controller.js
Normal file
29
zeppelin-web/src/app/search/result-list.controller.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* jshint loopfunc: true */
|
||||
/*
|
||||
* 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').controller('SearchResultCtrl', function($scope, $routeParams, searchService) {
|
||||
|
||||
var results = searchService.search({'q': $routeParams.searchTerm}).query();
|
||||
|
||||
console.log("Found: %o", results);
|
||||
results.$promise.then(function(result) {
|
||||
$scope.notes = result.body;
|
||||
});
|
||||
console.log("Found body: %o", $scope.notes);
|
||||
|
||||
$scope.page = 0;
|
||||
$scope.allResults = false;
|
||||
});
|
||||
27
zeppelin-web/src/app/search/result-list.html
Normal file
27
zeppelin-web/src/app/search/result-list.html
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<!--
|
||||
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.
|
||||
-->
|
||||
<div ng-controller="SearchResultCtrl" class="searchResults">
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-3">
|
||||
<ul style="list-style-type: none; margin-top: 10%;">
|
||||
<li ng-repeat="note in notes">
|
||||
<i style="font-size: 10px;" class="icon-doc"></i>
|
||||
<a style="text-decoration: none;"
|
||||
href="#/notebook/{{note.id}}">
|
||||
{{note.name || 'Note ' + note.id}}
|
||||
</a>
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('zeppelinWebApp').controller('NavCtrl', function($scope, $rootScope, $routeParams,
|
||||
notebookListDataFactory, websocketMsgSrv,arrayOrderingSrv, searchService) {
|
||||
$location, notebookListDataFactory, websocketMsgSrv, arrayOrderingSrv) {
|
||||
/** Current list of notes (ids) */
|
||||
|
||||
var vm = this;
|
||||
|
|
@ -35,10 +35,7 @@ angular.module('zeppelinWebApp').controller('NavCtrl', function($scope, $rootSco
|
|||
});
|
||||
|
||||
$scope.search = function() {
|
||||
$scope.page = 0;
|
||||
$scope.recipes = [];
|
||||
$scope.allResults = false;
|
||||
searchService.search({'q': $scope.searchTerm});
|
||||
$location.url(/search/ + $scope.searchTerm);
|
||||
};
|
||||
|
||||
function loadNotes() {
|
||||
|
|
|
|||
|
|
@ -13,22 +13,17 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
angular.module('zeppelinWebApp').service('searchService', function($http, baseUrlSrv) {
|
||||
angular.module('zeppelinWebApp').service('searchService', function($resource, baseUrlSrv) {
|
||||
|
||||
this.search = function(term) {
|
||||
console.log('Searching for: %o', term.q);
|
||||
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.data.body);
|
||||
//TODO(bzz): navigate to SearchResult page/controller
|
||||
}, function errorCallback(response) {
|
||||
console.log('Error: %o', response);
|
||||
});
|
||||
return $resource(baseUrlSrv.getRestApiBase()+'/notebook/search?q='+encQuery, {}, {
|
||||
query: {method:'GET'}
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ limitations under the License.
|
|||
<script src="bower_components/angular-animate/angular-animate.js"></script>
|
||||
<script src="bower_components/angular-touch/angular-touch.js"></script>
|
||||
<script src="bower_components/angular-route/angular-route.js"></script>
|
||||
<script src="bower_components/angular-resource/angular-resource.js"></script>
|
||||
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
|
||||
<script src="bower_components/angular-websocket/angular-websocket.min.js"></script>
|
||||
<script src="bower_components/ace-builds/src-noconflict/ace.js"></script>
|
||||
|
|
@ -131,6 +132,7 @@ limitations under the License.
|
|||
<script src="app/notebook/notebook.controller.js"></script>
|
||||
<script src="app/interpreter/interpreter.controller.js"></script>
|
||||
<script src="app/notebook/paragraph/paragraph.controller.js"></script>
|
||||
<script src="app/search/result-list.controller.js"></script>
|
||||
<script src="components/arrayOrderingSrv/arrayOrdering.service.js"></script>
|
||||
<script src="components/navbar/navbar.controller.js"></script>
|
||||
<script src="components/ngescape/ngescape.directive.js"></script>
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ module.exports = function(config) {
|
|||
'bower_components/angular-animate/angular-animate.js',
|
||||
'bower_components/angular-touch/angular-touch.js',
|
||||
'bower_components/angular-route/angular-route.js',
|
||||
'bower_components/angular-resource/angular-resource.js',
|
||||
'bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
|
||||
'bower_components/angular-websocket/angular-websocket.min.js',
|
||||
'bower_components/ace-builds/src-noconflict/ace.js',
|
||||
|
|
|
|||
Loading…
Reference in a new issue