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/11/11 02:51:23 UTC

incubator-zeppelin git commit: ZEPPELIN-265 auto save on page navigation

Repository: incubator-zeppelin
Updated Branches:
  refs/heads/master 6ba4cf96a -> d549165ca


ZEPPELIN-265 auto save on page navigation

Original PR https://github.com/apache/incubator-zeppelin/pull/260
have fixed build/travis issues and merge conflicts here

Author: Prabhjyot Singh <pr...@gmail.com>

Closes #357 from prabhjyotsingh/ZEPPELIN-265 and squashes the following commits:

620caa9 [Prabhjyot Singh] fix for firefox and edge
c20ad34 [Prabhjyot Singh] refactoring jQuery with angualr.element
4002367 [Prabhjyot Singh] ZEPPELIN-265 adding "killSaveTimer" on page upload
dd4b361 [Prabhjyot Singh] ZEPPELIN-265 auto save on page navigation


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

Branch: refs/heads/master
Commit: d549165cafdfc2ec1779f9a0b679abcf11c74adb
Parents: 6ba4cf9
Author: Prabhjyot Singh <pr...@gmail.com>
Authored: Tue Nov 10 14:40:09 2015 +0530
Committer: Damien CORNEAU <co...@gmail.com>
Committed: Wed Nov 11 10:51:02 2015 +0900

----------------------------------------------------------------------
 .../src/app/notebook/notebook.controller.js     | 23 +++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/d549165c/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 dc986a9..ff993cb 100644
--- a/zeppelin-web/src/app/notebook/notebook.controller.js
+++ b/zeppelin-web/src/app/notebook/notebook.controller.js
@@ -108,10 +108,12 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $ro
   };
 
   $scope.saveNote = function() {
-    _.forEach($scope.note.paragraphs, function(n, key) {
-      angular.element('#' + n.id + '_paragraphColumn_main').scope().saveParagraph();
-    });
-    $scope.isNoteDirty = null;
+    if ($scope.note && $scope.note.paragraphs) {
+      _.forEach($scope.note.paragraphs, function(n, key) {
+        angular.element('#' + n.id + '_paragraphColumn_main').scope().saveParagraph();
+      });
+      $scope.isNoteDirty = null;
+    }
   };
 
   $scope.toggleAllEditor = function() {
@@ -161,7 +163,7 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $ro
   };
 
   $scope.killSaveTimer = function() {
-    if($scope.saveTimer){
+    if ($scope.saveTimer) {
       $timeout.cancel($scope.saveTimer);
       $scope.saveTimer = null;
     }
@@ -176,6 +178,17 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $ro
     }, 10000);
   };
 
+  angular.element(window).on('beforeunload', function(e) {
+    $scope.killSaveTimer();
+    $scope.saveNote();
+  });
+
+  $scope.$on('$destroy', function() {
+    angular.element(window).off('beforeunload');
+    $scope.killSaveTimer();
+    $scope.saveNote();
+  });
+
   $scope.setLookAndFeel = function(looknfeel) {
     $scope.note.config.looknfeel = looknfeel;
     $scope.setConfig();