1
- import { ChangeDetectorRef , Component , ElementRef , OnInit , TemplateRef , ViewChild } from '@angular/core' ;
1
+ import {
2
+ ChangeDetectionStrategy ,
3
+ ChangeDetectorRef ,
4
+ Component ,
5
+ ElementRef ,
6
+ OnInit ,
7
+ TemplateRef ,
8
+ ViewChild ,
9
+ } from '@angular/core' ;
2
10
import { Risk } from '../../@core/Model/Risk' ;
3
11
import { ShowProjectService } from '../../@core/service/ShowProjectService' ;
4
12
import { ActivatedRoute , Router } from '@angular/router' ;
5
13
import { CookieService } from 'ngx-cookie-service' ;
6
14
import { ProjectConstants } from '../../@core/constants/ProjectConstants' ;
7
15
import { ScannerType } from '../../@core/Model/Scanner' ;
8
16
import { CiOperations } from '../../@core/Model/CiOperations' ;
9
- import { NbDialogService , NbWindowService } from '@nebular/theme' ;
17
+ import { NbDialogService , NbTabComponent , NbWindowService } from '@nebular/theme' ;
10
18
import { FormBuilder } from '@angular/forms' ;
11
19
import { Toast } from '../../@core/utils/Toast' ;
12
20
import { ProjectInfo } from '../../@core/Model/ProjectInfo' ;
@@ -23,6 +31,7 @@ import {DashboardService} from '../../@core/service/DashboardService';
23
31
selector : 'ngx-show-project' ,
24
32
templateUrl : './show-project.component.html' ,
25
33
styleUrls : [ './show-project.component.scss' ] ,
34
+ changeDetection : ChangeDetectionStrategy . OnPush ,
26
35
} )
27
36
export class ShowProjectComponent implements OnInit {
28
37
@ViewChild ( 'vulnAuditorSettings' )
@@ -56,6 +65,12 @@ export class ShowProjectComponent implements OnInit {
56
65
vulnsNumber : string = '0' ;
57
66
vulnsColor : string = 'success' ;
58
67
68
+ assetsDataLoaded = false ;
69
+ vulnerabilitiesDataLoaded = false ;
70
+ statisticsDataLoaded = false ;
71
+ metricsDataLoaded = false ;
72
+
73
+
59
74
private vulnAuditorForm : any ;
60
75
private projectUserForm : any ;
61
76
projectUser : ProjectUser = new ProjectUser ;
@@ -79,11 +94,11 @@ export class ShowProjectComponent implements OnInit {
79
94
this . loadScannerTypes ( ) ;
80
95
this . loadProjectInfo ( ) ;
81
96
this . loadCiOperations ( ) ;
82
- this . loadTrendChartData ( ) ;
83
- this . loadProjectStats ( ) ;
84
- this . loadCodes ( ) ;
97
+ // this.loadTrendChartData();
98
+ // this.loadProjectStats();
99
+ // this.loadCodes();
85
100
this . updateOffset ( ) ;
86
- this . loadProjectMetric ( ) ;
101
+ // this.loadProjectMetric();
87
102
this . vulnAuditorForm = this . formBuilder . group ( {
88
103
enableVulnAuditor : this . projectInfo . vulnAuditorEnable ,
89
104
dclocation : this . projectInfo . networkdc ,
@@ -189,7 +204,7 @@ export class ShowProjectComponent implements OnInit {
189
204
} ) ;
190
205
}
191
206
ngOnInit ( ) {
192
- this . loadSeveritiesChart ( ) ;
207
+ // this.loadSeveritiesChart();
193
208
this . role = this . cookieService . get ( 'role' ) ;
194
209
this . showConfigTemplate = this . role !== 'ROLE_ADMIN' && this . role !== 'ROLE_EDITOR_RUNNER' ;
195
210
this . showVulnAuditor = true ;
@@ -324,4 +339,55 @@ export class ShowProjectComponent implements OnInit {
324
339
} ) ;
325
340
} ) ;
326
341
}
342
+
343
+ onTabChange ( tab : NbTabComponent ) {
344
+ switch ( tab . tabTitle ) {
345
+ case 'Assets' :
346
+ if ( ! this . assetsDataLoaded ) {
347
+ this . loadAssetsData ( ) ;
348
+ this . assetsDataLoaded = true ;
349
+ }
350
+ break ;
351
+ case 'All Vulnerabilities' :
352
+ if ( ! this . vulnerabilitiesDataLoaded ) {
353
+ this . loadVulnerabilitiesData ( ) ;
354
+ this . vulnerabilitiesDataLoaded = true ;
355
+ }
356
+ break ;
357
+ case 'Statistics' :
358
+ if ( ! this . statisticsDataLoaded ) {
359
+ this . loadStatisticsData ( ) ;
360
+ this . statisticsDataLoaded = true ;
361
+ }
362
+ break ;
363
+ case 'Metrics' :
364
+ if ( ! this . metricsDataLoaded ) {
365
+ this . loadMetricsData ( ) ;
366
+ this . metricsDataLoaded = true ;
367
+ }
368
+ break ;
369
+ // Handle other tabs
370
+ }
371
+ }
372
+
373
+ loadAssetsData ( ) {
374
+ this . loadCodes ( ) ;
375
+ // Any additional data for Assets tab
376
+ }
377
+
378
+ loadVulnerabilitiesData ( ) {
379
+ this . loadProjectStats ( ) ;
380
+ // Any additional data for Vulnerabilities tab
381
+ }
382
+
383
+ loadStatisticsData ( ) {
384
+ this . loadTrendChartData ( ) ;
385
+ this . loadSeveritiesChart ( ) ;
386
+ // Any additional data for Statistics tab
387
+ }
388
+
389
+ loadMetricsData ( ) {
390
+ this . loadProjectMetric ( ) ;
391
+ // Any additional data for Metrics tab
392
+ }
327
393
}
0 commit comments