Add pdfmake dependency

This commit is contained in:
Kai S. K. Engelbart 2021-01-08 13:52:20 +01:00
parent e731882a5d
commit da51cd5621
4 changed files with 649 additions and 75 deletions

707
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -32,6 +32,7 @@
"flatpickr": "^4.6.3", "flatpickr": "^4.6.3",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"ng2-charts": "^2.3.2", "ng2-charts": "^2.3.2",
"pdfmake": "^0.1.70",
"quick-score": "0.0.8", "quick-score": "0.0.8",
"rxjs": "~6.5.5", "rxjs": "~6.5.5",
"str-compare": "^0.1.2", "str-compare": "^0.1.2",

View File

@ -61,9 +61,15 @@
</rb-form-radio> </rb-form-radio>
</div> </div>
<!-- CSV export -->
<rb-icon-button icon="forward-right" mode="primary" (click)="exportCSV()" *ngIf="spectrumNames.length"> <rb-icon-button icon="forward-right" mode="primary" (click)="exportCSV()" *ngIf="spectrumNames.length">
Export to CSV Export to CSV
</rb-icon-button> </rb-icon-button>
<!-- PDF exprot -->
<rb-icon-button icon="forward-right" mode="primary" (click)="exportPDF()" *ngIf="spectrumNames.length">
Export to PDF
</rb-icon-button>
</div> </div>
<div class="dpt-chart space-below"> <div class="dpt-chart space-below">

View File

@ -6,7 +6,11 @@ import cloneDeep from 'lodash/cloneDeep';
import omit from 'lodash/omit'; import omit from 'lodash/omit';
import { DataService } from '../services/data.service'; import { DataService } from '../services/data.service';
import { ModelItemModel } from '../models/model-item.model'; import { ModelItemModel } from '../models/model-item.model';
import * as FileSaver from 'file-saver' import * as FileSaver from 'file-saver';
import * as pdfMake from "pdfmake/build/pdfmake";
import * as pdfFonts from 'pdfmake/build/vfs_fonts';
(<any>pdfMake).vfs = pdfFonts.pdfMake.vfs;
@Component({ @Component({
@ -128,4 +132,8 @@ export class PredictionComponent implements OnInit {
const csv = predictions.map(line => line.join(";")).join("\n"); const csv = predictions.map(line => line.join(";")).join("\n");
FileSaver.saveAs(new Blob([csv], { type: 'text/csv;charset=utf-8' }), "predictions.csv"); FileSaver.saveAs(new Blob([csv], { type: 'text/csv;charset=utf-8' }), "predictions.csv");
} }
exportPDF() {
// TODO: Generate PDF export
}
} }