Repository: zeppelin
Updated Branches:
  refs/heads/branch-0.6 a058121c8 -> e4be11988


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

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.

Bug Fix

NA

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

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

![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)

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

Author: vensant <[email protected]>

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

(cherry picked from commit f0818ce266f82bd48570f6427fde7f6566d4695d)
Signed-off-by: Mina Lee <[email protected]>

Conflicts:
        zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js
        zeppelin-web/src/components/websocketEvents/websocketMsg.service.js


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

Branch: refs/heads/branch-0.6
Commit: e4be1198839e1f34daf43dfe60e59b0ca32294b0
Parents: a058121
Author: vensant <[email protected]>
Authored: Thu Sep 29 12:57:43 2016 +0530
Committer: Mina Lee <[email protected]>
Committed: Wed Oct 5 11:36:34 2016 +0900

----------------------------------------------------------------------
 .../noteName-import/note-import-dialog.html          |  3 +++
 .../noteName-import/notenameImport.controller.js     | 15 +++++++++++++++
 .../websocketEvents/websocketEvents.factory.js       |  2 ++
 .../websocketEvents/websocketMsg.service.js          |  6 +++++-
 4 files changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e4be1198/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 524e4d2..93921da 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/e4be1198/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 d48179d..3b82de0 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);
     };
@@ -107,4 +121,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/e4be1198/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 e07fb16..c59b171 100644
--- a/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js
+++ b/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js
@@ -96,6 +96,8 @@ angular.module('zeppelinWebApp').factory('websocketEvents', 
function($rootScope,
       $rootScope.$broadcast('angularObjectUpdate', data);
     } else if (op === 'ANGULAR_OBJECT_REMOVE') {
       $rootScope.$broadcast('angularObjectRemove', data);
+    } else if (op === 'CONFIGURATIONS_INFO') {
+      $rootScope.$broadcast('configurationsInfo', data);
     }
   });
 

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e4be1198/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 3b4df03..2158b16 100644
--- a/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js
+++ b/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js
@@ -161,8 +161,12 @@ 
angular.module('zeppelinWebApp').service('websocketMsgSrv', function($rootScope,
       });
     },
 
-    isConnected: function(){
+    isConnected: function() {
       return websocketEvents.isConnected();
+    },
+
+    listConfigurations: function() {
+      websocketEvents.sendNewEvent({op: 'LIST_CONFIGURATIONS'});
     }
 
   };

Reply via email to