Merge pull request #4241 from MaximilianKrambach/csvExport

explicitly set mimetype for csv export
This commit is contained in:
Emanuel Schütze 2019-02-01 14:41:09 +01:00 committed by GitHub
commit dc1e48329f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 8 deletions

View File

@ -154,7 +154,7 @@ export class CsvExportService {
})
.join(lineSeparator);
this.exporter.saveFile(csvContentAsString, filename);
this.exporter.saveFile(csvContentAsString, filename, 'text/csv');
}
/**

View File

@ -14,9 +14,14 @@ export class FileExportService {
* Saves a file
* @param file
* @param filename
* @param mimeType an optional mime type
*/
public saveFile(file: BlobPart, filename: string): void {
const blob = new Blob([file]);
public saveFile(file: BlobPart, filename: string, mimeType?: string): void {
const options: BlobPropertyBag = {};
if (mimeType) {
options.type = mimeType;
}
const blob = new Blob([file], options);
saveAs(blob, filename, { autoBOM: true });
// autoBOM = automatic byte-order-mark
}

View File

@ -112,7 +112,7 @@ export class AgendaImportListComponent extends BaseImportListComponent<ViewCreat
'Break,,0:10,,internal',
'Demo 2,Demo text 2,1:30,,hidden'
];
this.exporter.saveFile(rows.join('\n'), this.translate.instant('Topic example') + '.csv');
this.exporter.saveFile(rows.join('\n'), this.translate.instant('Topic example') + '.csv', 'text/csv');
}
/**

View File

@ -75,6 +75,6 @@ export class MotionCsvExportService {
'B1,Title 2,Text 2,Reason 2,Submitter B, Category B,, Block A',
',Title 3, Text 3,,,,,'
];
this.fileExport.saveFile(rows.join('\n'), this.translate.instant('motions-example') + '.csv');
this.fileExport.saveFile(rows.join('\n'), this.translate.instant('motions-example') + '.csv', 'text/csv');
}
}

View File

@ -52,7 +52,8 @@ export class StatuteCsvExportService {
];
this.fileExport.saveFile(
rows.join('\n'),
`${this.translate.instant('Statutes')} - ${this.translate.instant('example')}.csv`
`${this.translate.instant('Statutes')} - ${this.translate.instant('example')}.csv`,
'text/csv'
);
}
}

View File

@ -69,7 +69,7 @@ export class UserImportListComponent extends BaseImportListComponent<ViewUser> {
',Fred,Bloggs,London,,,,,,,,',
',,Executive Board,,,,,,,1,,'
];
this.exporter.saveFile(rows.join('\n'), this.translate.instant('participants-example') + '.csv');
this.exporter.saveFile(rows.join('\n'), this.translate.instant('participants-example') + '.csv', 'text/csv');
}
/**

View File

@ -3,7 +3,7 @@ coverage
flake8
isort
mypy
pytest
pytest<4.2.0
pytest-django
pytest-asyncio
pytest-cov