-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #481 from rushk014/vul-report
- Loading branch information
Showing
14 changed files
with
499 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...src/app/routes/vulnerabilities/pdf-generation-dialog/pdf-generation-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<div class="d-flex align-items-center justify-content-between"> | ||
<h4 mat-dialog-title class="mb-2"> | ||
{{ 'scan.report.PRINT_REPORT' | translate }} ({{ data.pdf_name }}) | ||
</h4> | ||
<button | ||
(click)="onNoClick()" | ||
class="mb-2" | ||
aria-label="Close dialog" | ||
mat-icon-button> | ||
<i class="eos-icons">close</i> | ||
</button> | ||
</div> | ||
<hr class="fancy" /> | ||
<form (ngSubmit)="submit()" [formGroup]="form"> | ||
<div class="last_modified_field"> | ||
<mat-icon | ||
aria-hidden="false" | ||
aria-label="Modified icon" | ||
class="mr-3 last_modified_icon" | ||
fontSet="fa" | ||
fontIcon="fa-calendar-times"> | ||
</mat-icon> | ||
<mat-form-field appearance="standard"> | ||
<mat-label>{{ 'scan.LAST_MODIFIED' | translate }}</mat-label> | ||
<mat-select | ||
formControlName="dateOption" | ||
(selectionChange)="changeDateOption(selectedDateOption)"> | ||
<mat-option | ||
*ngFor="let modifiedDateOption of dateOptions" | ||
[value]="modifiedDateOption"> | ||
{{ | ||
'scan.report.from.' + modifiedDateOption.toUpperCase() | translate | ||
}} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
<ng-container *ngIf="selectedDateOption === 'custom'"> | ||
<mat-form-field appearance="standard" class="ml-2"> | ||
<input matInput [matDatepicker]="picker" formControlName="customDate" /> | ||
<mat-hint>MM/DD/YYYY</mat-hint> | ||
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle> | ||
<mat-datepicker #picker></mat-datepicker> | ||
</mat-form-field> | ||
</ng-container> | ||
</div> | ||
<div class="d-flex justify-content-end"> | ||
<app-loading-button | ||
[disabled]="form.invalid || !!(saving$ | async)" | ||
[loading]="!!(saving$ | async)" | ||
[text]="'general.SUBMIT' | translate" | ||
appearance="mat-raised-button" | ||
buttonClasses="mr-1" | ||
color="primary" | ||
id="pdf-generation-dialog-submit" | ||
type="submit"> | ||
</app-loading-button> | ||
</div> | ||
</form> |
16 changes: 16 additions & 0 deletions
16
...src/app/routes/vulnerabilities/pdf-generation-dialog/pdf-generation-dialog.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.last_modified_field { | ||
display: flex; | ||
justify-content: flex-start; | ||
align-items: center; | ||
overflow: hidden; | ||
} | ||
|
||
.last_modified_icon { | ||
color: white; | ||
background-color: #30ba78; | ||
border-radius: 100%; | ||
padding: 20px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} |
25 changes: 25 additions & 0 deletions
25
.../app/routes/vulnerabilities/pdf-generation-dialog/pdf-generation-dialog.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PdfGenerationDialogComponent } from './pdf-generation-dialog.component'; | ||
|
||
describe('PdfGenerationDialogComponent', () => { | ||
let component: PdfGenerationDialogComponent; | ||
let fixture: ComponentFixture<PdfGenerationDialogComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ PdfGenerationDialogComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(PdfGenerationDialogComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
102 changes: 102 additions & 0 deletions
102
...ebsrc/app/routes/vulnerabilities/pdf-generation-dialog/pdf-generation-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
EventEmitter, | ||
Inject, | ||
OnInit, | ||
Output, | ||
} from '@angular/core'; | ||
import { FormControl, FormGroup, Validators } from '@angular/forms'; | ||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; | ||
import { Subject } from 'rxjs'; | ||
import { VulnerabilitiesComponent } from '../vulnerabilities.component'; | ||
import { LastModifiedDateOption } from '@common/types'; | ||
|
||
const today = new Date(); | ||
|
||
@Component({ | ||
selector: 'app-pdf-generation-dialog', | ||
templateUrl: './pdf-generation-dialog.component.html', | ||
styleUrls: ['./pdf-generation-dialog.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class PdfGenerationDialogComponent implements OnInit { | ||
dateOptions: LastModifiedDateOption[] = [ | ||
'all', | ||
'twoweeks', | ||
'onemonth', | ||
'threemonths', | ||
'custom', | ||
]; | ||
form = new FormGroup({ | ||
dateOption: new FormControl('none'), | ||
customDate: new FormControl( | ||
{ | ||
value: null, | ||
disabled: true, | ||
}, | ||
Validators.required | ||
), | ||
}); | ||
saving$ = new Subject(); | ||
get customDate(): Date { | ||
return this.form.get('customDate')?.value; | ||
} | ||
get selectedDateOption(): LastModifiedDateOption { | ||
return this.form.get('dateOption')?.value; | ||
} | ||
|
||
constructor( | ||
public dialogRef: MatDialogRef<VulnerabilitiesComponent>, | ||
@Inject(MAT_DIALOG_DATA) public data: any | ||
) {} | ||
|
||
ngOnInit(): void {} | ||
|
||
onNoClick(): void { | ||
this.dialogRef.close(); | ||
} | ||
|
||
@Output() submitDate = new EventEmitter(); | ||
submit(): void { | ||
this.saving$.next(true); | ||
this.submitDate.emit( | ||
this.getDate(this.selectedDateOption, this.customDate) | ||
); | ||
} | ||
|
||
changeDateOption(selectedDateOption: LastModifiedDateOption) { | ||
if (selectedDateOption === 'custom') { | ||
this.form.controls['customDate'].enable(); | ||
} else { | ||
this.form.controls['customDate'].disable(); | ||
} | ||
} | ||
|
||
getDate(dateOption: LastModifiedDateOption, customDate: Date): Date | null { | ||
switch (dateOption) { | ||
case 'all': | ||
return null; | ||
case 'twoweeks': | ||
return new Date( | ||
today.getFullYear(), | ||
today.getMonth(), | ||
today.getDate() - 14 | ||
); | ||
case 'onemonth': | ||
return new Date( | ||
today.getFullYear(), | ||
today.getMonth() - 1, | ||
today.getDate() | ||
); | ||
case 'threemonths': | ||
return new Date( | ||
today.getFullYear(), | ||
today.getMonth() - 3, | ||
today.getDate() | ||
); | ||
case 'custom': | ||
return customDate; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.