Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Fix gateway add to not populate fields with default values (#3429)

Rich Turner1c01e5ba0735
diff --git a/ui/app/manager/src/pages/page-gateway-tunnel.ts b/ui/app/manager/src/pages/page-gateway-tunnel.ts
index 661e07b11..8066a8d47 100644
--- a/ui/app/manager/src/pages/page-gateway-tunnel.ts
+++ b/ui/app/manager/src/pages/page-gateway-tunnel.ts
@@ -312,7 +312,7 @@ export class PageGatewayTunnel extends Page<AppStateKeyed> {
* meant to start a tunnel towards that instance.
*/
protected _onAddTunnelClick() {
- const tunnel = this._getDefaultTunnelToAdd();
+ const tunnel = {} as GatewayTunnelInfo;
let dialog: OrMwcDialog | undefined;
const onAddClick = () => {
@@ -323,7 +323,10 @@ export class PageGatewayTunnel extends Page<AppStateKeyed> {
{ actionName: "cancel", content: "cancel" },
{
actionName: "add",
- disabled: !tunnel.gatewayId || !tunnel.target || !tunnel.targetPort,
+ disabled:
+ !tunnel.gatewayId ||
+ (tunnel.hostname && tunnel.hostname.trim().length === 0) ||
+ (tunnel.targetPort !== undefined && (tunnel.targetPort <= 0 || tunnel.targetPort > 65535)),
content: "add",
action: () => onAddClick(),
},
@@ -351,6 +354,7 @@ export class PageGatewayTunnel extends Page<AppStateKeyed> {
<or-vaadin-select
.items=${types}
value=${tunnel.type}
+ placeholder=${this.GATEWAY_TUNNEL_PROTOCOL_TYPES?.[0]}
@change=${(ev: Event) => {
tunnel.type = (ev.currentTarget as OrVaadinSelect).value as GatewayTunnelInfoType;
updateActions();
@@ -360,6 +364,7 @@ export class PageGatewayTunnel extends Page<AppStateKeyed> {
</or-vaadin-select>
<or-vaadin-text-field
value=${tunnel.target}
+ placeholder="localhost"
@change=${(ev: Event) => {
tunnel.target = (ev.currentTarget as HTMLInputElement).value;
updateActions();
@@ -369,6 +374,7 @@ export class PageGatewayTunnel extends Page<AppStateKeyed> {
</or-vaadin-text-field>
<or-vaadin-number-field
value=${tunnel.targetPort}
+ placeholder="443"
min="0"
step="1"
@change=${(ev: Event) => {
@@ -399,8 +405,8 @@ export class PageGatewayTunnel extends Page<AppStateKeyed> {
console.warn("Tried to add tunnel, but failed.");
return;
}
- if (!tunnel.gatewayId || !tunnel.target || !tunnel.targetPort) {
- console.warn("Tried to add tunnel, but not all fields were filled in!");
+ if (!tunnel.gatewayId) {
+ console.warn("Tried to add tunnel, but gateway ID missing!");
return;
}
if (!tunnel.realm) {
@@ -550,15 +556,4 @@ export class PageGatewayTunnel extends Page<AppStateKeyed> {
} as AssetQuery;
return (await manager.rest.api.AssetResource.queryAssets(query)).data;
}
-
- /**
- * Utility function that returns the default values of a new tunnel.
- */
- protected _getDefaultTunnelToAdd(): GatewayTunnelInfo {
- return {
- target: "127.0.0.1",
- targetPort: 443,
- type: this.GATEWAY_TUNNEL_PROTOCOL_TYPES?.[0],
- };
- }
}