feat: Implement gateway normalization and inventory server loading in FilterManager, enhancing gateway management and improving server configuration reliability.
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m6s

This commit is contained in:
2025-12-07 01:54:50 +07:00
parent 9fb92c19cb
commit 53bf828797
+39
View File
@@ -35,6 +35,33 @@ import {
const API_URL = '/api';
// Нормализация шлюзов (аналог из ServerManager)
const normalizeGateways = (gateways = [], fallbackName = '') => {
if (!Array.isArray(gateways)) return [];
const cleaned = gateways
.map((g, idx) => ({
id: g?.id || `${Date.now()}-${idx}`,
name: String(g?.name || '').trim(),
ip: String(g?.ip || '').trim(),
comment: String(g?.comment || '').trim(),
primary: Boolean(g?.primary),
}))
.filter(g => g.name || g.ip || g.comment);
if (cleaned.length === 0) {
return [{ id: `${Date.now()}-primary`, name: fallbackName || 'gateway', ip: '', comment: '', primary: true }];
}
let hasPrimary = false;
cleaned.forEach((g) => {
if (g.primary && !hasPrimary) {
hasPrimary = true;
} else {
g.primary = false;
}
});
if (!hasPrimary) cleaned[0].primary = true;
return cleaned;
};
const countryToFlag = (code) => {
if (!code || typeof code !== 'string') return '';
const cc = code.trim().toUpperCase();
@@ -121,6 +148,9 @@ function FilterManager() {
// Communities directory for autocomplete
const [communities, setCommunities] = useState([]);
// Inventory servers (from /servers endpoint)
const [inventoryServers, setInventoryServers] = useState([]);
useEffect(() => {
(async () => {
try {
@@ -130,6 +160,15 @@ function FilterManager() {
// мягко игнорируем, автокомплит необязателен
}
})();
// Загружаем инвентарь серверов для отображения флагов и IP
(async () => {
try {
const res = await api.get(`/servers`);
setInventoryServers(Array.isArray(res.data) ? res.data : []);
} catch (e) {
// мягко игнорируем, дополнительная информация необязательна
}
})();
}, []);
const filterKey = (f) => {