You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by co...@apache.org on 2015/12/04 10:01:52 UTC

incubator-zeppelin git commit: Don't set Dirty state if text is same as last save

Repository: incubator-zeppelin
Updated Branches:
  refs/heads/master ccba2ec2d -> d90e3805b


Don't set Dirty state if text is same as last save

Previous Behavior
![masterbranch](https://cloud.githubusercontent.com/assets/710411/11531309/4696e4ec-993f-11e5-9f4b-ef0fe774e507.gif)

With this PR
![prbranch](https://cloud.githubusercontent.com/assets/710411/11531313/4e0e9c60-993f-11e5-9b47-8b33bb34243c.gif)

Author: Damien CORNEAU <co...@gmail.com>

Closes #505 from corneadoug/improve/saveOnDirty and squashes the following commits:

1c72502 [Damien CORNEAU] Fix run and update cases
95ea650 [Damien CORNEAU] Check that dirtyText is different from originalText before saving


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

Branch: refs/heads/master
Commit: d90e3805bb2d2434bc08672a6227c0afc927f6ae
Parents: ccba2ec
Author: Damien CORNEAU <co...@gmail.com>
Authored: Thu Dec 3 15:55:02 2015 +0900
Committer: Damien CORNEAU <co...@gmail.com>
Committed: Fri Dec 4 18:01:37 2015 +0900

----------------------------------------------------------------------
 .../src/app/notebook/paragraph/paragraph.controller.js      | 9 +++++++--
 zeppelin-web/src/app/notebook/paragraph/paragraph.html      | 3 ++-
 2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/d90e3805/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 a4e7c17..533b9d9 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
@@ -19,6 +19,7 @@ angular.module('zeppelinWebApp')
                                          $timeout, $compile, websocketMsgSrv) {
 
   $scope.paragraph = null;
+  $scope.originalText = '';
   $scope.editor = null;
 
   var editorModes = {
@@ -31,6 +32,7 @@ angular.module('zeppelinWebApp')
   // Controller init
   $scope.init = function(newParagraph) {
     $scope.paragraph = newParagraph;
+    $scope.originalText = angular.copy(newParagraph.text);
     $scope.chart = {};
     $scope.colWidthOption = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ];
     $scope.showTitleEditor = false;
@@ -181,11 +183,13 @@ angular.module('zeppelinWebApp')
           if ($scope.dirtyText === data.paragraph.text ) {  // when local update is the same from remote, clear local update
             $scope.paragraph.text = data.paragraph.text;
             $scope.dirtyText = undefined;
+            $scope.originalText = angular.copy(data.paragraph.text);
           } else { // if there're local update, keep it.
             $scope.paragraph.text = $scope.dirtyText;
           }
         } else {
           $scope.paragraph.text = data.paragraph.text;
+          $scope.originalText = angular.copy(data.paragraph.text);
         }
       }
 
@@ -261,14 +265,16 @@ angular.module('zeppelinWebApp')
   $scope.runParagraph = function(data) {
     websocketMsgSrv.runParagraph($scope.paragraph.id, $scope.paragraph.title,
                                  data, $scope.paragraph.config, $scope.paragraph.settings.params);
+    $scope.originalText = angular.copy(data);
     $scope.dirtyText = undefined;
   };
 
   $scope.saveParagraph = function(){
-    if($scope.dirtyText === undefined){
+    if($scope.dirtyText === undefined || $scope.dirtyText === $scope.originalText){
       return;
     }
     commitParagraph($scope.paragraph.title, $scope.dirtyText, $scope.paragraph.config, $scope.paragraph.settings.params);
+    $scope.originalText = angular.copy($scope.dirtyText);
     $scope.dirtyText = undefined;
   };
 
@@ -459,7 +465,6 @@ angular.module('zeppelinWebApp')
   };
 
   $scope.aceChanged = function() {
-
     $scope.dirtyText = $scope.editor.getSession().getValue();
     $scope.startSaveTimer();
 

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/d90e3805/zeppelin-web/src/app/notebook/paragraph/paragraph.html
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.html b/zeppelin-web/src/app/notebook/paragraph/paragraph.html
index 0edf43e..02c9a38 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.html
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.html
@@ -41,7 +41,8 @@ limitations under the License.
                      require : ['ace/ext/language_tools']
                    }"
            ng-model="paragraph.text"
-           ng-class="{'disable': paragraph.status == 'RUNNING' || paragraph.status == 'PENDING', 'paragraph-text--dirty' : dirtyText !== undefined}">
+           ng-class="{'disable': paragraph.status == 'RUNNING' || paragraph.status == 'PENDING',
+             'paragraph-text--dirty' : dirtyText !== originalText && dirtyText !== undefined}">
       </div>
     </div>