streampipes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [incubator-streampipes] branch dev updated: [STREAMPIPES-47]Rename File-Download Files
Date Wed, 18 Dec 2019 15:53:16 GMT
This is an automated email from the ASF dual-hosted git repository.

tex pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 9b9dec5  [STREAMPIPES-47]Rename File-Download Files
9b9dec5 is described below

commit 9b9dec5a930f62ce90035bdb50318578e520877e
Author: tex <tex@fzi.de>
AuthorDate: Wed Dec 18 16:41:38 2019 +0100

    [STREAMPIPES-47]Rename File-Download Files
---
 .../datadownloadDialog/dataDownload.dialog.ts      | 31 +++++++++++++++-------
 .../data-explorer/explorer/explorer.component.ts   |  2 +-
 2 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/ui/src/app/data-explorer/explorer/datadownloadDialog/dataDownload.dialog.ts b/ui/src/app/data-explorer/explorer/datadownloadDialog/dataDownload.dialog.ts
index 64e0e73..808081b 100644
--- a/ui/src/app/data-explorer/explorer/datadownloadDialog/dataDownload.dialog.ts
+++ b/ui/src/app/data-explorer/explorer/datadownloadDialog/dataDownload.dialog.ts
@@ -53,35 +53,39 @@ export class DataDownloadDialog {
             case "visible":
 
                 if (this.data.yAxesKeys === undefined) {
-                    this.createFile('', this.downloadFormat, this.data.index)
+                    this.createFile('', this.downloadFormat, this.data.index, this.getDateString(this.data.date[0]),
+                      this.getDateString((this.data.date[1])));
 
                 } else if (this.data.data["headers"] !== undefined) {
                  //Single Data
                     let result = this.convertData(this.data.data, this.downloadFormat, this.data.xAxesKey,
this.data.yAxesKeys);
-                    this.createFile(result, this.data.downloadFormat, this.data.index);
+                    this.createFile(result, this.data.downloadFormat, this.data.index, this.getDateString(this.data.date[0]),
+                      this.getDateString(this.data.date[1]));
                 } else {
                     //group data
                     Object.keys(this.data.data.dataResults).forEach( groupName => {
                         let dataResult = this.data.data.dataResults[groupName];
                         let result = this.convertData(dataResult, this.downloadFormat, this.data.xAxesKey,
this.data.yAxesKeys);
                         let fileName = this.data.index + ' ' + groupName;
-                        this.createFile(result, this.data.downloadFormat, fileName);
+                        this.createFile(result, this.data.downloadFormat, fileName, this.getDateString(this.data.date[0]),
+                          this.getDateString(this.data.date[1]));
                     });
 
                 }
                 this.downloadFinish = true;
                 break;
             case "all":
-                this.performRequest(this.restService.downloadRowData(this.data.index, this.downloadFormat));
+                this.performRequest(this.restService.downloadRowData(this.data.index, this.downloadFormat),
'', '');
                 break;
             case "customInterval":
                 this.performRequest(this.restService.downloadRowDataTimeInterval(this.data.index,
this.downloadFormat,
-                    this.dateRange[0].getTime(), this.dateRange[1].getTime()));
+                    this.dateRange[0].getTime(), this.dateRange[1].getTime()), this.getDateString(this.dateRange[0]),
+                  this.getDateString(this.dateRange[1]));
 
         }
     }
 
-    performRequest(request) {
+    performRequest(request, startDate, endDate) {
         this.downloadHttpRequestSubscribtion = request.subscribe(event => {
             // progress
             if (event.type === HttpEventType.DownloadProgress) {
@@ -90,7 +94,7 @@ export class DataDownloadDialog {
 
             // finished
             if (event.type === HttpEventType.Response) {
-                this.createFile(event.body, this.downloadFormat, this.data.index);
+                this.createFile(event.body, this.downloadFormat, this.data.index, startDate,
endDate);
                 this.downloadFinish = true
             }
         });
@@ -146,14 +150,18 @@ export class DataDownloadDialog {
         }
     }
 
-    createFile(data, format, fileName) {
+    createFile(data, format, fileName, startDate, endDate) {
         var a = document.createElement("a");
         document.body.appendChild(a);
         a.style.display = "display: none";
 
+        //let name = 'sp_' + startDate + '_' + endDate + '_' + fileName + '.' + this.downloadFormat;
+        let name = 'sp_' + startDate + '_' + fileName + '.' + this.downloadFormat;
+        name = name.replace('__','_');
+
         var url = window.URL.createObjectURL(new Blob([String(data)], { type: 'data:text/'
+ format + ';charset=utf-8' }));
         a.href = url;
-        a.download = 'spDatalake ' +  fileName + '.' + this.downloadFormat;
+        a.download = name;
         a.click();
         window.URL.revokeObjectURL(url)
     }
@@ -179,4 +187,9 @@ export class DataDownloadDialog {
         this.stepper.previous();
     }
 
+    getDateString(date: Date) {
+        return date.toLocaleDateString() + 'T' + date.toLocaleTimeString().replace(':','.')
+                                                                          .replace(':','.');
+    }
+
 }
\ No newline at end of file
diff --git a/ui/src/app/data-explorer/explorer/explorer.component.ts b/ui/src/app/data-explorer/explorer/explorer.component.ts
index 9dbc36a..ae9baec 100644
--- a/ui/src/app/data-explorer/explorer/explorer.component.ts
+++ b/ui/src/app/data-explorer/explorer/explorer.component.ts
@@ -314,7 +314,7 @@ export class ExplorerComponent implements OnInit {
     downloadDataAsFile() {
         const dialogRef = this.dialog.open(DataDownloadDialog, {
             width: '600px',
-            data: {data: this.data, xAxesKey: this.xAxesKey, yAxesKeys: this.yAxesKeys, index:
this.selectedInfoResult.measureName},
+            data: {data: this.data, xAxesKey: this.xAxesKey, yAxesKeys: this.yAxesKeys, index:
this.selectedInfoResult.measureName, date: this.dateRange},
             panelClass: 'custom-dialog-container'
 
         });


Mime
View raw message