remove lan stuff

This commit is contained in:
Matt Hill
2021-02-26 09:16:45 -07:00
committed by Aiden McClelland
parent 68eccdb63c
commit 92c297648c
11 changed files with 55 additions and 178 deletions

View File

@@ -35,7 +35,6 @@ export interface AppAvailableVersionSpecificInfo {
export interface AppInstalledPreview extends BaseApp {
lanAddress?: string
lanEnabled?: boolean
torAddress: string
versionInstalled: string
ui: boolean

View File

@@ -22,26 +22,26 @@
<ion-grid>
<ion-row>
<ion-col *ngFor="let app of apps" sizeXs="4" sizeSm="3" sizeMd="2" sizeLg="2">
<ng-container *ngIf="{ status: app.subject.status | async, ui: app.subject.ui | async, iconURL: app.subject.iconURL | async | iconParse, title: app.subject.title | async, lanEnabled: app.subject.lanEnabled } as vars" >
<ng-container *ngIf="{ status: app.subject.status | async, ui: app.subject.ui | async, iconURL: app.subject.iconURL | async | iconParse, title: app.subject.title | async } as vars" >
<ion-card class="installed-card" [class.installed-card-on]="vars.status === 'RUNNING'" style="position:relative" [routerLink]="['/services', 'installed', app.id]">
<div class="launch-container" *ngIf="vars.ui && !isConsulate">
<div class="launch-button-triangle" (click)="launchUiTab(app.id, $event)" [class.disabled]="vars.status !== AppStatus.RUNNING || (!isTor && !vars.lanEnabled)">
<ion-icon class="launch-button-triangle-icon" name="globe-outline"></ion-icon>
<ion-card class="installed-card" [class.installed-card-on]="vars.status === 'RUNNING'" style="position:relative" [routerLink]="['/services', 'installed', app.id]">
<div class="launch-container" *ngIf="vars.ui && !isConsulate">
<div class="launch-button-triangle" (click)="launchUiTab(app.id, $event)" [class.disabled]="vars.status !== AppStatus.RUNNING">
<ion-icon class="launch-button-triangle-icon" name="globe-outline"></ion-icon>
</div>
</div>
</div>
<img style="position: absolute" class="main-img" [src]="vars.iconURL" [alt]="vars.title" />
<img class="main-img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=">
<img class="bulb-on" *ngIf="vars.status | displayBulb: 'green'" src="assets/img/running-bulb.png"/>
<img class="bulb-on" *ngIf="vars.status | displayBulb: 'red'" src="assets/img/issue-bulb.png"/>
<img class="bulb-on" *ngIf="vars.status | displayBulb: 'yellow'" src="assets/img/warning-bulb.png"/>
<img class="bulb-off" *ngIf="vars.status | displayBulb: 'off'" src="assets/img/off-bulb.png"/>
<ion-card-header>
<status [appStatus]="vars.status" size="small"></status>
<p>{{ vars.title }}</p>
</ion-card-header>
</ion-card>
<img style="position: absolute" class="main-img" [src]="vars.iconURL" [alt]="vars.title" />
<img class="main-img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=">
<img class="bulb-on" *ngIf="vars.status | displayBulb: 'green'" src="assets/img/running-bulb.png"/>
<img class="bulb-on" *ngIf="vars.status | displayBulb: 'red'" src="assets/img/issue-bulb.png"/>
<img class="bulb-on" *ngIf="vars.status | displayBulb: 'yellow'" src="assets/img/warning-bulb.png"/>
<img class="bulb-off" *ngIf="vars.status | displayBulb: 'off'" src="assets/img/off-bulb.png"/>
<ion-card-header>
<status [appStatus]="vars.status" size="small"></status>
<p>{{ vars.title }}</p>
</ion-card-header>
</ion-card>
</ng-container>
</ion-col>
</ion-row>

View File

@@ -96,8 +96,6 @@ export class AppInstalledListPage extends Cleanup {
this.error = e.message
},
})
console.log(this.isTor, this.apps[2].subject.lanEnabled.getValue())
}
async launchUiTab (id: string, event: Event) {

View File

@@ -21,10 +21,7 @@
iconURL: app.iconURL | async,
title: app.title | async,
ui: app.ui | async,
lanAddress: app.lanAddress | async,
lanEnabled: app.lanEnabled | async,
launchDisabled: (app.status | async) !== 'RUNNING' || (!isTor && !($lanConnected$ | async)),
testingLanConnection: $testingLanConnection$ | async
lanAddress: app.lanAddress | async
} as vars" class="ion-padding-bottom">
<ion-spinner *ngIf="$loading$ | async" class="center" name="lines" color="warning"></ion-spinner>
<ng-container *ngIf="!($loading$ | async)">
@@ -56,42 +53,36 @@
</ion-label>
</ion-item>
<ion-item class="no-cushion-item" lines=none style="margin-bottom: 10px">
<ion-item class="no-cushion-item" lines=none style="margin-bottom: 10px;">
<ion-label class="status-readout">
<status size="bold-large" [appStatus]="vars.status"></status>
<ion-button *ngIf="vars.status === AppStatus.NEEDS_CONFIG" expand="block" fill="outline" [routerLink]="['config']">
<ion-button *ngIf="vars.status === AppStatus.NEEDS_CONFIG" expand="block" fill="outline" [routerLink]="['config']">
Configure
</ion-button>
<ion-button *ngIf="[AppStatus.RUNNING, AppStatus.CRASHED, AppStatus.PAUSED, AppStatus.RESTARTING] | includes: vars.status" expand="block" fill="outline" (click)="stop()">
<ion-button *ngIf="[AppStatus.RUNNING, AppStatus.CRASHED, AppStatus.PAUSED, AppStatus.RESTARTING] | includes: vars.status" expand="block" fill="outline" color="danger" (click)="stop()">
Stop
</ion-button>
<ion-button *ngIf="vars.status === AppStatus.CREATING_BACKUP" expand="block" fill="outline" (click)="presentAlertStopBackup()">
<ion-button *ngIf="vars.status === AppStatus.CREATING_BACKUP" expand="block" fill="outline" (click)="presentAlertStopBackup()">
Stop Backup
</ion-button>
<ion-button *ngIf="vars.status === AppStatus.DEAD" expand="block" fill="outline" (click)="uninstall()">
<ion-button *ngIf="vars.status === AppStatus.DEAD" expand="block" fill="outline" (click)="uninstall()">
Force Uninstall
</ion-button>
<ion-button *ngIf="vars.status === AppStatus.BROKEN_DEPENDENCIES" expand="block" fill="outline" (click)="scrollToRequirements()">
<ion-button *ngIf="vars.status === AppStatus.BROKEN_DEPENDENCIES" expand="block" fill="outline" (click)="scrollToRequirements()">
Fix
</ion-button>
<ion-button *ngIf="vars.status === AppStatus.STOPPED" expand="block" fill="outline" (click)="tryStart()">
<ion-button *ngIf="vars.status === AppStatus.STOPPED" expand="block" fill="outline" color="success" (click)="tryStart()">
Start
</ion-button>
</ion-label>
</ion-item>
<ion-item class="no-cushion-item" *ngIf="vars.ui && !isConsulate" lines="none">
<ion-label style="margin-bottom: 10px; margin-top: 0px; display: flex; justify-content: left; align-items: center;" class="ion-text-wrap">
<ion-button fill="clear" size="small" class="launch-explanation-button" (click)="presentLaunchPopover(vars.status, $event)">
<ion-icon color="medium" name="information-circle-outline">
</ion-icon>
</ion-button>
<ion-button [disabled]="vars.launchDisabled" class="launch-button" [class.launch-button-off]="vars.launchDisabled" (click)="launchUiTab()">
<ion-icon style="position: absolute; z-index: 1; left: 0;" name="globe-outline"></ion-icon>
<ion-text>LAUNCH</ion-text>
</ion-button>
</ion-label>
</ion-item>
<ion-button *ngIf="vars.status === AppStatus.RUNNING && vars.ui && !isConsulate" class="launch-button" expand="block" fill="outline" (click)="launchUiTab()">
<!-- <ion-icon slot="start" name="globe-outline"></ion-icon> -->
Launch Web
<ion-icon slot="end" name="open-outline"></ion-icon>
</ion-button>
</div>
<ng-container *ngIf="app && app.id && vars.status !== 'INSTALLING'">
@@ -100,21 +91,20 @@
<ion-item>
<ion-label class="ion-text-wrap">
<h2>Tor Address</h2>
<p><a (click)="copyTor()">{{ vars.torAddress }} <ion-icon name="copy-outline" class="tiny-icon"></ion-icon></a></p>
<p>{{ vars.torAddress }}</p>
</ion-label>
<ion-button slot="end" fill="clear" (click)="copyTor()">
<ion-icon slot="icon-only" name="copy-outline" color="primary"></ion-icon>
</ion-button>
</ion-item>
<ion-item *ngIf="vars.lanAddress" lines="none">
<ion-label class="ion-text-wrap">
<h2>LAN Address</h2>
<p>
<a (click)="copyLan()">{{ vars.lanAddress }} <ion-icon name="copy-outline" class="tiny-icon"></ion-icon></a>
</p>
<p *ngIf="vars.testingLanConnection" style="display: flex; align-items: center; font-size: x-small; margin-top: 2px">
<ion-text color="warning">Testing Connection</ion-text>
<ion-spinner style="height: 15px; margin-left: 5px;" name="dots" color="warning"></ion-spinner>
</p>
<p>{{ vars.lanAddress }}</p>
</ion-label>
<ion-toggle (ionChange)="$lanToggled$.next($event)" [checked]="vars.lanEnabled" slot="end" class="lan-toggle" [disabled]="vars.status !== 'RUNNING' || vars.testingLanConnection"></ion-toggle>
<ion-button slot="end" fill="clear" (click)="copyLAN()">
<ion-icon slot="icon-only" name="copy-outline" color="primary"></ion-icon>
</ion-button>
</ion-item>
<ion-item-divider>Backups</ion-item-divider>
@@ -122,7 +112,7 @@
<ion-item button [disabled]="[AppStatus.RESTORING_BACKUP, AppStatus.CREATING_BACKUP, AppStatus.INSTALLING, AppStatus.RESTARTING, AppStatus.STOPPING] | includes: vars.status" (click)="presentModalBackup('create')">
<ion-icon slot="start" name="save-outline" color="primary"></ion-icon>
<ion-label style="display: flex; flex-direction: column;">
<ion-text color="primary">Create new Backup</ion-text>
<ion-text color="primary">Create Backup</ion-text>
<ion-text color="medium" style="font-size: x-small">
Last Backup: {{vars.lastBackup ? (vars.lastBackup | date: 'short') : 'never'}}
</ion-text>

View File

@@ -40,35 +40,7 @@
}
.launch-button {
width: 100%;
padding: 0px 10px;
--background: linear-gradient(200deg, rgb(70 193 255), rgb(70 193 255 / 45%));
width: calc(100% - 32px);
border-radius: 8px;
--border-radius: 8px;
--border-width: 1px;
--border-radius: 10px;
margin: 10px;
}
.launch-button-off {
--background: #383838;
color: var(--ion-color-medium)
}
.launch-explanation-button {
position: absolute;
z-index: 1;
right: -2px;
--border-radius: 100px;
}
.lan-toggle {
width: 2em;
height: 1em;
--handle-width: 0.9em;
--handle-height: 0.9em;
}
.item-interactive-disabled:not(.item-multiple-inputs) ion-label {
cursor: default;
opacity: 1 !important;
pointer-events: auto !important;
}

View File

@@ -6,20 +6,20 @@ import { copyToClipboard } from 'src/app/util/web.util'
import { AppModel, AppStatus } from 'src/app/models/app-model'
import { AppInstalledFull } from 'src/app/models/app-types'
import { ModelPreload } from 'src/app/models/model-preload'
import { chill, modulateTime, pauseFor, traceWheel } from 'src/app/util/misc.util'
import { chill, pauseFor } from 'src/app/util/misc.util'
import { PropertySubject, peekProperties } from 'src/app/util/property-subject.util'
import { AppBackupPage } from 'src/app/modals/app-backup/app-backup.page'
import { LoaderService, markAsLoadingDuring$, markAsLoadingDuringP } from 'src/app/services/loader.service'
import { BehaviorSubject, combineLatest, from, merge, Observable, of, Subject } from 'rxjs'
import { BehaviorSubject, Observable, of } from 'rxjs'
import { wizardModal } from 'src/app/components/install-wizard/install-wizard.component'
import { WizardBaker } from 'src/app/components/install-wizard/prebaked-wizards'
import { catchError, concatMap, delay, distinctUntilChanged, filter, map, mergeMap, retryWhen, switchMap, take, tap } from 'rxjs/operators'
import { catchError, concatMap, filter, switchMap, tap } from 'rxjs/operators'
import { Cleanup } from 'src/app/util/cleanup'
import { InformationPopoverComponent } from 'src/app/components/information-popover/information-popover.component'
import { Emver } from 'src/app/services/emver.service'
import { displayEmver } from 'src/app/pipes/emver.pipe'
import { ConfigService } from 'src/app/services/config.service'
import { concatObservableValues, squash } from 'src/app/util/rxjs.util'
@Component({
selector: 'app-installed-show',
templateUrl: './app-installed-show.page.html',
@@ -37,15 +37,7 @@ export class AppInstalledShowPage extends Cleanup {
isConsulate: boolean
isTor: boolean
// true iff service lan address has been tested and is accessible
$lanConnected$: BehaviorSubject<boolean> = new BehaviorSubject(false)
// true during service lan address testing
$testingLanConnection$: BehaviorSubject<boolean> = new BehaviorSubject(false)
dependencyDefintion = () => `<span style="font-style: italic">Dependencies</span> are other services which must be installed, configured appropriately, and started in order to start ${this.app.title.getValue()}`
launchDefinition = `<span style="font-style: italic">Launch A Service</span> <p>This button appears only for services that can be accessed inside the browser. If a service does not have this button, you must access it using another interface, such as a mobile app, desktop app, or another service on the Embassy. Please view the instructions for a service for details on how to use it.</p>`
launchOffDefinition = `<span style="font-style: italic">Launch A Service</span> <p>This button appears only for services that can be accessed inside the browser. Get your service running in order to launch!</p>`
launchLocalDefinition = `<span style="font-style: italic">Launch A Service</span> <p>This button appears only for services that can be accessed inside the browser. To launch this service over LAN, enable the toggle below by your service's LAN Address.</p>`
@ViewChild(IonContent) content: IonContent
@@ -76,69 +68,12 @@ export class AppInstalledShowPage extends Cleanup {
markAsLoadingDuring$(this.$loading$, this.preload.appFull(this.appId))
.pipe(
tap(app => this.app = app),
concatMap(app =>
merge(
this.syncWhenDependencyInstalls(),
// new lan info or status info from sync daemon
combineLatest([app.lanEnabled, app.status]).pipe(
concatObservableValues<boolean, AppStatus, boolean, boolean>([this.$lanConnected$, this.$testingLanConnection$]),
concatMap(([enabled, status, connected, alreadyConnecting]) => {
if (status !== AppStatus.RUNNING) return of(this.$lanConnected$.next(false))
if (alreadyConnecting) return of()
if (enabled && !connected) return markAsLoadingDuring$(this.$testingLanConnection$, this.testLanConnection())
if (!enabled && connected) return of(this.$lanConnected$.next(false))
return of()
}),
),
// toggle lan
this.$lanToggled$.pipe(
map(toggleEvent => (toggleEvent as any).detail.checked),
concatObservableValues([app.lanEnabled, this.$testingLanConnection$]),
traceWheel('toggle'),
map( ([uiEnabled, appEnabled, alreadyConnecting]) => {
if (!alreadyConnecting && uiEnabled && !appEnabled) return this.enableLan().pipe(concatMap(() => this.testLanConnection()))
if (!alreadyConnecting && !uiEnabled) return this.disableLan() //do this even if app already disabled because of appModel update timeout hack.
return of()
}),
concatMap((o: Observable<void>) => this.testLanLoader(o)),
),
),
), //must be final in stack
catchError(e => this.setError(e)),
concatMap(() => this.syncWhenDependencyInstalls()), //must be final in stack
catchError(e => of(this.setError(e))),
).subscribe(),
)
}
testLanLoader (o: Observable<void>): Observable<void> {
return markAsLoadingDuring$(this.$testingLanConnection$, o).pipe(catchError(e => this.setError(e)))
}
testLanConnection () : Observable<void> {
if (!this.app.lanAddress) return of()
return this.app.lanAddress.pipe(
switchMap(la => this.apiService.testConnection(la)),
retryWhen(errors => errors.pipe(delay(2500), take(20))),
catchError(() => of(false)),
take(1),
traceWheel('lan connected test'),
map(connected => this.$lanConnected$.next(connected)),
)
}
enableLan (): Observable<void> {
return from(this.apiService.toggleAppLAN(this.appId, 'enable')).pipe(squash)
}
disableLan (): Observable<void> {
return from(this.apiService.toggleAppLAN(this.appId, 'disable')).pipe(
map(() => this.appModel.update({ id: this.appId, lanEnabled: false }), modulateTime(new Date(), 10, 'seconds')),
map(() => this.$lanConnected$.next(false)),
squash,
)
}
$lanToggled$ = new Subject()
ionViewDidEnter () {
markAsLoadingDuringP(this.$loadingDependencies$, this.getApp())
}
@@ -238,7 +173,7 @@ export class AppInstalledShowPage extends Cleanup {
await toast.present()
}
async copyLan () {
async copyLAN () {
const app = peekProperties(this.app)
let message = ''
await copyToClipboard(app.lanAddress).then(success => { message = success ? 'copied to clipboard!' : 'failed to copy' })
@@ -353,18 +288,6 @@ export class AppInstalledShowPage extends Cleanup {
return this.navCtrl.navigateRoot('/services/installed')
}
async presentLaunchPopover (status: AppStatus, ev: any) {
let desc: string
if (!this.isTor) {
desc = this.launchLocalDefinition
} else if (status !== AppStatus.RUNNING) {
desc = this.launchOffDefinition
} else {
desc = this.launchDefinition
}
return this.presentPopover(desc, ev)
}
async presentPopover (information: string, ev: any) {
const popover = await this.popoverController.create({
component: InformationPopoverComponent,

View File

@@ -16,7 +16,6 @@ export class AppInstructionsPage {
error = ''
app: AppInstalledFull = { } as any
appId: string
instructions: any
constructor (
private readonly route: ActivatedRoute,

View File

@@ -3,7 +3,7 @@
<ion-buttons slot="end">
<badge-menu-button></badge-menu-button>
</ion-buttons>
<ion-title>Secure LAN Setup</ion-title>
<ion-title>LAN Setup</ion-title>
<ion-buttons slot="start">
<pwa-back-button></pwa-back-button>
</ion-buttons>

View File

@@ -59,12 +59,12 @@
<ion-item [routerLink]="['lan']">
<ion-icon slot="start" name="home-outline" color="primary"></ion-icon>
<ion-label><ion-text color="primary">Secure LAN Setup</ion-text></ion-label>
<ion-label><ion-text color="primary">LAN Setup</ion-text></ion-label>
</ion-item>
<ion-item [routerLink]="['wifi']">
<ion-icon slot="start" name="wifi" color="primary"></ion-icon>
<ion-label><ion-text color="primary">WiFi</ion-text></ion-label>
<ion-label><ion-text color="primary">WiFi Setup</ion-text></ion-label>
</ion-item>
<ion-item lines="none" [routerLink]="['developer']">

View File

@@ -3,7 +3,7 @@
<ion-buttons slot="start">
<pwa-back-button></pwa-back-button>
</ion-buttons>
<ion-title>Wifi</ion-title>
<ion-title>WiFi Setup</ion-title>
<ion-buttons slot="end">
<badge-menu-button></badge-menu-button>
</ion-buttons>
@@ -26,7 +26,7 @@
<ion-text color="warning">Warning!</ion-text>
<br />
<br />
<ion-text color="dark">WiFi is a beta feature with known issues. If you make changes to WiFi, your Embassy and its Services may become unreachable for upward of a few hours over Tor. Please use with caution and patience.</ion-text>
<ion-text color="dark">Making changes to WiFi can cause your Embassy and its Services to become unreachable for a few minutes to an hour. Please be patient.</ion-text>
</ion-label>
</ion-item>

View File

@@ -25,7 +25,6 @@ export function toInstalledPreview (f: AppInstalledFull): AppInstalledPreview {
torAddress: f.torAddress,
ui: f.ui,
lanAddress: f.lanAddress,
lanEnabled: f.lanEnabled,
}
}
@@ -50,7 +49,6 @@ export const bitcoinI: AppInstalledFull = {
id: 'bitcoind',
versionInstalled: '0.18.1',
lanAddress: 'bitcoinLan.local',
lanEnabled: true,
title: 'Bitcoin Core',
torAddress: '4acth47i6kxnvkewtm6q7ib2s3ufpo5sqbsnzjpbi7utijcltosqemad.onion',
startAlert: 'Bitcoind could take a loooooong time to start. Please be patient.',
@@ -71,7 +69,6 @@ export const bitcoinI: AppInstalledFull = {
export const lightningI: AppInstalledFull = {
id: 'c-lightning',
lanAddress: 'lightningLan.local',
lanEnabled: true,
status: AppStatus.RUNNING,
title: 'C Lightning',
versionInstalled: '1.0.0',
@@ -97,7 +94,6 @@ export const lightningI: AppInstalledFull = {
export const cupsI: AppInstalledFull = {
id: 'cups',
lanAddress: 'cupsLan.local',
lanEnabled: false,
versionInstalled: '2.1.0',
title: 'Cups Messenger',
torAddress: 'sample-cups-tor-address.onion',