Skip to content

Commit

Permalink
fix: pdf report generation: sync with charts generation
Browse files Browse the repository at this point in the history
  • Loading branch information
edelclaux committed May 2, 2024
1 parent db567fc commit be0c571
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ <h3>
<button
mat-raised-button
color="primary"
[disabled]="loadingPdf"
[disabled]="loadingPdf || loadingChart"
(click)="exportAsPDF()"
class="align-self-center"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ import { FieldMappingValues } from '../../models/mapping.model';
import { HttpClient } from '@angular/common/http';
import { finalize } from 'rxjs/operators';

interface MatchedNomenclature {
source: Nomenclature;
target: Nomenclature;
}

@Component({
selector: 'pnx-import-report',
templateUrl: 'import_report.component.html',
Expand Down Expand Up @@ -57,6 +52,7 @@ export class ImportReportComponent implements OnInit {
public nbTotalErrors: number = 0;
public datasetName: string = '';
public rank: string = null;
public loadingChart: boolean
public options: any = {
legend: { position: 'left' },
};
Expand All @@ -79,14 +75,16 @@ export class ImportReportComponent implements OnInit {
private _map: MapService,
public _csvExport: CsvExportService,
public config: ConfigService,
private _httpclient: HttpClient
private _httpclient: HttpClient,

) {
this.rank = this.rankOptions.includes(this.config.IMPORT.DEFAULT_RANK)
? this.config.IMPORT.DEFAULT_RANK
: this.rankOptions[0];
}

ngOnInit() {
this.loadingChart = true;
this.importData = this.importProcessService.getImportData();
// Load additionnal data if imported data
this.loadValidData(this.importData);
Expand All @@ -102,10 +100,10 @@ export class ImportReportComponent implements OnInit {
this.nomenclatures = nomenclatures;
});
this._dataService
.getReportPlot(this.importData.destination.code, this.importData.id_import)
.subscribe((data) => {
Bokeh.embed.embed_item(data, 'chartreport');
});
.getReportPlot(this.importData.destination.code, this.importData.id_import).pipe(
finalize(() => this.loadingChart = false)).subscribe((data) => {
Bokeh.embed.embed_item(data, 'chartreport');
});
}

/** Gets the validBbox and validData (info about observations)
Expand Down Expand Up @@ -176,7 +174,7 @@ export class ImportReportComponent implements OnInit {
}
getChartPNG(): string {
const obj: any = Object.values(Bokeh.index)[0];
return obj.export().canvas.toDataURL('image/png');
return obj ? obj.export().canvas.toDataURL('image/png') : "";
}

async exportAsPDF() {
Expand Down

0 comments on commit be0c571

Please sign in to comment.