mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
better UX for http/https switching (#2494)
* open https in same tab * open http in same tab, use windowRef instead of window
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { Component, Input } from '@angular/core'
|
import { Component, Inject, Input } from '@angular/core'
|
||||||
|
import { WINDOW } from '@ng-web-apis/common'
|
||||||
import { ActivatedRoute } from '@angular/router'
|
import { ActivatedRoute } from '@angular/router'
|
||||||
import { ModalController, ToastController } from '@ionic/angular'
|
import { ModalController, ToastController } from '@ionic/angular'
|
||||||
import { copyToClipboard, getPkgId } from '@start9labs/shared'
|
import { copyToClipboard, getPkgId } from '@start9labs/shared'
|
||||||
@@ -91,10 +92,11 @@ export class AppInterfacesItemComponent {
|
|||||||
constructor(
|
constructor(
|
||||||
private readonly toastCtrl: ToastController,
|
private readonly toastCtrl: ToastController,
|
||||||
private readonly modalCtrl: ModalController,
|
private readonly modalCtrl: ModalController,
|
||||||
|
@Inject(WINDOW) private readonly windowRef: Window,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
launch(url: string): void {
|
launch(url: string): void {
|
||||||
window.open(url, '_blank', 'noreferrer')
|
this.windowRef.open(url, '_blank', 'noreferrer')
|
||||||
}
|
}
|
||||||
|
|
||||||
async showQR(text: string): Promise<void> {
|
async showQR(text: string): Promise<void> {
|
||||||
|
|||||||
@@ -27,7 +27,13 @@
|
|||||||
your device can verify the authenticity of encrypted communications with
|
your device can verify the authenticity of encrypted communications with
|
||||||
your server.
|
your server.
|
||||||
<br />
|
<br />
|
||||||
<ion-button strong size="small" (click)="instructions()">
|
<ion-button
|
||||||
|
strong
|
||||||
|
size="small"
|
||||||
|
href="https://docs.start9.com/0.3.5.x/user-manual/getting-started/trust-ca/#trust-root-ca"
|
||||||
|
target="_blank"
|
||||||
|
noreferrer
|
||||||
|
>
|
||||||
View Instructions
|
View Instructions
|
||||||
<ion-icon slot="end" name="open-outline"></ion-icon>
|
<ion-icon slot="end" name="open-outline"></ion-icon>
|
||||||
</ion-button>
|
</ion-button>
|
||||||
|
|||||||
@@ -31,21 +31,13 @@ export class CAWizardComponent {
|
|||||||
this.document.getElementById('install-cert')?.click()
|
this.document.getElementById('install-cert')?.click()
|
||||||
}
|
}
|
||||||
|
|
||||||
instructions() {
|
|
||||||
this.windowRef.open(
|
|
||||||
'https://docs.start9.com/0.3.5.x/user-manual/getting-started/trust-ca/#trust-root-ca',
|
|
||||||
'_blank',
|
|
||||||
'noreferrer',
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.document.location.reload()
|
this.document.location.reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
launchHttps() {
|
launchHttps() {
|
||||||
const host = this.config.getHost()
|
const host = this.config.getHost()
|
||||||
this.windowRef.open(`https://${host}`, '_blank', 'noreferrer')
|
this.windowRef.open(`https://${host}`, '_self')
|
||||||
}
|
}
|
||||||
|
|
||||||
private async testHttps() {
|
private async testHttps() {
|
||||||
|
|||||||
@@ -11,7 +11,17 @@
|
|||||||
<ion-icon slot="start" name="warning-outline"></ion-icon>
|
<ion-icon slot="start" name="warning-outline"></ion-icon>
|
||||||
<ion-label>
|
<ion-label>
|
||||||
<h2 style="font-weight: bold">Http detected</h2>
|
<h2 style="font-weight: bold">Http detected</h2>
|
||||||
<p style="font-weight: 600">Tor is faster over https.</p>
|
<p style="font-weight: 600">
|
||||||
|
Tor is faster over https. Your Root CA must be trusted.
|
||||||
|
<a
|
||||||
|
href="https://docs.start9.com/0.3.5.x/user-manual/getting-started/trust-ca/#trust-root-ca"
|
||||||
|
target="_blank"
|
||||||
|
noreferrer
|
||||||
|
style="color: black"
|
||||||
|
>
|
||||||
|
View instructions
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
<ion-button slot="end" color="light" (click)="launchHttps()">
|
<ion-button slot="end" color="light" (click)="launchHttps()">
|
||||||
Open Https
|
Open Https
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export class LoginPage {
|
|||||||
|
|
||||||
launchHttps() {
|
launchHttps() {
|
||||||
const host = this.config.getHost()
|
const host = this.config.getHost()
|
||||||
this.windowRef.open(`https://${host}`, '_blank', 'noreferrer')
|
this.windowRef.open(`https://${host}`, '_self')
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit() {
|
async submit() {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import {
|
|||||||
GenericInputOptions,
|
GenericInputOptions,
|
||||||
} from 'src/app/modals/generic-input/generic-input.component'
|
} from 'src/app/modals/generic-input/generic-input.component'
|
||||||
import { ConfigService } from 'src/app/services/config.service'
|
import { ConfigService } from 'src/app/services/config.service'
|
||||||
import { DOCUMENT } from '@angular/common'
|
import { WINDOW } from '@ng-web-apis/common'
|
||||||
import { getServerInfo } from 'src/app/util/get-server-info'
|
import { getServerInfo } from 'src/app/util/get-server-info'
|
||||||
import { GenericFormPage } from 'src/app/modals/generic-form/generic-form.page'
|
import { GenericFormPage } from 'src/app/modals/generic-form/generic-form.page'
|
||||||
import { ConfigSpec } from 'src/app/pkg-config/config-types'
|
import { ConfigSpec } from 'src/app/pkg-config/config-types'
|
||||||
@@ -57,7 +57,7 @@ export class ServerShowPage {
|
|||||||
private readonly authService: AuthService,
|
private readonly authService: AuthService,
|
||||||
private readonly toastCtrl: ToastController,
|
private readonly toastCtrl: ToastController,
|
||||||
private readonly config: ConfigService,
|
private readonly config: ConfigService,
|
||||||
@Inject(DOCUMENT) private readonly document: Document,
|
@Inject(WINDOW) private readonly windowRef: Window,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async setBrowserTab(): Promise<void> {
|
async setBrowserTab(): Promise<void> {
|
||||||
@@ -307,7 +307,7 @@ export class ServerShowPage {
|
|||||||
|
|
||||||
async launchHttps() {
|
async launchHttps() {
|
||||||
const { 'tor-address': torAddress } = await getServerInfo(this.patch)
|
const { 'tor-address': torAddress } = await getServerInfo(this.patch)
|
||||||
window.open(torAddress)
|
this.windowRef.open(torAddress, '_self')
|
||||||
}
|
}
|
||||||
|
|
||||||
addClick(title: string) {
|
addClick(title: string) {
|
||||||
@@ -495,7 +495,7 @@ export class ServerShowPage {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Root CA',
|
title: 'Root CA',
|
||||||
description: `Download and trust your server's root certificate authority`,
|
description: `Download and trust your server's Root Certificate Authority`,
|
||||||
icon: 'ribbon-outline',
|
icon: 'ribbon-outline',
|
||||||
action: () =>
|
action: () =>
|
||||||
this.navCtrl.navigateForward(['root-ca'], { relativeTo: this.route }),
|
this.navCtrl.navigateForward(['root-ca'], { relativeTo: this.route }),
|
||||||
@@ -621,7 +621,7 @@ export class ServerShowPage {
|
|||||||
description: 'Discover what StartOS can do',
|
description: 'Discover what StartOS can do',
|
||||||
icon: 'map-outline',
|
icon: 'map-outline',
|
||||||
action: () =>
|
action: () =>
|
||||||
window.open(
|
this.windowRef.open(
|
||||||
'https://docs.start9.com/0.3.5.x/user-manual',
|
'https://docs.start9.com/0.3.5.x/user-manual',
|
||||||
'_blank',
|
'_blank',
|
||||||
'noreferrer',
|
'noreferrer',
|
||||||
@@ -634,7 +634,11 @@ export class ServerShowPage {
|
|||||||
description: 'Get help from the Start9 team and community',
|
description: 'Get help from the Start9 team and community',
|
||||||
icon: 'chatbubbles-outline',
|
icon: 'chatbubbles-outline',
|
||||||
action: () =>
|
action: () =>
|
||||||
window.open('https://start9.com/contact', '_blank', 'noreferrer'),
|
this.windowRef.open(
|
||||||
|
'https://start9.com/contact',
|
||||||
|
'_blank',
|
||||||
|
'noreferrer',
|
||||||
|
),
|
||||||
detail: true,
|
detail: true,
|
||||||
disabled$: of(false),
|
disabled$: of(false),
|
||||||
},
|
},
|
||||||
@@ -643,7 +647,7 @@ export class ServerShowPage {
|
|||||||
description: `Support StartOS development`,
|
description: `Support StartOS development`,
|
||||||
icon: 'logo-bitcoin',
|
icon: 'logo-bitcoin',
|
||||||
action: () =>
|
action: () =>
|
||||||
this.document.defaultView?.open(
|
this.windowRef.open(
|
||||||
'https://donate.start9.com',
|
'https://donate.start9.com',
|
||||||
'_blank',
|
'_blank',
|
||||||
'noreferrer',
|
'noreferrer',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Inject, Injectable } from '@angular/core'
|
import { Inject, Injectable } from '@angular/core'
|
||||||
import { DOCUMENT } from '@angular/common'
|
import { WINDOW } from '@ng-web-apis/common'
|
||||||
import { PackageDataEntry } from 'src/app/services/patch-db/data-model'
|
import { PackageDataEntry } from 'src/app/services/patch-db/data-model'
|
||||||
import { ConfigService } from './config.service'
|
import { ConfigService } from './config.service'
|
||||||
|
|
||||||
@@ -8,15 +8,11 @@ import { ConfigService } from './config.service'
|
|||||||
})
|
})
|
||||||
export class UiLauncherService {
|
export class UiLauncherService {
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DOCUMENT) private readonly document: Document,
|
@Inject(WINDOW) private readonly windowRef: Window,
|
||||||
private readonly config: ConfigService,
|
private readonly config: ConfigService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
launch(pkg: PackageDataEntry): void {
|
launch(pkg: PackageDataEntry): void {
|
||||||
this.document.defaultView?.open(
|
this.windowRef.open(this.config.launchableURL(pkg), '_blank', 'noreferrer')
|
||||||
this.config.launchableURL(pkg),
|
|
||||||
'_blank',
|
|
||||||
'noreferrer',
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user