fix launching UI from list page

This commit is contained in:
Matt Hill
2021-02-24 16:48:18 -07:00
committed by Aiden McClelland
parent ee1c66d0c2
commit 68eccdb63c
3 changed files with 12 additions and 10 deletions

View File

@@ -22,16 +22,16 @@
<ion-grid>
<ion-row>
<ion-col *ngFor="let app of apps" sizeXs="4" sizeSm="3" sizeMd="2" sizeLg="2">
<ng-container *ngIf="{ tor: app.subject.torAddress | async, status: app.subject.status | async, ui: app.subject.ui | async, iconURL: app.subject.iconURL | async | iconParse, title: app.subject.title | async } 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, lanEnabled: app.subject.lanEnabled } 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(vars.tor, app.id, $event)" [class.disabled]="vars.status !== AppStatus.RUNNING">
<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>
</div>
</div>
<img style="position: absolute" class="main-img" [src]="vars.iconURL" [alt]="app.subject.title | async" />
<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"/>

View File

@@ -97,18 +97,22 @@ export class AppInstalledListPage extends Cleanup {
},
})
console.log(this.isTor, this.apps[2].subject.lanEnabled.getValue())
}
async launchUiTab (torAddress: string, id: string, event: Event) {
async launchUiTab (id: string, event: Event) {
event.preventDefault()
event.stopPropagation()
const app = this.apps.find(app => app.id === id).subject
let uiAddress: string
if (this.isTor) {
uiAddress = torAddress.startsWith('http') ? torAddress : `http://${torAddress}`
uiAddress = `http://${app.torAddress.getValue()}`
} else {
uiAddress = `https://${id}.${this.serverModel.peek().serverId}.local`
uiAddress = `https://${app.lanAddress.getValue()}`
}
console.log(uiAddress)
return window.open(uiAddress, '_blank')
}

View File

@@ -167,11 +167,9 @@ export class AppInstalledShowPage extends Cleanup {
async launchUiTab () {
let uiAddress: string
if (this.isTor) {
const torAddress = this.app.torAddress.getValue()
uiAddress = torAddress.startsWith('http') ? torAddress : `http://${torAddress}`
uiAddress = `http://${this.app.torAddress.getValue()}`
} else {
const lanAddress = this.app.lanAddress.getValue()
uiAddress = lanAddress.startsWith('http') ? lanAddress : `http://${lanAddress}`
uiAddress = `https://${this.app.lanAddress.getValue()}`
}
return window.open(uiAddress, '_blank')
}