Skip to content

Commit 4b888e5

Browse files
committed
merge master
2 parents d5f9f41 + fd118d7 commit 4b888e5

File tree

12 files changed

+252
-224
lines changed

12 files changed

+252
-224
lines changed

.prettierrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"arrowParens": "avoid",
88
"trailingComma": "es5",
99
"bracketSameLine": true,
10-
"printWidth": 80
10+
"printWidth": 80,
11+
"endOfLine": "auto"
1112
}

src/app/app-routing.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import { MappingComponent } from './component/mapping/mapping.component';
77
import { MatrixComponent } from './component/matrix/matrix.component';
88
import { ActivityDescriptionComponent } from './component/activity-description/activity-description.component';
99
import { UsageComponent } from './component/usage/usage.component';
10-
import { Teams } from './component/teams/teams.component';
10+
import { TeamsComponent } from './component/teams/teams.component';
1111

1212
const routes: Routes = [
1313
{ path: '', component: MatrixComponent },
1414
{ path: 'circular-heatmap', component: CircularHeatmapComponent },
1515
{ path: 'activity-description', component: ActivityDescriptionComponent },
1616
{ path: 'mapping', component: MappingComponent },
1717
{ path: 'usage', component: UsageComponent },
18-
{ path: 'teams', component: Teams },
18+
{ path: 'teams', component: TeamsComponent },
1919
{ path: 'about', component: AboutUsComponent },
2020
{ path: 'userday', component: UserdayComponent },
2121
];

src/app/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { UsageComponent } from './component/usage/usage.component';
2020
import { UserdayComponent } from './component/userday/userday.component';
2121
import { AboutUsComponent } from './component/about-us/about-us.component';
2222
import { DependencyGraphComponent } from './component/dependency-graph/dependency-graph.component';
23-
import { Teams } from './component/teams/teams.component';
23+
import { TeamsComponent } from './component/teams/teams.component';
2424
import { ToStringValuePipe } from './pipe/to-string-value.pipe';
2525

2626
@NgModule({
@@ -37,7 +37,7 @@ import { ToStringValuePipe } from './pipe/to-string-value.pipe';
3737
UsageComponent,
3838
AboutUsComponent,
3939
DependencyGraphComponent,
40-
Teams,
40+
TeamsComponent,
4141
ToStringValuePipe,
4242
UserdayComponent,
4343
],

src/app/component/activity-description/activity-description.component.ts

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface activityDescription {
3737
assessment: string;
3838
comments: string;
3939
isImplemented: boolean;
40-
teamsImplemented: Object;
40+
teamsImplemented: Record<string, any>;
4141
}
4242

4343
@Component({
@@ -78,6 +78,7 @@ export class ActivityDescriptionComponent implements OnInit {
7878
YamlObject: any;
7979
GeneralLabels: string[] = [];
8080
KnowledgeLabels: string[] = [];
81+
TeamList: string[] = [];
8182
rowIndex: number = 0;
8283
markdown: md = md();
8384
SAMMVersion: string = 'OWASP SAMM VERSION 2';
@@ -95,16 +96,20 @@ export class ActivityDescriptionComponent implements OnInit {
9596
//gets value from sample file
9697
this.yaml.setURI('./assets/YAML/meta.yaml');
9798
// Function sets label data
99+
console.log(this.perfNow() + 's: meta.yaml fetch');
98100
this.yaml.getJson().subscribe(data => {
99-
this.YamlObject = data;
100-
this.GeneralLabels = this.YamlObject['strings']['en']['labels'];
101-
this.KnowledgeLabels =
102-
this.YamlObject['strings']['en']['KnowledgeLabels'];
101+
console.log(this.perfNow() + 's: meta.yaml');
102+
this.GeneralLabels = data['strings']['en']['labels'];
103+
this.KnowledgeLabels = data['strings']['en']['KnowledgeLabels'];
104+
this.TeamList = data['teams']; // Genuine teams (the true source)
105+
console.log(this.perfNow() + 's: meta.yaml processed');
103106
});
104107
//gets value from generated folder
108+
console.log(this.perfNow() + 's: generated.yaml fetch');
105109
this.yaml.setURI('./assets/YAML/generated/generated.yaml');
106110
// Function sets data
107111
this.yaml.getJson().subscribe(data => {
112+
console.log(this.perfNow() + 's: generated.yaml downloaded');
108113
this.YamlObject = data;
109114

110115
var allDimensionNames = Object.keys(this.YamlObject);
@@ -250,40 +255,48 @@ export class ActivityDescriptionComponent implements OnInit {
250255
data['isImplemented'],
251256
false
252257
);
253-
const dataFromLocalStorage = localStorage.getItem('dataset');
258+
let combinedTeamsImplemented: any = {};
259+
const dataFromLocalStorage: string | null =
260+
localStorage.getItem('dataset');
254261
if (dataFromLocalStorage !== null) {
255-
var parsedDataFromLocalStorage = JSON.parse(dataFromLocalStorage);
256-
var index = -1;
257-
for (var i = 0; i < parsedDataFromLocalStorage.length; i++) {
258-
for (
259-
var j = 0;
260-
j < parsedDataFromLocalStorage[i]['Activity'].length;
261-
j++
262-
) {
263-
if (
264-
parsedDataFromLocalStorage[i]['Activity'][j]['uuid'] ===
265-
data['uuid']
266-
) {
267-
console.log('test', parsedDataFromLocalStorage[i]['Activity'][j]);
268-
269-
index = i;
270-
this.currentActivity.teamsImplemented =
271-
parsedDataFromLocalStorage[i]['Activity'][j][
272-
'teamsImplemented'
273-
];
262+
let localData = JSON.parse(dataFromLocalStorage);
263+
let localDataActivity = null;
274264

265+
// Find the activity with the correct uuid
266+
for (let subdim of localData) {
267+
for (let activity of subdim?.Activity) {
268+
if (activity?.uuid === data?.uuid) {
269+
console.log('Found', activity);
270+
localDataActivity = activity;
275271
break;
276272
}
277273
}
274+
if (localDataActivity) break;
278275
}
279-
// this.currentActivity.teamsEvidence = this.defineEvidenceObject();
280-
} else this.currentActivity.teamsImplemented = data['teamsImplemented'];
276+
277+
// Combine teams status from local storage and loaded yaml file
278+
combinedTeamsImplemented = Object.assign(
279+
{},
280+
localDataActivity?.teamsImplemented,
281+
this.currentActivity?.teamsImplemented
282+
);
283+
} else {
284+
combinedTeamsImplemented = data['teamsImplemented'];
285+
}
286+
287+
// Only keep genuine teams
288+
this.currentActivity.teamsImplemented = {};
289+
for (let team of this.TeamList) {
290+
this.currentActivity.teamsImplemented[team] =
291+
combinedTeamsImplemented[team];
292+
}
281293

282294
this.currentActivity.teamsEvidence = this.defineEvidenceObject(
283295
data['teamsEvidence']
284296
);
285297
// console.log("data['teamsEvidence']", data['teamsEvidence']);
286298
this.openall();
299+
console.log(this.perfNow() + 's: generated.yaml processed');
287300
});
288301
}
289302

@@ -378,4 +391,8 @@ export class ActivityDescriptionComponent implements OnInit {
378391
element.closeAll();
379392
});
380393
}
394+
395+
perfNow() {
396+
return (performance.now() / 1000).toFixed(3);
397+
}
381398
}

src/app/component/circular-heatmap/circular-heatmap.component.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
shape-rendering: crispEdges;
99
}
1010

11-
.normal-button {
12-
background-color: white;
11+
.title-button {
12+
background-color: transparent;
1313
border: none;
1414
text-align: left;
1515
cursor: pointer;

src/app/component/circular-heatmap/circular-heatmap.component.html

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ <h2>Nothing to show</h2>
206206
</mat-chip>
207207
<mat-chip
208208
#c="matChip"
209-
*ngFor="let group of teamGroups | keyvalue"
209+
*ngFor="let group of teamGroups | keyvalue : unsorted"
210210
(click)="toggleTeamGroupSelection(c)">
211211
{{ group.key }}
212212
</mat-chip>
@@ -218,7 +218,8 @@ <h2>Nothing to show</h2>
218218
<mat-chip
219219
#c="matChip"
220220
*ngFor="let team of teamList"
221-
(click)="toggleTeamSelection(c)">
221+
(click)="toggleTeamSelection(c)"
222+
selected>
222223
{{ team }}
223224
</mat-chip>
224225
</mat-chip-list>
@@ -235,10 +236,10 @@ <h2>Nothing to show</h2>
235236
<mat-expansion-panel-header>
236237
<mat-panel-title>
237238
<button
238-
class="normal-button"
239+
class="title-button"
239240
(click)="
240241
$event.preventDefault();
241-
navigate(
242+
openActivityDetails(
242243
currentDimension,
243244
cardHeader,
244245
activity['activityName']
@@ -250,14 +251,15 @@ <h2>Nothing to show</h2>
250251
</mat-expansion-panel-header>
251252
<ng-template matExpansionPanelContent>
252253
<ul class="team-list">
253-
<li
254-
*ngFor="let item of activity.teamsImplemented | keyvalue">
254+
<li *ngFor="let teamname of teamVisible">
255255
<mat-checkbox
256-
[checked]="item.value === true"
257-
*ngIf="teamVisible.includes(item.key | ToStringValue)"
256+
[checked]="activity.teamsImplemented[teamname]"
258257
color="primary"
259-
(click)="this.teamCheckbox(activityIndex, item.key)">
260-
{{ item.key }}
258+
(click)="
259+
this.teamCheckbox(activityIndex, teamname);
260+
$event.preventDefault()
261+
">
262+
{{ teamname }}
261263
</mat-checkbox>
262264
</li>
263265
</ul>
@@ -275,7 +277,7 @@ <h2>Nothing to show</h2>
275277
class="normal-button"
276278
mat-raised-button
277279
class="downloadButtonClass"
278-
(click)="SaveEditedYAMLfile()">
280+
(click)="saveEditedYAMLfile()">
279281
Download edited YAML file
280282
</button>
281283
<button

0 commit comments

Comments
 (0)