You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by ah...@apache.org on 2017/01/05 02:11:38 UTC

zeppelin git commit: [ZEPPELIN-1789] Make exported data file name more explicit

Repository: zeppelin
Updated Branches:
  refs/heads/master 4723c88a1 -> 9b430de18


[ZEPPELIN-1789] Make exported data file name more explicit

### What is this PR for?
Currently we can download table data set as `.csv` or `.tsv` format in Zeppelin note. But since the exported file name is always set as `data.csv`, it will be difficult to distinguish the each file if user tries to export it several times. So I changed the naming rule like below.

1. if the paragraph has title e.g. `this is title`, then the exported csv file name will be
`this is title_YYYY-MM-DD hh:mm:ss a.csv` .

2. if not, the file name will be `data_YYYY-MM-DD hh:mm:ss a.csv` .

Please see the short discussion in [ZEPPELIN-1789](https://issues.apache.org/jira/browse/ZEPPELIN-1789) for the more details. I just made this PR by following one person's opinion who raised this issue (_Ruslan Dautkhanov_ ). So if anyone has better idea, please feel free to share :)

### What type of PR is it?
Improvement

### What is the Jira issue?
[ZEPPELIN-1789](https://issues.apache.org/jira/browse/ZEPPELIN-1789)

### How should this be tested?
1. run Zeppelin web dev mode under `zeppelin-web`

```
$ npm run dev
```

2. browse `http://localhost:9000` and go to Zeppelin-Spark tutorial note
3. click ![screen shot 2016-12-30 at 2 26 32 pm](https://cloud.githubusercontent.com/assets/10060731/21560080/fcf86cdc-ce9b-11e6-8fe3-a8ea0bd9141d.png)

If the paragraph has title, then the exported file name will be `"paragraph_title_YYYY-MM-DD hh:mm:ss a".csv`, if not, will be `"data_YYYY-MM-DD hh:mm:ss a".csv`.

> The timestamp is not current time but paragraph finished time

### Screenshots (if appropriate)

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

Author: AhyoungRyu <fb...@hanmail.net>

Closes #1822 from AhyoungRyu/ZEPPELIN-1789 and squashes the following commits:

beb7558 [AhyoungRyu] Change exported filename prefix: 'Exported_data' to 'data'
d7d0087 [AhyoungRyu] Change timestamp to dateFinished instead of currentTime
64c3e18 [AhyoungRyu] Make exported data file name more explicit


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

Branch: refs/heads/master
Commit: 9b430de184107c7eb1c2960cf6eb8e0d26f610f6
Parents: 4723c88
Author: AhyoungRyu <fb...@hanmail.net>
Authored: Wed Jan 4 11:11:53 2017 +0900
Committer: ahyoungryu <ah...@apache.org>
Committed: Thu Jan 5 11:11:33 2017 +0900

----------------------------------------------------------------------
 .../src/app/notebook/paragraph/result/result.controller.js      | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9b430de1/zeppelin-web/src/app/notebook/paragraph/result/result.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/paragraph/result/result.controller.js b/zeppelin-web/src/app/notebook/paragraph/result/result.controller.js
index fd9b6ac..fb1a96e 100644
--- a/zeppelin-web/src/app/notebook/paragraph/result/result.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/result/result.controller.js
@@ -594,6 +594,9 @@ import ScatterchartVisualization from '../../../visualization/builtins/visualiza
 
     $scope.exportToDSV = function(delimiter) {
       var dsv = '';
+      var dateFinished = moment(paragraph.dateFinished).format('YYYY-MM-DD hh:mm:ss A');
+      var exportedFileName = paragraph.title ? paragraph.title + '_' + dateFinished : 'data_' + dateFinished;
+
       for (var titleIndex in tableData.columns) {
         dsv += tableData.columns[titleIndex].name + delimiter;
       }
@@ -617,7 +620,7 @@ import ScatterchartVisualization from '../../../visualization/builtins/visualiza
       } else if (delimiter === ',') {
         extension = 'csv';
       }
-      saveAsService.saveAs(dsv, 'data', extension);
+      saveAsService.saveAs(dsv, exportedFileName, extension);
     };
 
     $scope.getBase64ImageSrc = function(base64Data) {