Skip to content

Commit 318b5c5

Browse files
committed
feat: enhance adversary alerts graph with improved event handling and child alert metadata
Signed-off-by: Manuel Abascal <mjabascal10@gmail.com>
1 parent a0b618c commit 318b5c5

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

frontend/src/app/data-management/adversary-management/adversary-alerts-graph/adversary-alerts-graph.component.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {AdversaryAlerts} from '../models';
1313
export class AdversaryAlertsGraphComponent implements OnChanges {
1414
@Input() data!: AdversaryAlerts[];
1515
chartHeight: number;
16-
chartWidth: number;
1716
baseHeight = 600;
1817
nodeGap = 6;
1918
option: any;
@@ -27,7 +26,7 @@ export class AdversaryAlertsGraphComponent implements OnChanges {
2726
}
2827
}
2928

30-
onChartInit(chart: ECharts) {
29+
onChartInit(chart: any) {
3130

3231
chart.on('mouseover', (params) => {
3332
if (params.dataType === 'node') {
@@ -42,10 +41,11 @@ export class AdversaryAlertsGraphComponent implements OnChanges {
4241
});
4342

4443
chart.on('click', (params) => {
45-
if (params.dataType === 'node') {
46-
this.viewAlertDetail = true;
47-
this.alertDetail = params.data.meta.alert || {} as UtmAlertType;
48-
console.log('clicked node:', params);
44+
if (params.componentType === 'series'
45+
&& params.seriesType === 'sankey'
46+
&& (params.dataType === 'node' || params.dataType === 'label' || params.dataType === 'edge')) {
47+
this.alertDetail = params.data.meta.alert || null;
48+
this.viewAlertDetail = !!this.alertDetail;
4949
}
5050
});
5151
}
@@ -179,6 +179,10 @@ export class AdversaryAlertsGraphComponent implements OnChanges {
179179
depth: 1,
180180
symbolSize: getNodeSize(childCount),
181181
meta: {
182+
alert: {
183+
...alert,
184+
hasChildren: true
185+
},
182186
severity: alert.severityLabel,
183187
timestamp: alert.timestamp,
184188
dataSource: alert.dataSource
@@ -200,7 +204,7 @@ export class AdversaryAlertsGraphComponent implements OnChanges {
200204

201205
alertWithChildren.children.forEach(child => {
202206
const childKey = nodeKey(child.id, child.name);
203-
const childLabel = truncate(this.getLabel(alert));
207+
const childLabel = truncate(this.getLabel(child));
204208
const childSeverityColor = severityColors[child.severityLabel.toLowerCase()] || severityColors.default;
205209

206210
if (!nodeSet.has(childKey)) {
@@ -233,6 +237,9 @@ export class AdversaryAlertsGraphComponent implements OnChanges {
233237
color: gradientColor(severityColor, childSeverityColor),
234238
opacity: 0.5,
235239
curveness: 0.2
240+
},
241+
meta: {
242+
alert: child,
236243
}
237244
});
238245
});
@@ -283,9 +290,10 @@ export class AdversaryAlertsGraphComponent implements OnChanges {
283290
layoutIterations: 32,
284291
left: 20,
285292
right: 180,
286-
top: 20,
287-
bottom: 40,
293+
top: 30,
294+
bottom: 50,
288295
label: {
296+
show: true,
289297
position: 'right',
290298
fontSize: 10,
291299
formatter: (params: any) => params.name.split('::')[1] || params.name

0 commit comments

Comments
 (0)