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 05:32:53 UTC

zeppelin git commit: [ZEPPELIN-868] Notebook import fails when notebook is large

Repository: zeppelin
Updated Branches:
  refs/heads/master 5e02186df -> f0818ce26


[ZEPPELIN-868] Notebook import fails when notebook is large

### What is this PR for?
A bug fix: Added validation in the note import dialog box to check for the uploaded json file size and throw error report if the file size exceeds 1MB, as the websocket frame is not able to send json file of size over 1MB.

### What type of PR is it?
Bug Fix

### Todos
NA

### What is the Jira issue?

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

### How should this be tested?
1. Deploy Zeppelin and click on 'Import Note' in the Welcome to Zeppelin page.
2. Click 'Choose a JSON here' and upload a json file whose file size is over 1MB

### Screenshots (if appropriate)
![1](https://cloud.githubusercontent.com/assets/12062069/18556899/7add7a12-7b8a-11e6-85e6-f8b4fcef2195.png)
![2](https://cloud.githubusercontent.com/assets/12062069/18556966/b10bcb0c-7b8a-11e6-9448-1381d8e05d8f.png)
![3](https://cloud.githubusercontent.com/assets/12062069/18556999/d166b8a8-7b8a-11e6-927b-caa3a56618d1.png)
![4](https://cloud.githubusercontent.com/assets/12062069/18557002/d58f8d74-7b8a-11e6-8955-710eb093a795.png)

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

Author: vensant <ve...@imaginea.com>

Closes #1430 from vensant/ZEPPELIN-868 and squashes the following commits:

29ad4ce [vensant] committed the code which missed during rebase
bd1acc0 [vensant] fixed the review comments on the pull request
c65f2c7 [vensant] client level validation added for import file size check
5dcdcfe [vensant] made changes for reading the max limit from the configuration list and dynamically showing it in UI
e48aac6 [vensant] Rectified the errors due to grunt build no color failure
77a0cc1 [vensant] Added validation in the note import dialog box to check for the uploaded json file size as the websocket frame is not able to send file of size over 1MB


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

Branch: refs/heads/master
Commit: f0818ce266f82bd48570f6427fde7f6566d4695d
Parents: 5e02186
Author: vensant <ve...@imaginea.com>
Authored: Thu Sep 29 12:57:43 2016 +0530
Committer: Damien CORNEAU <co...@gmail.com>
Committed: Mon Oct 3 14:33:01 2016 +0900

----------------------------------------------------------------------
 .../noteName-import/note-import-dialog.html          |  3 +++
 .../noteName-import/notenameImport.controller.js     | 15 +++++++++++++++
 .../websocketEvents/websocketEvents.factory.js       | 14 ++++++++------
 .../websocketEvents/websocketMsg.service.js          |  4 ++++
 4 files changed, 30 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/f0818ce2/zeppelin-web/src/components/noteName-import/note-import-dialog.html
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/noteName-import/note-import-dialog.html b/zeppelin-web/src/components/noteName-import/note-import-dialog.html
index 4922cb8..084f108 100644
--- a/zeppelin-web/src/components/noteName-import/note-import-dialog.html
+++ b/zeppelin-web/src/components/noteName-import/note-import-dialog.html
@@ -29,6 +29,9 @@ limitations under the License.
             <input placeholder="Note name" type="text" class="form-control" id="noteImportName"
                    ng-model="note.noteImportName" />
           </div>
+          <div class="form-group">
+            <label for="fileSizeLimit">JSON file size cannot exceed {{maxLimit}} MB</label>
+          </div>
 
           <div class="form-group" ng-show="note.errorText">
             <div class="alert alert-danger">{{note.errorText}}</div>

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/f0818ce2/zeppelin-web/src/components/noteName-import/notenameImport.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/noteName-import/notenameImport.controller.js b/zeppelin-web/src/components/noteName-import/notenameImport.controller.js
index dea3dd3..4c9aa32 100644
--- a/zeppelin-web/src/components/noteName-import/notenameImport.controller.js
+++ b/zeppelin-web/src/components/noteName-import/notenameImport.controller.js
@@ -19,6 +19,14 @@ angular.module('zeppelinWebApp').controller('NoteImportCtrl', function($scope, $
   $scope.note = {};
   $scope.note.step1 = true;
   $scope.note.step2 = false;
+  $scope.maxLimit = '';
+  var limit = 0;
+
+  websocketMsgSrv.listConfigurations();
+  $scope.$on('configurationsInfo', function(scope, event) {
+    limit = event.configurations['zeppelin.websocket.max.text.message.size'];
+    $scope.maxLimit = Math.round(limit / 1048576);
+  });
 
   vm.resetFlags = function() {
     $scope.note = {};
@@ -37,6 +45,12 @@ angular.module('zeppelinWebApp').controller('NoteImportCtrl', function($scope, $
     var file = $scope.note.importFile;
     var reader = new FileReader();
 
+    if (file.size > limit) {
+      $scope.note.errorText = 'File size limit Exceeded!';
+      $scope.$apply();
+      return;
+    }
+
     reader.onloadend = function() {
       vm.processImportJson(reader.result);
     };
@@ -110,4 +124,5 @@ angular.module('zeppelinWebApp').controller('NoteImportCtrl', function($scope, $
     vm.resetFlags();
     angular.element('#noteImportModal').modal('hide');
   });
+
 });

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/f0818ce2/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js b/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js
index 6e0bbba..e99d6aa 100644
--- a/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js
+++ b/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js
@@ -125,13 +125,15 @@ angular.module('zeppelinWebApp').factory('websocketEvents',
         title: 'Details',
         message: data.info.toString(),
         buttons: [{
-            // close all the dialogs when there are error on running all paragraphs
-            label: 'Close',
-            action: function() {
-              BootstrapDialog.closeAll();
-            }
-          }]
+          // close all the dialogs when there are error on running all paragraphs
+          label: 'Close',
+          action: function() {
+            BootstrapDialog.closeAll();
+          }
+        }]
       });
+    } else if (op === 'CONFIGURATIONS_INFO') {
+      $rootScope.$broadcast('configurationsInfo', data);
     }
   });
 

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/f0818ce2/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js b/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js
index 3b27bce..90303c3 100644
--- a/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js
+++ b/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js
@@ -214,6 +214,10 @@ angular.module('zeppelinWebApp').service('websocketMsgSrv', function($rootScope,
     saveInterpreterBindings: function(noteID, selectedSettingIds) {
       websocketEvents.sendNewEvent({op: 'SAVE_INTERPRETER_BINDINGS',
         data: {noteID: noteID, selectedSettingIds: selectedSettingIds}});
+    },
+
+    listConfigurations: function() {
+      websocketEvents.sendNewEvent({op: 'LIST_CONFIGURATIONS'});
     }
 
   };