|
|
|
|
@@ -43,22 +43,28 @@ function parseTargetPort(value: any): number | undefined {
|
|
|
|
|
|
|
|
|
|
function getRouteTargetInputs(formEl: any) {
|
|
|
|
|
const textInputs = Array.from(formEl.querySelectorAll('dees-input-text')) as any[];
|
|
|
|
|
const checkboxInputs = Array.from(formEl.querySelectorAll('dees-input-checkbox')) as any[];
|
|
|
|
|
return {
|
|
|
|
|
hostInput: textInputs.find((input) => input.key === 'targetHost'),
|
|
|
|
|
portInput: textInputs.find((input) => input.key === 'targetPort'),
|
|
|
|
|
preservePortInput: checkboxInputs.find((input) => input.key === 'preserveMatchPort'),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setupTargetInputState(formEl: any) {
|
|
|
|
|
const updateState = async () => {
|
|
|
|
|
const data = await formEl.collectFormData();
|
|
|
|
|
const contentEl = formEl.closest('.content') || formEl.parentElement;
|
|
|
|
|
const usesNetworkTarget = !!getDropdownKey(data.networkTargetRef);
|
|
|
|
|
const { hostInput, portInput } = getRouteTargetInputs(formEl);
|
|
|
|
|
const preserveMatchPort = !usesNetworkTarget && Boolean(data.preserveMatchPort);
|
|
|
|
|
const { hostInput, portInput, preservePortInput } = getRouteTargetInputs(formEl);
|
|
|
|
|
const hostDescription = usesNetworkTarget
|
|
|
|
|
? 'Controlled by the selected network target'
|
|
|
|
|
: 'Used when no network target is selected';
|
|
|
|
|
const portDescription = usesNetworkTarget
|
|
|
|
|
? 'Controlled by the selected network target'
|
|
|
|
|
: preserveMatchPort
|
|
|
|
|
? 'Forwarded to the backend on the same port the client matched'
|
|
|
|
|
: 'Used when no network target is selected';
|
|
|
|
|
|
|
|
|
|
if (hostInput) {
|
|
|
|
|
@@ -67,10 +73,24 @@ function setupTargetInputState(formEl: any) {
|
|
|
|
|
hostInput.description = hostDescription;
|
|
|
|
|
}
|
|
|
|
|
if (portInput) {
|
|
|
|
|
portInput.disabled = usesNetworkTarget;
|
|
|
|
|
portInput.required = !usesNetworkTarget;
|
|
|
|
|
portInput.disabled = usesNetworkTarget || preserveMatchPort;
|
|
|
|
|
portInput.required = !usesNetworkTarget && !preserveMatchPort;
|
|
|
|
|
portInput.description = portDescription;
|
|
|
|
|
}
|
|
|
|
|
if (preservePortInput) {
|
|
|
|
|
preservePortInput.disabled = usesNetworkTarget;
|
|
|
|
|
preservePortInput.description = usesNetworkTarget
|
|
|
|
|
? 'Unavailable when a network target is selected'
|
|
|
|
|
: 'Forward to the backend using the same port that matched this route';
|
|
|
|
|
if (usesNetworkTarget) {
|
|
|
|
|
preservePortInput.value = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const remoteIngressGroup = contentEl?.querySelector('.remoteIngressGroup') as HTMLElement | null;
|
|
|
|
|
if (remoteIngressGroup) {
|
|
|
|
|
remoteIngressGroup.style.display = Boolean(data.remoteIngressEnabled) ? 'flex' : 'none';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await formEl.updateRequiredStatus?.();
|
|
|
|
|
};
|
|
|
|
|
@@ -465,10 +485,13 @@ export class OpsViewRoutes extends DeesElement {
|
|
|
|
|
? (Array.isArray(route.match.domains) ? route.match.domains : [route.match.domains])
|
|
|
|
|
: [];
|
|
|
|
|
const firstTarget = route.action.targets?.[0];
|
|
|
|
|
const currentPreserveMatchPort = firstTarget?.port === 'preserve';
|
|
|
|
|
const currentTargetHost = firstTarget
|
|
|
|
|
? (Array.isArray(firstTarget.host) ? firstTarget.host[0] : firstTarget.host)
|
|
|
|
|
: '';
|
|
|
|
|
const currentTargetPort = firstTarget?.port != null ? String(firstTarget.port) : '';
|
|
|
|
|
const currentTargetPort = typeof firstTarget?.port === 'number' ? String(firstTarget.port) : '';
|
|
|
|
|
const currentRemoteIngressEnabled = route.remoteIngress?.enabled === true;
|
|
|
|
|
const currentEdgeFilter = route.remoteIngress?.edgeFilter || [];
|
|
|
|
|
|
|
|
|
|
// Compute current TLS state for pre-population
|
|
|
|
|
const currentTls = (route.action as any).tls;
|
|
|
|
|
@@ -493,6 +516,11 @@ export class OpsViewRoutes extends DeesElement {
|
|
|
|
|
<dees-input-dropdown .key=${'networkTargetRef'} .label=${'Network Target'} .options=${targetOptions} .selectedOption=${targetOptions.find((o) => o.key === (merged.metadata?.networkTargetRef || '')) || null}></dees-input-dropdown>
|
|
|
|
|
<dees-input-text .key=${'targetHost'} .label=${'Target Host'} .description=${'Used when no network target is selected'} .value=${currentTargetHost}></dees-input-text>
|
|
|
|
|
<dees-input-text .key=${'targetPort'} .label=${'Target Port'} .description=${'Used when no network target is selected'} .value=${currentTargetPort}></dees-input-text>
|
|
|
|
|
<dees-input-checkbox .key=${'preserveMatchPort'} .label=${'Preserve incoming port'} .value=${currentPreserveMatchPort}></dees-input-checkbox>
|
|
|
|
|
<dees-input-checkbox .key=${'remoteIngressEnabled'} .label=${'Enable Remote Ingress'} .value=${currentRemoteIngressEnabled}></dees-input-checkbox>
|
|
|
|
|
<div class="remoteIngressGroup" style="display: ${currentRemoteIngressEnabled ? 'flex' : 'none'}; flex-direction: column; gap: 16px;">
|
|
|
|
|
<dees-input-list .key=${'remoteIngressEdgeFilter'} .label=${'Edge Filter'} .description=${'Optional edge IDs or tags. Leave empty to allow all edges.'} .placeholder=${'Add edge ID or tag...'} .value=${currentEdgeFilter}></dees-input-list>
|
|
|
|
|
</div>
|
|
|
|
|
<dees-input-dropdown .key=${'tlsMode'} .label=${'TLS Mode'} .options=${tlsModeOptions} .selectedOption=${tlsModeOptions.find((o) => o.key === currentTlsMode) || tlsModeOptions[0]}></dees-input-dropdown>
|
|
|
|
|
<div class="tlsCertificateGroup" style="display: ${needsCert ? 'flex' : 'none'}; flex-direction: column; gap: 16px;">
|
|
|
|
|
<dees-input-dropdown .key=${'tlsCertificate'} .label=${'Certificate'} .options=${tlsCertOptions} .selectedOption=${tlsCertOptions.find((o) => o.key === currentTlsCert) || tlsCertOptions[0]}></dees-input-dropdown>
|
|
|
|
|
@@ -526,14 +554,22 @@ export class OpsViewRoutes extends DeesElement {
|
|
|
|
|
|
|
|
|
|
const profileKey = getDropdownKey(formData.sourceProfileRef);
|
|
|
|
|
const targetKey = getDropdownKey(formData.networkTargetRef);
|
|
|
|
|
const targetPort = parseTargetPort(formData.targetPort)
|
|
|
|
|
?? (targetKey ? parseTargetPort(currentTargetPort) ?? ports[0] : undefined);
|
|
|
|
|
const preserveMatchPort = !targetKey && Boolean(formData.preserveMatchPort);
|
|
|
|
|
const targetPort = preserveMatchPort
|
|
|
|
|
? 'preserve'
|
|
|
|
|
: parseTargetPort(formData.targetPort)
|
|
|
|
|
?? (targetKey ? parseTargetPort(currentTargetPort) ?? ports[0] : undefined);
|
|
|
|
|
|
|
|
|
|
if (targetPort === undefined) {
|
|
|
|
|
alert('Target Port must be a valid port number when no network target is selected.');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const remoteIngressEnabled = Boolean(formData.remoteIngressEnabled);
|
|
|
|
|
const remoteIngressEdgeFilter: string[] = Array.isArray(formData.remoteIngressEdgeFilter)
|
|
|
|
|
? formData.remoteIngressEdgeFilter.filter(Boolean)
|
|
|
|
|
: [];
|
|
|
|
|
|
|
|
|
|
const updatedRoute: any = {
|
|
|
|
|
name: formData.name,
|
|
|
|
|
match: {
|
|
|
|
|
@@ -549,6 +585,12 @@ export class OpsViewRoutes extends DeesElement {
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
remoteIngress: remoteIngressEnabled
|
|
|
|
|
? {
|
|
|
|
|
enabled: true,
|
|
|
|
|
...(remoteIngressEdgeFilter.length > 0 ? { edgeFilter: remoteIngressEdgeFilter } : {}),
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
...(priority != null && !isNaN(priority) ? { priority } : {}),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@@ -640,6 +682,11 @@ export class OpsViewRoutes extends DeesElement {
|
|
|
|
|
<dees-input-dropdown .key=${'networkTargetRef'} .label=${'Network Target'} .options=${targetOptions}></dees-input-dropdown>
|
|
|
|
|
<dees-input-text .key=${'targetHost'} .label=${'Target Host'} .description=${'Used when no network target is selected'} .value=${'localhost'}></dees-input-text>
|
|
|
|
|
<dees-input-text .key=${'targetPort'} .label=${'Target Port'} .description=${'Used when no network target is selected'}></dees-input-text>
|
|
|
|
|
<dees-input-checkbox .key=${'preserveMatchPort'} .label=${'Preserve incoming port'} .value=${false}></dees-input-checkbox>
|
|
|
|
|
<dees-input-checkbox .key=${'remoteIngressEnabled'} .label=${'Enable Remote Ingress'} .value=${false}></dees-input-checkbox>
|
|
|
|
|
<div class="remoteIngressGroup" style="display: none; flex-direction: column; gap: 16px;">
|
|
|
|
|
<dees-input-list .key=${'remoteIngressEdgeFilter'} .label=${'Edge Filter'} .description=${'Optional edge IDs or tags. Leave empty to allow all edges.'} .placeholder=${'Add edge ID or tag...'}></dees-input-list>
|
|
|
|
|
</div>
|
|
|
|
|
<dees-input-dropdown .key=${'tlsMode'} .label=${'TLS Mode'} .options=${tlsModeOptions} .selectedOption=${tlsModeOptions[0]}></dees-input-dropdown>
|
|
|
|
|
<div class="tlsCertificateGroup" style="display: none; flex-direction: column; gap: 16px;">
|
|
|
|
|
<dees-input-dropdown .key=${'tlsCertificate'} .label=${'Certificate'} .options=${tlsCertOptions} .selectedOption=${tlsCertOptions[0]}></dees-input-dropdown>
|
|
|
|
|
@@ -673,14 +720,22 @@ export class OpsViewRoutes extends DeesElement {
|
|
|
|
|
|
|
|
|
|
const profileKey = getDropdownKey(formData.sourceProfileRef);
|
|
|
|
|
const targetKey = getDropdownKey(formData.networkTargetRef);
|
|
|
|
|
const targetPort = parseTargetPort(formData.targetPort)
|
|
|
|
|
?? (targetKey ? ports[0] : undefined);
|
|
|
|
|
const preserveMatchPort = !targetKey && Boolean(formData.preserveMatchPort);
|
|
|
|
|
const targetPort = preserveMatchPort
|
|
|
|
|
? 'preserve'
|
|
|
|
|
: parseTargetPort(formData.targetPort)
|
|
|
|
|
?? (targetKey ? ports[0] : undefined);
|
|
|
|
|
|
|
|
|
|
if (targetPort === undefined) {
|
|
|
|
|
alert('Target Port must be a valid port number when no network target is selected.');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const remoteIngressEnabled = Boolean(formData.remoteIngressEnabled);
|
|
|
|
|
const remoteIngressEdgeFilter: string[] = Array.isArray(formData.remoteIngressEdgeFilter)
|
|
|
|
|
? formData.remoteIngressEdgeFilter.filter(Boolean)
|
|
|
|
|
: [];
|
|
|
|
|
|
|
|
|
|
const route: any = {
|
|
|
|
|
name: formData.name,
|
|
|
|
|
match: {
|
|
|
|
|
@@ -696,6 +751,14 @@ export class OpsViewRoutes extends DeesElement {
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
...(remoteIngressEnabled
|
|
|
|
|
? {
|
|
|
|
|
remoteIngress: {
|
|
|
|
|
enabled: true,
|
|
|
|
|
...(remoteIngressEdgeFilter.length > 0 ? { edgeFilter: remoteIngressEdgeFilter } : {}),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
: {}),
|
|
|
|
|
...(priority != null && !isNaN(priority) ? { priority } : {}),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|