Skip to content

Commit 3faa884

Browse files
authored
Merge pull request #1351 from utmstack/backlog/feat_child_alerts
feat(alert-management): added alert children alert column
2 parents a7d5930 + deecbdd commit 3faa884

File tree

11 files changed

+130
-20
lines changed

11 files changed

+130
-20
lines changed

frontend/src/app/data-management/alert-management/alert-view/alert-view.component.html

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ <h5 class="card-title mb-0 text-uppercase label-header">
105105
icon="icon-table"
106106
tooltipClass="utm-tooltip-top"></app-utm-dtable-columns>
107107
</th>
108+
<th>Echoes</th>
108109
<th (sort)="onSortBy($event)"
109110
*ngFor="let item of fields; let i=index"
110111
[hidden]="!item.visible"
@@ -169,15 +170,18 @@ <h5 class="card-title mb-0 text-uppercase label-header">
169170
<div *ngIf="viewAlertDetail" class="utm-right-container">
170171
<div (click)="viewAlertDetail= false" class="overlay overlay-lg col-md-6"></div>
171172
<div class="card utm-right-action utm-right-action-lg">
172-
<div class="title d-flex justify-content-between align-items-center border-bottom-1
173-
border-bottom-grey-100 pl-3 pt-3 pr-3 pb-0">
174-
<h6 class="card-title text-blue-800 font-weight-light">
173+
<div class="title d-flex justify-content-between align-items-center border-bottom-1
174+
border-bottom-grey-100 p-3 ">
175+
<h6 class="card-title pb-0 mb-0 text-blue-800 font-weight-light">
175176
{{getRuleName()}}
176177
</h6>
178+
<div class="d-flex flex-row align-items-center gap-2">
179+
<app-alert-logs-related-action [logs]="alertDetail.events"></app-alert-logs-related-action>
177180
<button (click)="viewAlertDetail= false;onRefreshData(true)" aria-label="Close"
178-
class="close button-close" type="button">
181+
class="" type="button">
179182
<div class="close-icon"></div>
180183
</button>
184+
</div>
181185
</div>
182186
<app-alert-view-detail (refreshData)="onRefreshData($event)"
183187
[alert]="alertDetail"
@@ -212,6 +216,12 @@ <h6 class="card-title text-blue-800 font-weight-light">
212216
<td class="text-center">
213217
<ng-container *ngTemplateOutlet="actionContent; context: { $implicit: alert }"></ng-container>
214218
</td>
219+
<td>
220+
<app-alert-child-column [loadingChildren]="loadingChildren"
221+
(toggleExpand)="loadChildrenAlerts(alert)"
222+
[alert]="alert">
223+
</app-alert-child-column>
224+
</td>
215225
<ng-container *ngFor="let td of fields">
216226
<td *ngIf="td.visible"
217227
[ngClass]="{'min-width': td.field === ALERT_ADVERSARY_FIELD || td.field === ALERT_TARGET_FIELD}"
@@ -271,7 +281,6 @@ <h6 class="card-title text-blue-800 font-weight-light">
271281
[loadingChildren]="loadingChildren"
272282
[tags]="tags"
273283
[dataType]="dataType"
274-
(toggleExpand)="loadChildrenAlerts(alert)"
275284
(select)="addToSelected($event)"
276285
(filterRow)="getRowToFiltersData($event)"
277286
(incident)="onSuccessMarkAsIncident($event)"

frontend/src/app/data-management/alert-management/shared/alert-management-shared.module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import {FilterAppliedComponent} from './components/filters/filter-applied/filter
6060
import {RowToFiltersComponent} from './components/filters/row-to-filter/row-to-filters.component';
6161
import {StatusFilterComponent} from './components/filters/status-filter/status-filter.component';
6262
import { AlertActionSelectComponent } from './components/alert-action-select/alert-action-select.component';
63+
import { AlertChildColumnComponent } from './components/alert-child-column/alert-child-column.component';
6364

6465
@NgModule({
6566
declarations: [
@@ -85,6 +86,7 @@ import { AlertActionSelectComponent } from './components/alert-action-select/ale
8586
AlertIpComponent,
8687
AlertHistoryComponent,
8788
AlertMapLocationComponent,
89+
AlertChildColumnComponent,
8890
AlertSeverityDescriptionComponent,
8991
AlertFullLogComponent,
9092
AlertHostDetailComponent,
@@ -132,6 +134,7 @@ import { AlertActionSelectComponent } from './components/alert-action-select/ale
132134
ActiveFiltersComponent,
133135
RowToFiltersComponent,
134136
AlertGenericFilterComponent,
137+
AlertChildColumnComponent,
135138
AlertFilterComponent,
136139
DataFieldRenderComponent,
137140
StatusFilterComponent,
@@ -164,7 +167,8 @@ import { AlertActionSelectComponent } from './components/alert-action-select/ale
164167
AlertEntityDisplayComponent,
165168
AlertBadgeFieldComponent,
166169
AlertEventsRelatedComponent,
167-
AlertActionsContentComponent
170+
AlertActionsContentComponent,
171+
AlertLogsRelatedButtonComponent
168172
],
169173
imports: [
170174
CommonModule,

frontend/src/app/data-management/alert-management/shared/components/alert-actions-content/alert-actions-content.component.html

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
<div class="d-flex justify-content-between align-items-center h-100 w-100 small-md-icon">
22
<div class="list-icons">
3-
<i *ngIf="alert.hasChildren; else noChildren"
4-
(click)="onToggleExpand()"
5-
class="cursor-pointer mr-2"
6-
[ngClass]="loadingChildren && alert.expanded ? 'icon-spinner2 spinner' : alert.expanded ? 'icon-arrow-down32' : 'icon-arrow-right32'"
7-
[ngbTooltip]="alert.expanded ? 'Collapse' : 'View children alerts'"
8-
container="body"
9-
placement="top">
10-
</i>
113
<i (click)="onSelect()"
124
[ngClass]="isSelected(alert)?'icon-checkbox-checked':'icon-checkbox-unchecked'"
135
[ngbTooltip]="isSelected(alert)?'Remove from selected':'Add to selected'"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<div class="d-flex justify-content-between align-items-center h-100 w-100 small-md-icon">
2+
<div class="list-icons">
3+
<button
4+
(click)="onToggleExpand()"
5+
class="btn-expand d-flex flex-row justify-items-center"
6+
[disabled]="loadingChildren"
7+
[ngbTooltip]="alert.hasChildren?(alert.expanded ? 'Collapse' : 'View echoes'):'No echoes'"
8+
container="body"
9+
placement="top">
10+
<i class="!top-0" *ngIf="alert.hasChildren" [ngClass]="loadingChildren && alert.expanded ? 'icon-spinner2 spinner' : alert.expanded ? 'icon-arrow-down32' : 'icon-arrow-right32'"></i>
11+
<span>Echoes</span>
12+
<small class="text-xs">{{ alert.echoes }}</small>
13+
</button>
14+
</div>
15+
</div>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
.btn-expand {
2+
display: inline-flex;
3+
align-items: center;
4+
gap: 6px;
5+
padding: 6px 12px;
6+
height: 33.07px;
7+
border: 1px solid #0277bd;
8+
border-radius: 4px;
9+
background-color: white;
10+
color: #0277bd ;
11+
font-size: 14px;
12+
font-weight: 500;
13+
cursor: pointer;
14+
transition: all 0.2s ease-in-out;
15+
white-space: nowrap;
16+
}
17+
18+
.btn-expand:hover:not(:disabled) {
19+
background-color: #0277bd ;
20+
color: white;
21+
border-color: #0277bd ;
22+
}
23+
24+
.btn-expand:active:not(:disabled) {
25+
background-color: #0277bd ;
26+
border-color: #004b8a;
27+
transform: scale(0.98);
28+
}
29+
30+
.btn-expand:disabled {
31+
opacity: 0.6;
32+
cursor: not-allowed;
33+
}
34+
35+
.btn-expand i {
36+
font-size: 12px;
37+
display: inline-flex;
38+
align-items: center;
39+
}
40+
41+
.btn-expand .spinner {
42+
animation: spin 1s linear infinite;
43+
}
44+
45+
@keyframes spin {
46+
0% { transform: rotate(0deg); }
47+
100% { transform: rotate(360deg); }
48+
}
49+
50+
.no-children-spacer {
51+
display: inline-block;
52+
width: 70px;
53+
height: 32px;
54+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {Component, EventEmitter, Input, Output} from '@angular/core';
2+
import {UtmAlertType} from 'src/app/shared/types/alert/utm-alert.type';
3+
4+
@Component({
5+
selector: 'app-alert-child-column',
6+
templateUrl: './alert-child-column.component.html',
7+
styleUrls: ['./alert-child-column.component.scss']
8+
})
9+
export class AlertChildColumnComponent {
10+
11+
@Input() alert: UtmAlertType;
12+
@Input() loadingChildren = false;
13+
14+
@Output() toggleExpand = new EventEmitter<any>();
15+
16+
onToggleExpand():void {
17+
if(this.alert.hasChildren){
18+
this.toggleExpand.emit(this.alert);
19+
}
20+
}
21+
22+
}

frontend/src/app/data-management/alert-management/shared/components/alert-view-detail/alert-view-detail.component.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
<i class="icon-map5 mr-1"></i> View on map </a>
2828
</li>
2929
<li *ngIf="alert.hasChildren" (click)="view=alertDetailTabEnum.ECHOES" class="nav-item cursor-pointer">
30-
<a [ngClass]="{'active':view===alertDetailTabEnum.ECHOES}" class="nav-link">
31-
<i class="icon-database mr-1"></i> Echoes </a>
30+
<a [ngClass]="{'active':view===alertDetailTabEnum.ECHOES}" class="nav-link relative">
31+
<i class="icon-database mr-1"></i> Echoes <small class="badge-pill absolute top-0 end-0 badge badge-primary">{{alert.echoes}}</small> </a>
3232
</li>
3333
<li (click)="view=alertDetailTabEnum.HISTORY" class="nav-item cursor-pointer">
3434
<a [ngClass]="{'active':view===alertDetailTabEnum.HISTORY}" class="nav-link">
@@ -42,9 +42,10 @@
4242
<!--<button (click)="navigateToEvents()" *ngIf="countRelatedEvents>0" class="btn utm-button utm-button-primary ml-2">
4343
<i class="icon-eye8 mr-1"></i> View logs related
4444
</button>-->
45-
<app-alert-logs-related-action [logs]="logs"></app-alert-logs-related-action>
4645
</li>
4746
</ul>
47+
48+
4849
<div class="w-100" *ngIf="view === alertDetailTabEnum.DETAIL">
4950
<app-alert-description [alert]="alert"></app-alert-description>
5051
<app-alert-severity-description [alert]="alert"></app-alert-severity-description>

frontend/src/app/data-management/alert-management/shared/components/alert-view-detail/alert-view-detail.component.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,10 @@ a {
4343
gap: 0.5rem
4444
}
4545

46+
.badge{
47+
position: absolute;
48+
right: 0%;
49+
50+
}
51+
4652

frontend/src/app/data-management/alert-management/shared/services/alert-management.service.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {Injectable} from '@angular/core';
33
import {Observable} from 'rxjs';
44
import {SERVER_API_URL} from '../../../../app.constants';
55
import {QueryType} from '../../../../shared/types/query-type';
6+
import {AlertStatusEnum} from 'src/app/shared/types/alert/utm-alert.type'
67

78

89
@Injectable({
@@ -16,11 +17,16 @@ export class AlertManagementService {
1617
}
1718

1819
updateAlertStatus(alertId: string[], status: number, statusObservation: string = ''): Observable<HttpResponse<any>> {
19-
const req = {
20+
21+
const req:any = {
2022
alertIds: alertId,
2123
status,
2224
statusObservation
2325
};
26+
27+
if(status == AlertStatusEnum.COMPLETED){
28+
req['addFalsePositiveTag']=true;
29+
}
2430
return this.http.post<HttpResponse<any>>(this.resourceUrl + '/status', req, {observe: 'response'});
2531
}
2632

frontend/src/app/shared/types/alert/utm-alert.type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class UtmAlertType {
3131
parentId?: string;
3232
hasChildren: boolean;
3333
expanded: boolean;
34+
echoes:number
3435
}
3536

3637
export enum AlertStatusLabelEnum {

0 commit comments

Comments
 (0)