Skip to content

Commit 53dce17

Browse files
committed
feat(rule-filters): enhance rule filters with status and formatting options
Signed-off-by: Manuel Abascal <mjabascal10@gmail.com>
1 parent 21514d4 commit 53dce17

File tree

7 files changed

+33
-8
lines changed

7 files changed

+33
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h5 class="card-title mb-0 text-uppercase label-header">Manage Rules</h5>
3232
</div>
3333
</div>
3434
<div class="filter-container p-2 d-flex flex-column justify-content-start h-100 w-100 overflow-auto">
35-
<div *ngFor="let filter of fieldFilters" class="w-100">
35+
<div *ngFor="let filter of ruleFilters" class="w-100">
3636
<div *ngIf="filter.visible" class="w-100 mb-2">
3737
<app-generic-filter [fieldFilter]="filter"
3838
[url]="filterUrl">

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {SERVER_API_URL} from '../../app.constants';
33
import {EventDataTypeEnum} from '../../data-management/alert-management/shared/enums/event-data-type.enum';
44
import {Actions} from '../app-correlation-management/models/config.type';
55
import {ConfigService} from '../app-correlation-management/services/config.service';
6-
import {FILTER_RULE_FIELDS} from '../models/rule.constant';
6+
import {RULE_FILTERS_FIELDS} from '../models/rule.constant';
77
import {FilterService} from '../services/filter.service';
88

99

@@ -21,10 +21,12 @@ export class AppRuleComponent implements OnInit {
2121
}
2222

2323
dataType: EventDataTypeEnum = EventDataTypeEnum.ALERT;
24-
fieldFilters = FILTER_RULE_FIELDS;
24+
ruleFilters = RULE_FILTERS_FIELDS;
2525
filterUrl = `${SERVER_API_URL}api/correlation-rule/search-property-values`;
2626

27-
ngOnInit() {}
27+
ngOnInit() {
28+
console.log(this.ruleFilters);
29+
}
2830

2931
addRule(action: Actions) {
3032
this.configService.onAction(action);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,9 @@
285285
Next
286286
<i class="icon-arrow-right32"></i>&nbsp;
287287
</button>
288-
<button *ngIf="currentStep == RULE_FORM.STEP2" (click)="saveRule()" [disabled]="!isRuleFormValid"
288+
<button *ngIf="currentStep == RULE_FORM.STEP2" (click)="saveRule()" [disabled]="!isRuleFormValid || isSubmitting"
289289
class="btn utm-button utm-button-primary">
290-
<i [ngClass]="loading ? 'icon-spinner spinner' : 'icon-grid-alt top-0'"></i>&nbsp; Save
290+
<i [ngClass]="isSubmitting ? 'icon-spinner spinner' : 'icon-grid-alt top-0'"></i>&nbsp; Save
291291
</button>
292292
</div>
293293
</div>

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const RULE_CONFIDENTIALITY = 'confidentiality';
99
export const RULE_INTEGRITY = 'integrity';
1010
export const RULE_AVAILABILITY = 'availability';
1111
export const RULE_ADVERSARY = 'adversary';
12+
export const RULE_STATUS = 'active';
1213

1314
// FILTERS FIELDS
1415

@@ -17,6 +18,7 @@ export const RULE_FILTER_DATA_TYPES = 'RULE_DATA_TYPES';
1718
export const RULE_FILTER_CATEGORY = 'RULE_CATEGORY';
1819
export const RULE_FILTER_TECHNIQUE = 'RULE_TECHNIQUE';
1920
export const RULE_FILTER_ADVERSARY = 'RULE_ADVERSARY';
21+
export const RULE_FILTER_STATUS = 'RULE_STATUS';
2022
export const RULE_FILTER_REFERENCES = 'references';
2123

2224

@@ -98,7 +100,20 @@ export const RULE_FIELDS: UtmFieldType[] = [
98100
},
99101
];
100102

101-
export const FILTER_RULE_FIELDS = RULE_FIELDS.filter(f => f.filter);
103+
export const RULE_FILTERS_FIELDS = [
104+
{
105+
label: 'Status',
106+
field: RULE_STATUS,
107+
type: ElasticDataTypesEnum.BOOLEAN,
108+
visible: true,
109+
filter: true,
110+
width: '5%',
111+
sortField: 'ruleActive',
112+
filterField: RULE_FILTER_STATUS,
113+
formatValue: (value: boolean) => value ? 'Active' : 'Inactive'
114+
},
115+
... RULE_FIELDS.filter(f => f.filter)
116+
]
102117

103118
export interface RuleFilterType {
104119
ruleName?: string;

frontend/src/app/rule-management/share/generic-filter/generic-filter.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
class="mb-0 text-filter"
3636
placement="bottom"
3737
tooltipClass="utm-tooltip-bottom">
38-
{{item[0]}}
38+
{{ formatValue(item[0]) }}
3939
</label>
4040
</ng-template>
4141
</app-filter>

frontend/src/app/rule-management/share/generic-filter/generic-filter.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ export class GenericFilterComponent<T extends UtmFieldType> implements OnInit, A
9090
this.filterService.notifyRefresh(this.fieldFilter.filterField);
9191
}
9292

93+
formatValue(value: string): string {
94+
if (this.fieldFilter.formatValue) {
95+
return this.fieldFilter.formatValue(value);
96+
}
97+
return value;
98+
}
99+
93100
ngOnDestroy(): void {
94101
this.filterService.resetFieldValues();
95102
this.destroy$.next();

frontend/src/app/shared/types/table/utm-field.type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export class UtmFieldType {
1111
width?: string;
1212
fields?: UtmFieldType[];
1313
sortField?: string;
14+
formatValue?: (value: any) => string;
1415

1516
static findFieldByNameInArray(fieldName: string, fields: UtmFieldType[]): UtmFieldType | null {
1617
for (const field of fields) {

0 commit comments

Comments
 (0)