Skip to content

Commit 0cf4831

Browse files
committed
fix: refactor action terminal component to improve alert field handling and update command insertion logic
1 parent 6dfb3a9 commit 0cf4831

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

frontend/src/app/incident-response/shared/component/action-terminal/action-terminal.component.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, OnInit } from '@angular/core';
22
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
33
import {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
1111
export 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() {

frontend/src/app/shared/components/utm/filters/utm-elastic-filter/shared/util/operator.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {OperatorsType} from '../../../../../../types/filter/operators.type';
1111
export class OperatorService {
1212

1313
getOperators(field: ElasticSearchFieldInfoType, operators: OperatorsType[]) {
14-
console.log('field', field);
1514
if (field.type === ElasticDataTypesEnum.TEXT || field.type === ElasticDataTypesEnum.STRING ||
1615
field.type === ElasticDataTypesEnum.KEYWORD) {
1716
if (!field.name.includes('.keyword')) {

0 commit comments

Comments
 (0)