Skip to content

Commit 5882250

Browse files
committed
add show empty checkbox
1 parent f5f2edd commit 5882250

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

web/locales/en/plugin__netobserv-plugin.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
"Edges": "Edges",
152152
"Edges label": "Edges label",
153153
"Badges": "Badges",
154+
"Empty": "Empty",
154155
"Collapse groups": "Collapse groups",
155156
"XL": "XL",
156157
"L": "L",

web/src/components/dropdowns/topology-display-options.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,18 @@ export const TopologyDisplayOptions: React.FC<TopologyDisplayOptionsProps> = ({
191191
})
192192
}
193193
/>
194+
<Checkbox
195+
id="empty-switch"
196+
className="display-dropdown-padding"
197+
label={t('Empty')}
198+
isChecked={topologyOptions.showEmpty}
199+
onChange={() =>
200+
setTopologyOptions({
201+
...topologyOptions,
202+
showEmpty: !topologyOptions.showEmpty
203+
})
204+
}
205+
/>
194206
</div>
195207
<div className="pf-c-select__menu-group">
196208
<Tooltip content={t('Long labels can reduce visibility.')}>

web/src/components/netflow-traffic.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ export const NetflowTraffic: React.FC<NetflowTrafficProps> = ({
438438
clearFlows
439439
);
440440

441-
if (model.metricScope === 'udn') {
441+
if (model.topologyOptions.showEmpty && model.metricScope === 'udn') {
442442
drawerRef.current
443443
?.getTopologyHandle()
444444
?.fetchUDNs()
@@ -495,6 +495,7 @@ export const NetflowTraffic: React.FC<NetflowTrafficProps> = ({
495495
model.config.features,
496496
model.topologyMetricType,
497497
model.topologyMetricFunction,
498+
model.topologyOptions.showEmpty,
498499
model.selectedViewId,
499500
buildFlowQuery,
500501
manageWarnings,

web/src/model/topology.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export interface TopologyOptions {
5454
medScale: number;
5555
metricFunction: StatFunction;
5656
metricType: MetricType;
57+
showEmpty?: boolean;
5758
}
5859

5960
export const DefaultOptions: TopologyOptions = {
@@ -68,7 +69,8 @@ export const DefaultOptions: TopologyOptions = {
6869
lowScale: 0.3,
6970
medScale: 0.5,
7071
metricFunction: defaultMetricFunction,
71-
metricType: defaultMetricType
72+
metricType: defaultMetricType,
73+
showEmpty: true
7274
};
7375

7476
export type GraphElementPeer = GraphElement<ElementModel, NodeData>;
@@ -605,14 +607,16 @@ export const generateDataModel = (
605607
//remove empty groups
606608
nodes = nodes.filter(n => n.type !== 'group' || (n.children && n.children.length));
607609

608-
// add missing nodes to the view
609-
const currentNodes = nodes.map(n => n.label);
610-
const missingNodes = expectedNodes.filter(n => !currentNodes.includes(n));
611-
missingNodes.forEach(n => {
612-
const fields: Partial<TopologyMetricPeer> = { id: n };
613-
fields[metricScope] = n;
614-
addNode({ peer: createPeer(fields), nodeType: metricScope, canStepInto: false, noMetrics: true });
615-
});
610+
// add missing nodes to the view if available
611+
if (!_.isEmpty(expectedNodes)) {
612+
const currentNodes = nodes.map(n => n.label);
613+
const missingNodes = expectedNodes.filter(n => !currentNodes.includes(n));
614+
missingNodes.forEach(n => {
615+
const fields: Partial<TopologyMetricPeer> = { id: n };
616+
fields[metricScope] = n;
617+
addNode({ peer: createPeer(fields), nodeType: metricScope, canStepInto: false, noMetrics: true });
618+
});
619+
}
616620

617621
return { nodes, edges };
618622
};

0 commit comments

Comments
 (0)