@@ -10,8 +10,15 @@ export interface taskDescription {
1010 level :string
1111 taskIndex :number
1212 description :string
13- risk : string
13+ risk : string [ ]
1414 measure : string
15+ implementatonGuide :string
16+ iso :string [ ]
17+ samm :string [ ]
18+ knowledge :number
19+ resources :number
20+ time :number
21+ dependsOn :string [ ]
1522}
1623
1724@Component ( {
@@ -21,15 +28,14 @@ export interface taskDescription {
2128} )
2229export class TaskDescriptionComponent implements OnInit {
2330
24- currentTask : taskDescription = { dimension :'' , subDimension :'' , level :'' , taskIndex :- 1 , description :'' , risk :'' , measure :'' }
31+ currentTask : taskDescription = { dimension :'' , subDimension :'' , level :'' , taskIndex :- 1 , description :'' , risk :[ ] ,
32+ measure :'' , implementatonGuide :'' , samm :[ '' ] , iso :[ '' ] , knowledge :- 1 , resources :- 1 ,
33+ time :- 1 , dependsOn :[ ] }
2534
2635 YamlObject :any ;
2736
2837 rowIndex :number = 0 ;
2938 markdown :md = md ( )
30- description :any ;
31- risk :any ;
32- measure :any ;
3339
3440 @ViewChildren ( MatAccordion ) accordion ! : QueryList < MatAccordion > ;
3541 constructor ( private route : ActivatedRoute , private yaml :ymlService ) { }
@@ -59,23 +65,72 @@ export class TaskDescriptionComponent implements OnInit {
5965 catch {
6066 console . log ( 'Task does not exist!' )
6167 }
68+ var data = this . YamlObject [ 'dimension' ] [ this . rowIndex ] [ 'subdimension' ]
69+ [ this . currentTask . level ] [ this . currentTask . taskIndex ]
70+
71+
72+ this . currentTask . description = this . defineStringValues ( data [ 'description' ] , '' )
73+ this . currentTask . risk = this . defineStringArrayValues ( data [ 'risk' ] , [ ] )
74+ this . currentTask . measure = this . defineStringValues ( data [ 'measure' ] , '' )
75+ try {
76+ data [ 'meta' ]
77+ this . currentTask . implementatonGuide = this . defineStringValues ( data [ 'meta' ] [ 'implementationGuide' ] , '' )
78+ }
79+ catch {
80+ console . log ( 'Meta does not exist' )
81+ }
82+ try {
83+ data [ 'difficultyOfImplementation' ]
84+ this . currentTask . knowledge = this . defineIntegerValues ( data [ 'difficultyOfImplementation' ] [ 'knowledge' ] , - 1 )
85+ this . currentTask . time = this . defineIntegerValues ( data [ 'difficultyOfImplementation' ] [ 'time' ] , - 1 )
86+ this . currentTask . resources = this . defineIntegerValues ( data [ 'difficultyOfImplementation' ] [ 'resources' ] , - 1 )
87+ }
88+ catch {
89+ console . log ( 'difficultyOfImplementation does not exist' )
90+ }
91+ try {
92+ data [ 'references' ]
93+ this . currentTask . iso = this . defineStringArrayValues ( data [ 'iso27001-2017' ] , [ ] )
94+ this . currentTask . samm = this . defineStringArrayValues ( data [ 'samm2' ] , [ ] )
95+ }
96+ catch {
97+ console . log ( 'references does not exist' )
98+ }
6299
63- this . currentTask . description = this . YamlObject [ 'dimension' ] [ this . rowIndex ] [ 'subdimension' ]
64- [ this . currentTask . level ] [ this . currentTask . taskIndex ] [ 'description' ]
65- this . currentTask . risk = this . YamlObject [ 'dimension' ] [ this . rowIndex ] [ 'subdimension' ]
66- [ this . currentTask . level ] [ this . currentTask . taskIndex ] [ 'risk' ]
67- this . currentTask . measure = this . YamlObject [ 'dimension' ] [ this . rowIndex ] [ 'subdimension' ]
68- [ this . currentTask . level ] [ this . currentTask . taskIndex ] [ 'measure' ]
69- this . measure = this . markdown . render ( this . currentTask . measure ) ;
70- this . description = this . markdown . render ( this . currentTask . description ) ;
71- this . risk = this . markdown . render ( this . currentTask . risk ) ;
100+ this . currentTask . dependsOn = this . defineStringArrayValues ( data [ 'dependsOn' ] , [ ] )
101+
102+ //console.log(this.measure)
72103
73-
74- console . log ( 'ere' )
75104 } )
76105 }
77106
107+ defineStringValues ( dataToCheck :string , valueOfDataIfUndefined :string ) : string {
108+ try {
109+ return this . markdown . render ( dataToCheck )
110+ }
111+ catch {
112+ return valueOfDataIfUndefined
113+ }
114+ }
115+
116+ defineStringArrayValues ( dataToCheck :string [ ] , valueOfDataIfUndefined :string [ ] ) : string [ ] {
117+ try {
118+ return dataToCheck
119+ }
120+ catch {
121+ return valueOfDataIfUndefined
122+ }
123+ }
78124
125+ defineIntegerValues ( dataToCheck :number , valueOfDataIfUndefined :number ) : number {
126+ try {
127+ return dataToCheck
128+ }
129+ catch {
130+ return valueOfDataIfUndefined
131+ }
132+ }
133+
79134
80135 // Expand all function
81136 openall ( ) : void {
0 commit comments