From ecb4e57906c072815a7cccf80e843c7dc93a6388 Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Fri, 23 Oct 2026 11:47:12 +0300 Subject: [PATCH] refactor(iot-hub): keep the transport field wording per transport in HOST_FIELD_TRANSPORTS HOST_FIELD_TRANSPORTS mapped an install method to a protocol only, while the labels, hints and help popup of the fields were fixed to MQTT. A new entry such as DIRECT_HTTP -> 'https' would compile and fill the right placeholder, but the field would still be labelled "MQTT host" and the help would point to port 1883. Each entry now holds its translation keys: host and port labels, the hints by host source and the help popup id. addTransportFields reads them from the entry, so the next transport has to bring its own wording. --- .../device-install-dialog.component.ts | 63 ++++++++++++++----- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts index ca38fa383c..e1cacc2660 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts @@ -80,12 +80,43 @@ const TRANSPORT_PORT_FIELD_KEY = 'tbTransportPort'; // Not the translated label, so review mode finds the values in any UI language const TRANSPORT_STEP_STATE_KEY = 'tbTransportConnection'; -// Install methods whose packages get a transport host field, and the transport whose -// ${.host} it fills. Other methods use the host differently (a ChirpStack package -// builds the ThingsBoard URL from it, a gateway puts it into docker-compose) and keep the -// resolved value until they are handled separately. -const HOST_FIELD_TRANSPORTS = new Map([ - [InstallMethod.DIRECT_MQTT, 'mqtt'] +/** + * A transport whose ${.host} / ${.port} the install form lets the user check, + * with the translation keys of its fields. The wording is per transport (the label, the hints and + * the help popup name the protocol and its default port), so each entry brings its own keys. + */ +interface HostFieldTransport { + protocol: string; + hostLabel: string; + portLabel: string; + // Host taken from the address ThingsBoard was opened with / from the Base URL in General settings + requestHostHint: string; + baseUrlHostHint: string; + // Host resolved to a loopback address: via the request, via the Base URL, or from an unknown source + requestLoopbackHint: string; + baseUrlLoopbackHint: string; + loopbackHint: string; + // Review mode: the stored value is shown without its source + reviewHostHint: string; + helpPopupId: string; +} + +// Install methods whose packages get the transport fields. Other methods use the host differently +// (a ChirpStack package builds the ThingsBoard URL from it, a gateway puts it into docker-compose) +// and keep the resolved value until they are handled separately. +const HOST_FIELD_TRANSPORTS = new Map([ + [InstallMethod.DIRECT_MQTT, { + protocol: 'mqtt', + hostLabel: 'iot-hub.device-install-mqtt-host', + portLabel: 'iot-hub.device-install-mqtt-port', + requestHostHint: 'iot-hub.device-install-mqtt-host-request-hint', + baseUrlHostHint: 'iot-hub.device-install-mqtt-host-base-url-hint', + requestLoopbackHint: 'iot-hub.device-install-mqtt-host-opened-via-loopback-hint', + baseUrlLoopbackHint: 'iot-hub.device-install-mqtt-host-base-url-loopback-hint', + loopbackHint: 'iot-hub.device-install-mqtt-host-loopback-hint', + reviewHostHint: 'iot-hub.device-install-mqtt-host-hint', + helpPopupId: 'iot-hub/device-connection-host' + }] ]); /** @@ -777,7 +808,8 @@ export class TbDeviceInstallDialogComponent extends DialogComponent