Repository: zeppelin
Updated Branches:
refs/heads/master 14479fd7a -> 9eb580cd3
[ZEPPELIN-1763] Prevent duplicate $scope.$on('setNoteMenu') calls
### What is this PR for?
It's to fix the issue 'ZEPPELIN-1763' (Zeppelin hangs if I repeatedly select
and deselect note name).
When the note name was changed, there was a problem that the 'setNoteName'
listener was registered in duplicate and occupied resources.
To fix it, I moved the function that registers the listener out of
initNoteBook()
### What type of PR is it?
[Bug Fix]
### Todos
### What is the Jira issue?
[ZEPPELIN-1763](https://issues.apache.org/jira/browse/ZEPPELIN-1763?filter=-2)
### How should this be tested?
Repeat changing note name.
### Screenshots (if appropriate)
### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No
The listners are added in duplicate on $scope.$on('setNoteMenu') calls.
Author: Myoungdo Park <[email protected]>
Closes #1770 from cuspymd/note-name-pr2 and squashes the following commits:
2616277 [Myoungdo Park] Fix a style error
99a1031 [Myoungdo Park] Prevent duplicate $scope.$on('setNoteMenu') calls
Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/9eb580cd
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/9eb580cd
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/9eb580cd
Branch: refs/heads/master
Commit: 9eb580cd3207263eb2e8713e58ea8a77c94e5bbb
Parents: 14479fd
Author: Myoungdo Park <[email protected]>
Authored: Fri Dec 16 21:56:39 2016 +0900
Committer: Lee moon soo <[email protected]>
Committed: Sat Dec 17 08:04:34 2016 -0800
----------------------------------------------------------------------
.../src/app/notebook/notebook.controller.js | 10 +++++-----
zeppelin-web/test/spec/controllers/notebook.js | 16 ++++++++++++++++
2 files changed, 21 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9eb580cd/zeppelin-web/src/app/notebook/notebook.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/notebook.controller.js
b/zeppelin-web/src/app/notebook/notebook.controller.js
index 09d1878..6f15d95 100644
--- a/zeppelin-web/src/app/notebook/notebook.controller.js
+++ b/zeppelin-web/src/app/notebook/notebook.controller.js
@@ -112,11 +112,6 @@
var top = $id.offset().top - 103;
angular.element('html, body').scrollTo({top: top, left: 0});
}
-
- // force notebook reload on user change
- $scope.$on('setNoteMenu', function(event, note) {
- initNotebook();
- });
},
1000
);
@@ -125,6 +120,11 @@
initNotebook();
+ // force notebook reload on user change
+ $scope.$on('setNoteMenu', function(event, note) {
+ initNotebook();
+ });
+
$scope.focusParagraphOnClick = function(clickEvent) {
if (!$scope.note) {
return;
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9eb580cd/zeppelin-web/test/spec/controllers/notebook.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/test/spec/controllers/notebook.js
b/zeppelin-web/test/spec/controllers/notebook.js
index 4cd1cda..415b776 100644
--- a/zeppelin-web/test/spec/controllers/notebook.js
+++ b/zeppelin-web/test/spec/controllers/notebook.js
@@ -121,4 +121,20 @@ describe('Controller: NotebookCtrl', function() {
expect(scope.note.name).toEqual(newName);
expect(websocketMsgSrvMock.updateNote).toHaveBeenCalled();
});
+
+ it('should reload note info once per one "setNoteMenu" event', function() {
+ spyOn(websocketMsgSrvMock, 'getNote');
+ spyOn(websocketMsgSrvMock, 'listRevisionHistory');
+
+ scope.$broadcast('setNoteMenu');
+ expect(websocketMsgSrvMock.getNote.calls.count()).toEqual(1);
+ expect(websocketMsgSrvMock.listRevisionHistory.calls.count()).toEqual(1);
+
+ websocketMsgSrvMock.getNote.calls.reset();
+ websocketMsgSrvMock.listRevisionHistory.calls.reset();
+
+ scope.$broadcast('setNoteMenu');
+ expect(websocketMsgSrvMock.getNote.calls.count()).toEqual(1);
+ expect(websocketMsgSrvMock.listRevisionHistory.calls.count()).toEqual(1);
+ });
});