diff --git a/frontend/src/ASNsNewManager.jsx b/frontend/src/ASNsNewManager.jsx index 8c47a3d..b286a36 100644 --- a/frontend/src/ASNsNewManager.jsx +++ b/frontend/src/ASNsNewManager.jsx @@ -35,6 +35,19 @@ function ASNsNewManager() { const editInputRef = useRef(null); const pageSize = 10; + // Справочник community для подсказок + const [communities, setCommunities] = useState([]); + useEffect(() => { + (async () => { + try { + const res = await axios.get(`${API_URL}/communities`); + setCommunities(Array.isArray(res.data) ? res.data : []); + } catch (e) { + // тихо игнорируем + } + })(); + }, []); + const isValidAsn = (value) => /^[0-9]+$/.test(String(value).trim()); // Допускаем как числовые, так и строковые (AS:NNN) community const isValidCommunity = (value) => /^(\d+|\d+:\d+)$/.test(String(value).trim()); @@ -262,6 +275,7 @@ function ASNsNewManager() {
setNewItem({ ...newItem, community: e.target.value })} /> {newInvalid.community &&
Только цифры
} + {(() => { + const match = communities.find(c => c.value === String(newItem.community).trim()); + if (!match) return null; + return ( +
+ {match.name && (<>{match.name} — )} + {match.description || ''} + {match.tags && match.tags.length > 0 && ( + <> ({match.tags.join(', ')}) + )} +
+ ); + })()}
)} + {/* Общий список подсказок community */} + + {communities.map(c => ( + + ))} + ); } diff --git a/frontend/src/DomainsNewManager.jsx b/frontend/src/DomainsNewManager.jsx index eab64e1..b05bbf9 100644 --- a/frontend/src/DomainsNewManager.jsx +++ b/frontend/src/DomainsNewManager.jsx @@ -35,6 +35,19 @@ function DomainsNewManager() { const editInputRef = useRef(null); const pageSize = 10; + // Справочник community для подсказок + const [communities, setCommunities] = useState([]); + useEffect(() => { + (async () => { + try { + const res = await axios.get(`${API_URL}/communities`); + setCommunities(Array.isArray(res.data) ? res.data : []); + } catch (e) { + // тихо игнорируем + } + })(); + }, []); + const isValidDomain = (value) => { const v = String(value).trim().toLowerCase(); // Простой валидатор FQDN: sub.domain.tld @@ -268,6 +281,7 @@ function DomainsNewManager() {
setNewItem({ ...newItem, community: e.target.value })} /> {newInvalid.community &&
Только цифры
} + {(() => { + const match = communities.find(c => c.value === String(newItem.community).trim()); + if (!match) return null; + return ( +
+ {match.name && (<>{match.name} — )} + {match.description || ''} + {match.tags && match.tags.length > 0 && ( + <> ({match.tags.join(', ')}) + )} +
+ ); + })()}
)} + {/* Общий список подсказок community */} + + {communities.map(c => ( + + ))} + ); } diff --git a/frontend/src/IPRangesManager.jsx b/frontend/src/IPRangesManager.jsx index 8766ebb..3f15f69 100644 --- a/frontend/src/IPRangesManager.jsx +++ b/frontend/src/IPRangesManager.jsx @@ -35,6 +35,19 @@ function IPRangesManager() { const editInputRef = useRef(null); const pageSize = 10; + // Справочник community для подсказок + const [communities, setCommunities] = useState([]); + useEffect(() => { + (async () => { + try { + const res = await axios.get(`${API_URL}/communities`); + setCommunities(Array.isArray(res.data) ? res.data : []); + } catch (e) { + // тихо игнорируем + } + })(); + }, []); + const isValidIPv4 = (ip) => { const octets = ip.split('.'); if (octets.length !== 4) return false; @@ -277,6 +290,7 @@ function IPRangesManager() {
setNewItem({ ...newItem, community: e.target.value })} /> {newInvalid.community &&
Только цифры
} + {(() => { + const match = communities.find(c => c.value === String(newItem.community).trim()); + if (!match) return null; + return ( +
+ {match.name && (<>{match.name} — )} + {match.description || ''} + {match.tags && match.tags.length > 0 && ( + <> ({match.tags.join(', ')}) + )} +
+ ); + })()}
)} + {/* Общий список подсказок community */} + + {communities.map(c => ( + + ))} + ); }