-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(datapoints-graph): added export to csv #20
Conversation
"jest-fail-on-console": "^3.1.1", | ||
"jest-preset-angular": "^12.2.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"jest-preset-angular": "^12.2.0", | |
"jest-preset-angular": "^12.2.0", | |
"@types/file-saver": "^2.0.7", |
this.isLoading = true; | ||
import('file-saver').then((fileSaver) => { | ||
for (const series of this.csvData) { | ||
const dataSet = series.data | ||
.map((value: string[]) => value.join(this.form.separator)) | ||
.join('\n'); | ||
const blob = new Blob([dataSet], { type: 'text/csv;charset=utf-8' }); | ||
fileSaver.default.saveAs(blob, `${this.form.fileName}${series.id}.csv`); | ||
} | ||
|
||
this.isLoading = false; | ||
this.bsModalRef.hide(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.isLoading = true; | |
import('file-saver').then((fileSaver) => { | |
for (const series of this.csvData) { | |
const dataSet = series.data | |
.map((value: string[]) => value.join(this.form.separator)) | |
.join('\n'); | |
const blob = new Blob([dataSet], { type: 'text/csv;charset=utf-8' }); | |
fileSaver.default.saveAs(blob, `${this.form.fileName}${series.id}.csv`); | |
} | |
this.isLoading = false; | |
this.bsModalRef.hide(); | |
}); | |
import { saveAs } from 'file-saver'; | |
... | |
this.isLoading = true; | |
for (const series of this.csvData) { | |
const dataSet = series.data | |
.map((value: string[]) => value.join(this.form.separator)) | |
.join('\n'); | |
const blob = new Blob([dataSet], { type: 'text/csv;charset=utf-8' }); | |
saveAs(blob, `${this.form.fileName}${series.id}.csv`); | |
} | |
this.isLoading = false; | |
this.bsModalRef.hide(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why using import in method (as inline method, in method)? package file-saver is rather lightweightm, does it need lazy loading? also, after adding types, it's usage is more predictable (e.g. I immediately know that it is synchronous, but I was not sure before)
also I found a little issue on chrome- when we try to download multiple files at once (our case- I try to download csv of two series in data points graph), chrome blocks it and it's easy to miss that second file download was blocked. not sure if it's possible to handle as it's browser limitation, but if there is- it's worth to make it more user friendly. |
Proposed changes
Adds a CSV export to the datapoints view
Types of changes
Paste Link to the issue
#18
Checklist