Skip to content

Commit 66a923a

Browse files
authored
Merge pull request #214 from SoftwareDesignLab/dev-rebaseProblems
Dev rebase problems
2 parents ac1be12 + f4bf164 commit 66a923a

16 files changed

+252
-48
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ testem.log
4242
Thumbs.db
4343

4444
/.vscode/
45-
/builds/
45+
/builds/
46+
47+
temp.zip

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/app.module.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import { MetricsComponent } from './features/metrics/metrics/metrics.component';
2929
import { MergeModalComponent } from './shared/components/toolbar/modals/merge-modal/merge-modal.component';
3030
import { GenerateModalComponent } from './shared/components/toolbar/modals/generate-modal/generate-modal.component';
3131
import { DiffFiltersComponent } from './features/comparison/diff-filters/diff-filters.component';
32+
import { SpinnerComponent } from './shared/components/spinner/spinner.component';
33+
import { RepairModalComponent } from './shared/components/toolbar/modals/repair-modal/repair-modal.component';
3234

3335
@NgModule({
3436
declarations: [
@@ -56,7 +58,8 @@ import { DiffFiltersComponent } from './features/comparison/diff-filters/diff-fi
5658
MergeModalComponent,
5759
GenerateModalComponent,
5860
SpinnerComponent,
59-
DiffFiltersComponent
61+
DiffFiltersComponent,
62+
RepairModalComponent
6063
],
6164
imports: [BrowserModule, NgbModule, HttpClientModule, NgbTooltipModule, FormsModule],
6265
providers: [],

src/app/features/comparison/comparison.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<app-viewer
22
title="Comparison"
3-
[options]="['Target: ' + getAlias(GetComparison().target)]"
4-
[selectedOption]="'Target: ' + getAlias(GetComparison().target)"
3+
[options]="['Target: ' + getAlias(GetComparison()?.target)]"
4+
[selectedOption]="'Target: ' + getAlias(GetComparison()?.target)"
55
>
66

77
<div body-1 style="width: 100%">

src/app/features/comparison/comparison.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class ComparisonComponent {
4040
get resultStatus() {
4141
return this._resultStatus;
4242
}
43-
43+
4444
constructor(public sbomService: SbomService, public downloadService: DownloadService) { }
4545

4646
GetComparison() {
@@ -94,7 +94,7 @@ export class ComparisonComponent {
9494

9595
downloadReport() {
9696
const fileName = 'report.json';
97-
const reportData = this.GetComparison();
97+
const reportData = this.GetComparison();
9898
const reportJson = JSON.stringify(reportData, null, 2);
9999
this.downloadService.Download(fileName, new Blob([reportJson], { type: 'application/json' }));
100100
}
@@ -103,6 +103,6 @@ export class ComparisonComponent {
103103
* Get SBOM filename
104104
*/
105105
getAlias(sbom: string) {
106-
return this.sbomService.getSBOMAlias(sbom);
106+
return this.sbomService.getSBOMAliasByID(sbom);
107107
}
108108
}

src/app/features/metrics/metrics/metrics.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ export class MetricsComponent implements OnInit {
5858
) {
5959
routing.data$.subscribe((data) => {
6060
if (data) {
61-
this.name = data;
62-
const sbom = sbomService.GetSBOMInfo(data);
61+
const sbom = data;
62+
63+
this.name = data.fileName;
6364
SVIP.gradeSBOM(sbom.id).subscribe((qa) => {
6465
if (qa) {
6566
this.qa = qa;
@@ -121,7 +122,7 @@ export class MetricsComponent implements OnInit {
121122
* Get SBOM filename
122123
*/
123124
getAlias(sbom: string) {
124-
return this.sbomService.getSBOMAlias(sbom);
125+
return this.sbomService.getSBOMAliasByPath(sbom);
125126
}
126127

127128
downloadReport() {

src/app/features/upload/upload.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class UploadComponent implements OnInit {
119119
.sort((a: string, b: string) => {
120120
let aFormat = this.sbomService.GetSBOMInfo(a).fileName;
121121
let bFormat = this.sbomService.GetSBOMInfo(b).fileName;
122-
122+
123123
return this.sortingOptions[SORT_OPTIONS.NAME]
124124
? aFormat.localeCompare(bFormat)
125125
: bFormat.localeCompare(aFormat);
@@ -265,7 +265,7 @@ export class UploadComponent implements OnInit {
265265
* Get SBOM filename
266266
*/
267267
getAlias(sbom: string) {
268-
return this.sbomService.getSBOMAlias(sbom);
268+
return this.sbomService.getSBOMAliasByID(sbom);
269269
}
270270

271271
/**
@@ -344,7 +344,7 @@ export class UploadComponent implements OnInit {
344344

345345
ViewSBOM(sbom: string) {
346346
this.routing.SetPage(PAGES.VIEW);
347-
this.routing.data = sbom;
347+
this.routing.data = this.sbomService.GetSBOMInfo(sbom);
348348
}
349349

350350
SetPageIfOneSelected(page: PAGES) {
@@ -353,7 +353,7 @@ export class UploadComponent implements OnInit {
353353
if (selected.length !== 1) return;
354354

355355
this.routing.SetPage(page);
356-
this.routing.data = this.sbomService.GetSBOMInfo(selected[0]).id;
356+
this.routing.data = this.sbomService.GetSBOMInfo(selected[0]);
357357
}
358358

359359
sbomsRequiredMessage(amount: number, orMore: boolean) {
@@ -381,7 +381,7 @@ export class UploadComponent implements OnInit {
381381
if (selected.length !== 1) return;
382382

383383
this.routing.SetPage(PAGES.METRICS);
384-
this.routing.data = selected[0];
384+
this.routing.data = this.sbomService.GetSBOMInfo(selected[0]);
385385
}
386386

387387

src/app/features/view/view.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
*ngIf="data"
33
[options]="['PRETTY', 'RAW']"
44
title="View SBOM"
5-
subTitle="{{getAlias(title)}}"
5+
subTitle="{{getAlias()}}"
66
selectedOption="PRETTY"
77
>
88
<div body-1 style="width: 100%;">
99
<ng-template #components let-data>
10-
<ng-container *ngFor="let component of data.components">
10+
<ng-container *ngFor="let component of data.sbom.components">
1111
<app-accordion [title]="component.name">
1212
<div body>
1313
<ng-container *ngFor="let item of component | keyvalue">
@@ -54,7 +54,7 @@
5454

5555
<div body-2 style="width: 100%;">
5656
<pre class="content">
57-
{{ getContents(title)}}
57+
{{ getContents()}}
5858
</pre>
5959
</div>
6060
</app-viewer>

src/app/features/view/view.component.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Component, Input } from '@angular/core';
22
import { PAGES, RoutingService } from '../../shared/services/routing.service';
33
import { SbomService } from '../../shared/services/sbom.service';
44
import { SVIPService } from '../../shared/services/SVIP.service';
5+
import File from 'src/app/shared/models/file';
56

67
@Component({
78
selector: 'app-view',
@@ -13,34 +14,24 @@ export class ViewComponent {
1314
pretty: boolean = true;
1415
data: any;
1516
raw: string = '';
16-
title: string = '';
1717
@Input() components: any[] | undefined;
1818

1919
constructor(
2020
private routing: RoutingService,
2121
public sbomService: SbomService,
22-
private svipService: SVIPService
2322
) {
24-
routing.data$.subscribe((data) => {
23+
routing.data$.subscribe((data: File) => {
2524
if (routing.GetPage() !== PAGES.VIEW) return;
26-
this.title = data;
25+
if (!data) return;
2726
this.data = data;
28-
if (data) {
29-
const sbomData = sbomService.GetSBOMInfo(data);
30-
if (sbomData.id) {
31-
this.svipService.getSBOM(sbomData.id).subscribe((sbom) => {
32-
this.data = sbom;
33-
});
34-
}
35-
}
3627
});
3728
}
3829

3930
/**
4031
* Get SBOM filename
4132
*/
42-
getAlias(sbom: string) {
43-
return this.sbomService.getSBOMAlias(sbom);
33+
getAlias() {
34+
return this.sbomService.getSBOMAliasByID(this.data.id);
4435
}
4536

4637
isObjectType(value: any): boolean {
@@ -70,7 +61,7 @@ export class ViewComponent {
7061
return formattedValue.replace(/[[\]{},"]/g, '') + '\n';
7162
}
7263

73-
getContents(path: string) {
74-
return this.sbomService.GetSBOMInfo(path).contents;
64+
getContents() {
65+
return this.data.contents;
7566
}
7667
}

src/app/shared/components/toolbar/modals/compare-modal/compare-modal.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ export class CompareModalComponent {
4242
}
4343

4444
getAlias(sbom: string) {
45-
return this.sbomService.getSBOMAlias(sbom);
45+
return this.sbomService.getSBOMAliasByID(sbom);
4646
}
4747
}

src/app/shared/components/toolbar/modals/generate-modal/generate-modal.component.css

Whitespace-only changes.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<app-modal [opened]="opened" (close)="Close()">
2+
<div title>
3+
Generate SBOM
4+
</div>
5+
<div content *ngIf="this.status === 1" style="display: flex; flex-direction: column; align-items: center;">
6+
<app-spinner height="64px" style="height: 64px;"/>
7+
<div>Waiting for Project Selection...</div>
8+
</div>
9+
<div content *ngIf="this.status === 2" style="display: flex; flex-direction: column; align-items: center;">
10+
<app-spinner height="64px" style="height: 64px;"/>
11+
<div>Zipping Project Contents...</div>
12+
</div>
13+
<div content *ngIf="this.status === 4" style="display: flex; flex-direction: column; align-items: center;">
14+
<app-spinner height="64px" style="height: 64px;"/>
15+
<div>Generating SBOM...</div>
16+
</div>
17+
<div content style="display: flex; gap: 15px; flex-direction: column;" *ngIf="this.status === 3">
18+
<div>
19+
<div>Name:</div>
20+
<input [(ngModel)]="options.name" />
21+
</div>
22+
<div>
23+
<div>Schema:</div>
24+
<select [(ngModel)]="options.schema">
25+
<option value=""></option>
26+
<option *ngFor="let option of choices | keyvalue" [value]="option.key">{{ option.key }}</option>
27+
</select>
28+
</div>
29+
<div>
30+
<div>Format:</div>
31+
<select [(ngModel)]="options.format">
32+
<option value=""></option>
33+
<option *ngFor="let option of choices[options.schema]" [value]="option">{{ option }}</option>
34+
</select>
35+
</div>
36+
<div>
37+
<div>Type:</div>
38+
<select [(ngModel)]="options.type">
39+
<option value=""></option>
40+
<option *ngFor="let option of types" [value]="option">{{ option }}</option>
41+
</select>
42+
</div>
43+
<div *ngIf="options.type === 'OSI'">
44+
<div>OSI Tools:</div>
45+
<app-multiselect-dropdown title="Filter Tools" [options]="osiTools" style="width: 400px"
46+
(checkboxChange)="OSIToolChange($event)">
47+
</app-multiselect-dropdown>
48+
</div>
49+
</div>
50+
<div actions style=" display: flex; gap: 15px;">
51+
<div class="btn-modal button flex center hover" (click)="Generate()" *ngIf="this.zippedFileData !== undefined">
52+
<span>Generate</span>
53+
</div>
54+
<div class="btn-modal button flex center hover" (click)="Close()">
55+
<span>Cancel</span>
56+
</div>
57+
</div>
58+
</app-modal>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { GenerateModalComponent } from './generate-modal.component';
4+
5+
describe('GenerateModalComponent', () => {
6+
let component: GenerateModalComponent;
7+
let fixture: ComponentFixture<GenerateModalComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [ GenerateModalComponent ]
12+
})
13+
.compileComponents();
14+
15+
fixture = TestBed.createComponent(GenerateModalComponent);
16+
component = fixture.componentInstance;
17+
fixture.detectChanges();
18+
});
19+
20+
it('should create', () => {
21+
expect(component).toBeTruthy();
22+
});
23+
});

0 commit comments

Comments
 (0)