zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prabhjyotsi...@apache.org
Subject zeppelin git commit: [ZEPPELIN-3415] Fix export notebook functionality
Date Mon, 23 Apr 2018 03:34:29 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/branch-0.8 532c54012 -> bd5b99ca3


[ZEPPELIN-3415] Fix export notebook functionality

Export functionality for both notebook and download data as CSV stopped working for Chrome.

[Bug Fix]

* [ZEPPELIN-3415](https://issues.apache.org/jira/browse/ZEPPELIN-3415)

* Try exporting notebook and/or download data as CSV for any table.

Before:
![download button before](https://user-images.githubusercontent.com/674497/38939688-1d397dd6-4346-11e8-8738-d3d0a00dc333.gif)

After:
![download button after](https://user-images.githubusercontent.com/674497/38939687-1d04681c-4346-11e8-8183-c46042ede815.gif)

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

Author: Prabhjyot Singh <prabhjyotsingh@gmail.com>

Closes #2932 from prabhjyotsingh/ZEPPELIN-3415 and squashes the following commits:

fae64e09d [Prabhjyot Singh] ZEPPELIN-3415: Fix export notebook functionality

Change-Id: Iad481bc304c6dd2d8c6fcb22cd4f4287c89b8d39
(cherry picked from commit 2472e2dac4049313d2fdf34d7d83c041dfa38f0a)
Signed-off-by: Prabhjyot Singh <prabhjyotsingh@gmail.com>


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

Branch: refs/heads/branch-0.8
Commit: bd5b99ca30173475d021cfaed3dbbb9c076e5bc4
Parents: 532c540
Author: Prabhjyot Singh <prabhjyotsingh@gmail.com>
Authored: Wed Apr 18 20:17:22 2018 +0530
Committer: Prabhjyot Singh <prabhjyotsingh@gmail.com>
Committed: Mon Apr 23 09:04:13 2018 +0530

----------------------------------------------------------------------
 .../src/app/notebook/save-as/save-as.service.js | 24 +++++++++-----------
 1 file changed, 11 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/bd5b99ca/zeppelin-web/src/app/notebook/save-as/save-as.service.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/save-as/save-as.service.js b/zeppelin-web/src/app/notebook/save-as/save-as.service.js
index 72a54d1..4653098 100644
--- a/zeppelin-web/src/app/notebook/save-as/save-as.service.js
+++ b/zeppelin-web/src/app/notebook/save-as/save-as.service.js
@@ -38,19 +38,17 @@ function SaveAsService(browserDetectService) {
       }
       angular.element('body > iframe#SaveAsId').remove();
     } else {
-      let binaryData = [];
-      binaryData.push(BOM);
-      binaryData.push(content);
-      content = window.URL.createObjectURL(new Blob(binaryData));
-
-      angular.element('body').append('<a id="SaveAsId"></a>');
-      let saveAsElement = angular.element('body > a#SaveAsId');
-      saveAsElement.attr('href', content);
-      saveAsElement.attr('download', filename + '.' + extension);
-      saveAsElement.attr('target', '_blank');
-      saveAsElement[0].click();
-      saveAsElement.remove();
-      window.URL.revokeObjectURL(content);
+      const fileName = filename + '.' + extension;
+      const json = JSON.stringify(content);
+      const blob = new Blob([json], {type: 'octet/stream'});
+      const url = window.URL.createObjectURL(blob);
+      let a = document.createElement('a');
+      document.body.appendChild(a);
+      a.style = 'display: none';
+      a.href = url;
+      a.download = fileName;
+      a.click();
+      window.URL.revokeObjectURL(url);
     }
   };
 }


Mime
View raw message