Skip to content

Commit 354b223

Browse files
committed
set sampling from consumption step
1 parent 94eb078 commit 354b223

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

web/src/components/forms/consumption.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ import './forms.css';
1414

1515
export type ResourceCalculatorProps = {
1616
flowCollector: K8sResourceKind | null;
17+
setSampling?: (sampling: number) => void;
1718
};
1819

19-
export const Consumption: FC<ResourceCalculatorProps> = ({ flowCollector }) => {
20+
export const Consumption: FC<ResourceCalculatorProps> = ({ flowCollector, setSampling }) => {
2021
const { t } = useTranslation('plugin__netobserv-plugin');
2122

2223
const [receivedPackets, rpLoaded, rpError] = usePrometheusPoll({
@@ -64,8 +65,8 @@ export const Consumption: FC<ResourceCalculatorProps> = ({ flowCollector }) => {
6465
return t('n/a');
6566
}
6667
return _.uniq(_.map(receivedPackets.data.result, r => r.metric[label])).length;
67-
// eslint-disable-next-line react-hooks/exhaustive-deps
6868
},
69+
// eslint-disable-next-line react-hooks/exhaustive-deps
6970
[receivedPackets, rpError, rpLoaded]
7071
);
7172

@@ -114,7 +115,13 @@ export const Consumption: FC<ResourceCalculatorProps> = ({ flowCollector }) => {
114115
{getSamplings().map((sampling, i) => {
115116
const current = getCurrentSampling() === sampling;
116117
return (
117-
<Tr key={i} isRowSelected={current}>
118+
<Tr
119+
key={i}
120+
isSelectable={setSampling !== undefined}
121+
isClickable={setSampling !== undefined}
122+
isRowSelected={current}
123+
onClick={() => setSampling && setSampling(sampling)}
124+
>
118125
<Td>{`${sampling} ${current ? t('(current)') : ''}`}</Td>
119126
<Td></Td>
120127
<Td></Td>

web/src/components/forms/flowCollector-wizard.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ export const FlowCollectorWizard: FC<FlowCollectorWizardProps> = props => {
107107
[]
108108
);
109109

110+
const setSampling = React.useCallback(
111+
(sampling: number) => {
112+
if (!data) {
113+
return;
114+
}
115+
data.spec.agent.ebpf.sampling = sampling;
116+
setData({ ...data });
117+
},
118+
[data]
119+
);
120+
110121
return (
111122
<DynamicLoader>
112123
<ResourceWatcher
@@ -157,7 +168,7 @@ export const FlowCollectorWizard: FC<FlowCollectorWizardProps> = props => {
157168
{form()}
158169
</WizardStep>
159170
<WizardStep name={t('Consumption')} id="consumption">
160-
<Consumption flowCollector={data} />
171+
<Consumption flowCollector={data} setSampling={setSampling} />
161172
</WizardStep>
162173
<WizardStep
163174
name={t('Review')}

0 commit comments

Comments
 (0)