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/04/04 04:20:49 UTC

incubator-zeppelin git commit: [ZEPPELIN-696] Add notification system for AngularJS z functions

Repository: incubator-zeppelin
Updated Branches:
  refs/heads/master f8265bb33 -> b51af33cb


[ZEPPELIN-696] Add notification system for AngularJS z functions

### What is this PR for?
Add notification system for AngularJS z functions. Now that we expose the `z` Angular object, we should also catch error/exceptions and display error messages properly to the user.

I changed a little bit the default settings for **ngToast**. Instead of having notifications on **bottom right**, I let the default value undefined.

For **Interpreter** page notification, I force the position to **bottom right** as before when using default config.

For `z` functions error messages, I choose to display notifications on **top right** corner because it's clearer. See screen capture

_This is a sub-task of epic **[ZEPPELIN-635]**_

### What type of PR is it?
[Improvement]

### Todos
* [ ] - Code Review
* [ ] - Simple Test

### Is there a relevant Jira issue?
**[ZEPPELIN-696]**

### How should this be tested?
* `git fetch origin pull/744/head:AngularJSNotification`
* `git checkout AngularJSNotification`
* `mvn clean package -DskipTests`
* `bin/zeppelin-daemon.sh restart`
* Create a new note
* In the first paragraph, put the following code

```html
%angular

<form class="form-inline">
  <button type="submit" class="btn btn-primary" ng-click="z.runParagraph()"> Run Paragraph Without Id</button>
  <button type="submit" class="btn btn-primary" ng-click="z.runParagraph('20160223-141919_305734436')"> Run Paragraph Without Wrong Id</button>
  <button type="submit" class="btn btn-primary" ng-click="z.angularBind('superhero', superhero)"> Angular Bind Without Paragraph Id</button>
  <button type="submit" class="btn btn-primary" ng-click="z.angularUnbind('superhero')"> Angular UnBind Without Paragraph Id</button>
</form>
```
* Click on each button to see the appropriate error message

### Screenshots (if appropriate)
![angularnotification](https://cloud.githubusercontent.com/assets/1532977/13901504/734b5112-ee26-11e5-9962-bcf2101eb700.gif)

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

[angular-growl-2]: http://janstevens.github.io/angular-growl-2/
[ZEPPELIN-635]: https://issues.apache.org/jira/browse/ZEPPELIN-635
[ZEPPELIN-696]: https://issues.apache.org/jira/browse/ZEPPELIN-696

Author: DuyHai DOAN <do...@gmail.com>

Closes #744 from doanduyhai/ZEPPELIN-696 and squashes the following commits:

0f7bff4 [DuyHai DOAN] [ZEPPELIN-696] Add notification system for AngularJS z functions


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

Branch: refs/heads/master
Commit: b51af33cb1e74f337ee119f8a26f87989d86fcbc
Parents: f8265bb
Author: DuyHai DOAN <do...@gmail.com>
Authored: Sun Mar 27 11:40:18 2016 +0200
Committer: Damien CORNEAU <co...@gmail.com>
Committed: Mon Apr 4 11:20:34 2016 +0900

----------------------------------------------------------------------
 zeppelin-web/src/app/app.js                      |  3 +--
 .../app/interpreter/interpreter.controller.js    |  6 +++---
 .../notebook/paragraph/paragraph.controller.js   | 19 +++++++++++++++++--
 .../src/assets/styles/looknfeel/default.css      |  4 ++++
 .../src/assets/styles/looknfeel/report.css       |  4 ++++
 .../src/assets/styles/looknfeel/simple.css       |  4 ++++
 6 files changed, 33 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/b51af33c/zeppelin-web/src/app/app.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/app.js b/zeppelin-web/src/app/app.js
index ff2be77..16fad36 100644
--- a/zeppelin-web/src/app/app.js
+++ b/zeppelin-web/src/app/app.js
@@ -81,8 +81,7 @@
             ngToastProvider.configure({
                 dismissButton: true,
                 dismissOnClick: false,
-                timeout: 6000,
-                verticalPosition: 'bottom'
+                timeout: 6000
             });
         });
 

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/b51af33c/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 ab66033..195360a 100644
--- a/zeppelin-web/src/app/interpreter/interpreter.controller.js
+++ b/zeppelin-web/src/app/interpreter/interpreter.controller.js
@@ -75,7 +75,7 @@ angular.module('zeppelinWebApp').controller('InterpreterCtrl', function($scope,
       // add missing field of option
       if (!setting.option) {
         setting.option = {};
-      }      
+      }
       if (setting.option.remote === undefined) {
         // remote always true for now
         setting.option.remote = true;
@@ -94,7 +94,7 @@ angular.module('zeppelinWebApp').controller('InterpreterCtrl', function($scope,
         }).
         error(function (data, status, headers, config) {
           console.log('Error %o %o', status, data.message);
-          ngToast.danger(data.message);
+          ngToast.danger({content: data.message, verticalPosition: 'bottom'});
           form.$show();
         });
     }
@@ -210,7 +210,7 @@ angular.module('zeppelinWebApp').controller('InterpreterCtrl', function($scope,
       }).
       error(function(data, status, headers, config) {
         console.log('Error %o %o', status, data.message);
-        ngToast.danger(data.message);
+        ngToast.danger({content: data.message, verticalPosition: 'bottom'});
       });
   };
 

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/b51af33c/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 bb9bc89..599ed90 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
@@ -16,7 +16,7 @@
 
 angular.module('zeppelinWebApp')
   .controller('ParagraphCtrl', function($scope,$rootScope, $route, $window, $element, $routeParams, $location,
-                                         $timeout, $compile, websocketMsgSrv) {
+                                         $timeout, $compile, websocketMsgSrv, ngToast) {
   var ANGULAR_FUNCTION_OBJECT_NAME_PREFIX = '_Z_ANGULAR_FUNC_';
   $scope.parentNote = null;
   $scope.paragraph = null;
@@ -39,8 +39,13 @@ angular.module('zeppelinWebApp')
           websocketMsgSrv.runParagraph(paragraph.id, paragraph.title, paragraph.text,
               paragraph.config, paragraph.settings.params);
         } else {
-          // Error message here
+          ngToast.danger({content: 'Cannot find a paragraph with id \'' + paragraphId + '\'',
+            verticalPosition: 'top', dismissOnTimeout: false});
         }
+      } else {
+        ngToast.danger({
+          content: 'Please provide a \'paragraphId\' when calling z.runParagraph(paragraphId)',
+          verticalPosition: 'top', dismissOnTimeout: false});
       }
     },
 
@@ -49,6 +54,11 @@ angular.module('zeppelinWebApp')
       // Only push to server if there paragraphId is defined
       if (paragraphId) {
         websocketMsgSrv.clientBindAngularObject($routeParams.noteId, varName, value, paragraphId);
+      } else {
+        ngToast.danger({
+          content: 'Please provide a \'paragraphId\' when calling ' +
+          'z.angularBind(varName, value, \'PUT_HERE_PARAGRAPH_ID\')',
+          verticalPosition: 'top', dismissOnTimeout: false});
       }
     },
 
@@ -57,6 +67,11 @@ angular.module('zeppelinWebApp')
       // Only push to server if paragraphId is defined
       if (paragraphId) {
         websocketMsgSrv.clientUnbindAngularObject($routeParams.noteId, varName, paragraphId);
+      } else {
+        ngToast.danger({
+          content: 'Please provide a \'paragraphId\' when calling ' +
+          'z.angularUnbind(varName, \'PUT_HERE_PARAGRAPH_ID\')',
+          verticalPosition: 'top', dismissOnTimeout: false});
       }
     }
   };

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/b51af33c/zeppelin-web/src/assets/styles/looknfeel/default.css
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/assets/styles/looknfeel/default.css b/zeppelin-web/src/assets/styles/looknfeel/default.css
index 3e0c461..9803bc2 100644
--- a/zeppelin-web/src/assets/styles/looknfeel/default.css
+++ b/zeppelin-web/src/assets/styles/looknfeel/default.css
@@ -33,3 +33,7 @@ body {
   border-color: white;
 }
 
+.ng-toast.ng-toast--top {
+  top: 100px;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/b51af33c/zeppelin-web/src/assets/styles/looknfeel/report.css
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/assets/styles/looknfeel/report.css b/zeppelin-web/src/assets/styles/looknfeel/report.css
index 0a15e8a..8c850ef 100644
--- a/zeppelin-web/src/assets/styles/looknfeel/report.css
+++ b/zeppelin-web/src/assets/styles/looknfeel/report.css
@@ -73,3 +73,7 @@ body {
 .noteAction button.btn {
   border-radius: 4px !important;
 }
+
+.ng-toast.ng-toast--top {
+  top: 100px;
+}

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/b51af33c/zeppelin-web/src/assets/styles/looknfeel/simple.css
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/assets/styles/looknfeel/simple.css b/zeppelin-web/src/assets/styles/looknfeel/simple.css
index 7817da2..8373114 100644
--- a/zeppelin-web/src/assets/styles/looknfeel/simple.css
+++ b/zeppelin-web/src/assets/styles/looknfeel/simple.css
@@ -89,3 +89,7 @@ body {
 .nv-controlsWrap {
   display: block;
 }
+
+.ng-toast.ng-toast--top {
+  top: 100px;
+}