Skip to content

Commit 18b1d45

Browse files
committed
Optimized PDF Report Generation
1 parent 1685b0d commit 18b1d45

File tree

12 files changed

+56
-23
lines changed

12 files changed

+56
-23
lines changed

frontend/src/app/compliance/shared/components/utm-compliance-select/utm-compliance-select.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</div>
4141
<div class="table-responsive">
4242
<table class="table text-nowrap">
43-
<tbody *ngIf="complianceReports && complianceReports.length>0">
43+
<tbody *ngIf="standardSections && standardSections.length > 0">
4444
<tr *ngFor="let report of complianceReports">
4545
<td colspan="1">
4646
<div (click)="selectDashboard(report)"

frontend/src/app/compliance/shared/components/utm-compliance-select/utm-compliance-select.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class UtmComplianceSelectComponent implements OnInit {
8989
};
9090
this.cpStandardSectionService.query(query).subscribe(response => {
9191
this.standardSections = response.body;
92-
this.section = this.standardSections[0].id;
92+
this.section = !!this.section ? this.section : this.standardSections[0].id;
9393
this.getDashboardList();
9494
if (this.idReport) {
9595
this.getSelectedDashboard(this.idReport);
@@ -101,7 +101,7 @@ export class UtmComplianceSelectComponent implements OnInit {
101101
this.cpStandardService.query({page: 0, size: 1000}).subscribe(
102102
(res: HttpResponse<any>) => {
103103
this.standards = res.body;
104-
this.standard = this.standards[0].id;
104+
this.standard = !!this.standard ? this.standard : this.standards[0].id;
105105
this.getSections();
106106
},
107107
(res: HttpResponse<any>) => this.onError(res)

frontend/src/app/dashboard/dashboard-export-pdf/dashboard-export-pdf.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ <h3 class="">{{dashboardName}}</h3>
2727
<h5 class="mt-5 ">Generated on {{date | date:'short':'UTC'}}</h5>
2828
</div>
2929

30-
<div *ngIf="!preparingPrint" class="report-loading"></div>
3130
<!-- <img class="img-front-page" src="/assets/img/report/A4_compliance.png">-->
3231
<img [src]="sanitizer.bypassSecurityTrustUrl(cover)"
3332
*ngIf="cover;else loadImage"

frontend/src/app/dashboard/dashboard-overview/dashboard-overview.component.html

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,29 @@ <h5 class="card-title label-header mb-0 text-uppercase label-header">Overview</h
55
<app-elastic-filter-time [invertContent]="true"
66
[isEmitter]="true"
77
container="body"></app-elastic-filter-time>
8-
<!--<button (click)="exportToPdf()"
8+
<button (click)="exportToPdf()"
99
[disabled]="pdfExport" class="btn utm-button utm-button-primary ml-2">
1010
<i [ngClass]="pdfExport?'icon-download10':'icon-file-pdf'" class="mr-1"></i>
1111
{{pdfExport ? 'Generating...' : 'Save to PDF'}}
12-
</button>-->
12+
</button>
1313
</div>
1414
</div>
15+
<div *ngIf="!preparingPrint" class="report-loading"></div>
1516
<app-utm-report-header *ngIf="pdfExport" [reportName]="'UTMSTACK Overview'"></app-utm-report-header>
1617
<div [ngClass]="{'mt-3':pdfExport}" id="utmDashboardAlert">
1718
<div class="w-100 border-bottom-grey-100 border-bottom-1 mb-3 pb-2">
1819
<label class="font-weight-bold text-uppercase">Alerts</label>
1920
</div>
2021
<div class="row">
2122
<div class="col-lg-4 col-md-12 col-sm-12">
22-
<app-chart-alert-daily-week [refreshInterval]="refreshInterval"></app-chart-alert-daily-week>
23+
<app-chart-alert-daily-week [refreshInterval]="refreshInterval"
24+
(loaded)="onRun()">
25+
</app-chart-alert-daily-week>
2326
</div>
2427
<div class="col-lg-8 col-md-12 col-sm-12">
25-
<app-chart-alert-by-status [refreshInterval]="refreshInterval"></app-chart-alert-by-status>
28+
<app-chart-alert-by-status [refreshInterval]="refreshInterval"
29+
(loaded)="onRun()">
30+
</app-chart-alert-by-status>
2631
</div>
2732
</div>
2833

@@ -34,17 +39,22 @@ <h5 class="card-title label-header mb-0 text-uppercase label-header">Overview</h
3439
[navigateUrl]="ALERT_ROUTE"
3540
[paramClick]="paramAlertSeverityCLick"
3641
[params]="paramsAlertSeverity"
37-
[refreshInterval]="refreshInterval"></app-chart-common-pie>
42+
(loaded)="onRun()"
43+
[refreshInterval]="refreshInterval">
44+
</app-chart-common-pie>
3845
</div>
3946
<div class="col-lg-5 col-md-12 col-sm-12">
40-
<app-chart-alert-by-category [refreshInterval]="refreshInterval"></app-chart-alert-by-category>
47+
<app-chart-alert-by-category [refreshInterval]="refreshInterval"
48+
(loaded)="onRun()">
49+
</app-chart-alert-by-category>
4150
</div>
4251
<div class="col-lg-4 col-md-12 col-sm-12">
4352
<app-chart-common-table [endpoint]="'top-alerts'"
4453
[header]="'Top 20 Alerts'"
4554
[navigateUrl]="ALERT_ROUTE"
4655
[paramClick]="tableTopAlertsParamsClick"
4756
[params]="tableTopAlertsParams"
57+
(loaded)="onRun()"
4858
[refreshInterval]="refreshInterval">
4959
</app-chart-common-table>
5060
</div>
@@ -63,17 +73,20 @@ <h5 class="card-title label-header mb-0 text-uppercase label-header">Overview</h
6373
[navigateUrl]="LOG_ANALYZER_ROUTE"
6474
[paramClick]="paramEventByTypeCLick"
6575
[params]="paramsEventByType"
76+
(loaded)="onRun()"
6677
[refreshInterval]="refreshInterval"></app-chart-common-pie>
6778
</div>
6879
<div class="col-lg-5 col-md-12 col-sm-12">
69-
<app-chart-event-in-time [refreshInterval]="refreshInterval"></app-chart-event-in-time>
80+
<app-chart-event-in-time [refreshInterval]="refreshInterval"
81+
(loaded)="onRun()"></app-chart-event-in-time>
7082
</div>
7183
<div class="col-lg-4 col-md-12 col-sm-12">
7284
<app-chart-common-table [endpoint]="'top-windows-events'"
7385
[header]="'Top 20 windows event'"
7486
[navigateUrl]="LOG_ANALYZER_ROUTE"
7587
[paramClick]="paramEvenTopCLick"
7688
[params]="paramsTopEvent"
89+
(loaded)="onRun()"
7790
[refreshInterval]="refreshInterval">
7891
</app-chart-common-table>
7992
</div>

frontend/src/app/dashboard/dashboard-overview/dashboard-overview.component.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import {HttpResponse} from '@angular/common/http';
21
import {Component, OnDestroy, OnInit} from '@angular/core';
32
import {ActivatedRoute} from '@angular/router';
43
import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
54
import {NgxSpinnerService} from 'ngx-spinner';
65
import {Subject} from 'rxjs';
76
import {filter, map, takeUntil} from 'rxjs/operators';
8-
// tslint:disable-next-line:max-line-length
97
import {UtmModulesEnum} from '../../app-module/shared/enum/utm-module.enum';
108
import {UtmModulesService} from '../../app-module/shared/services/utm-modules.service';
119
import {UtmModuleType} from '../../app-module/shared/type/utm-module.type';
1210
import {AccountService} from '../../core/auth/account.service';
13-
import {rebuildVisualizationFilterTime} from '../../graphic-builder/shared/util/chart-filter/chart-filter.util';
1411
import {UtmToastService} from '../../shared/alert/utm-toast.service';
1512
import {MenuBehavior} from '../../shared/behaviors/menu.behavior';
1613
import {TimeFilterBehavior} from '../../shared/behaviors/time-filter.behavior';
@@ -33,9 +30,8 @@ import {LocalFieldService} from '../../shared/services/elasticsearch/local-field
3330
import {ExportPdfService} from '../../shared/services/util/export-pdf.service';
3431
import {ChartSerieValueType} from '../../shared/types/chart-reponse/chart-serie-value.type';
3532
import {ElasticFilterType} from '../../shared/types/filter/elastic-filter.type';
36-
import {UtmIndexPattern} from '../../shared/types/index-pattern/utm-index-pattern';
3733
import {buildFormatInstantFromDate} from '../../shared/util/utm-time.util';
38-
import {UtmIndexPatternFields} from "../../shared/types/index-pattern/utm-index-pattern-fields";
34+
import {UtmIndexPatternFields} from '../../shared/types/index-pattern/utm-index-pattern-fields';
3935

4036
@Component({
4137
selector: 'app-dashboard-overview',
@@ -87,6 +83,9 @@ export class DashboardOverviewComponent implements OnInit, OnDestroy {
8783
filterTime: { from: string, to: string };
8884
filtersValues: ElasticFilterType[] = [];
8985
destroy$: Subject<void> = new Subject();
86+
runList = 0;
87+
visualizationRender = 8;
88+
preparingPrint = true;
9089

9190

9291
constructor(private overviewAlertDashboardService: OverviewAlertDashboardService,
@@ -265,8 +264,18 @@ export class DashboardOverviewComponent implements OnInit, OnDestroy {
265264
});
266265
}
267266

267+
onRun() {
268+
this.runList += 1;
269+
if (this.runList === this.visualizationRender) {
270+
console.log('All the visualizations data has loaded, waiting for rendering');
271+
setTimeout(() => this.preparingPrint = false, 3000);
272+
console.log('All the visualizations now has rendered');
273+
}
274+
}
275+
268276
ngOnDestroy(): void {
269277
this.destroy$.next();
270278
this.destroy$.complete();
271279
}
280+
272281
}

frontend/src/app/defined-charts/components/alert/chart-alert-by-category/chart-alert-by-category.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Input, OnDestroy, OnInit} from '@angular/core';
1+
import {Component, EventEmitter, Input, OnDestroy, OnInit, Output} from '@angular/core';
22
import {Router} from '@angular/router';
33
import {NgxSpinnerService} from 'ngx-spinner';
44
import {Legend} from '../../../../shared/chart/types/charts/chart-properties/legend/legend';
@@ -20,6 +20,7 @@ import {deleteNullValues} from '../../../../shared/util/object-util';
2020
})
2121
export class ChartAlertByCategoryComponent implements OnInit, OnDestroy {
2222
@Input() refreshInterval;
23+
@Output() loaded = new EventEmitter<void>();
2324
interval: any;
2425
defaultTime: ElasticFilterCommonType = {time: ElasticTimeEnum.DAY, last: 7, label: 'last 7 days'};
2526
queryParams = {from: 'now-7d', to: 'now', top: 10};
@@ -63,6 +64,7 @@ export class ChartAlertByCategoryComponent implements OnInit, OnDestroy {
6364
} else {
6465
this.noData = true;
6566
}
67+
this.loaded.emit();
6668
});
6769
}
6870

frontend/src/app/defined-charts/components/alert/chart-alert-by-status/chart-alert-by-status.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Input, OnDestroy, OnInit} from '@angular/core';
1+
import {Component, EventEmitter, Input, OnDestroy, OnInit, Output} from '@angular/core';
22
import {Router} from '@angular/router';
33
import {NgxSpinnerService} from 'ngx-spinner';
44
import {ALERT_GLOBAL_FIELD, ALERT_STATUS_FIELD, ALERT_TIMESTAMP_FIELD} from '../../../../shared/constants/alert/alert-field.constant';
@@ -26,6 +26,7 @@ import {TimeFilterType} from '../../../../shared/types/time-filter.type';
2626
})
2727
export class ChartAlertByStatusComponent implements OnInit, OnDestroy {
2828
@Input() refreshInterval;
29+
@Output() loaded = new EventEmitter<void>();
2930
interval: any;
3031
defaultTime: ElasticFilterCommonType = {time: ElasticTimeEnum.DAY, last: 7, label: 'last 7 days'};
3132
time: TimeFilterType;
@@ -67,6 +68,7 @@ export class ChartAlertByStatusComponent implements OnInit, OnDestroy {
6768
this.overviewAlertDashboardService.getCardAlertByStatus(req).subscribe(res => {
6869
this.status = res.body;
6970
this.loadingStatusAlert = false;
71+
this.loaded.emit();
7072
});
7173
}
7274

frontend/src/app/defined-charts/components/alert/chart-alert-daily-week/chart-alert-daily-week.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Input, OnDestroy, OnInit} from '@angular/core';
1+
import {Component, EventEmitter, Input, OnDestroy, OnInit, Output} from '@angular/core';
22
import {Router} from '@angular/router';
33
import {NgxSpinnerService} from 'ngx-spinner';
44
import {ALERT_GLOBAL_FIELD, ALERT_TIMESTAMP_FIELD} from '../../../../shared/constants/alert/alert-field.constant';
@@ -13,6 +13,7 @@ import {ChartSerieValueType} from '../../../../shared/types/chart-reponse/chart-
1313
})
1414
export class ChartAlertDailyWeekComponent implements OnInit, OnDestroy {
1515
@Input() refreshInterval;
16+
@Output() loaded = new EventEmitter<void>();
1617
interval: any;
1718
dailyAlert: ChartSerieValueType[] = [];
1819
loadingChartDailyAlert = true;
@@ -39,6 +40,7 @@ export class ChartAlertDailyWeekComponent implements OnInit, OnDestroy {
3940
this.overviewAlertDashboardService.getCardAlertTodayWeek().subscribe(response => {
4041
this.dailyAlert = response.body;
4142
this.loadingChartDailyAlert = false;
43+
this.loaded.emit();
4244
});
4345
}
4446

frontend/src/app/defined-charts/components/common/chart-common-pie/chart-common-pie.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Input, OnDestroy, OnInit} from '@angular/core';
1+
import {Component, EventEmitter, Input, OnDestroy, OnInit, Output} from '@angular/core';
22
import {Router} from '@angular/router';
33
import {NgxSpinnerService} from 'ngx-spinner';
44
import {Legend} from '../../../../shared/chart/types/charts/chart-properties/legend/legend';
@@ -28,6 +28,7 @@ export class ChartCommonPieComponent implements OnInit, OnDestroy {
2828
@Input() params;
2929
@Input() paramClick: string;
3030
@Input() navigateUrl: string;
31+
@Output() loaded = new EventEmitter<void>();
3132
interval: any;
3233
defaultTime: ElasticFilterCommonType = {time: ElasticTimeEnum.DAY, last: 7, label: 'last 7 days'};
3334
queryParams = {from: 'now-7d', to: 'now', top: 10};
@@ -70,6 +71,7 @@ export class ChartCommonPieComponent implements OnInit, OnDestroy {
7071
} else {
7172
this.noData = true;
7273
}
74+
this.loaded.emit();
7375
});
7476
}
7577

frontend/src/app/defined-charts/components/common/chart-common-table/chart-common-table.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Input, OnDestroy, OnInit, QueryList, ViewChildren} from '@angular/core';
1+
import {Component, EventEmitter, Input, OnDestroy, OnInit, Output, QueryList, ViewChildren} from '@angular/core';
22
import {Router} from '@angular/router';
33
import {NgxSpinnerService} from 'ngx-spinner';
44
import {TableBuilderResponseType} from '../../../../shared/chart/types/response/table-builder-response.type';
@@ -23,6 +23,7 @@ export class ChartCommonTableComponent implements OnInit, OnDestroy {
2323
@Input() navigateUrl: string;
2424
@Input() params;
2525
@Input() paramClick: string;
26+
@Output() loaded = new EventEmitter<void>();
2627
interval: any;
2728
defaultTime: ElasticFilterCommonType = {time: ElasticTimeEnum.DAY, last: 7, label: 'last 7 days'};
2829
@ViewChildren(SortableDirective) headers: QueryList<SortableDirective>;
@@ -64,6 +65,7 @@ export class ChartCommonTableComponent implements OnInit, OnDestroy {
6465
this.pageEnd = this.itemsPerPage;
6566
this.responseRows = this.data.rows;
6667
this.totalItems = this.data.rows.length;
68+
this.loaded.emit();
6769
});
6870
}
6971

0 commit comments

Comments
 (0)