fix(network-config-manager): correct sorting logic for cost in areas and item lists, update cost calculation during reordering
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m58s

This commit is contained in:
2026-03-05 16:30:21 +07:00
parent 114d7b2731
commit 817f550f4d
+5 -5
View File
@@ -590,7 +590,7 @@ function NetworkConfigManager() {
const areas = Object.entries(areasMap) const areas = Object.entries(areasMap)
.map(([area, items]) => ({ .map(([area, items]) => ({
area, area,
items: [...items].sort((a, b) => Number(b?.cost || 0) - Number(a?.cost || 0)), items: [...items].sort((a, b) => Number(a?.cost || 0) - Number(b?.cost || 0)),
})) }))
.sort((a, b) => a.area.localeCompare(b.area)); .sort((a, b) => a.area.localeCompare(b.area));
@@ -628,14 +628,14 @@ function NetworkConfigManager() {
const itemArea = String(item?.area || '').trim() || 'backbone'; const itemArea = String(item?.area || '').trim() || 'backbone';
return identity.key === String(routerKey) && itemArea === String(area || 'backbone'); return identity.key === String(routerKey) && itemArea === String(area || 'backbone');
}) })
.sort((a, b) => Number(b?.cost || 0) - Number(a?.cost || 0)); .sort((a, b) => Number(a?.cost || 0) - Number(b?.cost || 0));
const fromIndex = current.findIndex((item) => String(item.key || '') === draggedKey); const fromIndex = current.findIndex((item) => String(item.key || '') === draggedKey);
const toIndex = current.findIndex((item) => String(item.key || '') === destinationKey); const toIndex = current.findIndex((item) => String(item.key || '') === destinationKey);
if (fromIndex < 0 || toIndex < 0) return prev; if (fromIndex < 0 || toIndex < 0) return prev;
const reordered = moveInArray(current, fromIndex, toIndex).map((item, idx, arr) => ({ const reordered = moveInArray(current, fromIndex, toIndex).map((item, idx) => ({
...item, ...item,
cost: (arr.length - idx) * OSPF_COST_STEP, cost: (idx + 1) * OSPF_COST_STEP,
})); }));
const otherServers = (prev.ospfInterfaceTemplates || []).filter((item) => { const otherServers = (prev.ospfInterfaceTemplates || []).filter((item) => {
@@ -3937,7 +3937,7 @@ function NetworkConfigManager() {
<div> <div>
<h3 className="card-title mb-0">OSPF Interface Template (HOME)</h3> <h3 className="card-title mb-0">OSPF Interface Template (HOME)</h3>
<div className="text-muted small"> <div className="text-muted small">
Только для HOME роутеров. Источник данных MikroTik, группировка по Area. Только для HOME роутеров. Источник данных MikroTik, группировка по Area. Чем меньше cost, тем выше приоритет.
</div> </div>
</div> </div>
<div className="d-flex align-items-center gap-2"> <div className="d-flex align-items-center gap-2">