diff --git a/packages/api-client/src/modules/archon/servers/v1.ts b/packages/api-client/src/modules/archon/servers/v1.ts index 9435bf11c7..0aad12eb07 100644 --- a/packages/api-client/src/modules/archon/servers/v1.ts +++ b/packages/api-client/src/modules/archon/servers/v1.ts @@ -66,4 +66,19 @@ export class ArchonServersV1Module extends AbstractModule { method: 'POST', }) } + + /** + * Roll SFTP credentials for a server + * POST /v1/servers/:server_id/sftp/roll + */ + public async rollSftp(serverId: string): Promise { + return this.client.request( + `/servers/${serverId}/sftp/roll`, + { + api: 'archon', + version: 1, + method: 'POST', + }, + ) + } } diff --git a/packages/api-client/src/modules/archon/types.ts b/packages/api-client/src/modules/archon/types.ts index 00fb3c7da4..beea64e832 100644 --- a/packages/api-client/src/modules/archon/types.ts +++ b/packages/api-client/src/modules/archon/types.ts @@ -746,6 +746,11 @@ export namespace Archon { worlds: WorldFull[] } + export type SftpCredentials = { + sftp_username: string + sftp_password: string + } + export type ServerResources = { cpu: number memory_mb: number @@ -981,6 +986,11 @@ export namespace Archon { type: 'server.network.patch' ports: ServerNetworkPort[] } + export type ServerSftpPatchEvent = { + type: 'server.sftp.patch' + sftp_username: string + sftp_password: string + } export type ServerTransferEvent = { type: 'server.transfer.start' | 'server.transfer.done' target_node: string @@ -1094,6 +1104,7 @@ export namespace Archon { | BackupOperationDoneEvent | ServerPatchEvent | ServerNetworkPatchEvent + | ServerSftpPatchEvent | ServerTransferEvent | UsersPatchEvent | WorldPatchEvent diff --git a/packages/ui/src/composables/server-panel-sync.ts b/packages/ui/src/composables/server-panel-sync.ts index cd4101b096..30541a240e 100644 --- a/packages/ui/src/composables/server-panel-sync.ts +++ b/packages/ui/src/composables/server-panel-sync.ts @@ -96,6 +96,9 @@ export function useServerPanelSync(options: UseServerPanelSyncOptions) { case 'server.network.patch': handleServerNetworkPatch(serverId, event) break + case 'server.sftp.patch': + handleServerSftpPatch(serverId, event) + break case 'server.transfer.start': case 'server.transfer.done': void invalidateServerDetails(serverId) @@ -149,6 +152,24 @@ export function useServerPanelSync(options: UseServerPanelSyncOptions) { ) } + function handleServerSftpPatch(serverId: string, event: Archon.Sync.v1.ServerSftpPatchEvent) { + applySftpCredentials(serverId, { + sftp_username: event.sftp_username, + sftp_password: event.sftp_password, + }) + } + + function applySftpCredentials(serverId: string, credentials: Archon.Servers.v1.SftpCredentials) { + queryClient.setQueryData( + legacyServerDetailKey(serverId), + (current) => (current ? { ...current, ...credentials } : current), + ) + queryClient.setQueryData( + serverV1DetailKey(serverId), + (current) => (current ? { ...current, ...credentials } : current), + ) + } + function handleServerNetworkPatch( serverId: string, event: Archon.Sync.v1.ServerNetworkPatchEvent, diff --git a/packages/ui/src/layouts/shared/server-settings/pages/advanced.vue b/packages/ui/src/layouts/shared/server-settings/pages/advanced.vue index 9a610883f6..ba14261e7e 100644 --- a/packages/ui/src/layouts/shared/server-settings/pages/advanced.vue +++ b/packages/ui/src/layouts/shared/server-settings/pages/advanced.vue @@ -1,23 +1,45 @@