11import { Component , OnInit } from '@angular/core' ;
22import { FormBuilder , FormGroup , Validators } from '@angular/forms' ;
33import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' ;
4- import { INCIDENT_AUTOMATION_ALERT_FIELDS } from '../../../../shared/constants/alert/alert-field.constant' ;
4+ import { ALERT_FIELDS , INCIDENT_AUTOMATION_ALERT_FIELDS } from '../../../../shared/constants/alert/alert-field.constant' ;
55
66@Component ( {
77 selector : 'app-action-terminal' ,
@@ -11,11 +11,19 @@ import {INCIDENT_AUTOMATION_ALERT_FIELDS} from '../../../../shared/constants/ale
1111export class ActionTerminalComponent implements OnInit {
1212
1313 form : FormGroup ;
14- alertFields = INCIDENT_AUTOMATION_ALERT_FIELDS ;
14+ alertFields = ALERT_FIELDS ;
1515 command : any ;
1616
1717 constructor ( public activeModal : NgbActiveModal ,
18- private fb : FormBuilder ) { }
18+ private fb : FormBuilder ) {
19+ this . alertFields = this . alertFields . reduce ( ( acc : any [ ] , field ) => {
20+ if ( typeof field === 'object' && field !== null && 'fields' in field ) {
21+ return acc . concat ( field . fields ) ;
22+ }
23+
24+ return acc . concat ( field ) ;
25+ } , [ ] ) ;
26+ }
1927
2028 ngOnInit ( ) {
2129 this . form = this . fb . group ( {
@@ -26,11 +34,11 @@ export class ActionTerminalComponent implements OnInit {
2634 }
2735
2836 insertVariablePlaceholder ( $event : string ) {
29- this . command += `$[ ${ $event } ]` ;
37+ this . form . get ( ' command' ) . setValue ( this . form . get ( 'command' ) . value + `$( ${ $event } )` ) ;
3038 }
3139
3240 insertFieldPlaceholder ( field : string ) {
33- this . command += `$(${ field } )` ;
41+ this . form . get ( ' command' ) . setValue ( this . form . get ( 'command' ) . value + `$(${ field } )` ) ;
3442 }
3543
3644 close ( ) {
0 commit comments