|
|
|
|
@ -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)}`);
|
|
|
|
|
|