mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
remove not needed subs
This commit is contained in:
committed by
Aiden McClelland
parent
fbe1b26a55
commit
c680a3b830
@@ -8,17 +8,10 @@ import { PatchDbModel } from '../services/patch-db/patch-db.service'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class MaintenanceGuard implements CanActivate, CanActivateChild {
|
||||
serverStatus: ServerStatus
|
||||
|
||||
constructor (
|
||||
private readonly router: Router,
|
||||
private readonly patch: PatchDbModel,
|
||||
) {
|
||||
this.patch.watch$('server-info', 'status')
|
||||
.pipe(
|
||||
tap(status => this.serverStatus = status),
|
||||
).subscribe()
|
||||
}
|
||||
) { }
|
||||
|
||||
canActivate (): boolean {
|
||||
return this.runServerStatusCheck()
|
||||
@@ -29,7 +22,7 @@ export class MaintenanceGuard implements CanActivate, CanActivateChild {
|
||||
}
|
||||
|
||||
private runServerStatusCheck (): boolean {
|
||||
if ([ServerStatus.Updating, ServerStatus.BackingUp].includes(this.serverStatus)) {
|
||||
if ([ServerStatus.Updating, ServerStatus.BackingUp].includes(this.patch.data['server-info']?.status)) {
|
||||
this.router.navigate(['/maintenance'], { replaceUrl: true })
|
||||
return false
|
||||
} else {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</ion-header>
|
||||
|
||||
<ion-content class="ion-padding-top">
|
||||
<ng-container *ngIf="installed">
|
||||
<ng-container *ngIf="patch.data['server-info'][pkgId]?.installed as installed">
|
||||
<ion-item-group>
|
||||
<ion-item button *ngFor="let action of installed.manifest.actions | keyvalue: asIsOrder" (click)="handleAction(installed, action)" >
|
||||
<ion-label class="ion-text-wrap">
|
||||
|
||||
@@ -16,11 +16,11 @@ import { Subscription } from 'rxjs'
|
||||
styleUrls: ['./app-actions.page.scss'],
|
||||
})
|
||||
export class AppActionsPage {
|
||||
installed: InstalledPackageDataEntry
|
||||
|
||||
subs: Subscription[] = []
|
||||
@ViewChild(IonContent) content: IonContent
|
||||
|
||||
pkgId: string
|
||||
|
||||
constructor (
|
||||
private readonly route: ActivatedRoute,
|
||||
private readonly apiService: ApiService,
|
||||
@@ -29,18 +29,11 @@ export class AppActionsPage {
|
||||
private readonly loaderService: LoaderService,
|
||||
private readonly wizardBaker: WizardBaker,
|
||||
private readonly navCtrl: NavController,
|
||||
private readonly patch: PatchDbModel,
|
||||
public readonly patch: PatchDbModel,
|
||||
) { }
|
||||
|
||||
ngOnInit () {
|
||||
const pkgId = this.route.snapshot.paramMap.get('pkgId')
|
||||
|
||||
this.subs = [
|
||||
this.patch.watch$('package-data', pkgId, 'installed')
|
||||
.subscribe(installed => {
|
||||
this.installed = installed
|
||||
}),
|
||||
]
|
||||
this.pkgId = this.route.snapshot.paramMap.get('pkgId')
|
||||
}
|
||||
|
||||
ngAfterViewInit () {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</ion-header>
|
||||
|
||||
<ion-content>
|
||||
<ion-grid *ngIf="pkg">
|
||||
<ion-grid *ngIf="patch.data['package-data'][pkgId] as pkg">
|
||||
<ion-row>
|
||||
<ion-col *ngFor="let interface of pkg.installed.manifest.interfaces | keyvalue: asIsOrder" sizeSm="12" sizeMd="6">
|
||||
<ion-card>
|
||||
|
||||
@@ -16,30 +16,23 @@ export class AppInterfacesPage {
|
||||
pkg: PackageDataEntry
|
||||
|
||||
@ViewChild(IonContent) content: IonContent
|
||||
subs: Subscription[] = []
|
||||
pkgId: string
|
||||
|
||||
constructor (
|
||||
private readonly route: ActivatedRoute,
|
||||
private readonly toastCtrl: ToastController,
|
||||
private readonly config: ConfigService,
|
||||
private readonly patch: PatchDbModel,
|
||||
public readonly patch: PatchDbModel,
|
||||
) { }
|
||||
|
||||
ngOnInit () {
|
||||
const pkgId = this.route.snapshot.paramMap.get('pkgId')
|
||||
this.subs = [
|
||||
this.patch.watch$('package-data', pkgId).subscribe(pkg => this.pkg = pkg),
|
||||
]
|
||||
this.pkgId = this.route.snapshot.paramMap.get('pkgId')
|
||||
}
|
||||
|
||||
ngAfterViewInit () {
|
||||
this.content.scrollToPoint(undefined, 1)
|
||||
}
|
||||
|
||||
ngOnDestroy () {
|
||||
this.subs.forEach(sub => sub.unsubscribe())
|
||||
}
|
||||
|
||||
async copy (address: string): Promise<void> {
|
||||
let message = ''
|
||||
await copyToClipboard(address || '')
|
||||
|
||||
@@ -8,43 +8,44 @@
|
||||
</ion-header>
|
||||
|
||||
<ion-content style="position: relative">
|
||||
|
||||
<div *ngIf="pkgs | empty; else list" class="ion-text-center ion-padding">
|
||||
<div style="display: flex; flex-direction: column; justify-content: center; height: 40vh">
|
||||
<h2>Welcome to your <span style="font-style: italic; color: var(--ion-color-danger)">Embassy</span></h2>
|
||||
<p class="ion-text-wrap">Get started by installing your first service.</p>
|
||||
<div *ngIf="patch.data['package-data'] as pkgs">
|
||||
<div *ngIf="pkgs | empty; else list" class="ion-text-center ion-padding">
|
||||
<div style="display: flex; flex-direction: column; justify-content: center; height: 40vh">
|
||||
<h2>Welcome to your <span style="font-style: italic; color: var(--ion-color-danger)">Embassy</span></h2>
|
||||
<p class="ion-text-wrap">Get started by installing your first service.</p>
|
||||
</div>
|
||||
<ion-button [routerLink]="['/marketplace']" style="width: 50%;" fill="outline">
|
||||
<ion-icon slot="start" name="storefront-outline"></ion-icon>
|
||||
Marketplace
|
||||
</ion-button>
|
||||
</div>
|
||||
<ion-button [routerLink]="['/marketplace']" style="width: 50%;" fill="outline">
|
||||
<ion-icon slot="start" name="storefront-outline"></ion-icon>
|
||||
Marketplace
|
||||
</ion-button>
|
||||
</div>
|
||||
|
||||
<ng-template #list>
|
||||
<ion-grid>
|
||||
<ion-row>
|
||||
<ion-col *ngFor="let pkg of pkgs | keyvalue : asIsOrder" sizeXs="4" sizeSm="3" sizeLg="3" sizeXl="2">
|
||||
<ion-card class="installed-card" [routerLink]="['/services', (pkg.value | manifest).id]">
|
||||
<div class="launch-container" *ngIf="pkg.value | hasUi">
|
||||
<div class="launch-button-triangle" (click)="launchUi(pkg.value, $event)" [class.launch-disabled]="!(pkg.value | isLaunchable)">
|
||||
<ion-icon name="rocket-outline"></ion-icon>
|
||||
<ng-template #list>
|
||||
<ion-grid>
|
||||
<ion-row>
|
||||
<ion-col *ngFor="let pkg of pkgs | keyvalue : asIsOrder" sizeXs="4" sizeSm="3" sizeLg="3" sizeXl="2">
|
||||
<ion-card class="installed-card" [routerLink]="['/services', (pkg.value | manifest).id]">
|
||||
<div class="launch-container" *ngIf="pkg.value | hasUi">
|
||||
<div class="launch-button-triangle" (click)="launchUi(pkg.value, $event)" [class.launch-disabled]="!(pkg.value | isLaunchable)">
|
||||
<ion-icon name="rocket-outline"></ion-icon>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<img style="position: absolute" class="main-img" [src]="pkg.value['static-files'].icon" alt="icon" />
|
||||
<img class="main-img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=">
|
||||
<img class="bulb-on" *ngIf="(pkg.key | displayBulb : 'green' : connected) | async" src="assets/img/running-bulb.png"/>
|
||||
<img class="bulb-on" *ngIf="(pkg.key | displayBulb : 'red' : connected) | async" src="assets/img/issue-bulb.png"/>
|
||||
<img class="bulb-on" *ngIf="(pkg.key | displayBulb : 'yellow' : connected) | async" src="assets/img/warning-bulb.png"/>
|
||||
<img class="bulb-off" *ngIf="(pkg.key | displayBulb : 'off' : connected) | async" src="assets/img/off-bulb.png"/>
|
||||
|
||||
<img style="position: absolute" class="main-img" [src]="pkg.value['static-files'].icon" alt="icon" />
|
||||
<img class="main-img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=">
|
||||
<img class="bulb-on" *ngIf="(pkg.key | displayBulb : 'green' : connected) | async" src="assets/img/running-bulb.png"/>
|
||||
<img class="bulb-on" *ngIf="(pkg.key | displayBulb : 'red' : connected) | async" src="assets/img/issue-bulb.png"/>
|
||||
<img class="bulb-on" *ngIf="(pkg.key | displayBulb : 'yellow' : connected) | async" src="assets/img/warning-bulb.png"/>
|
||||
<img class="bulb-off" *ngIf="(pkg.key | displayBulb : 'off' : connected) | async" src="assets/img/off-bulb.png"/>
|
||||
|
||||
<ion-card-header>
|
||||
<status *ngIf="connected" [pkgId]="pkg.key" size="calc(8px + .4vw)" weight="bold"></status>
|
||||
<ion-card-title>{{ (pkg.value | manifest).title }}</ion-card-title>
|
||||
</ion-card-header>
|
||||
</ion-card>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
</ng-template>
|
||||
<ion-card-header>
|
||||
<status *ngIf="connected" [pkgId]="pkg.key" size="calc(8px + .4vw)" weight="bold"></status>
|
||||
<ion-card-title>{{ (pkg.value | manifest).title }}</ion-card-title>
|
||||
</ion-card-header>
|
||||
</ion-card>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
</ng-template>
|
||||
</div>
|
||||
</ion-content>
|
||||
|
||||
@@ -11,7 +11,6 @@ import { Subscription } from 'rxjs'
|
||||
styleUrls: ['./app-list.page.scss'],
|
||||
})
|
||||
export class AppListPage {
|
||||
pkgs: { [id: string]: PackageDataEntry } = { }
|
||||
connected: boolean
|
||||
subs: Subscription[] = []
|
||||
|
||||
@@ -23,9 +22,6 @@ export class AppListPage {
|
||||
|
||||
ngOnInit () {
|
||||
this.subs = [
|
||||
this.patch.watch$('package-data').subscribe(pkgs => {
|
||||
this.pkgs = pkgs
|
||||
}),
|
||||
this.patch.connected$().subscribe(c => this.connected = c),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Component, ViewChild } from '@angular/core'
|
||||
import { IonContent, LoadingController, ModalController } from '@ionic/angular'
|
||||
import { ApiService } from 'src/app/services/api/api.service'
|
||||
import { BackupConfirmationComponent } from 'src/app/modals/backup-confirmation/backup-confirmation.component'
|
||||
import { DiskInfo, PartitionInfoEntry } from 'src/app/services/api/api-types'
|
||||
import { DiskInfo } from 'src/app/services/api/api-types'
|
||||
import { ActivatedRoute } from '@angular/router'
|
||||
import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service'
|
||||
import { Subscription } from 'rxjs'
|
||||
@@ -33,13 +33,7 @@ export class AppRestorePage {
|
||||
|
||||
ngOnInit () {
|
||||
this.pkgId = this.route.snapshot.paramMap.get('pkgId')
|
||||
|
||||
this.subs = [
|
||||
this.patch.watch$('package-data', this.pkgId, 'installed', 'manifest', 'title')
|
||||
.subscribe(title => {
|
||||
this.title = title
|
||||
}),
|
||||
]
|
||||
this.title = this.patch.data['package-data'][this.pkgId].installed.manifest.title
|
||||
|
||||
this.getExternalDisks()
|
||||
}
|
||||
@@ -48,10 +42,6 @@ export class AppRestorePage {
|
||||
this.content.scrollToPoint(undefined, 1)
|
||||
}
|
||||
|
||||
ngOnDestroy () {
|
||||
this.subs.forEach(sub => sub.unsubscribe())
|
||||
}
|
||||
|
||||
async refresh () {
|
||||
this.loading = true
|
||||
await this.getExternalDisks()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<ion-content *ngrxLet="patch.watch$('server-info', 'status') as status">
|
||||
<ion-content *ngIf="patch.data['serverInfo'].status as status">
|
||||
|
||||
<ion-grid style="height: 100%;">
|
||||
<ion-row class="ion-align-items-center ion-text-center" style="height: 100%;">
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<ion-label>
|
||||
<h2 style="font-family: 'Montserrat';">{{ pkg.title }}</h2>
|
||||
<p>{{ pkg.descriptionShort }}</p>
|
||||
<ng-container *ngIf="installedPkgs[pkg.id] as pkgI">
|
||||
<ng-container *ngIf="patch.data['package-data'] as pkgI">
|
||||
<p *ngIf="pkgI.state === PackageState.Installed">
|
||||
<ion-text *ngIf="(pkg.version | compareEmver : pkgI.installed.manifest.version) === 0" color="success">Installed</ion-text>
|
||||
<ion-text *ngIf="(pkg.version | compareEmver : pkgI.installed.manifest.version) === 1" color="warning">Update Available</ion-text>
|
||||
@@ -81,45 +81,6 @@
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
|
||||
<!-- <ion-card *ngFor="let pkg of pkgs" style="margin: 10px 10px;" [routerLink]="['/marketplace', pkg.id]">
|
||||
<ion-item style="--inner-border-width: 0 0 .4px 0; --border-color: #525252;">
|
||||
<ion-avatar style="margin-top: 8px;" slot="start">
|
||||
<img [src]="pkg.icon" />
|
||||
</ion-avatar>
|
||||
<ion-label style="margin-top: 6px; margin-bottom: 3px">
|
||||
<h1 style="font-family: 'Montserrat'; font-size: 20px; margin-bottom: 0px;">
|
||||
{{ pkg.title }}
|
||||
</h1>
|
||||
<p>{{ pkg.version }}</p>
|
||||
<div class="beneath-title" *ngIf="installedPkgs[pkg.id] as pkgI">
|
||||
<ng-container *ngIf="pkgI.state === PackageState.Installed">
|
||||
<ion-text *ngIf="(pkg.version | compareEmver : pkgI.installed.manifest.version) === 0" style="font-size: 12px;" color="success">Installed</ion-text>
|
||||
<ion-text *ngIf="(pkg.version | compareEmver : pkgI.installed.manifest.version) === 1" style="font-size: 12px;" color="warning">Update Available</ion-text>
|
||||
</ng-container>
|
||||
<div class="beneath-title" *ngIf="pkgI.state === PackageState.Installing" style="display: flex; flex-direction: row; align-items: center;">
|
||||
<ion-text style="font-size: 12px;" color="primary">Installing</ion-text>
|
||||
<ion-spinner name="crescent" style="height: 10px; width: 15px; margin-left: 3px; margin-right: -4px;" color="primary"></ion-spinner>
|
||||
</div>
|
||||
<div class="beneath-title" *ngIf="pkgI.state === PackageState.Updating" style="display: flex; flex-direction: row; align-items: center;">
|
||||
<ion-text style="font-size: 12px;" color="primary">Updating</ion-text>
|
||||
<ion-spinner name="crescent" style="height: 10px; width: 15px; margin-left: 3px; margin-right: -4px;" color="primary"></ion-spinner>
|
||||
</div>
|
||||
<div class="beneath-title" *ngIf="pkgI.state === PackageState.Removing" style="display: flex; flex-direction: row; align-items: center;">
|
||||
<ion-text style="font-size: 12px;" color="danger">Removing</ion-text>
|
||||
<ion-spinner name="crescent" style="height: 10px; width: 15px; margin-left: 3px; margin-right: -4px;" color="danger"></ion-spinner>
|
||||
</div>
|
||||
</div>
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
<ion-card-content style="
|
||||
font-size: small !important;
|
||||
padding-bottom: 10px;
|
||||
padding-top: 6px;
|
||||
">
|
||||
{{ pkg.descriptionShort }}
|
||||
</ion-card-content>
|
||||
</ion-card> -->
|
||||
</ng-template>
|
||||
</ng-template>
|
||||
</ion-content>
|
||||
|
||||
@@ -25,7 +25,6 @@ export class MarketplaceListPage {
|
||||
data: MarketplaceData
|
||||
eos: MarketplaceEOS
|
||||
pkgs: AvailablePreview[] = []
|
||||
installedPkgs: { [id: string]: PackageDataEntry } = { }
|
||||
|
||||
PackageState = PackageState
|
||||
|
||||
@@ -43,10 +42,6 @@ export class MarketplaceListPage {
|
||||
) { }
|
||||
|
||||
async ngOnInit () {
|
||||
this.subs = [
|
||||
this.patch.watch$('package-data')
|
||||
.subscribe(pkgs => this.installedPkgs = pkgs),
|
||||
]
|
||||
|
||||
try {
|
||||
const [data, eos, pkgs] = await Promise.all([
|
||||
|
||||
@@ -46,7 +46,6 @@ export class MarketplaceShowPage {
|
||||
this.subs = [
|
||||
this.patch.watch$('package-data', this.pkgId)
|
||||
.subscribe(pkg => {
|
||||
console.log(pkg)
|
||||
this.installedPkg = pkg
|
||||
}),
|
||||
]
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content class="ion-padding-top">
|
||||
<ion-content class="ion-padding-top" *ngIf="patch.data['server-info] as server">
|
||||
|
||||
<ion-item-group>
|
||||
<ion-item detail="true" button [routerLink]="['ssh-keys']">
|
||||
|
||||
@@ -10,27 +10,13 @@ import { Subscription } from 'rxjs'
|
||||
styleUrls: ['./dev-options.page.scss'],
|
||||
})
|
||||
export class DevOptionsPage {
|
||||
server: ServerInfo = { } as any
|
||||
subs: Subscription[] = []
|
||||
|
||||
constructor (
|
||||
private readonly serverConfigService: ServerConfigService,
|
||||
private readonly patch: PatchDbModel,
|
||||
public readonly patch: PatchDbModel,
|
||||
) { }
|
||||
|
||||
ngOnInit () {
|
||||
this.subs = [
|
||||
this.patch.watch$('server-info')
|
||||
.subscribe(server => {
|
||||
this.server = server
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
ngOnDestroy () {
|
||||
this.subs.forEach(sub => sub.unsubscribe())
|
||||
}
|
||||
|
||||
async presentModalValueEdit (key: string, current?: any): Promise<void> {
|
||||
await this.serverConfigService.presentModalValueEdit(key, current)
|
||||
}
|
||||
|
||||
@@ -10,14 +10,10 @@
|
||||
<ion-content class="ion-padding-top">
|
||||
|
||||
<ion-item-group>
|
||||
<ion-item button (click)="presentModalValueEdit('autoCheckUpdates', ui['auto-check-updates'])">
|
||||
<ion-item button (click)="presentModalValueEdit('autoCheckUpdates', patch.data.ui['auto-check-updates'])">
|
||||
<ion-label>Auto Check for Updates</ion-label>
|
||||
<ion-note slot="end">{{ ui['auto-check-updates'] }}</ion-note>
|
||||
<ion-note slot="end">{{ patch.data.ui['auto-check-updates'] }}</ion-note>
|
||||
</ion-item>
|
||||
<!-- <ion-item style="word-break: break-all;" button (click)="presentModalValueEdit('password', ui.password)">
|
||||
<ion-label>Change Password</ion-label>
|
||||
<ion-note slot="end">********</ion-note>
|
||||
</ion-item> -->
|
||||
</ion-item-group>
|
||||
|
||||
</ion-content>
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Component } from '@angular/core'
|
||||
import { ServerConfigService } from 'src/app/services/server-config.service'
|
||||
import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { UIData } from 'src/app/services/patch-db/data-model'
|
||||
|
||||
@Component({
|
||||
selector: 'preferences',
|
||||
@@ -11,26 +10,12 @@ import { UIData } from 'src/app/services/patch-db/data-model'
|
||||
})
|
||||
export class PreferencesPage {
|
||||
subs: Subscription[] = []
|
||||
ui: UIData = { } as any
|
||||
|
||||
constructor (
|
||||
private readonly serverConfigService: ServerConfigService,
|
||||
private readonly patch: PatchDbModel,
|
||||
public readonly patch: PatchDbModel,
|
||||
) { }
|
||||
|
||||
ngOnInit () {
|
||||
this.subs = [
|
||||
this.patch.watch$('ui')
|
||||
.subscribe(ui => {
|
||||
this.ui = ui
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
ngOnDestroy () {
|
||||
this.subs.forEach(sub => sub.unsubscribe())
|
||||
}
|
||||
|
||||
async presentModalValueEdit (key: string, current?: string): Promise<void> {
|
||||
await this.serverConfigService.presentModalValueEdit(key, current)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<ion-item-divider>Basic</ion-item-divider>
|
||||
|
||||
<ion-item-group *ngIf="server">
|
||||
<ion-item-group *ngIf="patch.data['server-info'] as server">
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
<h2>Version</h2>
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Component } from '@angular/core'
|
||||
import { ToastController } from '@ionic/angular'
|
||||
import { copyToClipboard } from 'src/app/util/web.util'
|
||||
import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service'
|
||||
import { ServerInfo } from 'src/app/services/patch-db/data-model'
|
||||
import { Subscription } from 'rxjs'
|
||||
|
||||
@Component({
|
||||
@@ -11,27 +10,13 @@ import { Subscription } from 'rxjs'
|
||||
styleUrls: ['./server-specs.page.scss'],
|
||||
})
|
||||
export class ServerSpecsPage {
|
||||
server: ServerInfo
|
||||
subs: Subscription[] = []
|
||||
|
||||
constructor (
|
||||
private readonly toastCtrl: ToastController,
|
||||
private readonly patch: PatchDbModel,
|
||||
public readonly patch: PatchDbModel,
|
||||
) { }
|
||||
|
||||
ngOnInit () {
|
||||
this.subs = [
|
||||
this.patch.watch$('server-info')
|
||||
.subscribe(server => {
|
||||
this.server = server
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
ngOnDestroy () {
|
||||
this.subs.forEach(sub => sub.unsubscribe())
|
||||
}
|
||||
|
||||
async copy (address: string) {
|
||||
let message = ''
|
||||
await copyToClipboard(address || '')
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</ion-item>
|
||||
|
||||
<ion-item-divider>Saved Networks</ion-item-divider>
|
||||
<ng-container *ngIf="wifi">
|
||||
<ng-container *ngIf="patch.data['server-info']?.wifi as wifi">
|
||||
<ion-item button detail="false" *ngFor="let ssid of wifi.ssids" (click)="presentAction(ssid, wifi)">
|
||||
<ion-label>{{ ssid }}</ion-label>
|
||||
<ion-note slot="end" *ngIf="ssid === wifi.connected"><ion-text color="success">Connected</ion-text></ion-note>
|
||||
|
||||
@@ -15,7 +15,6 @@ import { Subscription } from 'rxjs'
|
||||
})
|
||||
export class WifiListPage {
|
||||
error = ''
|
||||
wifi: WiFiInfo
|
||||
subs: Subscription[] = []
|
||||
|
||||
constructor (
|
||||
@@ -23,22 +22,9 @@ export class WifiListPage {
|
||||
private readonly loader: LoaderService,
|
||||
private readonly actionCtrl: ActionSheetController,
|
||||
private readonly wifiService: WifiService,
|
||||
private readonly patch: PatchDbModel,
|
||||
public readonly patch: PatchDbModel,
|
||||
) { }
|
||||
|
||||
ngOnInit () {
|
||||
this.subs = [
|
||||
this.patch.watch$('server-info', 'wifi')
|
||||
.subscribe(wifi => {
|
||||
this.wifi = wifi
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
ngOnDestroy () {
|
||||
this.subs.forEach(sub => sub.unsubscribe())
|
||||
}
|
||||
|
||||
async presentAction (ssid: string, wifi: WiFiInfo) {
|
||||
const buttons: ActionSheetButton[] = [
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { BehaviorSubject, combineLatest, fromEvent, merge, Subscription } from 'rxjs'
|
||||
import { DataModel } from './patch-db/data-model'
|
||||
import { ConnectionStatus, PatchDbModel } from './patch-db/patch-db.service'
|
||||
import { HttpService, Method } from './http.service'
|
||||
import { distinctUntilChanged } from 'rxjs/operators'
|
||||
@@ -9,7 +8,6 @@ import { distinctUntilChanged } from 'rxjs/operators'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ConnectionService {
|
||||
private addrs: DataModel['server-info']['connection-addresses']
|
||||
private readonly networkState$ = new BehaviorSubject<boolean>(true)
|
||||
private readonly connectionFailure$ = new BehaviorSubject<ConnectionFailure>(ConnectionFailure.None)
|
||||
private subs: Subscription[] = []
|
||||
@@ -25,15 +23,6 @@ export class ConnectionService {
|
||||
|
||||
start () {
|
||||
this.subs = [
|
||||
this.patch.watch$('server-info')
|
||||
.subscribe(data => {
|
||||
if (!data) return
|
||||
this.addrs = data['connection-addresses'] || {
|
||||
tor: [],
|
||||
clearnet: [],
|
||||
}
|
||||
}),
|
||||
|
||||
merge(fromEvent(window, 'online'), fromEvent(window, 'offline'))
|
||||
.subscribe(event => {
|
||||
this.networkState$.next(event.type === 'online')
|
||||
@@ -42,6 +31,7 @@ export class ConnectionService {
|
||||
combineLatest([this.networkState$.pipe(distinctUntilChanged()), this.patch.watchConnection$().pipe(distinctUntilChanged())])
|
||||
.subscribe(async ([network, connectionStatus]) => {
|
||||
console.log('CONNECTION STATUS', connectionStatus)
|
||||
const addrs = this.patch.data['server-info']?.['connection-addresses']
|
||||
if (connectionStatus !== ConnectionStatus.Disconnected) {
|
||||
this.connectionFailure$.next(ConnectionFailure.None)
|
||||
} else if (!network) {
|
||||
@@ -49,12 +39,12 @@ export class ConnectionService {
|
||||
} else {
|
||||
console.log('diagnosing')
|
||||
this.connectionFailure$.next(ConnectionFailure.Diagnosing)
|
||||
const torSuccess = await this.testAddrs(this.addrs.tor)
|
||||
const torSuccess = await this.testAddrs(addrs?.tor || [])
|
||||
if (torSuccess) {
|
||||
console.log('TOR SUCCESS, EMBASSY IS PROBLEM')
|
||||
this.connectionFailure$.next(ConnectionFailure.Embassy)
|
||||
} else {
|
||||
const clearnetSuccess = await this.testAddrs(this.addrs.clearnet)
|
||||
const clearnetSuccess = await this.testAddrs(addrs?.clearnet || [])
|
||||
if (clearnetSuccess) {
|
||||
console.log('CLEARNET SUCCESS, TOR IS PROBLEM')
|
||||
this.connectionFailure$.next(ConnectionFailure.Tor)
|
||||
|
||||
@@ -33,6 +33,7 @@ export class PatchDbModel {
|
||||
|
||||
async init (): Promise<void> {
|
||||
const cache = await this.bootstrapper.init()
|
||||
console.log('CACHECACHE', cache)
|
||||
this.patchDb = new PatchDB([this.source, this.http], this.http, cache)
|
||||
|
||||
this.sequence$ = this.patchDb.store.sequence$.asObservable()
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
},
|
||||
"mocks": {
|
||||
"enabled": true,
|
||||
"connection": "ws",
|
||||
"connection": "poll",
|
||||
"rpcPort": "5959",
|
||||
"wsPort": "5960",
|
||||
"maskAs": "tor",
|
||||
|
||||
Reference in New Issue
Block a user