Skip to content

Commit 1e1357c

Browse files
felizbearbzz
authored andcommitted
redirect to notebook and scroll to paragraph from search view
1 parent 09d44d2 commit 1e1357c

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

zeppelin-web/src/app/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ angular.module('zeppelinWebApp', [
5151
templateUrl: 'app/notebook/notebook.html',
5252
controller: 'NotebookCtrl'
5353
})
54+
.when('/notebook/:noteId/paragraph?=:paragraphId', {
55+
templateUrl: 'app/notebook/notebook.html',
56+
controller: 'NotebookCtrl'
57+
})
5458
.when('/notebook/:noteId/paragraph/:paragraphId?', {
5559
templateUrl: 'app/notebook/notebook.html',
5660
controller: 'NotebookCtrl'

zeppelin-web/src/app/notebook/notebook.controller.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* jshint loopfunc: true */
2+
/* global $: false */
23
/*
34
* Licensed under the Apache License, Version 2.0 (the "License");
45
* you may not use this file except in compliance with the License.
@@ -14,9 +15,9 @@
1415
*/
1516
'use strict';
1617

17-
angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $route, $routeParams, $location,
18-
$rootScope, $http, websocketMsgSrv, baseUrlSrv,
19-
$timeout, SaveAsService) {
18+
angular.module('zeppelinWebApp').controller('NotebookCtrl',
19+
function($scope, $route, $routeParams, $location, $rootScope, $http,
20+
websocketMsgSrv, baseUrlSrv, $timeout, SaveAsService) {
2021
$scope.note = null;
2122
$scope.showEditor = false;
2223
$scope.editorToggled = false;
@@ -66,6 +67,21 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $ro
6667
/** Init the new controller */
6768
var initNotebook = function() {
6869
websocketMsgSrv.getNotebook($routeParams.noteId);
70+
71+
var currentRoute = $route.current;
72+
73+
if (currentRoute) {
74+
var routeParams = currentRoute.params;
75+
var id = '#' + routeParams.paragraph + '_container';
76+
setTimeout(
77+
function() {
78+
// adjust for navbar
79+
var top = $(id).offset().top - 103;
80+
$('html, body').scrollTo({top: top, left: 0});
81+
},
82+
1000
83+
);
84+
}
6985
};
7086

7187
initNotebook();
@@ -314,11 +330,11 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $ro
314330
$scope.$on('insertParagraph', function(event, paragraphId, position) {
315331
var newIndex = -1;
316332
for (var i=0; i<$scope.note.paragraphs.length; i++) {
317-
if ( $scope.note.paragraphs[i].id === paragraphId ) {
333+
if ( $scope.note.paragraphs[i].id === paragraphId ) {
318334
//determine position of where to add new paragraph; default is below
319-
if ( position === 'above' ) {
335+
if ( position === 'above' ) {
320336
newIndex = i;
321-
} else {
337+
} else {
322338
newIndex = i+1;
323339
}
324340
break;

zeppelin-web/src/app/search/result-list.controller.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ angular
2020

2121
var results = searchService.search({'q': $routeParams.searchTerm}).query();
2222

23-
console.log('Found: %o', results);
2423
results.$promise.then(function(result) {
25-
$scope.notes = result.body;
24+
$scope.notes = result.body.map(function(note) {
25+
note.id = note.id.replace('paragraph/', '?paragraph=') +
26+
'&term=' +
27+
$routeParams.searchTerm;
28+
29+
return note;
30+
});
2631
});
2732

2833
$scope.page = 0;

0 commit comments

Comments
 (0)