Skip to content

Commit c23afc0

Browse files
committed
Added 'isImplemented' in YAML and made circular heatmap dynamic
1 parent 0cd03e4 commit c23afc0

2 files changed

Lines changed: 100 additions & 114 deletions

File tree

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

Lines changed: 82 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,92 @@
11
import { Component, OnInit } from '@angular/core';
2+
import { ymlService } from '../../service/yaml-parser/yaml-parser.service';
23
import * as d3 from 'd3';
34

5+
export interface task{
6+
name:string
7+
done:boolean
8+
}
9+
10+
export interface dataset{
11+
Name:string
12+
Level:string
13+
"Done%":number
14+
Task:task[]
15+
}
16+
417
@Component({
518
selector: 'app-circular-heatmap',
619
templateUrl: './circular-heatmap.component.html',
720
styleUrls: ['./circular-heatmap.component.css']
821
})
922
export class CircularHeatmapComponent implements OnInit {
10-
11-
show:number=0
23+
maxLevel:number=-1
24+
show:boolean=false
1225
header:string=''
1326
subheader:string=''
1427
tasks:any[]=[]
15-
data:any[] =[{
16-
"Name": "Build",
17-
"Level": "Level 1",
18-
"Done%":1/2,
19-
"Task":[
20-
{ name:"temp1",
21-
done:1
22-
},
23-
{ name:"temp2",
24-
done:0
25-
}
26-
]
27-
},{
28-
"Name": "Deployment",
29-
"Level": "Level 1",
30-
"Done%":1/2,
31-
"Task":[
32-
{ name:"temp1",
33-
done:1
34-
},
35-
{ name:"temp2",
36-
done:0
37-
}
38-
]
39-
},{
40-
"Name": "Build",
41-
"Level": "Level 2",
42-
"Done%":1/2,
43-
"Task":[
44-
{ name:"temp1",
45-
done:1
46-
},
47-
{ name:"temp2",
48-
done:0
49-
}
50-
]
51-
},{
52-
"Name": "Deployment",
53-
"Level": "Level 2",
54-
"Done%":1/2,
55-
"Task":[
56-
{ name:"temp1",
57-
done:1
58-
},
59-
{ name:"temp2",
60-
done:0
61-
}
62-
]
63-
}, {
64-
"Name": "Build",
65-
"Level": "Level 3",
66-
"Done%":1/2,
67-
"Task":[
68-
{ name:"temp1",
69-
done:1
70-
},
71-
{ name:"temp2",
72-
done:0
73-
}
74-
]
75-
},{
76-
"Name": "Deployment",
77-
"Level": "Level 3",
78-
"Done%":1/2,
79-
"Task":[
80-
{ name:"temp1",
81-
done:1
82-
},
83-
{ name:"temp2",
84-
done:0
85-
}
86-
]
87-
},{
88-
"Name": "Build",
89-
"Level": "Level 4",
90-
"Done%":1/2,
91-
"Task":[
92-
{ name:"temp1",
93-
done:1
94-
},
95-
{ name:"temp2",
96-
done:0
97-
}
98-
]
99-
},{
100-
"Name": "Deployment",
101-
"Level": "Level 4",
102-
"Done%":1/3,
103-
"Task":[
104-
{ name:"temp1",
105-
done:1
106-
},
107-
{ name:"temp2",
108-
done:0
109-
},
110-
{ name:"temp3",
111-
done:0
112-
}
113-
]
114-
}];
115-
radial_labels = ['Level 1','Level 2','Level 3','Level 4'];
116-
117-
segment_labels = ['Build', 'Deployment'];
118-
constructor() { }
28+
tempdata:dataset[]=[]
29+
data:dataset[] =[];
30+
radial_labels:string[]= [];
31+
YamlObject:any;
32+
segment_labels:string[] = [];
33+
constructor(private yaml:ymlService) { }
11934

12035
ngOnInit(): void {
36+
this.yaml.setURI('./assets/YAML/sample.yaml');
37+
// Function sets column header
38+
this.yaml.getJson().subscribe((data) => {
39+
this.YamlObject = data;
12140

122-
this.loadCircularHeatMap(this.data, "#chart", this.radial_labels, this.segment_labels);
41+
// Levels header
42+
for(let x in this.YamlObject['strings']['en']['maturity_levels']){
43+
var y=parseInt(x)+1
44+
this.radial_labels.push('Level '+y)
45+
this.maxLevel=y
46+
}
47+
48+
});
12349

50+
this.yaml.setURI('./assets/YAML/generated/sample.yaml');
51+
// Function sets data
52+
this.yaml.getJson().subscribe((data) => {
53+
console.log(this.radial_labels)
54+
this.YamlObject = data;
55+
56+
for(var x in this.YamlObject['dimension']){
57+
this.segment_labels.push(this.YamlObject['dimension'][x]['subdimension']['name'])
58+
}
59+
for(var l=0 ; l<this.maxLevel; l++){
60+
for(var x in this.YamlObject['dimension']){
61+
var tempdata:dataset={
62+
"Name": "",
63+
"Level": "",
64+
"Done%":0,
65+
"Task":[]
66+
}
67+
var totalDone:number=0
68+
try{
69+
tempdata["Name"]=this.YamlObject['dimension'][x]['subdimension']['name']
70+
tempdata["Level"]="Level "+(l+1)
71+
for(var i=0;i<this.YamlObject['dimension'][x]['subdimension']['level-'+(l+1)].length;i++){
72+
var nameOfTask=this.YamlObject['dimension'][x]['subdimension']['level-'+(l+1)][i]['name']
73+
var Status:boolean=this.YamlObject['dimension'][x]['subdimension']['level-'+(l+1)][i]['isImplemented']
74+
if(Status){
75+
totalDone+=1
76+
}
77+
tempdata["Task"].push({"name":nameOfTask,"done":Status})
78+
}
79+
tempdata["Done%"]=totalDone/this.YamlObject['dimension'][x]['subdimension']['level-'+(l+1)].length
80+
}
81+
catch{
82+
tempdata["Done%"]=0
83+
}
84+
this.data.push(tempdata)
85+
}
86+
}
87+
console.log(this.data)
88+
this.loadCircularHeatMap(this.data, "#chart", this.radial_labels, this.segment_labels);
89+
})
12490
}
12591

12692
checkboxToggle(taskIndex:number){
@@ -134,16 +100,16 @@ export class CircularHeatmapComponent implements OnInit {
134100
break;
135101
}
136102
}
137-
if(this.data[index]["Task"][taskIndex]["done"]==1){
138-
this.data[index]["Task"][taskIndex]["done"]=0
103+
if(this.data[index]["Task"][taskIndex]["done"]){
104+
this.data[index]["Task"][taskIndex]["done"]=false
139105
}
140106
else{
141-
this.data[index]["Task"][taskIndex]["done"]=1
107+
this.data[index]["Task"][taskIndex]["done"]=true
142108
}
143109
//console.log(this.data[i]["Task"][taskIndex]["done"])
144110
for(var i=0;i< this.data[index]["Task"].length;i++){
145111
console.log(this.data[index]["Task"][i]["done"])
146-
if(this.data[index]["Task"][i]["done"]==1){
112+
if(this.data[index]["Task"][i]["done"]){
147113
cnt+=1
148114
}
149115
}
@@ -152,7 +118,7 @@ export class CircularHeatmapComponent implements OnInit {
152118
var color = d3.scaleLinear<string,string>().domain([0,1]).range(["white", "green"]);
153119

154120
this.loadCircularHeatMap(this.data, "#chart", this.radial_labels, this.segment_labels);
155-
d3.selectAll("#segment-" + this.data[index]["Name"]+'-'+this.data[index]["Level"].replaceAll(' ','-')).attr("fill", function(p) {
121+
d3.selectAll("#segment-" + this.data[index]["Name"]+'-'+this.data[index]["Level"].replace(' ','-')).attr("fill", function(p) {
156122
return color(_self.data[index]["Done%"])
157123
});
158124

@@ -168,7 +134,7 @@ export class CircularHeatmapComponent implements OnInit {
168134
bottom: 50,
169135
left: 50
170136
};
171-
var width = 1000 - margin.left - margin.right;
137+
var width = 950 - margin.left - margin.right;
172138
var curr:any;
173139
var height = width;
174140
var innerRadius = 100; // width/14;
@@ -214,7 +180,7 @@ export class CircularHeatmapComponent implements OnInit {
214180
_self.subheader=d.explicitOriginalTarget.__data__.Level
215181
_self.tasks=d.explicitOriginalTarget.__data__.Task;
216182
_self.header=d.explicitOriginalTarget.__data__.Name
217-
_self.show=1
183+
_self.show=true
218184
console.log(_self.tasks)
219185
})
220186
.on('mouseover', function(d) {
@@ -412,5 +378,7 @@ export class CircularHeatmapComponent implements OnInit {
412378

413379
return chart;
414380
}
381+
382+
415383

416384
}

src/assets/YAML/generated/sample.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ dimension:
4646
- Quality is not visible to everyone, quality checks are distributed or
4747
manually and not deterministic.
4848
usefulness: 2
49+
isImplemented: true
4950
- dependsOn:
5051
- Continuous Integration
52+
isImplemented: false
5153
description: 'Sample evidence as an attribute in the yaml: The build process
5254
is defined in <a href="REPLACE-ME">REPLACE-ME Pipeline</a>
5355
@@ -92,6 +94,7 @@ dimension:
9294
knowledge: 2
9395
resources: 2
9496
time: 2
97+
isImplemented: true
9598
implementation:
9699
- name: CI/CD tools # string
97100
tags:
@@ -135,6 +138,7 @@ dimension:
135138
level: 2
136139
measure: Pinning of artifacts ensure that changes are performed only when intended.
137140
name: Pinning of artifacts
141+
isImplemented: false
138142
references:
139143
iso27001-2017:
140144
- 14.2.6
@@ -162,6 +166,7 @@ dimension:
162166
- '8.1'
163167
- '8.2'
164168
level: 2
169+
isImplemented: true
165170
measure: Creation of an SBOM of components (e.g. application and container image
166171
content) during build.
167172
name: SBOM of components
@@ -184,6 +189,7 @@ dimension:
184189
CI/CD tools such as jenkins, gitlab-ci or github-actions
185190
- name: Container technologies and orchestration like Docker, Kubernetes # string
186191
level: 3
192+
isImplemented: true
187193
measure: Digitally signing commits helps to prevent unauthorized manipulation
188194
of source code.
189195
name: Signing of code
@@ -210,6 +216,7 @@ dimension:
210216
description: CI/CD tools such as jenkins, gitlab-ci or github-actions
211217
- name: Container technologies and orchestration like Docker, Kubernetes # string
212218
level: 3
219+
isImplemented: false
213220
measure: Digitally signing artifacts for all steps during the build and especially
214221
docker images, helps to ensure their integrity.
215222
name: Signing of artifacts
@@ -244,6 +251,7 @@ dimension:
244251
measure: A defined deployment process significantly lowers the likelihood of
245252
errors during the deployment phase.
246253
name: Defined deployment process
254+
isImplemented: true
247255
references:
248256
iso27001-2017:
249257
- 12.1.1
@@ -267,6 +275,7 @@ dimension:
267275
description: CI/CD tools such as jenkins, gitlab-ci or github-actions
268276
- name: Container technologies and orchestration like Docker, Kubernetes # string
269277
level: 2
278+
isImplemented: false
270279
measure: 'Configuration parameters are set for each environment not in the source
271280
code.
272281
@@ -306,6 +315,7 @@ dimension:
306315
- 15.1.3
307316
- 14.1.3
308317
level: 2
318+
isImplemented: true
309319
measure: Create image assessment criteria, perform an evaluation of images and
310320
create a whitelist of artifacts/container images/virtual machine images.
311321
name: Usage of trusted images
@@ -320,6 +330,7 @@ dimension:
320330
resources: 1
321331
time: 2
322332
level: 2
333+
isImplemented: false
323334
measure: By having a clear decommissioning process, applicaitons not used are
324335
not running anymore and can therefore not be explointed.
325336
name: Defined decommissioning process
@@ -352,6 +363,7 @@ dimension:
352363
- 14.2.2
353364
- 17.2.1
354365
level: 3
366+
isImplemented: true
355367
measure: A deployment without downtime is performed*.
356368
name: Rolling update on deployment
357369
risk:
@@ -377,6 +389,7 @@ dimension:
377389
- 14.2.8
378390
- 12.1.4
379391
level: 3
392+
isImplemented: false
380393
measure: Building an artifact once and deploying it to different environments
381394
means that only tested artifacts are allowed to reach the production environment
382395
name: Same artifact for environments
@@ -404,6 +417,7 @@ dimension:
404417
file system. Also, the usage of a credential management system can help protect
405418
credentials.
406419
name: Handover of confidential parameters
420+
isImplemented: true
407421
references:
408422
iso27001-2017:
409423
- 14.1.3
@@ -439,6 +453,7 @@ dimension:
439453
- 14.2.9
440454
- 12.1.4
441455
level: 3
456+
isImplemented: false
442457
measure: Usage of environment independent configuration parameter, called feature
443458
toggles, helps to enhance the test coverage. Only what has been tested, goes
444459
to production.
@@ -464,6 +479,7 @@ dimension:
464479
- '8.1'
465480
- '8.2'
466481
level: 3
482+
isImplemented: true
467483
measure: A documented inventory or a possibility to gather the needed information.
468484
name: Inventory of running artifacts
469485
risk:
@@ -492,6 +508,7 @@ dimension:
492508
- '8.1'
493509
- '8.2'
494510
level: 3
511+
isImplemented: false
495512
measure: A documented inventory of dependencies used in images and containers
496513
exists.
497514
name: Inventory of dependencies
@@ -517,6 +534,7 @@ dimension:
517534
description: CI/CD tools such as jenkins, gitlab-ci or github-actions
518535
- name: Container technologies and orchestration like Docker, Kubernetes # string
519536
level: 4
537+
isImplemented: true
520538
measure: By having multiple production environments, a deployment can be performant
521539
on the first environment to spot possible defects before it is deployment
522540
in the production environment(s)

0 commit comments

Comments
 (0)