dont watch patch.data directly in TS (#371)

* dont watch patch.data directly in TS

* installs and uninstalls working

* minor repairs
This commit is contained in:
Matt Hill
2021-07-20 10:20:39 -06:00
committed by Aiden McClelland
parent 65c4db09f3
commit d1b8f51b78
50 changed files with 444 additions and 340 deletions

View File

@@ -7,7 +7,7 @@
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding-top" *ngIf="patch.data['server-info] as server">
<ion-content class="ion-padding-top" *ngIf="patch.data['server-info'] as server">
<ion-item-group>
<ion-item detail="true" button [routerLink]="['ssh-keys']">

View File

@@ -10,7 +10,7 @@ export class SSHService {
private readonly keys$ = new BehaviorSubject<SSHKeys>({ })
constructor (
private readonly apiService: ApiService,
private readonly embassyApi: ApiService,
) { }
watch$ () {
@@ -18,18 +18,18 @@ export class SSHService {
}
async getKeys (): Promise<void> {
const keys = await this.apiService.getSshKeys({ })
const keys = await this.embassyApi.getSshKeys({ })
this.keys$.next(keys)
}
async add (pubkey: string): Promise<void> {
const key = await this.apiService.addSshKey({ pubkey })
const key = await this.embassyApi.addSshKey({ pubkey })
const keys = this.keys$.getValue()
this.keys$.next({ ...keys, ...key })
}
async delete (hash: string): Promise<void> {
await this.apiService.deleteSshKey({ hash })
await this.embassyApi.deleteSshKey({ hash })
const keys = this.keys$.getValue()
const filtered = Object.keys(keys)

View File

@@ -26,7 +26,7 @@ export class LANPage {
private readonly toastCtrl: ToastController,
private readonly config: ConfigService,
private readonly loader: LoaderService,
private readonly apiService: ApiService,
private readonly embassyApi: ApiService,
private readonly patch: PatchDbService,
) { }
@@ -54,7 +54,7 @@ export class LANPage {
spinner: 'lines',
cssClass: 'loader',
}).displayDuringAsync( async () => {
await this.apiService.refreshLan({ })
await this.embassyApi.refreshLan({ })
}).catch(e => {
console.error(e)
})

View File

@@ -17,7 +17,7 @@ export class ServerBackupPage {
constructor (
private readonly modalCtrl: ModalController,
private readonly apiService: ApiService,
private readonly embassyApi: ApiService,
private readonly loadingCtrl: LoadingController,
) { }
@@ -32,7 +32,7 @@ export class ServerBackupPage {
async getExternalDisks (): Promise<void> {
try {
this.disks = await this.apiService.getDisks({ })
this.disks = await this.embassyApi.getDisks({ })
this.allPartitionsMounted = Object.values(this.disks).every(d => Object.values(d.partitions).every(p => p['is-mounted']))
} catch (e) {
console.error(e)
@@ -70,7 +70,7 @@ export class ServerBackupPage {
await loader.present()
try {
await this.apiService.createBackup({ logicalname, password })
await this.embassyApi.createBackup({ logicalname, password })
} catch (e) {
console.error(e)
this.error = e.message

View File

@@ -15,7 +15,7 @@ export class ServerLogsPage {
constructor (
private readonly errToast: ErrorToastService,
private readonly apiService: ApiService,
private readonly embassyApi: ApiService,
) { }
ngOnInit () {
@@ -26,7 +26,7 @@ export class ServerLogsPage {
this.logs = ''
this.loading = true
try {
const logs = await this.apiService.getServerLogs({ })
const logs = await this.embassyApi.getServerLogs({ })
this.logs = logs.map(l => `${l.timestamp} ${l.log}`).join('\n\n')
setTimeout(async () => await this.content.scrollToBottom(100), 200)
} catch (e) {

View File

@@ -16,7 +16,7 @@ export class ServerMetricsPage {
constructor (
private readonly errToast: ErrorToastService,
private readonly apiService: ApiService,
private readonly embassyApi: ApiService,
) { }
ngOnInit () {
@@ -41,7 +41,7 @@ export class ServerMetricsPage {
async getMetrics (): Promise<void> {
try {
this.metrics = await this.apiService.getServerMetrics({ })
this.metrics = await this.embassyApi.getServerMetrics({ })
} catch (e) {
console.error(e)
this.errToast.present(e.message)

View File

@@ -16,7 +16,7 @@ export class ServerShowPage {
constructor (
private readonly alertCtrl: AlertController,
private readonly loader: LoaderService,
private readonly apiService: ApiService,
private readonly embassyApi: ApiService,
private readonly navCtrl: NavController,
private readonly route: ActivatedRoute,
) { }
@@ -73,7 +73,7 @@ export class ServerShowPage {
this.loader
.of(LoadingSpinner(`Restarting...`))
.displayDuringAsync( async () => {
await this.apiService.restartServer({ })
await this.embassyApi.restartServer({ })
})
.catch(console.error)
}
@@ -82,7 +82,7 @@ export class ServerShowPage {
this.loader
.of(LoadingSpinner(`Shutting down...`))
.displayDuringAsync( async () => {
await this.apiService.shutdownServer({ })
await this.embassyApi.shutdownServer({ })
})
.catch(console.error)
}
@@ -91,9 +91,9 @@ export class ServerShowPage {
this.settings = {
'Settings': [
{
title: 'Preferences',
icon: 'cog-outline',
action: () => this.navCtrl.navigateForward(['preferences'], { relativeTo: this.route }),
title: 'Privacy and Security',
icon: 'shield-checkmark-outline',
action: () => this.navCtrl.navigateForward(['privacy'], { relativeTo: this.route }),
},
{
title: 'LAN',

View File

@@ -19,7 +19,7 @@ export class WifiAddPage {
constructor (
private readonly navCtrl: NavController,
private readonly errToast: ErrorToastService,
private readonly apiService: ApiService,
private readonly embassyApi: ApiService,
private readonly loader: LoaderService,
private readonly wifiService: WifiService,
) { }
@@ -30,7 +30,7 @@ export class WifiAddPage {
spinner: 'lines',
cssClass: 'loader',
}).displayDuringAsync(async () => {
await this.apiService.addWifi({
await this.embassyApi.addWifi({
ssid: this.ssid,
password: this.password,
country: this.countryCode,
@@ -50,7 +50,7 @@ export class WifiAddPage {
spinner: 'lines',
cssClass: 'loader',
}).displayDuringAsync(async () => {
await this.apiService.addWifi({
await this.embassyApi.addWifi({
ssid: this.ssid,
password: this.password,
country: this.countryCode,

View File

@@ -18,7 +18,7 @@ export class WifiListPage {
subs: Subscription[] = []
constructor (
private readonly apiService: ApiService,
private readonly embassyApi: ApiService,
private readonly loader: LoaderService,
private readonly errToast: ErrorToastService,
private readonly actionCtrl: ActionSheetController,
@@ -62,7 +62,7 @@ export class WifiListPage {
spinner: 'lines',
cssClass: 'loader',
}).displayDuringAsync(async () => {
await this.apiService.connectWifi({ ssid })
await this.embassyApi.connectWifi({ ssid })
this.wifiService.confirmWifi(ssid)
}).catch(e => {
console.error(e)
@@ -76,7 +76,7 @@ export class WifiListPage {
spinner: 'lines',
cssClass: 'loader',
}).displayDuringAsync(async () => {
await this.apiService.deleteWifi({ ssid })
await this.embassyApi.deleteWifi({ ssid })
}).catch(e => {
console.error(e)
this.errToast.present(e.message)