feat: Добавить инициализацию загрузки данных в менеджеры ASNs, Domains и IPRanges, улучшить обработку поиска с использованием таймера
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m43s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m43s
This commit is contained in:
@@ -40,6 +40,7 @@ function ASNsNewManager() {
|
|||||||
const [success, setSuccess] = useState('');
|
const [success, setSuccess] = useState('');
|
||||||
const [searchTerm, setSearchTerm] = useState('');
|
const [searchTerm, setSearchTerm] = useState('');
|
||||||
const searchTimer = useRef(null);
|
const searchTimer = useRef(null);
|
||||||
|
const didInit = useRef(false);
|
||||||
const [editingAsn, setEditingAsn] = useState(null);
|
const [editingAsn, setEditingAsn] = useState(null);
|
||||||
const [editingValue, setEditingValue] = useState('');
|
const [editingValue, setEditingValue] = useState('');
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
@@ -95,7 +96,6 @@ function ASNsNewManager() {
|
|||||||
};
|
};
|
||||||
acquire();
|
acquire();
|
||||||
const interval = setInterval(acquire, 60_000);
|
const interval = setInterval(acquire, 60_000);
|
||||||
fetchItems();
|
|
||||||
// Load WS URL once
|
// Load WS URL once
|
||||||
(async () => {
|
(async () => {
|
||||||
try { const r = await api.get('/ws/url'); setWsUrl(String(r.data?.url || '')); } catch {}
|
try { const r = await api.get('/ws/url'); setWsUrl(String(r.data?.url || '')); } catch {}
|
||||||
@@ -131,10 +131,9 @@ function ASNsNewManager() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!didInit.current) { didInit.current = true; fetchItems(); return; }
|
||||||
if (searchTimer.current) clearTimeout(searchTimer.current);
|
if (searchTimer.current) clearTimeout(searchTimer.current);
|
||||||
searchTimer.current = setTimeout(() => {
|
searchTimer.current = setTimeout(() => { fetchItems(); }, 350);
|
||||||
fetchItems();
|
|
||||||
}, 350);
|
|
||||||
return () => { if (searchTimer.current) clearTimeout(searchTimer.current); };
|
return () => { if (searchTimer.current) clearTimeout(searchTimer.current); };
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [currentPage, searchTerm, filterCommunity]);
|
}, [currentPage, searchTerm, filterCommunity]);
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ function DomainsNewManager() {
|
|||||||
const [success, setSuccess] = useState('');
|
const [success, setSuccess] = useState('');
|
||||||
const [searchTerm, setSearchTerm] = useState('');
|
const [searchTerm, setSearchTerm] = useState('');
|
||||||
const searchTimer = useRef(null);
|
const searchTimer = useRef(null);
|
||||||
|
const didInit = useRef(false);
|
||||||
const [editingDomain, setEditingDomain] = useState(null);
|
const [editingDomain, setEditingDomain] = useState(null);
|
||||||
const [editingValue, setEditingValue] = useState('');
|
const [editingValue, setEditingValue] = useState('');
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
@@ -100,7 +101,6 @@ function DomainsNewManager() {
|
|||||||
};
|
};
|
||||||
acquire();
|
acquire();
|
||||||
const interval = setInterval(acquire, 60_000);
|
const interval = setInterval(acquire, 60_000);
|
||||||
fetchItems();
|
|
||||||
(async () => { try { const r = await api.get('/ws/url'); setWsUrl(String(r.data?.url || '')); } catch {} })();
|
(async () => { try { const r = await api.get('/ws/url'); setWsUrl(String(r.data?.url || '')); } catch {} })();
|
||||||
return () => {
|
return () => {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
@@ -133,10 +133,9 @@ function DomainsNewManager() {
|
|||||||
|
|
||||||
// Подгрузка при изменении страницы/поиска/фильтра
|
// Подгрузка при изменении страницы/поиска/фильтра
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!didInit.current) { didInit.current = true; fetchItems(); return; }
|
||||||
if (searchTimer.current) clearTimeout(searchTimer.current);
|
if (searchTimer.current) clearTimeout(searchTimer.current);
|
||||||
searchTimer.current = setTimeout(() => {
|
searchTimer.current = setTimeout(() => { fetchItems(); }, 350);
|
||||||
fetchItems();
|
|
||||||
}, 350);
|
|
||||||
return () => { if (searchTimer.current) clearTimeout(searchTimer.current); };
|
return () => { if (searchTimer.current) clearTimeout(searchTimer.current); };
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [currentPage, searchTerm, filterCommunity]);
|
}, [currentPage, searchTerm, filterCommunity]);
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ function IPRangesManager() {
|
|||||||
const [success, setSuccess] = useState('');
|
const [success, setSuccess] = useState('');
|
||||||
const [searchTerm, setSearchTerm] = useState('');
|
const [searchTerm, setSearchTerm] = useState('');
|
||||||
const searchTimer = useRef(null);
|
const searchTimer = useRef(null);
|
||||||
|
const didInit = useRef(false);
|
||||||
const [editingIp, setEditingIp] = useState(null);
|
const [editingIp, setEditingIp] = useState(null);
|
||||||
const [editingValue, setEditingValue] = useState('');
|
const [editingValue, setEditingValue] = useState('');
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
@@ -111,7 +112,6 @@ function IPRangesManager() {
|
|||||||
};
|
};
|
||||||
acquire();
|
acquire();
|
||||||
const interval = setInterval(acquire, 60_000);
|
const interval = setInterval(acquire, 60_000);
|
||||||
fetchItems();
|
|
||||||
(async () => { try { const r = await api.get('/ws/url'); setWsUrl(String(r.data?.url || '')); } catch {} })();
|
(async () => { try { const r = await api.get('/ws/url'); setWsUrl(String(r.data?.url || '')); } catch {} })();
|
||||||
return () => {
|
return () => {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
@@ -143,10 +143,9 @@ function IPRangesManager() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!didInit.current) { didInit.current = true; fetchItems(); return; }
|
||||||
if (searchTimer.current) clearTimeout(searchTimer.current);
|
if (searchTimer.current) clearTimeout(searchTimer.current);
|
||||||
searchTimer.current = setTimeout(() => {
|
searchTimer.current = setTimeout(() => { fetchItems(); }, 350);
|
||||||
fetchItems();
|
|
||||||
}, 350);
|
|
||||||
return () => { if (searchTimer.current) clearTimeout(searchTimer.current); };
|
return () => { if (searchTimer.current) clearTimeout(searchTimer.current); };
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [currentPage, searchTerm, filterCommunity]);
|
}, [currentPage, searchTerm, filterCommunity]);
|
||||||
|
|||||||
Reference in New Issue
Block a user