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 2016/10/03 08:58:35 UTC

[3/3] zeppelin git commit: [Zeppelin-1496] Apply Zeppelin-Web Good Practice Guide #1 to the code

[Zeppelin-1496] Apply Zeppelin-Web Good Practice Guide #1 to the code

### What is this PR for?
This is some refactoring of zeppelin-web to apply the IIFE as stated in the Good Practice Guide #1 (https://zeppelin.apache.org/contribution/zeppelinweb/goodPracticeGuide01.html)

### What type of PR is it?
Refactoring

### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-1496

### How should this be tested?
Run The webapp, and go around the page, things should work like usual.
But overall, just need to check that there is no type or parameter mismatch during the refactoring process (controller to controller, params in $inject etc...)

### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

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

Closes #1469 from corneadoug/ZEPPELIN-1496 and squashes the following commits:

966cb27 [Damien CORNEAU] refactor components controllers
1807cf6 [Damien CORNEAU] Refactor components directives
0055191 [Damien CORNEAU] Refactor components service and factory
f86adb4 [Damien CORNEAU] Finish refactoring of App
409c65c [Damien CORNEAU] IIFE refactoring of job page
4c45e08 [Damien CORNEAU] Refactor for IIFE credential, home and interpreter controller
7e88eef [Damien CORNEAU] Add congiguration.controller.js
6adb522 [Damien CORNEAU] Move use strict outside IFFE
ffba0f3 [Damien CORNEAU] Add IIFE to app.controller.js


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

Branch: refs/heads/master
Commit: a9e7bc381a2f4d0dcabf153709291a3687a75087
Parents: 23a7e1b
Author: Damien CORNEAU <co...@gmail.com>
Authored: Wed Sep 28 17:56:28 2016 +0900
Committer: Damien CORNEAU <co...@gmail.com>
Committed: Mon Oct 3 17:58:42 2016 +0900

----------------------------------------------------------------------
 zeppelin-web/src/app/app.controller.js          |   89 +-
 .../configuration/configuration.controller.js   |   63 +-
 .../src/app/credential/credential.controller.js |  247 +-
 zeppelin-web/src/app/home/home.controller.js    |  109 +-
 .../app/interpreter/interpreter.controller.js   |   12 +-
 .../src/app/interpreter/interpreter.filter.js   |   17 +-
 .../src/app/jobmanager/jobmanager.controller.js |  120 +-
 .../src/app/jobmanager/jobs/job.controller.js   |   10 +-
 .../src/app/notebook/notebook.controller.js     | 1450 +++---
 .../notebook/paragraph/paragraph.controller.js  | 4752 +++++++++---------
 .../src/app/search/result-list.controller.js    |   12 +-
 .../arrayOrderingSrv/arrayOrdering.service.js   |   29 +-
 .../src/components/baseUrl/baseUrl.service.js   |   57 +-
 .../browser-detect/browserDetect.service.js     |   49 +-
 .../dropdowninput/dropdowninput.directive.js    |   25 +-
 .../elasticInputCtrl/elasticInput.controller.js |   14 +-
 .../expandCollapse/expandCollapse.directive.js  |   37 +-
 .../interpreter/interpreter.directive.js        |   31 +-
 .../src/components/login/login.controller.js    |   12 +-
 .../src/components/navbar/navbar.controller.js  |  177 +-
 .../src/components/ngenter/ngenter.directive.js |   31 +-
 .../components/ngescape/ngescape.directive.js   |   29 +-
 .../noteName-create/notename.controller.js      |  131 +-
 .../noteName-create/visible.directive.js        |   61 +-
 .../notenameImport.controller.js                |  227 +-
 .../notebookList.datafactory.js                 |   88 +-
 .../popover-html-unsafe-popup.directive.js      |   28 +
 .../popover-html-unsafe.directive.js            |   19 +-
 .../components/resizable/resizable.directive.js |  100 +-
 .../src/components/saveAs/saveAs.service.js     |   68 +-
 .../components/searchService/search.service.js  |   33 +-
 .../websocketEvents/websocketEvents.factory.js  |  262 +-
 .../websocketEvents/websocketMsg.service.js     |  429 +-
 zeppelin-web/src/index.html                     |    1 +
 34 files changed, 4523 insertions(+), 4296 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a9e7bc38/zeppelin-web/src/app/app.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/app.controller.js b/zeppelin-web/src/app/app.controller.js
index ff30b82..c51a72a 100644
--- a/zeppelin-web/src/app/app.controller.js
+++ b/zeppelin-web/src/app/app.controller.js
@@ -12,45 +12,52 @@
  * limitations under the License.
  */
 'use strict';
+(function() {
 
-angular.module('zeppelinWebApp').controller('MainCtrl', function($scope, $rootScope, $window, arrayOrderingSrv) {
-  $scope.looknfeel = 'default';
-
-  var init = function() {
-    $scope.asIframe = (($window.location.href.indexOf('asIframe') > -1) ? true : false);
-  };
-
-  init();
-
-  $rootScope.$on('setIframe', function(event, data) {
-    if (!event.defaultPrevented) {
-      $scope.asIframe = data;
-      event.preventDefault();
-    }
-  });
-
-  $rootScope.$on('setLookAndFeel', function(event, data) {
-    if (!event.defaultPrevented && data && data !== '' && data !== $scope.looknfeel) {
-      $scope.looknfeel = data;
-      event.preventDefault();
-    }
-  });
-
-  // Set The lookAndFeel to default on every page
-  $rootScope.$on('$routeChangeStart', function(event, next, current) {
-    $rootScope.$broadcast('setLookAndFeel', 'default');
-  });
-
-  $rootScope.noteName = function(note) {
-    if (!_.isEmpty(note)) {
-      return arrayOrderingSrv.getNoteName(note);
-    }
-  };
-
-  BootstrapDialog.defaultOptions.onshown = function() {
-    angular.element('#' + this.id).find('.btn:last').focus();
-  };
-
-  // Remove BootstrapDialog animation
-  BootstrapDialog.configDefaultOptions({animate: false});
-});
+  angular.module('zeppelinWebApp').controller('MainCtrl', MainCtrl);
+
+  MainCtrl.$inject = ['$scope', '$rootScope', '$window', 'arrayOrderingSrv'];
+
+  function MainCtrl($scope, $rootScope, $window, arrayOrderingSrv) {
+    $scope.looknfeel = 'default';
+
+    var init = function() {
+      $scope.asIframe = (($window.location.href.indexOf('asIframe') > -1) ? true : false);
+    };
+
+    init();
+
+    $rootScope.$on('setIframe', function(event, data) {
+      if (!event.defaultPrevented) {
+        $scope.asIframe = data;
+        event.preventDefault();
+      }
+    });
+
+    $rootScope.$on('setLookAndFeel', function(event, data) {
+      if (!event.defaultPrevented && data && data !== '' && data !== $scope.looknfeel) {
+        $scope.looknfeel = data;
+        event.preventDefault();
+      }
+    });
+
+    // Set The lookAndFeel to default on every page
+    $rootScope.$on('$routeChangeStart', function(event, next, current) {
+      $rootScope.$broadcast('setLookAndFeel', 'default');
+    });
+
+    $rootScope.noteName = function(note) {
+      if (!_.isEmpty(note)) {
+        return arrayOrderingSrv.getNoteName(note);
+      }
+    };
+
+    BootstrapDialog.defaultOptions.onshown = function() {
+      angular.element('#' + this.id).find('.btn:last').focus();
+    };
+
+    // Remove BootstrapDialog animation
+    BootstrapDialog.configDefaultOptions({animate: false});
+  }
+
+})();

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a9e7bc38/zeppelin-web/src/app/configuration/configuration.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/configuration/configuration.controller.js b/zeppelin-web/src/app/configuration/configuration.controller.js
index 8f11879..611575e 100644
--- a/zeppelin-web/src/app/configuration/configuration.controller.js
+++ b/zeppelin-web/src/app/configuration/configuration.controller.js
@@ -11,36 +11,41 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-'use strict';
+ 'use strict';
+(function() {
 
-angular.module('zeppelinWebApp').controller('ConfigurationCtrl', function($scope, $rootScope, $http,
-                                                                          baseUrlSrv, ngToast) {
-  $scope.configrations = [];
-  $scope._ = _;
+  angular.module('zeppelinWebApp').controller('ConfigurationCtrl', ConfigurationCtrl);
 
-  var getConfigurations = function() {
-    $http.get(baseUrlSrv.getRestApiBase() + '/configurations/all').
-    success(function(data, status, headers, config) {
-      $scope.configurations = data.body;
-    }).
-    error(function(data, status, headers, config) {
-      if (status === 401) {
-        ngToast.danger({
-          content: 'You don\'t have permission on this page',
-          verticalPosition: 'bottom',
-          timeout: '3000'
-        });
-        setTimeout(function() {
-          window.location.replace('/');
-        }, 3000);
-      }
-      console.log('Error %o %o', status, data.message);
-    });
-  };
+  ConfigurationCtrl.$inject = ['$scope', '$rootScope', '$http', 'baseUrlSrv', 'ngToast'];
 
-  var init = function() {
-    getConfigurations();
-  };
+  function ConfigurationCtrl($scope, $rootScope, $http, baseUrlSrv, ngToast) {
+    $scope.configrations = [];
+    $scope._ = _;
 
-  init();
-});
+    var getConfigurations = function() {
+      $http.get(baseUrlSrv.getRestApiBase() + '/configurations/all').
+      success(function(data, status, headers, config) {
+        $scope.configurations = data.body;
+      }).
+      error(function(data, status, headers, config) {
+        if (status === 401) {
+          ngToast.danger({
+            content: 'You don\'t have permission on this page',
+            verticalPosition: 'bottom',
+            timeout: '3000'
+          });
+          setTimeout(function() {
+            window.location.replace('/');
+          }, 3000);
+        }
+        console.log('Error %o %o', status, data.message);
+      });
+    };
+
+    var init = function() {
+      getConfigurations();
+    };
+
+    init();
+  }
+})();

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a9e7bc38/zeppelin-web/src/app/credential/credential.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/credential/credential.controller.js b/zeppelin-web/src/app/credential/credential.controller.js
index b831805..bfb8bba 100644
--- a/zeppelin-web/src/app/credential/credential.controller.js
+++ b/zeppelin-web/src/app/credential/credential.controller.js
@@ -12,145 +12,152 @@
  * limitations under the License.
  */
 'use strict';
+(function() {
 
-angular.module('zeppelinWebApp').controller('CredentialCtrl', function($scope, $rootScope, $http, baseUrlSrv, ngToast) {
-  $scope._ = _;
+  angular.module('zeppelinWebApp').controller('CredentialCtrl', CredentialCtrl);
 
-  $scope.credentialInfo = [];
-  $scope.showAddNewCredentialInfo = false;
+  CredentialCtrl.$inject = ['$scope', '$rootScope', '$http', 'baseUrlSrv', 'ngToast'];
 
-  var getCredentialInfo = function() {
-    $http.get(baseUrlSrv.getRestApiBase() + '/credential').
-    success(function(data, status, headers, config) {
-      $scope.credentialInfo  = _.map(data.body.userCredentials, function(value, prop) {
-        return {entity: prop, password: value.password, username: value.username};
+  function CredentialCtrl($scope, $rootScope, $http, baseUrlSrv, ngToast) {
+    $scope._ = _;
+
+    $scope.credentialInfo = [];
+    $scope.showAddNewCredentialInfo = false;
+
+    var getCredentialInfo = function() {
+      $http.get(baseUrlSrv.getRestApiBase() + '/credential').
+      success(function(data, status, headers, config) {
+        $scope.credentialInfo  = _.map(data.body.userCredentials, function(value, prop) {
+          return {entity: prop, password: value.password, username: value.username};
+        });
+        console.log('Success %o %o', status, $scope.credentialInfo);
+      }).
+      error(function(data, status, headers, config) {
+        if (status === 401) {
+          ngToast.danger({
+            content: 'You don\'t have permission on this page',
+            verticalPosition: 'bottom',
+            timeout: '3000'
+          });
+          setTimeout(function() {
+            window.location.replace('/');
+          }, 3000);
+        }
+        console.log('Error %o %o', status, data.message);
       });
-      console.log('Success %o %o', status, $scope.credentialInfo);
-    }).
-    error(function(data, status, headers, config) {
-      if (status === 401) {
+    };
+
+    $scope.addNewCredentialInfo = function() {
+      if ($scope.entity && _.isEmpty($scope.entity.trim()) &&
+        $scope.username && _.isEmpty($scope.username.trim())) {
         ngToast.danger({
-          content: 'You don\'t have permission on this page',
+          content: 'Username \\ Entity can not be empty.',
           verticalPosition: 'bottom',
           timeout: '3000'
         });
-        setTimeout(function() {
-          window.location.replace('/');
-        }, 3000);
+        return;
       }
-      console.log('Error %o %o', status, data.message);
-    });
-  };
-
-  $scope.addNewCredentialInfo = function() {
-    if ($scope.entity && _.isEmpty($scope.entity.trim()) &&
-      $scope.username && _.isEmpty($scope.username.trim())) {
-      ngToast.danger({
-        content: 'Username \\ Entity can not be empty.',
-        verticalPosition: 'bottom',
-        timeout: '3000'
-      });
-      return;
-    }
 
-    var newCredential  = {
-      'entity': $scope.entity,
-      'username': $scope.username,
-      'password': $scope.password
-    };
+      var newCredential  = {
+        'entity': $scope.entity,
+        'username': $scope.username,
+        'password': $scope.password
+      };
 
-    $http.put(baseUrlSrv.getRestApiBase() + '/credential', newCredential).
-    success(function(data, status, headers, config) {
-      ngToast.success({
-        content: 'Successfully saved credentials.',
-        verticalPosition: 'bottom',
-        timeout: '3000'
+      $http.put(baseUrlSrv.getRestApiBase() + '/credential', newCredential).
+      success(function(data, status, headers, config) {
+        ngToast.success({
+          content: 'Successfully saved credentials.',
+          verticalPosition: 'bottom',
+          timeout: '3000'
+        });
+        $scope.credentialInfo.push(newCredential);
+        resetCredentialInfo();
+        $scope.showAddNewCredentialInfo = false;
+        console.log('Success %o %o', status, data.message);
+      }).
+      error(function(data, status, headers, config) {
+        ngToast.danger({
+          content: 'Error saving credentials',
+          verticalPosition: 'bottom',
+          timeout: '3000'
+        });
+        console.log('Error %o %o', status, data.message);
       });
-      $scope.credentialInfo.push(newCredential);
-      resetCredentialInfo();
+    };
+
+    $scope.cancelCredentialInfo = function() {
       $scope.showAddNewCredentialInfo = false;
-      console.log('Success %o %o', status, data.message);
-    }).
-    error(function(data, status, headers, config) {
-      ngToast.danger({
-        content: 'Error saving credentials',
-        verticalPosition: 'bottom',
-        timeout: '3000'
-      });
-      console.log('Error %o %o', status, data.message);
-    });
-  };
+      resetCredentialInfo();
+    };
 
-  $scope.cancelCredentialInfo = function() {
-    $scope.showAddNewCredentialInfo = false;
-    resetCredentialInfo();
-  };
-
-  var resetCredentialInfo = function() {
-    $scope.entity = '';
-    $scope.username = '';
-    $scope.password = '';
-  };
-
-  $scope.copyOriginCredentialsInfo = function() {
-    ngToast.info({
-      content: 'Since entity is a unique key, you can edit only username & password',
-      verticalPosition: 'bottom',
-      timeout: '3000'
-    });
-  };
-
-  $scope.updateCredentialInfo = function(form, data, entity) {
-    var request = {
-      entity: entity,
-      username: data.username,
-      password: data.password
+    var resetCredentialInfo = function() {
+      $scope.entity = '';
+      $scope.username = '';
+      $scope.password = '';
     };
 
-    $http.put(baseUrlSrv.getRestApiBase() + '/credential/', request).
-    success(function(data, status, headers, config) {
-      var index = _.findIndex($scope.credentialInfo, {'entity': entity});
-      $scope.credentialInfo[index] = request;
-      return true;
-    }).
-    error(function(data, status, headers, config) {
-      console.log('Error %o %o', status, data.message);
-      ngToast.danger({
-        content: 'We couldn\'t save the credential',
+    $scope.copyOriginCredentialsInfo = function() {
+      ngToast.info({
+        content: 'Since entity is a unique key, you can edit only username & password',
         verticalPosition: 'bottom',
         timeout: '3000'
       });
-      form.$show();
-    });
-    return false;
-  };
-
-  $scope.removeCredentialInfo = function(entity) {
-    BootstrapDialog.confirm({
-      closable: false,
-      closeByBackdrop: false,
-      closeByKeyboard: false,
-      title: '',
-      message: 'Do you want to delete this credential information?',
-      callback: function(result) {
-        if (result) {
-          $http.delete(baseUrlSrv.getRestApiBase() + '/credential/' + entity).
-          success(function(data, status, headers, config) {
-            var index = _.findIndex($scope.credentialInfo, {'entity': entity});
-            $scope.credentialInfo.splice(index, 1);
-            console.log('Success %o %o', status, data.message);
-          }).
-          error(function(data, status, headers, config) {
-            console.log('Error %o %o', status, data.message);
-          });
+    };
+
+    $scope.updateCredentialInfo = function(form, data, entity) {
+      var request = {
+        entity: entity,
+        username: data.username,
+        password: data.password
+      };
+
+      $http.put(baseUrlSrv.getRestApiBase() + '/credential/', request).
+      success(function(data, status, headers, config) {
+        var index = _.findIndex($scope.credentialInfo, {'entity': entity});
+        $scope.credentialInfo[index] = request;
+        return true;
+      }).
+      error(function(data, status, headers, config) {
+        console.log('Error %o %o', status, data.message);
+        ngToast.danger({
+          content: 'We couldn\'t save the credential',
+          verticalPosition: 'bottom',
+          timeout: '3000'
+        });
+        form.$show();
+      });
+      return false;
+    };
+
+    $scope.removeCredentialInfo = function(entity) {
+      BootstrapDialog.confirm({
+        closable: false,
+        closeByBackdrop: false,
+        closeByKeyboard: false,
+        title: '',
+        message: 'Do you want to delete this credential information?',
+        callback: function(result) {
+          if (result) {
+            $http.delete(baseUrlSrv.getRestApiBase() + '/credential/' + entity).
+            success(function(data, status, headers, config) {
+              var index = _.findIndex($scope.credentialInfo, {'entity': entity});
+              $scope.credentialInfo.splice(index, 1);
+              console.log('Success %o %o', status, data.message);
+            }).
+            error(function(data, status, headers, config) {
+              console.log('Error %o %o', status, data.message);
+            });
+          }
         }
-      }
-    });
-  };
+      });
+    };
+
+    var init = function() {
+      getCredentialInfo();
+    };
 
-  var init = function() {
-    getCredentialInfo();
-  };
+    init();
+  }
 
-  init();
-});
+})();

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a9e7bc38/zeppelin-web/src/app/home/home.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/home/home.controller.js b/zeppelin-web/src/app/home/home.controller.js
index 1a23f9c..2c7407b 100644
--- a/zeppelin-web/src/app/home/home.controller.js
+++ b/zeppelin-web/src/app/home/home.controller.js
@@ -12,66 +12,77 @@
  * limitations under the License.
  */
 'use strict';
+(function() {
 
-angular.module('zeppelinWebApp').controller('HomeCtrl', function($scope, notebookListDataFactory, websocketMsgSrv,
-                                                                 $rootScope, arrayOrderingSrv) {
-  var vm = this;
-  vm.notes = notebookListDataFactory;
-  vm.websocketMsgSrv = websocketMsgSrv;
-  vm.arrayOrderingSrv = arrayOrderingSrv;
-
-  vm.notebookHome = false;
-  if ($rootScope.ticket !== undefined) {
-    vm.staticHome = false;
-  } else {
-    vm.staticHome = true;
-  }
+  angular.module('zeppelinWebApp').controller('HomeCtrl', HomeCtrl);
 
-  $scope.isReloading = false;
+  HomeCtrl.$inject = [
+    '$scope',
+    'notebookListDataFactory',
+    'websocketMsgSrv',
+    '$rootScope',
+    'arrayOrderingSrv'
+  ];
 
-  var initHome = function() {
-    websocketMsgSrv.getHomeNotebook();
-  };
+  function HomeCtrl($scope, notebookListDataFactory, websocketMsgSrv, $rootScope, arrayOrderingSrv) {
+    var vm = this;
+    vm.notes = notebookListDataFactory;
+    vm.websocketMsgSrv = websocketMsgSrv;
+    vm.arrayOrderingSrv = arrayOrderingSrv;
 
-  initHome();
+    vm.notebookHome = false;
+    if ($rootScope.ticket !== undefined) {
+      vm.staticHome = false;
+    } else {
+      vm.staticHome = true;
+    }
 
-  $scope.reloadNotebookList = function() {
-    websocketMsgSrv.reloadAllNotesFromRepo();
-    $scope.isReloadingNotes = true;
-  };
+    $scope.isReloading = false;
 
-  $scope.toggleFolderNode = function(node) {
-    node.hidden = !node.hidden;
-  };
+    var initHome = function() {
+      websocketMsgSrv.getHomeNotebook();
+    };
 
-  angular.element('#loginModal').on('hidden.bs.modal', function(e) {
-    $rootScope.$broadcast('initLoginValues');
-  });
+    initHome();
 
-  /*
-  ** $scope.$on functions below
-  */
+    $scope.reloadNotebookList = function() {
+      websocketMsgSrv.reloadAllNotesFromRepo();
+      $scope.isReloadingNotes = true;
+    };
 
-  $scope.$on('setNoteMenu', function(event, notes) {
-    $scope.isReloadingNotes = false;
-  });
+    $scope.toggleFolderNode = function(node) {
+      node.hidden = !node.hidden;
+    };
 
-  $scope.$on('setNoteContent', function(event, note) {
-    if (note) {
-      vm.note = note;
+    angular.element('#loginModal').on('hidden.bs.modal', function(e) {
+      $rootScope.$broadcast('initLoginValues');
+    });
 
-      // initialize look And Feel
-      $rootScope.$broadcast('setLookAndFeel', 'home');
+    /*
+    ** $scope.$on functions below
+    */
 
-      // make it read only
-      vm.viewOnly = true;
+    $scope.$on('setNoteMenu', function(event, notes) {
+      $scope.isReloadingNotes = false;
+    });
 
-      vm.notebookHome = true;
-      vm.staticHome = false;
-    } else {
-      vm.staticHome = true;
-      vm.notebookHome = false;
-    }
-  });
+    $scope.$on('setNoteContent', function(event, note) {
+      if (note) {
+        vm.note = note;
+
+        // initialize look And Feel
+        $rootScope.$broadcast('setLookAndFeel', 'home');
+
+        // make it read only
+        vm.viewOnly = true;
+
+        vm.notebookHome = true;
+        vm.staticHome = false;
+      } else {
+        vm.staticHome = true;
+        vm.notebookHome = false;
+      }
+    });
+  }
 
-});
+})();

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a9e7bc38/zeppelin-web/src/app/interpreter/interpreter.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/interpreter/interpreter.controller.js b/zeppelin-web/src/app/interpreter/interpreter.controller.js
index 378dce4..97d4ea7 100644
--- a/zeppelin-web/src/app/interpreter/interpreter.controller.js
+++ b/zeppelin-web/src/app/interpreter/interpreter.controller.js
@@ -12,9 +12,13 @@
  * limitations under the License.
  */
 'use strict';
+(function() {
 
-angular.module('zeppelinWebApp').controller('InterpreterCtrl',
-  function($scope, $http, baseUrlSrv, ngToast, $timeout, $route) {
+  angular.module('zeppelinWebApp').controller('InterpreterCtrl', InterpreterCtrl);
+
+  InterpreterCtrl.$inject = ['$scope', '$http', 'baseUrlSrv', 'ngToast', '$timeout', '$route'];
+
+  function InterpreterCtrl($scope, $http, baseUrlSrv, ngToast, $timeout, $route) {
     var interpreterSettingsTmp = [];
     $scope.interpreterSettings = [];
     $scope.availableInterpreters = {};
@@ -574,4 +578,6 @@ angular.module('zeppelinWebApp').controller('InterpreterCtrl',
     };
 
     init();
-  });
+  }
+
+})();

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a9e7bc38/zeppelin-web/src/app/interpreter/interpreter.filter.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/interpreter/interpreter.filter.js b/zeppelin-web/src/app/interpreter/interpreter.filter.js
index e225c95..49362b2 100644
--- a/zeppelin-web/src/app/interpreter/interpreter.filter.js
+++ b/zeppelin-web/src/app/interpreter/interpreter.filter.js
@@ -12,10 +12,15 @@
  * limitations under the License.
  */
 'use strict';
+(function() {
 
-angular.module('zeppelinWebApp').filter('sortByKey', function() {
-  return function(properties) {
-    var sortedKeys = properties ? Object.keys(properties) : [];
-    return sortedKeys.sort();
-  };
-});
+  angular.module('zeppelinWebApp').filter('sortByKey', sortByKey);
+
+  function sortByKey() {
+    return function(properties) {
+      var sortedKeys = properties ? Object.keys(properties) : [];
+      return sortedKeys.sort();
+    };
+  }
+
+})();

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a9e7bc38/zeppelin-web/src/app/jobmanager/jobmanager.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/jobmanager/jobmanager.controller.js b/zeppelin-web/src/app/jobmanager/jobmanager.controller.js
index 85c68c6..2c6b675 100644
--- a/zeppelin-web/src/app/jobmanager/jobmanager.controller.js
+++ b/zeppelin-web/src/app/jobmanager/jobmanager.controller.js
@@ -12,78 +12,82 @@
  * limitations under the License.
  */
 'use strict';
+(function() {
 
-angular.module('zeppelinWebApp')
-  .controller('JobmanagerCtrl',
-    function($scope, websocketMsgSrv, $interval) {
+  angular.module('zeppelinWebApp').controller('JobmanagerCtrl', JobmanagerCtrl);
 
-      $scope.filterValueToName = function(filterValue) {
-        var index = _.findIndex($scope.ACTIVE_INTERPRETERS, {value: filterValue});
+  JobmanagerCtrl.$inject = ['$scope', 'websocketMsgSrv', '$interval'];
 
-        if ($scope.ACTIVE_INTERPRETERS[index].name !== undefined) {
-          return $scope.ACTIVE_INTERPRETERS[index].name;
-        } else {
-          return 'undefined';
-        }
-      };
-
-      $scope.init = function() {
-        $scope.jobInfomations = [];
-        $scope.JobInfomationsByFilter = $scope.jobInfomations;
+  function JobmanagerCtrl($scope, websocketMsgSrv, $interval) {
+    $scope.filterValueToName = function(filterValue) {
+      var index = _.findIndex($scope.ACTIVE_INTERPRETERS, {value: filterValue});
 
-        websocketMsgSrv.getNotebookJobsList();
+      if ($scope.ACTIVE_INTERPRETERS[index].name !== undefined) {
+        return $scope.ACTIVE_INTERPRETERS[index].name;
+      } else {
+        return 'undefined';
+      }
+    };
 
-        $scope.$on('$destroy', function() {
-          websocketMsgSrv.unsubscribeJobManager();
-        });
-      };
+    $scope.init = function() {
+      $scope.jobInfomations = [];
+      $scope.JobInfomationsByFilter = $scope.jobInfomations;
 
-      /*
-      ** $scope.$on functions below
-      */
+      websocketMsgSrv.getNotebookJobsList();
 
-      $scope.$on('setNotebookJobs', function(event, responseData) {
-        $scope.lastJobServerUnixTime = responseData.lastResponseUnixTime;
-        $scope.jobInfomations = responseData.jobs;
-        $scope.jobInfomationsIndexs = $scope.jobInfomations ? _.indexBy($scope.jobInfomations, 'notebookId') : {};
+      $scope.$on('$destroy', function() {
+        websocketMsgSrv.unsubscribeJobManager();
       });
+    };
 
-      $scope.$on('setUpdateNotebookJobs', function(event, responseData) {
-        var jobInfomations = $scope.jobInfomations;
-        var indexStore = $scope.jobInfomationsIndexs;
-        $scope.lastJobServerUnixTime = responseData.lastResponseUnixTime;
-        var notes = responseData.jobs;
-        notes.map(function(changedItem) {
-          if (indexStore[changedItem.notebookId] === undefined) {
-            var newItem = angular.copy(changedItem);
-            jobInfomations.push(newItem);
-            indexStore[changedItem.notebookId] = newItem;
-          } else {
-            var changeOriginTarget = indexStore[changedItem.notebookId];
+    /*
+    ** $scope.$on functions below
+    */
+
+    $scope.$on('setNotebookJobs', function(event, responseData) {
+      $scope.lastJobServerUnixTime = responseData.lastResponseUnixTime;
+      $scope.jobInfomations = responseData.jobs;
+      $scope.jobInfomationsIndexs = $scope.jobInfomations ? _.indexBy($scope.jobInfomations, 'notebookId') : {};
+    });
 
-            if (changedItem.isRemoved !== undefined && changedItem.isRemoved === true) {
+    $scope.$on('setUpdateNotebookJobs', function(event, responseData) {
+      var jobInfomations = $scope.jobInfomations;
+      var indexStore = $scope.jobInfomationsIndexs;
+      $scope.lastJobServerUnixTime = responseData.lastResponseUnixTime;
+      var notes = responseData.jobs;
+      notes.map(function(changedItem) {
+        if (indexStore[changedItem.notebookId] === undefined) {
+          var newItem = angular.copy(changedItem);
+          jobInfomations.push(newItem);
+          indexStore[changedItem.notebookId] = newItem;
+        } else {
+          var changeOriginTarget = indexStore[changedItem.notebookId];
 
-              // remove Item.
-              var removeIndex = _.findIndex(indexStore, changedItem.notebookId);
-              if (removeIndex > -1) {
-                indexStore.splice(removeIndex, 1);
-              }
+          if (changedItem.isRemoved !== undefined && changedItem.isRemoved === true) {
 
-              removeIndex = _.findIndex(jobInfomations, {'notebookId': changedItem.notebookId});
-              if (removeIndex) {
-                jobInfomations.splice(removeIndex, 1);
-              }
+            // remove Item.
+            var removeIndex = _.findIndex(indexStore, changedItem.notebookId);
+            if (removeIndex > -1) {
+              indexStore.splice(removeIndex, 1);
+            }
 
-            } else {
-              // change value for item.
-              changeOriginTarget.isRunningJob = changedItem.isRunningJob;
-              changeOriginTarget.notebookName = changedItem.notebookName;
-              changeOriginTarget.notebookType = changedItem.notebookType;
-              changeOriginTarget.interpreter = changedItem.interpreter;
-              changeOriginTarget.unixTimeLastRun = changedItem.unixTimeLastRun;
-              changeOriginTarget.paragraphs = changedItem.paragraphs;
+            removeIndex = _.findIndex(jobInfomations, {'notebookId': changedItem.notebookId});
+            if (removeIndex) {
+              jobInfomations.splice(removeIndex, 1);
             }
+
+          } else {
+            // change value for item.
+            changeOriginTarget.isRunningJob = changedItem.isRunningJob;
+            changeOriginTarget.notebookName = changedItem.notebookName;
+            changeOriginTarget.notebookType = changedItem.notebookType;
+            changeOriginTarget.interpreter = changedItem.interpreter;
+            changeOriginTarget.unixTimeLastRun = changedItem.unixTimeLastRun;
+            changeOriginTarget.paragraphs = changedItem.paragraphs;
           }
-        });
+        }
       });
     });
+  }
+
+})();

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a9e7bc38/zeppelin-web/src/app/jobmanager/jobs/job.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/jobmanager/jobs/job.controller.js b/zeppelin-web/src/app/jobmanager/jobs/job.controller.js
index cbbf986..b594bb7 100644
--- a/zeppelin-web/src/app/jobmanager/jobs/job.controller.js
+++ b/zeppelin-web/src/app/jobmanager/jobs/job.controller.js
@@ -12,10 +12,13 @@
  * limitations under the License.
  */
 'use strict';
+(function() {
 
-angular.module('zeppelinWebApp')
-  .controller('JobCtrl', function($scope) {
+  angular.module('zeppelinWebApp').controller('JobCtrl', JobCtrl);
 
+  JobCtrl.$inject = ['$scope'];
+
+  function JobCtrl($scope) {
     $scope.init = function(jobInformation) {
       $scope.progressValue = 0;
     };
@@ -34,5 +37,6 @@ angular.module('zeppelinWebApp')
       var result = Math.ceil(runningJobCount / totalCount * 100);
       return isNaN(result) ? 0 : result;
     };
+  }
 
-  });
+})();

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a9e7bc38/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 f2dce09..da15768 100644
--- a/zeppelin-web/src/app/notebook/notebook.controller.js
+++ b/zeppelin-web/src/app/notebook/notebook.controller.js
@@ -12,826 +12,842 @@
  * limitations under the License.
  */
 'use strict';
-
-angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $route, $routeParams, $location,
-                                                                     $rootScope, $http, websocketMsgSrv,
-                                                                     baseUrlSrv, $timeout, saveAsService) {
-  $scope.note = null;
-  $scope.moment = moment;
-  $scope.editorToggled = false;
-  $scope.tableToggled = false;
-  $scope.viewOnly = false;
-  $scope.showSetting = false;
-  $scope.looknfeelOption = ['default', 'simple', 'report'];
-  $scope.cronOption = [
-    {name: 'None', value: undefined},
-    {name: '1m', value: '0 0/1 * * * ?'},
-    {name: '5m', value: '0 0/5 * * * ?'},
-    {name: '1h', value: '0 0 0/1 * * ?'},
-    {name: '3h', value: '0 0 0/3 * * ?'},
-    {name: '6h', value: '0 0 0/6 * * ?'},
-    {name: '12h', value: '0 0 0/12 * * ?'},
-    {name: '1d', value: '0 0 0 * * ?'}
+(function() {
+
+  angular.module('zeppelinWebApp').controller('NotebookCtrl', NotebookCtrl);
+
+  NotebookCtrl.$inject = [
+    '$scope',
+    '$route',
+    '$routeParams',
+    '$location',
+    '$rootScope',
+    '$http',
+    'websocketMsgSrv',
+    'baseUrlSrv',
+    '$timeout',
+    'saveAsService'
   ];
 
-  $scope.interpreterSettings = [];
-  $scope.interpreterBindings = [];
-  $scope.isNoteDirty = null;
-  $scope.saveTimer = null;
+  function NotebookCtrl($scope, $route, $routeParams, $location, $rootScope,
+                        $http, websocketMsgSrv, baseUrlSrv, $timeout, saveAsService) {
+    $scope.note = null;
+    $scope.moment = moment;
+    $scope.editorToggled = false;
+    $scope.tableToggled = false;
+    $scope.viewOnly = false;
+    $scope.showSetting = false;
+    $scope.looknfeelOption = ['default', 'simple', 'report'];
+    $scope.cronOption = [
+      {name: 'None', value: undefined},
+      {name: '1m', value: '0 0/1 * * * ?'},
+      {name: '5m', value: '0 0/5 * * * ?'},
+      {name: '1h', value: '0 0 0/1 * * ?'},
+      {name: '3h', value: '0 0 0/3 * * ?'},
+      {name: '6h', value: '0 0 0/6 * * ?'},
+      {name: '12h', value: '0 0 0/12 * * ?'},
+      {name: '1d', value: '0 0 0 * * ?'}
+    ];
+
+    $scope.interpreterSettings = [];
+    $scope.interpreterBindings = [];
+    $scope.isNoteDirty = null;
+    $scope.saveTimer = null;
+
+    var connectedOnce = false;
+
+    // user auto complete related
+    $scope.noteRevisions = [];
+
+    $scope.$on('setConnectedStatus', function(event, param) {
+      if (connectedOnce && param) {
+        initNotebook();
+      }
+      connectedOnce = true;
+    });
 
-  var connectedOnce = false;
+    $scope.getCronOptionNameFromValue = function(value) {
+      if (!value) {
+        return '';
+      }
 
-  // user auto complete related
-  $scope.noteRevisions = [];
+      for (var o in $scope.cronOption) {
+        if ($scope.cronOption[o].value === value) {
+          return $scope.cronOption[o].name;
+        }
+      }
+      return value;
+    };
+
+    /** Init the new controller */
+    var initNotebook = function() {
+      websocketMsgSrv.getNotebook($routeParams.noteId);
+      websocketMsgSrv.listRevisionHistory($routeParams.noteId);
+      var currentRoute = $route.current;
+      if (currentRoute) {
+        setTimeout(
+          function() {
+            var routeParams = currentRoute.params;
+            var $id = angular.element('#' + routeParams.paragraph + '_container');
+
+            if ($id.length > 0) {
+              // adjust for navbar
+              var top = $id.offset().top - 103;
+              angular.element('html, body').scrollTo({top: top, left: 0});
+            }
 
-  $scope.$on('setConnectedStatus', function(event, param) {
-    if (connectedOnce && param) {
-      initNotebook();
-    }
-    connectedOnce = true;
-  });
+            // force notebook reload on user change
+            $scope.$on('setNoteMenu', function(event, note) {
+              initNotebook();
+            });
+          },
+          1000
+        );
+      }
+    };
 
-  $scope.getCronOptionNameFromValue = function(value) {
-    if (!value) {
-      return '';
-    }
+    initNotebook();
 
-    for (var o in $scope.cronOption) {
-      if ($scope.cronOption[o].value === value) {
-        return $scope.cronOption[o].name;
+    $scope.focusParagraphOnClick = function(clickEvent) {
+      if (!$scope.note) {
+        return;
       }
-    }
-    return value;
-  };
-
-  /** Init the new controller */
-  var initNotebook = function() {
-    websocketMsgSrv.getNotebook($routeParams.noteId);
-    websocketMsgSrv.listRevisionHistory($routeParams.noteId);
-    var currentRoute = $route.current;
-    if (currentRoute) {
-      setTimeout(
-        function() {
-          var routeParams = currentRoute.params;
-          var $id = angular.element('#' + routeParams.paragraph + '_container');
-
-          if ($id.length > 0) {
-            // adjust for navbar
-            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
-      );
-    }
-  };
+      for (var i = 0; i < $scope.note.paragraphs.length; i++) {
+        var paragraphId = $scope.note.paragraphs[i].id;
+        if (jQuery.contains(angular.element('#' + paragraphId + '_container')[0], clickEvent.target)) {
+          $scope.$broadcast('focusParagraph', paragraphId, 0, true);
+          break;
+        }
+      }
+    };
 
-  initNotebook();
+    // register mouseevent handler for focus paragraph
+    document.addEventListener('click', $scope.focusParagraphOnClick);
 
-  $scope.focusParagraphOnClick = function(clickEvent) {
-    if (!$scope.note) {
-      return;
-    }
-    for (var i = 0; i < $scope.note.paragraphs.length; i++) {
-      var paragraphId = $scope.note.paragraphs[i].id;
-      if (jQuery.contains(angular.element('#' + paragraphId + '_container')[0], clickEvent.target)) {
-        $scope.$broadcast('focusParagraph', paragraphId, 0, true);
-        break;
+    $scope.keyboardShortcut = function(keyEvent) {
+      // handle keyevent
+      if (!$scope.viewOnly) {
+        $scope.$broadcast('keyEvent', keyEvent);
       }
-    }
-  };
+    };
 
-  // register mouseevent handler for focus paragraph
-  document.addEventListener('click', $scope.focusParagraphOnClick);
+    // register mouseevent handler for focus paragraph
+    document.addEventListener('keydown', $scope.keyboardShortcut);
 
-  $scope.keyboardShortcut = function(keyEvent) {
-    // handle keyevent
-    if (!$scope.viewOnly) {
-      $scope.$broadcast('keyEvent', keyEvent);
-    }
-  };
-
-  // register mouseevent handler for focus paragraph
-  document.addEventListener('keydown', $scope.keyboardShortcut);
-
-  /** Remove the note and go back tot he main page */
-  /** TODO(anthony): In the nearly future, go back to the main page and telle to the dude that the note have been remove */
-  $scope.removeNote = function(noteId) {
-    BootstrapDialog.confirm({
-      closable: true,
-      title: '',
-      message: 'Do you want to delete this notebook?',
-      callback: function(result) {
-        if (result) {
-          websocketMsgSrv.deleteNotebook(noteId);
-          $location.path('/');
+    /** Remove the note and go back tot he main page */
+    /** TODO(anthony): In the nearly future, go back to the main page and telle to the dude that the note have been remove */
+    $scope.removeNote = function(noteId) {
+      BootstrapDialog.confirm({
+        closable: true,
+        title: '',
+        message: 'Do you want to delete this notebook?',
+        callback: function(result) {
+          if (result) {
+            websocketMsgSrv.deleteNotebook(noteId);
+            $location.path('/');
+          }
         }
-      }
-    });
-  };
-
-  //Export notebook
-  $scope.exportNotebook = function() {
-    var jsonContent = JSON.stringify($scope.note);
-    saveAsService.saveAs(jsonContent, $scope.note.name, 'json');
-  };
-
-  //Clone note
-  $scope.cloneNote = function(noteId) {
-    BootstrapDialog.confirm({
-      closable: true,
-      title: '',
-      message: 'Do you want to clone this notebook?',
-      callback: function(result) {
-        if (result) {
-          websocketMsgSrv.cloneNotebook(noteId);
-          $location.path('/');
+      });
+    };
+
+    //Export notebook
+    $scope.exportNotebook = function() {
+      var jsonContent = JSON.stringify($scope.note);
+      saveAsService.saveAs(jsonContent, $scope.note.name, 'json');
+    };
+
+    //Clone note
+    $scope.cloneNote = function(noteId) {
+      BootstrapDialog.confirm({
+        closable: true,
+        title: '',
+        message: 'Do you want to clone this notebook?',
+        callback: function(result) {
+          if (result) {
+            websocketMsgSrv.cloneNotebook(noteId);
+            $location.path('/');
+          }
         }
-      }
-    });
-  };
-
-  // checkpoint/commit notebook
-  $scope.checkpointNotebook = function(commitMessage) {
-    BootstrapDialog.confirm({
-      closable: true,
-      title: '',
-      message: 'Commit notebook to current repository?',
-      callback: function(result) {
-        if (result) {
-          websocketMsgSrv.checkpointNotebook($routeParams.noteId, commitMessage);
+      });
+    };
+
+    // checkpoint/commit notebook
+    $scope.checkpointNotebook = function(commitMessage) {
+      BootstrapDialog.confirm({
+        closable: true,
+        title: '',
+        message: 'Commit notebook to current repository?',
+        callback: function(result) {
+          if (result) {
+            websocketMsgSrv.checkpointNotebook($routeParams.noteId, commitMessage);
+          }
         }
-      }
+      });
+      document.getElementById('note.checkpoint.message').value = '';
+    };
+
+    $scope.$on('listRevisionHistory', function(event, data) {
+      console.log('We got the revisions %o', data);
+      $scope.noteRevisions = data.revisionList;
     });
-    document.getElementById('note.checkpoint.message').value = '';
-  };
-
-  $scope.$on('listRevisionHistory', function(event, data) {
-    console.log('We got the revisions %o', data);
-    $scope.noteRevisions = data.revisionList;
-  });
-
-  // receive certain revision of note
-  $scope.$on('noteRevision', function(event, data) {
-    console.log('received note revision %o', data);
-    //TODO(xxx): render it
-  });
-
-  $scope.runNote = function() {
-    BootstrapDialog.confirm({
-      closable: true,
-      title: '',
-      message: 'Run all paragraphs?',
-      callback: function(result) {
-        if (result) {
-          _.forEach($scope.note.paragraphs, function(n, key) {
-            angular.element('#' + n.id + '_paragraphColumn_main').scope().runParagraph(n.text);
-          });
-        }
-      }
+
+    // receive certain revision of note
+    $scope.$on('noteRevision', function(event, data) {
+      console.log('received note revision %o', data);
+      //TODO(xxx): render it
     });
-  };
 
-  $scope.saveNote = function() {
-    if ($scope.note && $scope.note.paragraphs) {
-      _.forEach($scope.note.paragraphs, function(n, key) {
-        angular.element('#' + n.id + '_paragraphColumn_main').scope().saveParagraph();
+    $scope.runNote = function() {
+      BootstrapDialog.confirm({
+        closable: true,
+        title: '',
+        message: 'Run all paragraphs?',
+        callback: function(result) {
+          if (result) {
+            _.forEach($scope.note.paragraphs, function(n, key) {
+              angular.element('#' + n.id + '_paragraphColumn_main').scope().runParagraph(n.text);
+            });
+          }
+        }
       });
-      $scope.isNoteDirty = null;
-    }
-  };
-
-  $scope.clearAllParagraphOutput = function() {
-    BootstrapDialog.confirm({
-      closable: true,
-      title: '',
-      message: 'Do you want to clear all output?',
-      callback: function(result) {
-        if (result) {
-          _.forEach($scope.note.paragraphs, function(n, key) {
-            angular.element('#' + n.id + '_paragraphColumn_main').scope().clearParagraphOutput();
-          });
+    };
+
+    $scope.saveNote = function() {
+      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.clearAllParagraphOutput = function() {
+      BootstrapDialog.confirm({
+        closable: true,
+        title: '',
+        message: 'Do you want to clear all output?',
+        callback: function(result) {
+          if (result) {
+            _.forEach($scope.note.paragraphs, function(n, key) {
+              angular.element('#' + n.id + '_paragraphColumn_main').scope().clearParagraphOutput();
+            });
+          }
         }
+      });
+    };
+
+    $scope.toggleAllEditor = function() {
+      if ($scope.editorToggled) {
+        $scope.$broadcast('openEditor');
+      } else {
+        $scope.$broadcast('closeEditor');
       }
-    });
-  };
+      $scope.editorToggled = !$scope.editorToggled;
+    };
 
-  $scope.toggleAllEditor = function() {
-    if ($scope.editorToggled) {
+    $scope.showAllEditor = function() {
       $scope.$broadcast('openEditor');
-    } else {
-      $scope.$broadcast('closeEditor');
-    }
-    $scope.editorToggled = !$scope.editorToggled;
-  };
+    };
 
-  $scope.showAllEditor = function() {
-    $scope.$broadcast('openEditor');
-  };
+    $scope.hideAllEditor = function() {
+      $scope.$broadcast('closeEditor');
+    };
 
-  $scope.hideAllEditor = function() {
-    $scope.$broadcast('closeEditor');
-  };
+    $scope.toggleAllTable = function() {
+      if ($scope.tableToggled) {
+        $scope.$broadcast('openTable');
+      } else {
+        $scope.$broadcast('closeTable');
+      }
+      $scope.tableToggled = !$scope.tableToggled;
+    };
 
-  $scope.toggleAllTable = function() {
-    if ($scope.tableToggled) {
+    $scope.showAllTable = function() {
       $scope.$broadcast('openTable');
-    } else {
-      $scope.$broadcast('closeTable');
-    }
-    $scope.tableToggled = !$scope.tableToggled;
-  };
-
-  $scope.showAllTable = function() {
-    $scope.$broadcast('openTable');
-  };
+    };
 
-  $scope.hideAllTable = function() {
-    $scope.$broadcast('closeTable');
-  };
-
-  $scope.isNoteRunning = function() {
-    var running = false;
-    if (!$scope.note) { return false; }
-    for (var i = 0; i < $scope.note.paragraphs.length; i++) {
-      if ($scope.note.paragraphs[i].status === 'PENDING' || $scope.note.paragraphs[i].status === 'RUNNING') {
-        running = true;
-        break;
+    $scope.hideAllTable = function() {
+      $scope.$broadcast('closeTable');
+    };
+
+    $scope.isNoteRunning = function() {
+      var running = false;
+      if (!$scope.note) { return false; }
+      for (var i = 0; i < $scope.note.paragraphs.length; i++) {
+        if ($scope.note.paragraphs[i].status === 'PENDING' || $scope.note.paragraphs[i].status === 'RUNNING') {
+          running = true;
+          break;
+        }
       }
-    }
-    return running;
-  };
-
-  $scope.killSaveTimer = function() {
-    if ($scope.saveTimer) {
-      $timeout.cancel($scope.saveTimer);
-      $scope.saveTimer = null;
-    }
-  };
+      return running;
+    };
 
-  $scope.startSaveTimer = function() {
-    $scope.killSaveTimer();
-    $scope.isNoteDirty = true;
-    //console.log('startSaveTimer called ' + $scope.note.id);
-    $scope.saveTimer = $timeout(function() {
+    $scope.killSaveTimer = function() {
+      if ($scope.saveTimer) {
+        $timeout.cancel($scope.saveTimer);
+        $scope.saveTimer = null;
+      }
+    };
+
+    $scope.startSaveTimer = function() {
+      $scope.killSaveTimer();
+      $scope.isNoteDirty = true;
+      //console.log('startSaveTimer called ' + $scope.note.id);
+      $scope.saveTimer = $timeout(function() {
+        $scope.saveNote();
+      }, 10000);
+    };
+
+    angular.element(window).on('beforeunload', function(e) {
+      $scope.killSaveTimer();
       $scope.saveNote();
-    }, 10000);
-  };
-
-  angular.element(window).on('beforeunload', function(e) {
-    $scope.killSaveTimer();
-    $scope.saveNote();
-  });
-
-  $scope.setLookAndFeel = function(looknfeel) {
-    $scope.note.config.looknfeel = looknfeel;
-    $scope.setConfig();
-  };
-
-  /** Set cron expression for this note **/
-  $scope.setCronScheduler = function(cronExpr) {
-    $scope.note.config.cron = cronExpr;
-    $scope.setConfig();
-  };
-
-  /** Set the username of the user to be used to execute all notes in notebook **/
-  $scope.setCronExecutingUser = function(cronExecutingUser) {
-    $scope.note.config.cronExecutingUser = cronExecutingUser;
-    $scope.setConfig();
-  };
-
-  /** Set release resource for this note **/
-  $scope.setReleaseResource = function(value) {
-    $scope.note.config.releaseresource = value;
-    $scope.setConfig();
-  };
-
-  /** Update note config **/
-  $scope.setConfig = function(config) {
-    if (config) {
-      $scope.note.config = config;
-    }
-    websocketMsgSrv.updateNotebook($scope.note.id, $scope.note.name, $scope.note.config);
-  };
+    });
 
-  /** Update the note name */
-  $scope.sendNewName = function() {
-    if ($scope.note.name) {
+    $scope.setLookAndFeel = function(looknfeel) {
+      $scope.note.config.looknfeel = looknfeel;
+      $scope.setConfig();
+    };
+
+    /** Set cron expression for this note **/
+    $scope.setCronScheduler = function(cronExpr) {
+      $scope.note.config.cron = cronExpr;
+      $scope.setConfig();
+    };
+
+    /** Set the username of the user to be used to execute all notes in notebook **/
+    $scope.setCronExecutingUser = function(cronExecutingUser) {
+      $scope.note.config.cronExecutingUser = cronExecutingUser;
+      $scope.setConfig();
+    };
+
+    /** Set release resource for this note **/
+    $scope.setReleaseResource = function(value) {
+      $scope.note.config.releaseresource = value;
+      $scope.setConfig();
+    };
+
+    /** Update note config **/
+    $scope.setConfig = function(config) {
+      if (config) {
+        $scope.note.config = config;
+      }
       websocketMsgSrv.updateNotebook($scope.note.id, $scope.note.name, $scope.note.config);
-    }
-  };
+    };
 
-  var initializeLookAndFeel = function() {
-    if (!$scope.note.config.looknfeel) {
-      $scope.note.config.looknfeel = 'default';
-    } else {
-      $scope.viewOnly = $scope.note.config.looknfeel === 'report' ? true : false;
-    }
-    $scope.note.paragraphs[0].focus = true;
-    $rootScope.$broadcast('setLookAndFeel', $scope.note.config.looknfeel);
-  };
-
-  var cleanParagraphExcept = function(paragraphId, note) {
-    var noteCopy = {};
-    noteCopy.id = note.id;
-    noteCopy.name = note.name;
-    noteCopy.config = note.config;
-    noteCopy.info = note.info;
-    noteCopy.paragraphs = [];
-    for (var i = 0; i < note.paragraphs.length; i++) {
-      if (note.paragraphs[i].id === paragraphId) {
-        noteCopy.paragraphs[0] = note.paragraphs[i];
-        if (!noteCopy.paragraphs[0].config) {
-          noteCopy.paragraphs[0].config = {};
-        }
-        noteCopy.paragraphs[0].config.editorHide = true;
-        noteCopy.paragraphs[0].config.tableHide = false;
-        break;
+    /** Update the note name */
+    $scope.sendNewName = function() {
+      if ($scope.note.name) {
+        websocketMsgSrv.updateNotebook($scope.note.id, $scope.note.name, $scope.note.config);
       }
-    }
-    return noteCopy;
-  };
-
-  var updateNote = function(note) {
-    /** update Note name */
-    if (note.name !== $scope.note.name) {
-      console.log('change note name: %o to %o', $scope.note.name, note.name);
-      $scope.note.name = note.name;
-    }
+    };
 
-    $scope.note.config = note.config;
-    $scope.note.info = note.info;
+    var initializeLookAndFeel = function() {
+      if (!$scope.note.config.looknfeel) {
+        $scope.note.config.looknfeel = 'default';
+      } else {
+        $scope.viewOnly = $scope.note.config.looknfeel === 'report' ? true : false;
+      }
+      $scope.note.paragraphs[0].focus = true;
+      $rootScope.$broadcast('setLookAndFeel', $scope.note.config.looknfeel);
+    };
+
+    var cleanParagraphExcept = function(paragraphId, note) {
+      var noteCopy = {};
+      noteCopy.id = note.id;
+      noteCopy.name = note.name;
+      noteCopy.config = note.config;
+      noteCopy.info = note.info;
+      noteCopy.paragraphs = [];
+      for (var i = 0; i < note.paragraphs.length; i++) {
+        if (note.paragraphs[i].id === paragraphId) {
+          noteCopy.paragraphs[0] = note.paragraphs[i];
+          if (!noteCopy.paragraphs[0].config) {
+            noteCopy.paragraphs[0].config = {};
+          }
+          noteCopy.paragraphs[0].config.editorHide = true;
+          noteCopy.paragraphs[0].config.tableHide = false;
+          break;
+        }
+      }
+      return noteCopy;
+    };
+
+    var updateNote = function(note) {
+      /** update Note name */
+      if (note.name !== $scope.note.name) {
+        console.log('change note name: %o to %o', $scope.note.name, note.name);
+        $scope.note.name = note.name;
+      }
 
-    var newParagraphIds = note.paragraphs.map(function(x) {return x.id;});
-    var oldParagraphIds = $scope.note.paragraphs.map(function(x) {return x.id;});
+      $scope.note.config = note.config;
+      $scope.note.info = note.info;
 
-    var numNewParagraphs = newParagraphIds.length;
-    var numOldParagraphs = oldParagraphIds.length;
+      var newParagraphIds = note.paragraphs.map(function(x) {return x.id;});
+      var oldParagraphIds = $scope.note.paragraphs.map(function(x) {return x.id;});
 
-    var paragraphToBeFocused;
-    var focusedParagraph;
-    for (var i = 0; i < $scope.note.paragraphs.length; i++) {
-      var paragraphId = $scope.note.paragraphs[i].id;
-      if (angular.element('#' + paragraphId + '_paragraphColumn_main').scope().paragraphFocused) {
-        focusedParagraph = paragraphId;
-        break;
-      }
-    }
+      var numNewParagraphs = newParagraphIds.length;
+      var numOldParagraphs = oldParagraphIds.length;
 
-    /** add a new paragraph */
-    if (numNewParagraphs > numOldParagraphs) {
-      for (var index in newParagraphIds) {
-        if (oldParagraphIds[index] !== newParagraphIds[index]) {
-          $scope.note.paragraphs.splice(index, 0, note.paragraphs[index]);
-          paragraphToBeFocused = note.paragraphs[index].id;
+      var paragraphToBeFocused;
+      var focusedParagraph;
+      for (var i = 0; i < $scope.note.paragraphs.length; i++) {
+        var paragraphId = $scope.note.paragraphs[i].id;
+        if (angular.element('#' + paragraphId + '_paragraphColumn_main').scope().paragraphFocused) {
+          focusedParagraph = paragraphId;
           break;
         }
-        $scope.$broadcast('updateParagraph', {
-          note: $scope.note, // pass the note object to paragraph scope
-          paragraph: note.paragraphs[index]});
       }
-    }
 
-    /** update or move paragraph */
-    if (numNewParagraphs === numOldParagraphs) {
-      for (var idx in newParagraphIds) {
-        var newEntry = note.paragraphs[idx];
-        if (oldParagraphIds[idx] === newParagraphIds[idx]) {
+      /** add a new paragraph */
+      if (numNewParagraphs > numOldParagraphs) {
+        for (var index in newParagraphIds) {
+          if (oldParagraphIds[index] !== newParagraphIds[index]) {
+            $scope.note.paragraphs.splice(index, 0, note.paragraphs[index]);
+            paragraphToBeFocused = note.paragraphs[index].id;
+            break;
+          }
           $scope.$broadcast('updateParagraph', {
             note: $scope.note, // pass the note object to paragraph scope
-            paragraph: newEntry});
-        } else {
-          // move paragraph
-          var oldIdx = oldParagraphIds.indexOf(newParagraphIds[idx]);
-          $scope.note.paragraphs.splice(oldIdx, 1);
-          $scope.note.paragraphs.splice(idx, 0, newEntry);
-          // rebuild id list since paragraph has moved.
-          oldParagraphIds = $scope.note.paragraphs.map(function(x) {return x.id;});
+            paragraph: note.paragraphs[index]});
         }
+      }
+
+      /** update or move paragraph */
+      if (numNewParagraphs === numOldParagraphs) {
+        for (var idx in newParagraphIds) {
+          var newEntry = note.paragraphs[idx];
+          if (oldParagraphIds[idx] === newParagraphIds[idx]) {
+            $scope.$broadcast('updateParagraph', {
+              note: $scope.note, // pass the note object to paragraph scope
+              paragraph: newEntry});
+          } else {
+            // move paragraph
+            var oldIdx = oldParagraphIds.indexOf(newParagraphIds[idx]);
+            $scope.note.paragraphs.splice(oldIdx, 1);
+            $scope.note.paragraphs.splice(idx, 0, newEntry);
+            // rebuild id list since paragraph has moved.
+            oldParagraphIds = $scope.note.paragraphs.map(function(x) {return x.id;});
+          }
 
-        if (focusedParagraph === newParagraphIds[idx]) {
-          paragraphToBeFocused = focusedParagraph;
+          if (focusedParagraph === newParagraphIds[idx]) {
+            paragraphToBeFocused = focusedParagraph;
+          }
         }
       }
-    }
 
-    /** remove paragraph */
-    if (numNewParagraphs < numOldParagraphs) {
-      for (var oldidx in oldParagraphIds) {
-        if (oldParagraphIds[oldidx] !== newParagraphIds[oldidx]) {
-          $scope.note.paragraphs.splice(oldidx, 1);
-          break;
+      /** remove paragraph */
+      if (numNewParagraphs < numOldParagraphs) {
+        for (var oldidx in oldParagraphIds) {
+          if (oldParagraphIds[oldidx] !== newParagraphIds[oldidx]) {
+            $scope.note.paragraphs.splice(oldidx, 1);
+            break;
+          }
         }
       }
-    }
 
-    // restore focus of paragraph
-    for (var f = 0; f < $scope.note.paragraphs.length; f++) {
-      if (paragraphToBeFocused === $scope.note.paragraphs[f].id) {
-        $scope.note.paragraphs[f].focus = true;
+      // restore focus of paragraph
+      for (var f = 0; f < $scope.note.paragraphs.length; f++) {
+        if (paragraphToBeFocused === $scope.note.paragraphs[f].id) {
+          $scope.note.paragraphs[f].focus = true;
+        }
       }
-    }
-  };
+    };
 
-  var getInterpreterBindings = function() {
-    websocketMsgSrv.getInterpreterBindings($scope.note.id);
-  };
+    var getInterpreterBindings = function() {
+      websocketMsgSrv.getInterpreterBindings($scope.note.id);
+    };
 
-  $scope.$on('interpreterBindings', function(event, data) {
-    $scope.interpreterBindings = data.interpreterBindings;
-    $scope.interpreterBindingsOrig = angular.copy($scope.interpreterBindings); // to check dirty
+    $scope.$on('interpreterBindings', function(event, data) {
+      $scope.interpreterBindings = data.interpreterBindings;
+      $scope.interpreterBindingsOrig = angular.copy($scope.interpreterBindings); // to check dirty
 
-    var selected = false;
-    var key;
-    var setting;
-
-    for (key in $scope.interpreterBindings) {
-      setting = $scope.interpreterBindings[key];
-      if (setting.selected) {
-        selected = true;
-        break;
-      }
-    }
+      var selected = false;
+      var key;
+      var setting;
 
-    if (!selected) {
-      // make default selection
-      var selectedIntp = {};
       for (key in $scope.interpreterBindings) {
         setting = $scope.interpreterBindings[key];
-        if (!selectedIntp[setting.name]) {
-          setting.selected = true;
-          selectedIntp[setting.name] = true;
+        if (setting.selected) {
+          selected = true;
+          break;
         }
       }
-      $scope.showSetting = true;
-    }
-  });
 
-  $scope.interpreterSelectionListeners = {
-    accept: function(sourceItemHandleScope, destSortableScope) {return true;},
-    itemMoved: function(event) {},
-    orderChanged: function(event) {}
-  };
+      if (!selected) {
+        // make default selection
+        var selectedIntp = {};
+        for (key in $scope.interpreterBindings) {
+          setting = $scope.interpreterBindings[key];
+          if (!selectedIntp[setting.name]) {
+            setting.selected = true;
+            selectedIntp[setting.name] = true;
+          }
+        }
+        $scope.showSetting = true;
+      }
+    });
 
-  $scope.openSetting = function() {
-    $scope.showSetting = true;
-    getInterpreterBindings();
-  };
+    $scope.interpreterSelectionListeners = {
+      accept: function(sourceItemHandleScope, destSortableScope) {return true;},
+      itemMoved: function(event) {},
+      orderChanged: function(event) {}
+    };
 
-  $scope.closeSetting = function() {
-    if (isSettingDirty()) {
-      BootstrapDialog.confirm({
-        closable: true,
-        title: '',
-        message: 'Interpreter setting changes will be discarded.',
-        callback: function(result) {
-          if (result) {
-            $scope.$apply(function() {
-              $scope.showSetting = false;
-            });
+    $scope.openSetting = function() {
+      $scope.showSetting = true;
+      getInterpreterBindings();
+    };
+
+    $scope.closeSetting = function() {
+      if (isSettingDirty()) {
+        BootstrapDialog.confirm({
+          closable: true,
+          title: '',
+          message: 'Interpreter setting changes will be discarded.',
+          callback: function(result) {
+            if (result) {
+              $scope.$apply(function() {
+                $scope.showSetting = false;
+              });
+            }
           }
+        });
+      } else {
+        $scope.showSetting = false;
+      }
+    };
+
+    $scope.saveSetting = function() {
+      var selectedSettingIds = [];
+      for (var no in $scope.interpreterBindings) {
+        var setting = $scope.interpreterBindings[no];
+        if (setting.selected) {
+          selectedSettingIds.push(setting.id);
         }
-      });
-    } else {
+      }
+      websocketMsgSrv.saveInterpreterBindings($scope.note.id, selectedSettingIds);
+      console.log('Interpreter bindings %o saved', selectedSettingIds);
       $scope.showSetting = false;
-    }
-  };
+    };
 
-  $scope.saveSetting = function() {
-    var selectedSettingIds = [];
-    for (var no in $scope.interpreterBindings) {
-      var setting = $scope.interpreterBindings[no];
-      if (setting.selected) {
-        selectedSettingIds.push(setting.id);
+    $scope.toggleSetting = function() {
+      if ($scope.showSetting) {
+        $scope.closeSetting();
+      } else {
+        $scope.openSetting();
+        $scope.closePermissions();
       }
-    }
-    websocketMsgSrv.saveInterpreterBindings($scope.note.id, selectedSettingIds);
-    console.log('Interpreter bindings %o saved', selectedSettingIds);
-    $scope.showSetting = false;
-  };
-
-  $scope.toggleSetting = function() {
-    if ($scope.showSetting) {
-      $scope.closeSetting();
-    } else {
-      $scope.openSetting();
-      $scope.closePermissions();
-    }
-  };
-
-  var getPermissions = function(callback) {
-    $http.get(baseUrlSrv.getRestApiBase() + '/notebook/' + $scope.note.id + '/permissions').
-    success(function(data, status, headers, config) {
-      $scope.permissions = data.body;
-      $scope.permissionsOrig = angular.copy($scope.permissions); // to check dirty
-
-      var selectJson = {
-        tokenSeparators: [',', ' '],
-        ajax: {
-          url: function(params) {
-            if (!params.term) {
-              return false;
-            }
-            return baseUrlSrv.getRestApiBase() + '/security/userlist/' + params.term;
-          },
-          delay: 250,
-          processResults: function(data, params) {
-            var results = [];
-
-            if (data.body.users.length !== 0) {
-              var users = [];
-              for (var len = 0; len < data.body.users.length; len++) {
-                users.push({
-                  'id': data.body.users[len],
-                  'text': data.body.users[len]
+    };
+
+    var getPermissions = function(callback) {
+      $http.get(baseUrlSrv.getRestApiBase() + '/notebook/' + $scope.note.id + '/permissions').
+      success(function(data, status, headers, config) {
+        $scope.permissions = data.body;
+        $scope.permissionsOrig = angular.copy($scope.permissions); // to check dirty
+
+        var selectJson = {
+          tokenSeparators: [',', ' '],
+          ajax: {
+            url: function(params) {
+              if (!params.term) {
+                return false;
+              }
+              return baseUrlSrv.getRestApiBase() + '/security/userlist/' + params.term;
+            },
+            delay: 250,
+            processResults: function(data, params) {
+              var results = [];
+
+              if (data.body.users.length !== 0) {
+                var users = [];
+                for (var len = 0; len < data.body.users.length; len++) {
+                  users.push({
+                    'id': data.body.users[len],
+                    'text': data.body.users[len]
+                  });
+                }
+                results.push({
+                  'text': 'Users :',
+                  'children': users
                 });
               }
-              results.push({
-                'text': 'Users :',
-                'children': users
-              });
-            }
-            if (data.body.roles.length !== 0) {
-              var roles = [];
-              for (var len = 0; len < data.body.roles.length; len++) {
-                roles.push({
-                  'id': data.body.roles[len],
-                  'text': data.body.roles[len]
+              if (data.body.roles.length !== 0) {
+                var roles = [];
+                for (var len = 0; len < data.body.roles.length; len++) {
+                  roles.push({
+                    'id': data.body.roles[len],
+                    'text': data.body.roles[len]
+                  });
+                }
+                results.push({
+                  'text': 'Roles :',
+                  'children': roles
                 });
               }
-              results.push({
-                'text': 'Roles :',
-                'children': roles
+              return {
+                results: results,
+                pagination: {
+                  more: false
+                }
+              };
+            },
+            cache: false
+          },
+          width: ' ',
+          tags: true,
+          minimumInputLength: 3
+        };
+
+        angular.element('#selectOwners').select2(selectJson);
+        angular.element('#selectReaders').select2(selectJson);
+        angular.element('#selectWriters').select2(selectJson);
+        if (callback) {
+          callback();
+        }
+      }).
+      error(function(data, status, headers, config) {
+        if (status !== 0) {
+          console.log('Error %o %o', status, data.message);
+        }
+      });
+    };
+
+    $scope.openPermissions = function() {
+      $scope.showPermissions = true;
+      getPermissions();
+    };
+
+    $scope.closePermissions = function() {
+      if (isPermissionsDirty()) {
+        BootstrapDialog.confirm({
+          closable: true,
+          title: '',
+          message: 'Changes will be discarded.',
+          callback: function(result) {
+            if (result) {
+              $scope.$apply(function() {
+                $scope.showPermissions = false;
               });
             }
-            return {
-              results: results,
-              pagination: {
-                more: false
-              }
-            };
-          },
-          cache: false
-        },
-        width: ' ',
-        tags: true,
-        minimumInputLength: 3
-      };
-
-      angular.element('#selectOwners').select2(selectJson);
-      angular.element('#selectReaders').select2(selectJson);
-      angular.element('#selectWriters').select2(selectJson);
-      if (callback) {
-        callback();
-      }
-    }).
-    error(function(data, status, headers, config) {
-      if (status !== 0) {
-        console.log('Error %o %o', status, data.message);
+          }
+        });
+      } else {
+        $scope.showPermissions = false;
       }
-    });
-  };
-
-  $scope.openPermissions = function() {
-    $scope.showPermissions = true;
-    getPermissions();
-  };
-
-  $scope.closePermissions = function() {
-    if (isPermissionsDirty()) {
-      BootstrapDialog.confirm({
-        closable: true,
-        title: '',
-        message: 'Changes will be discarded.',
-        callback: function(result) {
-          if (result) {
-            $scope.$apply(function() {
-              $scope.showPermissions = false;
+    };
+
+    function convertPermissionsToArray() {
+      $scope.permissions.owners = angular.element('#selectOwners').val();
+      $scope.permissions.readers = angular.element('#selectReaders').val();
+      $scope.permissions.writers = angular.element('#selectWriters').val();
+    }
+
+    $scope.savePermissions = function() {
+      convertPermissionsToArray();
+      $http.put(baseUrlSrv.getRestApiBase() + '/notebook/' + $scope.note.id + '/permissions',
+        $scope.permissions, {withCredentials: true}).
+        success(function(data, status, headers, config) {
+          getPermissions(function() {
+            console.log('Note permissions %o saved', $scope.permissions);
+            BootstrapDialog.alert({
+              closable: true,
+              title: 'Permissions Saved Successfully!!!',
+              message: 'Owners : ' + $scope.permissions.owners + '\n\n' + 'Readers : ' +
+              $scope.permissions.readers + '\n\n' + 'Writers  : ' + $scope.permissions.writers
             });
-          }
-        }
-      });
-    } else {
-      $scope.showPermissions = false;
-    }
-  };
-
-  function convertPermissionsToArray() {
-    $scope.permissions.owners = angular.element('#selectOwners').val();
-    $scope.permissions.readers = angular.element('#selectReaders').val();
-    $scope.permissions.writers = angular.element('#selectWriters').val();
-  }
-
-  $scope.savePermissions = function() {
-    convertPermissionsToArray();
-    $http.put(baseUrlSrv.getRestApiBase() + '/notebook/' + $scope.note.id + '/permissions',
-      $scope.permissions, {withCredentials: true}).
-      success(function(data, status, headers, config) {
-        getPermissions(function() {
-          console.log('Note permissions %o saved', $scope.permissions);
-          BootstrapDialog.alert({
-            closable: true,
-            title: 'Permissions Saved Successfully!!!',
-            message: 'Owners : ' + $scope.permissions.owners + '\n\n' + 'Readers : ' +
-            $scope.permissions.readers + '\n\n' + 'Writers  : ' + $scope.permissions.writers
+            $scope.showPermissions = false;
           });
-          $scope.showPermissions = false;
-        });
-      }).
-      error(function(data, status, headers, config) {
-        console.log('Error %o %o', status, data.message);
-        BootstrapDialog.show({
-          closable: false,
-          closeByBackdrop: false,
-          closeByKeyboard: false,
-          title: 'Insufficient privileges',
-          message: data.message,
-          buttons: [
-            {
-              label: 'Login',
-              action: function(dialog) {
-                dialog.close();
-                angular.element('#loginModal').modal({
-                  show: 'true'
-                });
-              }
-            },
-            {
-              label: 'Cancel',
-              action: function(dialog) {
-                dialog.close();
-                $location.path('/');
+        }).
+        error(function(data, status, headers, config) {
+          console.log('Error %o %o', status, data.message);
+          BootstrapDialog.show({
+            closable: false,
+            closeByBackdrop: false,
+            closeByKeyboard: false,
+            title: 'Insufficient privileges',
+            message: data.message,
+            buttons: [
+              {
+                label: 'Login',
+                action: function(dialog) {
+                  dialog.close();
+                  angular.element('#loginModal').modal({
+                    show: 'true'
+                  });
+                }
+              },
+              {
+                label: 'Cancel',
+                action: function(dialog) {
+                  dialog.close();
+                  $location.path('/');
+                }
               }
-            }
-          ]
+            ]
+          });
         });
-      });
-  };
-
-  $scope.togglePermissions = function() {
-    if ($scope.showPermissions) {
-      $scope.closePermissions();
-      angular.element('#selectOwners').select2({});
-      angular.element('#selectReaders').select2({});
-      angular.element('#selectWriters').select2({});
-    } else {
-      $scope.openPermissions();
-      $scope.closeSetting();
-    }
-  };
+    };
+
+    $scope.togglePermissions = function() {
+      if ($scope.showPermissions) {
+        $scope.closePermissions();
+        angular.element('#selectOwners').select2({});
+        angular.element('#selectReaders').select2({});
+        angular.element('#selectWriters').select2({});
+      } else {
+        $scope.openPermissions();
+        $scope.closeSetting();
+      }
+    };
 
-  var isSettingDirty = function() {
-    if (angular.equals($scope.interpreterBindings, $scope.interpreterBindingsOrig)) {
-      return false;
-    } else {
-      return true;
-    }
-  };
+    var isSettingDirty = function() {
+      if (angular.equals($scope.interpreterBindings, $scope.interpreterBindingsOrig)) {
+        return false;
+      } else {
+        return true;
+      }
+    };
 
-  var isPermissionsDirty = function() {
-    if (angular.equals($scope.permissions, $scope.permissionsOrig)) {
-      return false;
-    } else {
-      return true;
-    }
-  };
+    var isPermissionsDirty = function() {
+      if (angular.equals($scope.permissions, $scope.permissionsOrig)) {
+        return false;
+      } else {
+        return true;
+      }
+    };
 
-  angular.element(document).click(function() {
-    angular.element('.ace_autocomplete').hide();
-  });
+    angular.element(document).click(function() {
+      angular.element('.ace_autocomplete').hide();
+    });
 
-  /*
-  ** $scope.$on functions below
-  */
+    /*
+    ** $scope.$on functions below
+    */
 
-  $scope.$on('setConnectedStatus', function(event, param) {
-    if (connectedOnce && param) {
-      initNotebook();
-    }
-    connectedOnce = true;
-  });
+    $scope.$on('setConnectedStatus', function(event, param) {
+      if (connectedOnce && param) {
+        initNotebook();
+      }
+      connectedOnce = true;
+    });
 
-  $scope.$on('moveParagraphUp', function(event, paragraphId) {
-    var newIndex = -1;
-    for (var i = 0; i < $scope.note.paragraphs.length; i++) {
-      if ($scope.note.paragraphs[i].id === paragraphId) {
-        newIndex = i - 1;
-        break;
+    $scope.$on('moveParagraphUp', function(event, paragraphId) {
+      var newIndex = -1;
+      for (var i = 0; i < $scope.note.paragraphs.length; i++) {
+        if ($scope.note.paragraphs[i].id === paragraphId) {
+          newIndex = i - 1;
+          break;
+        }
       }
-    }
-    if (newIndex < 0 || newIndex >= $scope.note.paragraphs.length) {
-      return;
-    }
-    // save dirtyText of moving paragraphs.
-    var prevParagraphId = $scope.note.paragraphs[newIndex].id;
-    angular.element('#' + paragraphId + '_paragraphColumn_main').scope().saveParagraph();
-    angular.element('#' + prevParagraphId + '_paragraphColumn_main').scope().saveParagraph();
-    websocketMsgSrv.moveParagraph(paragraphId, newIndex);
-  });
-
-  $scope.$on('moveParagraphDown', function(event, paragraphId) {
-    var newIndex = -1;
-    for (var i = 0; i < $scope.note.paragraphs.length; i++) {
-      if ($scope.note.paragraphs[i].id === paragraphId) {
-        newIndex = i + 1;
-        break;
+      if (newIndex < 0 || newIndex >= $scope.note.paragraphs.length) {
+        return;
       }
-    }
+      // save dirtyText of moving paragraphs.
+      var prevParagraphId = $scope.note.paragraphs[newIndex].id;
+      angular.element('#' + paragraphId + '_paragraphColumn_main').scope().saveParagraph();
+      angular.element('#' + prevParagraphId + '_paragraphColumn_main').scope().saveParagraph();
+      websocketMsgSrv.moveParagraph(paragraphId, newIndex);
+    });
 
-    if (newIndex < 0 || newIndex >= $scope.note.paragraphs.length) {
-      return;
-    }
-    // save dirtyText of moving paragraphs.
-    var nextParagraphId = $scope.note.paragraphs[newIndex].id;
-    angular.element('#' + paragraphId + '_paragraphColumn_main').scope().saveParagraph();
-    angular.element('#' + nextParagraphId + '_paragraphColumn_main').scope().saveParagraph();
-    websocketMsgSrv.moveParagraph(paragraphId, newIndex);
-  });
-
-  $scope.$on('moveFocusToPreviousParagraph', function(event, currentParagraphId) {
-    var focus = false;
-    for (var i = $scope.note.paragraphs.length - 1; i >= 0; i--) {
-      if (focus === false) {
-        if ($scope.note.paragraphs[i].id === currentParagraphId) {
-          focus = true;
-          continue;
+    $scope.$on('moveParagraphDown', function(event, paragraphId) {
+      var newIndex = -1;
+      for (var i = 0; i < $scope.note.paragraphs.length; i++) {
+        if ($scope.note.paragraphs[i].id === paragraphId) {
+          newIndex = i + 1;
+          break;
         }
-      } else {
-        $scope.$broadcast('focusParagraph', $scope.note.paragraphs[i].id, -1);
-        break;
       }
-    }
-  });
-
-  $scope.$on('moveFocusToNextParagraph', function(event, currentParagraphId) {
-    var focus = false;
-    for (var i = 0; i < $scope.note.paragraphs.length; i++) {
-      if (focus === false) {
-        if ($scope.note.paragraphs[i].id === currentParagraphId) {
-          focus = true;
-          continue;
+
+      if (newIndex < 0 || newIndex >= $scope.note.paragraphs.length) {
+        return;
+      }
+      // save dirtyText of moving paragraphs.
+      var nextParagraphId = $scope.note.paragraphs[newIndex].id;
+      angular.element('#' + paragraphId + '_paragraphColumn_main').scope().saveParagraph();
+      angular.element('#' + nextParagraphId + '_paragraphColumn_main').scope().saveParagraph();
+      websocketMsgSrv.moveParagraph(paragraphId, newIndex);
+    });
+
+    $scope.$on('moveFocusToPreviousParagraph', function(event, currentParagraphId) {
+      var focus = false;
+      for (var i = $scope.note.paragraphs.length - 1; i >= 0; i--) {
+        if (focus === false) {
+          if ($scope.note.paragraphs[i].id === currentParagraphId) {
+            focus = true;
+            continue;
+          }
+        } else {
+          $scope.$broadcast('focusParagraph', $scope.note.paragraphs[i].id, -1);
+          break;
         }
-      } else {
-        $scope.$broadcast('focusParagraph', $scope.note.paragraphs[i].id, 0);
-        break;
       }
-    }
-  });
-
-  $scope.$on('insertParagraph', function(event, paragraphId, position) {
-    var newIndex = -1;
-    for (var i = 0; i < $scope.note.paragraphs.length; i++) {
-      if ($scope.note.paragraphs[i].id === paragraphId) {
-        //determine position of where to add new paragraph; default is below
-        if (position === 'above') {
-          newIndex = i;
+    });
+
+    $scope.$on('moveFocusToNextParagraph', function(event, currentParagraphId) {
+      var focus = false;
+      for (var i = 0; i < $scope.note.paragraphs.length; i++) {
+        if (focus === false) {
+          if ($scope.note.paragraphs[i].id === currentParagraphId) {
+            focus = true;
+            continue;
+          }
         } else {
-          newIndex = i + 1;
+          $scope.$broadcast('focusParagraph', $scope.note.paragraphs[i].id, 0);
+          break;
         }
-        break;
       }
-    }
+    });
 
-    if (newIndex < 0 || newIndex > $scope.note.paragraphs.length) {
-      return;
-    }
-    websocketMsgSrv.insertParagraph(newIndex);
-  });
+    $scope.$on('insertParagraph', function(event, paragraphId, position) {
+      var newIndex = -1;
+      for (var i = 0; i < $scope.note.paragraphs.length; i++) {
+        if ($scope.note.paragraphs[i].id === paragraphId) {
+          //determine position of where to add new paragraph; default is below
+          if (position === 'above') {
+            newIndex = i;
+          } else {
+            newIndex = i + 1;
+          }
+          break;
+        }
+      }
 
-  $scope.$on('setNoteContent', function(event, note) {
-    if (note === undefined) {
-      $location.path('/');
-    }
+      if (newIndex < 0 || newIndex > $scope.note.paragraphs.length) {
+        return;
+      }
+      websocketMsgSrv.insertParagraph(newIndex);
+    });
 
-    $scope.paragraphUrl = $routeParams.paragraphId;
-    $scope.asIframe = $routeParams.asIframe;
-    if ($scope.paragraphUrl) {
-      note = cleanParagraphExcept($scope.paragraphUrl, note);
-      $rootScope.$broadcast('setIframe', $scope.asIframe);
-    }
+    $scope.$on('setNoteContent', function(event, note) {
+      if (note === undefined) {
+        $location.path('/');
+      }
 
-    if ($scope.note === null) {
-      $scope.note = note;
-    } else {
-      updateNote(note);
-    }
-    initializeLookAndFeel();
-    //open interpreter binding setting when there're none selected
-    getInterpreterBindings();
-  });
+      $scope.paragraphUrl = $routeParams.paragraphId;
+      $scope.asIframe = $routeParams.asIframe;
+      if ($scope.paragraphUrl) {
+        note = cleanParagraphExcept($scope.paragraphUrl, note);
+        $rootScope.$broadcast('setIframe', $scope.asIframe);
+      }
+
+      if ($scope.note === null) {
+        $scope.note = note;
+      } else {
+        updateNote(note);
+      }
+      initializeLookAndFeel();
+      //open interpreter binding setting when there're none selected
+      getInterpreterBindings();
+    });
 
-  $scope.$on('$destroy', function() {
-    angular.element(window).off('beforeunload');
-    $scope.killSaveTimer();
-    $scope.saveNote();
+    $scope.$on('$destroy', function() {
+      angular.element(window).off('beforeunload');
+      $scope.killSaveTimer();
+      $scope.saveNote();
 
-    document.removeEventListener('click', $scope.focusParagraphOnClick);
-    document.removeEventListener('keydown', $scope.keyboardShortcut);
-  });
+      document.removeEventListener('click', $scope.focusParagraphOnClick);
+      document.removeEventListener('keydown', $scope.keyboardShortcut);
+    });
+  }
 
-});
+})();