Skip to content

Commit dd19a4a

Browse files
committed
fix(ui): refactor add correlation rule
1 parent c4394de commit dd19a4a

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

frontend/src/app/rule-management/app-rule/components/add-rule/add-rule.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
[ngClass]="{'is-invalid': ruleForm.get('adversary').invalid && ruleForm.get('adversary').touched}"
143143
[virtualScroll]="true"
144144
bindLabel="name"
145-
bindValue="id"
145+
bindValue="name"
146146
class="flex-item type-select"
147147
formControlName="adversary"
148148
placeholder="Choose adversary">

frontend/src/app/rule-management/app-rule/components/add-rule/add-rule.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class AddRuleComponent implements OnInit, OnDestroy {
9797
const variables = this.savedVariables .length > 0 ? this.savedVariables.map(variable => ({
9898
as: variable.as,
9999
get: variable.get,
100-
of_type: variable.of_type
100+
ofType: variable.ofType
101101
})) : [];
102102
this.isSubmitting = true;
103103
const rule: Rule = {
@@ -131,7 +131,7 @@ export class AddRuleComponent implements OnInit, OnDestroy {
131131
id: [rule ? rule.id : ''],
132132
dataTypes: [rule ? rule.dataTypes : '', Validators.required],
133133
name: [rule ? rule.name : '', Validators.required],
134-
adversary: [rule ? rule.adversary : '', Validators.required],
134+
adversary: [rule ? rule.adversary : null, Validators.required],
135135
confidentiality: [rule ? rule.confidentiality : 0, [Validators.required, Validators.min(0), Validators.max(3)]],
136136
integrity: [rule ? rule.integrity : 0, [Validators.required, Validators.min(0), Validators.max(3)]],
137137
availability: [rule ? rule.availability : 0, [Validators.required, Validators.min(0), Validators.max(3)]],

frontend/src/app/rule-management/app-rule/components/add-variable/add-variable.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<label class="section-label">Variables</label>
1717
<button
1818
type="button"
19-
[disabled]="variable.invalid || variable.get('of_type').value == null || variable.get('get').value == null"
19+
[disabled]="variable.invalid || variable.get('ofType').value == null || variable.get('get').value == null"
2020
class="btn btn-icon btn-sm btn-outline-primary"
2121
(click)="saveVariable(i)"
2222
ngbTooltip="Add a new variable">
@@ -71,15 +71,15 @@
7171
<div class="form-group-select">
7272
<label>Type:</label>
7373
<ng-select
74-
[ngClass]="{'is-invalid': variable.get('of_type').invalid && variable.get('of_type').touched}"
74+
[ngClass]="{'is-invalid': variable.get('ofType').invalid && variable.get('ofType').touched}"
7575
[items]="variablesDataType"
7676
class="flex-item type-select"
7777
bindLabel="label"
7878
bindValue="value"
79-
formControlName="of_type"
79+
formControlName="ofType"
8080
placeholder="Select type">
8181
</ng-select>
82-
<div *ngIf="variable.get('of_type').invalid && variable.get('of_type').touched"
82+
<div *ngIf="variable.get('ofType').invalid && variable.get('ofType').touched"
8383
class="invalid-feedback">
8484
Type is required.
8585
</div>

frontend/src/app/rule-management/app-rule/components/add-variable/add-variable.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class AddVariableComponent implements OnInit {
9898
control.markAsDirty();
9999
}
100100

101-
onVariablesChange(updatedVars: { as: string; of_type: string; get: string }[]) {
101+
onVariablesChange(updatedVars: { as: string; ofType: string; get: string }[]) {
102102
this.savedVariables = updatedVars;
103103
}
104104

frontend/src/app/rule-management/app-rule/components/expression-console/expression-console.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
1212
}]
1313
})
1414
export class ExpressionConsoleComponent implements ControlValueAccessor {
15-
@Input() variables: { as: string; of_type: string; get: string }[] = [];
16-
@Output() variablesChange = new EventEmitter<{ as: string; of_type: string; get: string }[]>();
15+
@Input() variables: { as: string; ofType: string; get: string }[] = [];
16+
@Output() variablesChange = new EventEmitter<{ as: string; ofType: string; get: string }[]>();
1717
@ViewChild('console', {}) consoleRef!: ElementRef<HTMLTextAreaElement>;
1818

1919
@Output() touched = new EventEmitter<void>();

frontend/src/app/rule-management/custom-validators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {AbstractControl, FormArray, ValidationErrors, ValidatorFn} from "@angular/forms";
22

3-
export const variableTemplate = {get: [], as: [''], of_type: []};
3+
export const variableTemplate = {get: [], as: [''], ofType: []};
44
export function urlValidator(control: AbstractControl): ValidationErrors | null {
55
const urlPattern = /^(https?|ftp):\/\/[^\s/$.?#].\S*$/i;
66
return urlPattern.test(control.value) ? null : {invalidUrl: true};

frontend/src/app/rule-management/models/rule.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const itemsPerPage = 25;
1313
export interface Variable {
1414
get: string;
1515
as: string;
16-
of_type: string;
16+
ofType: string;
1717
}
1818

1919
export interface Definition {

0 commit comments

Comments
 (0)