mirror of
https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
synced 2025-10-30 01:42:19 +00:00
Merge pull request #134 from stephb9959/main
[WIFI-11749] Limiting device search bar input text length
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ucentral-client",
|
||||
"version": "2.8.0(24)",
|
||||
"version": "2.8.0(25)",
|
||||
"description": "",
|
||||
"private": true,
|
||||
"main": "index.tsx",
|
||||
|
||||
@@ -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],
|
||||
);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
Reference in New Issue
Block a user