diff --git a/sdk/base/lib/osBindings/SetDefaultOutboundParams.ts b/sdk/base/lib/osBindings/SetDefaultOutboundParams.ts new file mode 100644 index 000000000..de66785ac --- /dev/null +++ b/sdk/base/lib/osBindings/SetDefaultOutboundParams.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { GatewayId } from './GatewayId' + +export type SetDefaultOutboundParams = { gateway: GatewayId | null } diff --git a/sdk/base/lib/osBindings/SetOutboundGatewayParams.ts b/sdk/base/lib/osBindings/SetOutboundGatewayParams.ts new file mode 100644 index 000000000..717509d85 --- /dev/null +++ b/sdk/base/lib/osBindings/SetOutboundGatewayParams.ts @@ -0,0 +1,8 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { GatewayId } from './GatewayId' +import type { PackageId } from './PackageId' + +export type SetOutboundGatewayParams = { + package: PackageId + gateway: GatewayId | null +} diff --git a/sdk/base/lib/osBindings/index.ts b/sdk/base/lib/osBindings/index.ts index 1c8b4b839..4da98b340 100644 --- a/sdk/base/lib/osBindings/index.ts +++ b/sdk/base/lib/osBindings/index.ts @@ -243,6 +243,7 @@ export { Sessions } from './Sessions' export { Session } from './Session' export { SetCountryParams } from './SetCountryParams' export { SetDataVersionParams } from './SetDataVersionParams' +export { SetDefaultOutboundParams } from './SetDefaultOutboundParams' export { SetDependenciesParams } from './SetDependenciesParams' export { SetHealth } from './SetHealth' export { SetIconParams } from './SetIconParams' @@ -250,6 +251,7 @@ export { SetLanguageParams } from './SetLanguageParams' export { SetMainStatusStatus } from './SetMainStatusStatus' export { SetMainStatus } from './SetMainStatus' export { SetNameParams } from './SetNameParams' +export { SetOutboundGatewayParams } from './SetOutboundGatewayParams' export { SetStaticDnsParams } from './SetStaticDnsParams' export { SetupExecuteParams } from './SetupExecuteParams' export { SetupInfo } from './SetupInfo' diff --git a/sdk/base/lib/osBindings/tunnel/AnyVerifyingKey.ts b/sdk/base/lib/osBindings/tunnel/AnyVerifyingKey.ts index eb9973e82..58a45aaa7 100644 --- a/sdk/base/lib/osBindings/tunnel/AnyVerifyingKey.ts +++ b/sdk/base/lib/osBindings/tunnel/AnyVerifyingKey.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type AnyVerifyingKey = string; +export type AnyVerifyingKey = string diff --git a/sdk/base/lib/osBindings/tunnel/Base64.ts b/sdk/base/lib/osBindings/tunnel/Base64.ts index 4b19ad7bf..597227fc9 100644 --- a/sdk/base/lib/osBindings/tunnel/Base64.ts +++ b/sdk/base/lib/osBindings/tunnel/Base64.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type Base64 = string; +export type Base64 = string diff --git a/sdk/base/lib/osBindings/tunnel/Pem.ts b/sdk/base/lib/osBindings/tunnel/Pem.ts index f9cfaea8e..1ec1cd375 100644 --- a/sdk/base/lib/osBindings/tunnel/Pem.ts +++ b/sdk/base/lib/osBindings/tunnel/Pem.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type Pem = string; +export type Pem = string diff --git a/sdk/base/lib/osBindings/tunnel/PortForwards.ts b/sdk/base/lib/osBindings/tunnel/PortForwards.ts index 792c6b0c7..aa9991452 100644 --- a/sdk/base/lib/osBindings/tunnel/PortForwards.ts +++ b/sdk/base/lib/osBindings/tunnel/PortForwards.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type PortForwards = { [key: string]: string }; +export type PortForwards = { [key: string]: string } diff --git a/sdk/base/lib/osBindings/tunnel/Session.ts b/sdk/base/lib/osBindings/tunnel/Session.ts index cd538f564..36ebd2766 100644 --- a/sdk/base/lib/osBindings/tunnel/Session.ts +++ b/sdk/base/lib/osBindings/tunnel/Session.ts @@ -1,3 +1,7 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type Session = { loggedIn: string, lastActive: string, userAgent: string | null, }; +export type Session = { + loggedIn: string + lastActive: string + userAgent: string | null +} diff --git a/sdk/base/lib/osBindings/tunnel/Sessions.ts b/sdk/base/lib/osBindings/tunnel/Sessions.ts index f6dfcfff7..340315855 100644 --- a/sdk/base/lib/osBindings/tunnel/Sessions.ts +++ b/sdk/base/lib/osBindings/tunnel/Sessions.ts @@ -1,4 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { Session } from "./Session"; +import type { Session } from './Session' -export type Sessions = { [key: string]: Session }; +export type Sessions = { [key: string]: Session } diff --git a/sdk/base/lib/osBindings/tunnel/SignerInfo.ts b/sdk/base/lib/osBindings/tunnel/SignerInfo.ts index 50f34b9e3..76cbdafce 100644 --- a/sdk/base/lib/osBindings/tunnel/SignerInfo.ts +++ b/sdk/base/lib/osBindings/tunnel/SignerInfo.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type SignerInfo = { name: string, }; +export type SignerInfo = { name: string } diff --git a/sdk/base/lib/osBindings/tunnel/TunnelCertData.ts b/sdk/base/lib/osBindings/tunnel/TunnelCertData.ts index 7fd7d31ef..8a28ef25c 100644 --- a/sdk/base/lib/osBindings/tunnel/TunnelCertData.ts +++ b/sdk/base/lib/osBindings/tunnel/TunnelCertData.ts @@ -1,4 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { Pem } from "./Pem"; +import type { Pem } from './Pem' -export type TunnelCertData = { key: Pem, cert: Pem, }; +export type TunnelCertData = { key: Pem; cert: Pem } diff --git a/sdk/base/lib/osBindings/tunnel/TunnelDatabase.ts b/sdk/base/lib/osBindings/tunnel/TunnelDatabase.ts index 4333d29b6..2f484b5b7 100644 --- a/sdk/base/lib/osBindings/tunnel/TunnelDatabase.ts +++ b/sdk/base/lib/osBindings/tunnel/TunnelDatabase.ts @@ -1,9 +1,17 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { AnyVerifyingKey } from "./AnyVerifyingKey"; -import type { PortForwards } from "./PortForwards"; -import type { Sessions } from "./Sessions"; -import type { SignerInfo } from "./SignerInfo"; -import type { WebserverInfo } from "./WebserverInfo"; -import type { WgServer } from "./WgServer"; +import type { AnyVerifyingKey } from './AnyVerifyingKey' +import type { PortForwards } from './PortForwards' +import type { Sessions } from './Sessions' +import type { SignerInfo } from './SignerInfo' +import type { WebserverInfo } from './WebserverInfo' +import type { WgServer } from './WgServer' -export type TunnelDatabase = { webserver: WebserverInfo, sessions: Sessions, password: string | null, authPubkeys: { [key: AnyVerifyingKey]: SignerInfo }, gateways: { [key: AnyVerifyingKey]: SignerInfo }, wg: WgServer, portForwards: PortForwards, }; +export type TunnelDatabase = { + webserver: WebserverInfo + sessions: Sessions + password: string | null + authPubkeys: { [key: AnyVerifyingKey]: SignerInfo } + gateways: { [key: AnyVerifyingKey]: SignerInfo } + wg: WgServer + portForwards: PortForwards +} diff --git a/sdk/base/lib/osBindings/tunnel/WebserverInfo.ts b/sdk/base/lib/osBindings/tunnel/WebserverInfo.ts index 76c0862f4..c5a48ace0 100644 --- a/sdk/base/lib/osBindings/tunnel/WebserverInfo.ts +++ b/sdk/base/lib/osBindings/tunnel/WebserverInfo.ts @@ -1,4 +1,8 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { TunnelCertData } from "./TunnelCertData"; +import type { TunnelCertData } from './TunnelCertData' -export type WebserverInfo = { enabled: boolean, listen: string | null, certificate: TunnelCertData | null, }; +export type WebserverInfo = { + enabled: boolean + listen: string | null + certificate: TunnelCertData | null +} diff --git a/sdk/base/lib/osBindings/tunnel/WgConfig.ts b/sdk/base/lib/osBindings/tunnel/WgConfig.ts index 06c27e55b..4ca18e900 100644 --- a/sdk/base/lib/osBindings/tunnel/WgConfig.ts +++ b/sdk/base/lib/osBindings/tunnel/WgConfig.ts @@ -1,4 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { Base64 } from "./Base64"; +import type { Base64 } from './Base64' -export type WgConfig = { name: string, key: Base64, psk: Base64, }; +export type WgConfig = { name: string; key: Base64; psk: Base64 } diff --git a/sdk/base/lib/osBindings/tunnel/WgServer.ts b/sdk/base/lib/osBindings/tunnel/WgServer.ts index f60edf8f3..c6bbb7c9c 100644 --- a/sdk/base/lib/osBindings/tunnel/WgServer.ts +++ b/sdk/base/lib/osBindings/tunnel/WgServer.ts @@ -1,5 +1,5 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { Base64 } from "./Base64"; -import type { WgSubnetMap } from "./WgSubnetMap"; +import type { Base64 } from './Base64' +import type { WgSubnetMap } from './WgSubnetMap' -export type WgServer = { port: number, key: Base64, subnets: WgSubnetMap, }; +export type WgServer = { port: number; key: Base64; subnets: WgSubnetMap } diff --git a/sdk/base/lib/osBindings/tunnel/WgSubnetClients.ts b/sdk/base/lib/osBindings/tunnel/WgSubnetClients.ts index ad83d5b64..023c51ca5 100644 --- a/sdk/base/lib/osBindings/tunnel/WgSubnetClients.ts +++ b/sdk/base/lib/osBindings/tunnel/WgSubnetClients.ts @@ -1,4 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { WgConfig } from "./WgConfig"; +import type { WgConfig } from './WgConfig' -export type WgSubnetClients = { [key: string]: WgConfig }; +export type WgSubnetClients = { [key: string]: WgConfig } diff --git a/sdk/base/lib/osBindings/tunnel/WgSubnetConfig.ts b/sdk/base/lib/osBindings/tunnel/WgSubnetConfig.ts index 1606c928f..37c9af3a1 100644 --- a/sdk/base/lib/osBindings/tunnel/WgSubnetConfig.ts +++ b/sdk/base/lib/osBindings/tunnel/WgSubnetConfig.ts @@ -1,4 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { WgSubnetClients } from "./WgSubnetClients"; +import type { WgSubnetClients } from './WgSubnetClients' -export type WgSubnetConfig = { name: string, clients: WgSubnetClients, }; +export type WgSubnetConfig = { name: string; clients: WgSubnetClients } diff --git a/sdk/base/lib/osBindings/tunnel/WgSubnetMap.ts b/sdk/base/lib/osBindings/tunnel/WgSubnetMap.ts index 5cf96c79c..8347dcf84 100644 --- a/sdk/base/lib/osBindings/tunnel/WgSubnetMap.ts +++ b/sdk/base/lib/osBindings/tunnel/WgSubnetMap.ts @@ -1,4 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { WgSubnetConfig } from "./WgSubnetConfig"; +import type { WgSubnetConfig } from './WgSubnetConfig' -export type WgSubnetMap = { [key: string]: WgSubnetConfig }; +export type WgSubnetMap = { [key: string]: WgSubnetConfig } diff --git a/web/projects/ui/src/app/routes/portal/routes/services/routes/actions.component.ts b/web/projects/ui/src/app/routes/portal/routes/services/routes/actions.component.ts index f8b0fcf47..5f8c30cff 100644 --- a/web/projects/ui/src/app/routes/portal/routes/services/routes/actions.component.ts +++ b/web/projects/ui/src/app/routes/portal/routes/services/routes/actions.component.ts @@ -119,6 +119,10 @@ export default class ServiceActionsRoute { ungrouped: 'General' | 'Other' = 'General' readonly service = inject(StandardActionsService) + private readonly gateways = toSignal( + this.patch.watch$('serverInfo', 'network', 'gateways'), + ) + readonly package = toSignal( this.patch.watch$('packageData', getPkgId()).pipe( map(pkg => { @@ -173,11 +177,18 @@ export default class ServiceActionsRoute { readonly outboundGatewayAction = computed(() => { const pkg = this.package() - const gateway = pkg?.outboundGateway + const gatewayId = pkg?.outboundGateway + const gateways = this.gateways() + const gatewayName = + gatewayId && gateways?.[gatewayId] + ? (gateways[gatewayId].name ?? + gateways[gatewayId].ipInfo?.name ?? + gatewayId) + : null return { name: this.i18n.transform('Set Outbound Gateway')!, - description: gateway - ? `${this.i18n.transform('Current')}: ${gateway}` + description: gatewayName + ? `${this.i18n.transform('Current')}: ${gatewayName}` : `${this.i18n.transform('Current')}: ${this.i18n.transform('System')}`, } }) @@ -256,7 +267,7 @@ export default class ServiceActionsRoute { try { await this.api.setServiceOutbound({ - packageId: pkg.manifest.id, + package: pkg.manifest.id, gateway: input.gateway === SYSTEM_KEY ? null : input.gateway, }) return true diff --git a/web/projects/ui/src/app/services/api/embassy-api.service.ts b/web/projects/ui/src/app/services/api/embassy-api.service.ts index 06d4d5de7..d44667ca9 100644 --- a/web/projects/ui/src/app/services/api/embassy-api.service.ts +++ b/web/projects/ui/src/app/services/api/embassy-api.service.ts @@ -191,10 +191,9 @@ export abstract class ApiService { abstract setDefaultOutbound(params: { gateway: string | null }): Promise - abstract setServiceOutbound(params: { - packageId: string - gateway: string | null - }): Promise + abstract setServiceOutbound( + params: T.SetOutboundGatewayParams, + ): Promise // ** domains ** diff --git a/web/projects/ui/src/app/services/api/embassy-live-api.service.ts b/web/projects/ui/src/app/services/api/embassy-live-api.service.ts index 8ba04d82b..0d12469d8 100644 --- a/web/projects/ui/src/app/services/api/embassy-live-api.service.ts +++ b/web/projects/ui/src/app/services/api/embassy-live-api.service.ts @@ -276,9 +276,7 @@ export class LiveApiService extends ApiService { }) } - async checkPort( - params: T.CheckPortParams, - ): Promise { + async checkPort(params: T.CheckPortParams): Promise { return this.rpcRequest({ method: 'net.gateway.check-port', params, @@ -369,17 +367,14 @@ export class LiveApiService extends ApiService { return this.rpcRequest({ method: 'net.tunnel.remove', params }) } - async setDefaultOutbound(params: { gateway: string | null }): Promise { + async setDefaultOutbound(params: T.SetDefaultOutboundParams): Promise { return this.rpcRequest({ method: 'net.gateway.set-default-outbound', params, }) } - async setServiceOutbound(params: { - packageId: string - gateway: string | null - }): Promise { + async setServiceOutbound(params: T.SetOutboundGatewayParams): Promise { return this.rpcRequest({ method: 'package.set-outbound-gateway', params }) } diff --git a/web/projects/ui/src/app/services/api/embassy-mock-api.service.ts b/web/projects/ui/src/app/services/api/embassy-mock-api.service.ts index b59761613..ab6399eb8 100644 --- a/web/projects/ui/src/app/services/api/embassy-mock-api.service.ts +++ b/web/projects/ui/src/app/services/api/embassy-mock-api.service.ts @@ -662,15 +662,14 @@ export class MockApiService extends ApiService { return null } - async setServiceOutbound(params: { - packageId: string - gateway: string | null - }): Promise { + async setServiceOutbound( + params: T.SetOutboundGatewayParams, + ): Promise { await pauseFor(2000) const patch = [ { op: PatchOp.REPLACE, - path: `/packageData/${params.packageId}/outboundGateway`, + path: `/packageData/${params.package}/outboundGateway`, value: params.gateway, }, ]