fix: 允许保存 IPv4 地址池状态

go
codex 2 weeks ago
parent 10341fa943
commit 2c50eea492

@ -969,7 +969,23 @@ function renderNetworkPoolForm(pool) {
const maxAllocations = networkPoolInput('number', 'max_allocations', Number(pool.max_allocations || 0), { min: 1, max: 65535 });
for (const [control, suffix] of [[attachment, 'attachment'], [name, 'name'], [family, 'family'], [cidr, 'cidr'], [gateway, 'gateway'], [gatewayOnLink, 'gateway-on-link'], [prefix, 'prefix'], [status, 'state'], [dns, 'dns'], [reserved, 'reserved'], [allocationStart, 'allocation-start'], [allocationEnd, 'allocation-end'], [maxAllocations, 'max-allocations']]) control.id = `host-network-pool-${pool.pool_key}-${suffix}`;
const sparseFields = [networkPoolField('IPv6 分配起始地址', allocationStart), networkPoolField('IPv6 分配结束地址', allocationEnd), networkPoolField('IPv6 最大分配数量', maxAllocations)];
const syncFamily = () => { const ipv6 = family.value === '6'; prefix.min = ipv6 ? '48' : '24'; prefix.max = ipv6 ? '120' : '30'; for (const field of sparseFields) field.hidden = !ipv6; allocationStart.required = ipv6; allocationEnd.required = ipv6; maxAllocations.required = ipv6; gatewayOnLink.disabled = !canManage || !ipv6; if (!ipv6) { allocationStart.value = ''; allocationEnd.value = ''; maxAllocations.value = '0'; gatewayOnLink.value = '0'; } };
const syncFamily = () => {
const ipv6 = family.value === '6';
prefix.min = ipv6 ? '48' : '24';
prefix.max = ipv6 ? '120' : '30';
for (const field of sparseFields) field.hidden = !ipv6;
for (const control of [allocationStart, allocationEnd, maxAllocations]) {
control.required = ipv6;
control.disabled = !canManage || !ipv6;
}
gatewayOnLink.disabled = !canManage || !ipv6;
if (!ipv6) {
allocationStart.value = '';
allocationEnd.value = '';
maxAllocations.value = '0';
gatewayOnLink.value = '0';
}
};
family.addEventListener('change', syncFamily); syncFamily();
grid.append(networkPoolAttachmentField(attachment, attachmentDetail), networkPoolField('地址池名称', name, true), networkPoolField('地址族', family), networkPoolField('网关方式', gatewayOnLink), networkPoolField('实际公网 CIDR', cidr), networkPoolField('公网网关', gateway), networkPoolField('客户机网络前缀', prefix), networkPoolField('运行状态', status), networkPoolField('DNS(逗号或空格分隔)', dns, true), networkPoolField('保留 / 禁用 IP', reserved, true), ...sparseFields);
const metadata = element('p', 'form-text mb-0', `面板版本 ${Number(pool.revision || 0)} · 已应用版本 ${pool.live_revision === null ? '未确认' : Number(pool.live_revision)} · 占用 ${Number(pool.occupied_count || 0)} · 可分配 ${Number(pool.available_count || 0)}`);

@ -1,2 +1,2 @@
{* Shared Venix CSS/JS cache key. Increment whenever a shared browser asset changes. *}
{assign var=venix_asset_version value='2026110403' scope='global'}
{assign var=venix_asset_version value='2026110404' scope='global'}

@ -284,9 +284,18 @@ for (const [family, enabled] of [[4, false], [6, true]]) {
}, 7, 0);
const gatewayOnLink = descendants(test.get('host-network-pools-list'))
.find(node => node.name === 'gateway_on_link');
const ipv6OnlyControls = descendants(test.get('host-network-pools-list'))
.filter(node => ['allocation_start', 'allocation_end', 'max_allocations'].includes(node.name));
assert.equal(gatewayOnLink?.disabled, !enabled,
`IPv${family} edit mode exposed the wrong on-link state.`);
if (family === 4) assert.equal(gatewayOnLink?.value, '0');
for (const control of ipv6OnlyControls) {
assert.equal(control.disabled, !enabled,
`IPv${family} edit mode exposed the wrong ${control.name} state.`);
}
if (family === 4) {
assert.equal(gatewayOnLink?.value, '0');
assert.equal(ipv6OnlyControls.find(node => node.name === 'max_allocations')?.value, '0');
}
}
{

@ -15,7 +15,7 @@ $assert = static function (bool $condition, string $message): void {
};
$assert(is_string($assets)
&& str_contains($assets, "venix_asset_version value='2026110403'")
&& str_contains($assets, "venix_asset_version value='2026110404'")
&& is_string($cloudShell)
&& str_contains($cloudShell, '/cloud/app.js?v={$venix_asset_version}'),
'The cloud application entry must use the shared Venix asset version.');

Loading…
Cancel
Save