Merge pull request #134 from stephb9959/main

[WIFI-11749] Limiting device search bar input text length
This commit is contained in:
Charles Bourque
2022-11-28 09:26:42 +00:00
committed by GitHub
8 changed files with 12 additions and 10 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "ucentral-client",
"version": "2.8.0(24)",
"version": "2.8.0(25)",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "ucentral-client",
"version": "2.8.0(24)",
"version": "2.8.0(25)",
"license": "ISC",
"dependencies": {
"@chakra-ui/icons": "^2.0.11",

View File

@@ -1,6 +1,6 @@
{
"name": "ucentral-client",
"version": "2.8.0(24)",
"version": "2.8.0(25)",
"description": "",
"private": true,
"main": "index.tsx",

View File

@@ -5,9 +5,10 @@ import { randomIntId } from 'helpers/stringHelper';
export type UseControllerDeviceSearchProps = {
minLength?: number;
maxLength?: number;
};
export const useControllerDeviceSearch = ({ minLength = 4 }: UseControllerDeviceSearchProps) => {
export const useControllerDeviceSearch = ({ minLength = 4, maxLength = 12 }: UseControllerDeviceSearchProps) => {
const [tempValue, setTempValue] = useState('');
const [waitingSearch, setWaitingSearch] = useState<
{ command: string; serial_prefix: string; operatorId?: string } | undefined
@@ -31,7 +32,8 @@ export const useControllerDeviceSearch = ({ minLength = 4 }: UseControllerDevice
);
const onChange = useCallback(
(v: string) => {
if (v.length >= minLength) setWaitingSearch({ command: 'serial_number_search', serial_prefix: v });
if (v.length >= minLength || v.length <= maxLength)
setWaitingSearch({ command: 'serial_number_search', serial_prefix: v });
},
[setWaitingSearch],
);

View File

@@ -21,7 +21,7 @@ export const useStatisticsCard = ({ serialNumber }: Props) => {
const onProgressChange = React.useCallback((newProgress: number) => {
setProgress(newProgress);
}, []);
const getStats = useGetDeviceNewestStats({ serialNumber, limit: 100 });
const getStats = useGetDeviceNewestStats({ serialNumber, limit: 30 });
const getCustomStats = useGetDeviceStatsWithTimestamps({
serialNumber,
start: time ? Math.floor(time.start.getTime() / 1000) : undefined,

View File

@@ -175,7 +175,7 @@ const WifiAnalysisAssocationsTable = ({ data, ouis }: Props) => {
hiddenColumns={hiddenColumns}
data={data ?? []}
hideEmptyListText
sortBy={data?.[0]?.radio?.band ? [{ id: 'index', desc: true }] : undefined}
sortBy={[{ id: 'index', desc: true }]}
// @ts-ignore
hideControls
showAllRows

View File

@@ -121,7 +121,7 @@ const WifiAnalysisRadioTable = ({ data }: Props) => {
hiddenColumns={hiddenColumns}
data={data ?? []}
obj={t('controller.devices.logs')}
sortBy={data?.[0]?.band ? [{ id: 'index', desc: true }] : undefined}
sortBy={[{ id: 'index', desc: true }]}
// @ts-ignore
hideControls
showAllRows

View File

@@ -92,7 +92,7 @@ const parseAssociations = (data: { data: DeviceStatistics; recorded: number }, r
const WifiAnalysisCard = ({ serialNumber }: Props) => {
const { t } = useTranslation();
const [sliderIndex, setSliderIndex] = React.useState(0);
const getStats = useGetDeviceNewestStats({ serialNumber, limit: 100 });
const getStats = useGetDeviceNewestStats({ serialNumber, limit: 30 });
const parsedData = React.useMemo(() => {
if (!getStats.data) return undefined;

View File

@@ -31,7 +31,7 @@ const DeviceSearchBar = () => {
navigate(`/devices/${v.value}`);
}, []);
const onChange = React.useCallback((v: string) => {
if (v.length === 0 || v.match('^[a-fA-F0-9-*]+$')) onInputChange(v);
if ((v.length === 0 || v.match('^[a-fA-F0-9-*]+$')) && v.length <= 13) onInputChange(v);
}, []);
const onFocus = () => {