diff --git a/ui/src/app/pages/server-routes/security-routes/ssh-keys/ssh-keys.page.html b/ui/src/app/pages/server-routes/security-routes/ssh-keys/ssh-keys.page.html index a79c14590..34d1460c7 100644 --- a/ui/src/app/pages/server-routes/security-routes/ssh-keys/ssh-keys.page.html +++ b/ui/src/app/pages/server-routes/security-routes/ssh-keys/ssh-keys.page.html @@ -46,14 +46,14 @@ - + -

{{ ssh.value.hostname }}

-

{{ ssh.value['created-at'] | date: 'short' }}

-

{{ ssh.value.alg }} {{ ssh.key }}

+

{{ ssh.hostname }}

+

{{ ssh['created-at'] | date: 'short' }}

+

{{ ssh.alg }} {{ ssh.hash }}

- + Remove diff --git a/ui/src/app/pages/server-routes/security-routes/ssh-keys/ssh-keys.page.ts b/ui/src/app/pages/server-routes/security-routes/ssh-keys/ssh-keys.page.ts index 54e9f77d1..ab403d2e1 100644 --- a/ui/src/app/pages/server-routes/security-routes/ssh-keys/ssh-keys.page.ts +++ b/ui/src/app/pages/server-routes/security-routes/ssh-keys/ssh-keys.page.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core' import { AlertController, LoadingController, ModalController } from '@ionic/angular' -import { SSHKeys } from 'src/app/services/api/api.types' +import { SSHKey } from 'src/app/services/api/api.types' import { ErrorToastService } from 'src/app/services/error-toast.service' import { ApiService } from 'src/app/services/api/embassy-api.service' import { GenericInputComponent } from 'src/app/modals/generic-input/generic-input.component' @@ -12,7 +12,7 @@ import { GenericInputComponent } from 'src/app/modals/generic-input/generic-inpu }) export class SSHKeysPage { loading = true - sshKeys: SSHKeys + sshKeys: SSHKey[] readonly docsUrl = 'https://docs.start9.com/user-manual/general/developer-options/ssh-setup.html' constructor ( @@ -63,7 +63,7 @@ export class SSHKeysPage { try { const key = await this.embassyApi.addSshKey({ key: pubkey }) - this.sshKeys = { ...this.sshKeys, ...key } + this.sshKeys.push(key) } catch (e) { this.errToast.present(e) } finally { @@ -71,7 +71,7 @@ export class SSHKeysPage { } } - async presentAlertDelete (hash: string) { + async presentAlertDelete (i: number) { const alert = await this.alertCtrl.create({ header: 'Caution', message: `Are you sure you want to delete this key?`, @@ -83,7 +83,7 @@ export class SSHKeysPage { { text: 'Delete', handler: () => { - this.delete(hash) + this.delete(i) }, cssClass: 'enter-click', }, @@ -92,7 +92,7 @@ export class SSHKeysPage { await alert.present() } - async delete (hash: string): Promise { + async delete (i: number): Promise { const loader = await this.loadingCtrl.create({ spinner: 'lines', message: 'Deleting...', @@ -101,18 +101,15 @@ export class SSHKeysPage { await loader.present() try { - await this.embassyApi.deleteSshKey({ hash }) - delete this.sshKeys[hash] + const entry = this.sshKeys[i] + await this.embassyApi.deleteSshKey({ hash: entry.hash }) + delete this.sshKeys[i] } catch (e) { this.errToast.present(e) } finally { loader.dismiss() } } - - asIsOrder (a: any, b: any) { - return 0 - } } const sshSpec = { diff --git a/ui/src/app/services/api/api.fixures.ts b/ui/src/app/services/api/api.fixures.ts index 44a00c2a1..e343eb59f 100644 --- a/ui/src/app/services/api/api.fixures.ts +++ b/ui/src/app/services/api/api.fixures.ts @@ -832,28 +832,26 @@ export module Mock { }, } - export const SshKeys: RR.GetSSHKeysRes = { - '28:d2:7e:78:61:b4:bf:g2:de:24:15:96:4e:d4:15:53': { + export const SshKeys: RR.GetSSHKeysRes = [ + { 'created-at': new Date().toISOString(), alg: 'ed25519', hostname: 'Matt Key', - hash: 'VeryLongHashOfSSHKey1', + hash: '28:d2:7e:78:61:b4:bf:g2:de:24:15:96:4e:d4:15:53', }, - '12:f8:7e:78:61:b4:bf:e2:de:24:15:96:4e:d4:72:53': { + { 'created-at': new Date().toISOString(), alg: 'ed25519', hostname: 'Aiden Key', - hash: 'VeryLongHashOfSSHKey2', + hash: '12:f8:7e:78:61:b4:bf:e2:de:24:15:96:4e:d4:72:53', }, - } + ] export const SshKey: RR.AddSSHKeyRes = { - '44:44:7e:78:61:b4:bf:g2:de:24:15:96:4e:d4:15:53': { - 'created-at': new Date().toISOString(), - alg: 'ed25519', - hostname: 'Lucy Key', - hash: 'VeryLongHashOfSSHKey3', - }, + 'created-at': new Date().toISOString(), + alg: 'ed25519', + hostname: 'Lucy Key', + hash: '44:44:7e:78:61:b4:bf:g2:de:24:15:96:4e:d4:15:53', } export const Wifi: RR.GetWifiRes = { diff --git a/ui/src/app/services/api/api.types.ts b/ui/src/app/services/api/api.types.ts index bdfcff1cd..20d1e9fca 100644 --- a/ui/src/app/services/api/api.types.ts +++ b/ui/src/app/services/api/api.types.ts @@ -108,10 +108,10 @@ export module RR { // ssh export type GetSSHKeysReq = { } // ssh.list - export type GetSSHKeysRes = SSHKeys + export type GetSSHKeysRes = SSHKey[] export type AddSSHKeyReq = { key: string } // ssh.add - export type AddSSHKeyRes = SSHKeys + export type AddSSHKeyRes = SSHKey export type DeleteSSHKeyReq = { hash: string } // ssh.delete export type DeleteSSHKeyRes = null @@ -312,11 +312,7 @@ export interface ServerSpecs { [key: string]: string | number } -export interface SSHKeys { - [hash: string]: SSHKeyEntry -} - -export interface SSHKeyEntry { +export interface SSHKey { 'created-at': string alg: string hostname: string