Repository: zeppelin
Updated Branches:
  refs/heads/branch-0.7 4021520f7 -> 42af64bb9


[ZEPPELIN-1492] fixing the issue where updating a paragraph was not propagated 
correctly

This pull request fixes two issues regarding paragraphs not being updated and 
therefore overwritten unintentionally. The first issue yields to local changes 
being overwritten when remote changes are made. The second issue yields to 
changes being overwritten when, e.g., the notebook is renamed.

The first change happens in the `updateParagraph` broadcast event handler 
function. This function has the purpose to update the local state of the 
paragraph in the paragraph controller scope when there is an update from the 
web socket.

However, it did not update the state if the only thing that has changed was the 
text. Now it will, which fixes the original issue in the issue description. 
This was one of the issues identified by 
https://issues.apache.org/jira/browse/ZEPPELIN-1492?focusedCommentId=15744928&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15744928

The second issue is fixed by saving the paragraph when the editor loses focus.

Bug Fix

- https://issues.apache.org/jira/browse/ZEPPELIN-1492

The first issue can be reproduced with the following two browser-windows and a 
single notebook.

Browser A:

```
%pyspark
print "Original Zeppelin Notebook"
```

In Browser B, edit the notebook and the above command to:

```
%pyspark
print "Notebook is updated...."
```

If I run the notebook via browser A followed by Browser B, everything is 
updated nicely. Now also if I you add the following line to the Notebook though 
Browser B:

```
print "....once again"
```

and run the notebook through Browser B again, the content in Browser A will be 
updated.

The second issue can be reproduced by editing a cell without executing it and 
renaming the notebook right afterwards. The rename will reset your cell to the 
previous state. With the fix, your state is saved.

Author: Frank Rosner <[email protected]>

Closes #2120 from FRosner/ZEPPELIN-1492 and squashes the following commits:

be28a5d [Frank Rosner] ZEPPELIN-1492 save paragraph on editor blur
4a0cf72 [Frank Rosner] ZEPPELIN-1492 newPara is already a paragraph I guess :S
c5c53fd [Frank Rosner] ZEPPELIN-1492 also update paragraph if the text has 
changed

(cherry picked from commit c23aa88717488788d88305f34a36ee9cddc90152)
Signed-off-by: Lee moon soo <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/42af64bb
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/42af64bb
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/42af64bb

Branch: refs/heads/branch-0.7
Commit: 42af64bb9d7a90f06a4ece07b7d9d6b59457466b
Parents: 4021520
Author: Frank Rosner <[email protected]>
Authored: Mon Mar 13 11:32:08 2017 +0100
Committer: Lee moon soo <[email protected]>
Committed: Wed Apr 5 04:59:30 2017 +0900

----------------------------------------------------------------------
 zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/42af64bb/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js 
b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
index c40a56d..5e1d5c5 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
@@ -554,6 +554,7 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, 
$routeParams, $locat
 
       $scope.editor.on('blur', function() {
         handleFocus(false);
+        $scope.saveParagraph($scope.paragraph);
       });
 
       $scope.editor.on('paste', function(e) {
@@ -993,6 +994,7 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, 
$routeParams, $locat
   $scope.$on('updateParagraph', function(event, data) {
     if (data.paragraph.id === $scope.paragraph.id &&
       (data.paragraph.dateCreated !== $scope.paragraph.dateCreated ||
+      data.paragraph.text !== $scope.paragraph.text ||
       data.paragraph.dateFinished !== $scope.paragraph.dateFinished ||
       data.paragraph.dateStarted !== $scope.paragraph.dateStarted ||
       data.paragraph.dateUpdated !== $scope.paragraph.dateUpdated ||

Reply via email to