[WIFI-10857] Fixed display when there are no entries

Signed-off-by: Charles <charles.bourque96@gmail.com>
This commit is contained in:
Charles
2022-09-15 16:33:01 +01:00
parent 0ce641d10b
commit d733daed9d

View File

@@ -246,18 +246,33 @@ const StatisticsChartList = ({ deviceSerialNumber, setOptions, section, time })
setOptions([...sectionOptions, { value: 'memory', label: t('statistics.memory') }]); setOptions([...sectionOptions, { value: 'memory', label: t('statistics.memory') }]);
setStatOptions({ ...newOptions }); setStatOptions({ ...newOptions });
} }
setError(false); setError(undefined);
} catch (e) { } catch (e) {
setError(true); if (data?.length === 0) {
setError('nodata');
} else {
setError('error');
}
} }
}; };
const getInterface = useCallback(() => { const getInterface = useCallback(() => {
if (error) { if (error === 'error') {
return ( return (
<CAlert color="danger" style={{ width: '240px' }}> <div style={{ textAlign: 'center' }}>
Error while parsing statistics <CAlert color="danger" style={{ width: '240px', margin: 'auto' }}>
</CAlert> Error while parsing statistics
</CAlert>
</div>
);
}
if (error === 'nodata') {
return (
<div style={{ textAlign: 'center' }}>
<CAlert color="danger" style={{ width: '340px', margin: 'auto' }}>
No available statistics during this time period
</CAlert>
</div>
); );
} }
if (statOptions.interfaceList.length === 0) return <p>N/A</p>; if (statOptions.interfaceList.length === 0) return <p>N/A</p>;