suggest ssh key

This commit is contained in:
Drew Ansbacher
2022-01-13 15:01:50 -07:00
committed by Aiden McClelland
parent f29608576d
commit 20d7f7b236
9 changed files with 31 additions and 9 deletions

View File

@@ -65,8 +65,6 @@ export class PreferencesPage {
try {
await this.api.setDbValue({ pointer: `/${key}`, value })
} catch (e) {
throw new Error(e)
} finally {
loader.dismiss()
}

View File

@@ -91,7 +91,7 @@ export class ServerBackupPage {
await this.createBackup(target.id, password)
} catch (e) {
if (oldPassword) {
throw new Error(e)
throw e
} else {
setTimeout(() => this.presentModalOldPassword(target, password), 500)
}
@@ -133,8 +133,6 @@ export class ServerBackupPage {
'old-password': oldPassword || null,
password,
})
} catch (e) {
throw new Error(e)
} finally {
loader.dismiss()
}

View File

@@ -39,6 +39,7 @@
</ng-container>
</p>
</ion-label>
<ion-icon *ngIf="button.warning | async" slot="end" name="warning" color="warning" style="padding-right: 8px;"></ion-icon>
</ion-item>
</div>
</ion-item-group>

View File

@@ -112,6 +112,7 @@ export class ServerShowPage {
action: () => this.navCtrl.navigateForward(['backup'], { relativeTo: this.route }),
detail: true,
disabled: of(false),
warning: of(false),
},
{
title: 'Restore From Backup',
@@ -120,6 +121,7 @@ export class ServerShowPage {
action: () => this.navCtrl.navigateForward(['restore'], { relativeTo: this.route }),
detail: true,
disabled: this.patch.watch$('server-info', 'status').pipe(map(status => [ServerStatus.Updated, ServerStatus.BackingUp].includes(status))),
warning: of(false),
},
],
'Insights': [
@@ -130,6 +132,7 @@ export class ServerShowPage {
action: () => this.navCtrl.navigateForward(['specs'], { relativeTo: this.route }),
detail: true,
disabled: of(false),
warning: of(false),
},
{
title: 'Monitor',
@@ -138,6 +141,7 @@ export class ServerShowPage {
action: () => this.navCtrl.navigateForward(['metrics'], { relativeTo: this.route }),
detail: true,
disabled: of(false),
warning: of(false),
},
{
title: 'Logs',
@@ -146,6 +150,7 @@ export class ServerShowPage {
action: () => this.navCtrl.navigateForward(['logs'], { relativeTo: this.route }),
detail: true,
disabled: of(false),
warning: of(false),
},
],
'Settings': [
@@ -156,6 +161,7 @@ export class ServerShowPage {
action: () => this.navCtrl.navigateForward(['preferences'], { relativeTo: this.route }),
detail: true,
disabled: of(false),
warning: of(false),
},
{
title: 'LAN',
@@ -164,6 +170,7 @@ export class ServerShowPage {
action: () => this.navCtrl.navigateForward(['lan'], { relativeTo: this.route }),
detail: true,
disabled: of(false),
warning: of(false),
},
{
title: 'SSH',
@@ -172,6 +179,8 @@ export class ServerShowPage {
action: () => this.navCtrl.navigateForward(['ssh'], { relativeTo: this.route }),
detail: true,
disabled: of(false),
warning: this.patch.watch$('ui', 'has-ssh-key').pipe(map(hasSSHKey => !hasSSHKey)),
},
{
title: 'WiFi',
@@ -180,6 +189,7 @@ export class ServerShowPage {
action: () => this.navCtrl.navigateForward(['wifi'], { relativeTo: this.route }),
detail: true,
disabled: of(false),
warning: of(false),
},
{
title: 'Active Sessions',
@@ -188,6 +198,7 @@ export class ServerShowPage {
action: () => this.navCtrl.navigateForward(['sessions'], { relativeTo: this.route }),
detail: true,
disabled: of(false),
warning: of(false),
},
],
'Power': [
@@ -198,6 +209,7 @@ export class ServerShowPage {
action: () => this.presentAlertRestart(),
detail: false,
disabled: of(false),
warning: of(false),
},
{
title: 'Shutdown',
@@ -206,6 +218,7 @@ export class ServerShowPage {
action: () => this.presentAlertShutdown(),
detail: false,
disabled: of(false),
warning: of(false),
},
],
}
@@ -223,5 +236,6 @@ interface ServerSettings {
action: Function
detail: boolean
disabled: Observable<boolean>
warning: Observable<boolean>
}[]
}

View File

@@ -13,7 +13,14 @@
<!-- always -->
<ion-item>
<ion-label>
<h2>
<ion-item *ngIf="!patch.data.ui['has-ssh-key']">
<ion-icon slot="start" color="warning" name="warning-outline" size="large"></ion-icon>
<h2>
We highly recommend adding an SSH key to your Embassy. It can be useful for debugging should anything go wrong. We <b>do not</b> recommend using your SSH key <b>unless</b> (1) you have advanced technical knowledge of the command line or (2) are following the guidance of a Start 9 support representitive.
<a [href]="docsUrl" target="_blank" rel="noreferrer">View instructions</a>
</h2>
</ion-item>
<h2 *ngIf="patch.data.ui['has-ssh-key']">
Adding SSH keys to your Embassy is useful for command line access, as well as for debugging purposes.
<a [href]="docsUrl" target="_blank" rel="noreferrer">View instructions</a>
</h2>

View File

@@ -4,6 +4,7 @@ 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, GenericInputOptions } from 'src/app/modals/generic-input/generic-input.component'
import { PatchDbService } from 'src/app/services/patch-db/patch-db.service'
@Component({
selector: 'ssh-keys',
@@ -21,6 +22,7 @@ export class SSHKeysPage {
private readonly errToast: ErrorToastService,
private readonly alertCtrl: AlertController,
private readonly embassyApi: ApiService,
public readonly patch: PatchDbService,
) { }
async ngOnInit () {
@@ -66,8 +68,9 @@ export class SSHKeysPage {
try {
const key = await this.embassyApi.addSshKey({ key: pubkey })
this.sshKeys.push(key)
} catch (e) {
throw new Error(e)
if (!this.patch.getData().ui['has-ssh-key']) {
await this.embassyApi.setDbValue({ pointer: '/has-ssh-key', value: true })
}
} finally {
loader.dismiss()
}

View File

@@ -7,6 +7,7 @@ export const mockPatchData: DataModel = {
'pkg-order': [],
'ack-welcome': '1.0.0',
'ack-share-stats': false,
'has-ssh-key': false,
},
'server-info': {
'id': 'embassy-abcdefgh',

View File

@@ -32,7 +32,6 @@ export class HttpService {
if (rpcOpts.timeout) httpOpts.timeout = rpcOpts.timeout
const res = await this.httpRequest<RPCResponse<T>>(httpOpts)
if (isRpcError(res)) {
if (res.error.code === 34) this.auth.setUnverified()
throw new RpcError(res.error)

View File

@@ -13,6 +13,7 @@ export interface UIData {
'pkg-order': string[]
'ack-welcome': string // EOS version
'ack-share-stats': boolean
'has-ssh-key': boolean
}
export interface ServerInfo {