fix ui address bug and streamline install flow

This commit is contained in:
Matt Hill
2021-09-08 21:51:01 -06:00
committed by Aiden McClelland
parent 45d945db2e
commit c5585f7f35
12 changed files with 78 additions and 82 deletions

View File

@@ -366,7 +366,7 @@ export module Mock {
rpc: {
name: 'RPC interface',
description: 'Good for connecting to your node at a distance.',
ui: true,
ui: false,
'tor-config': {
'port-mapping': { },
},

View File

@@ -77,7 +77,6 @@ export class MockApiService extends ApiService {
await pauseFor(2000)
let entries
if (Math.random() < .2) {
console.log('last page')
entries = Mock.ServerLogs
} else {
const arrLength = params.limit ? Math.ceil(params.limit / Mock.ServerLogs.length) : 10
@@ -324,7 +323,6 @@ export class MockApiService extends ApiService {
await pauseFor(2000)
let entries
if (Math.random() < .2) {
console.log('last page')
entries = Mock.PackageLogs
} else {
const arrLength = params.limit ? Math.ceil(params.limit / Mock.PackageLogs.length) : 10

View File

@@ -67,31 +67,43 @@ export class ConfigService {
}
export function hasTorUi (interfaces: { [id: string]: InterfaceDef }): boolean {
return !!Object.values(interfaces).find(i => i.ui && i['tor-config'])
const int = getUiInterfaceValue(interfaces)
return !!int?.['tor-config']
}
export function hasLanUi (interfaces: { [id: string]: InterfaceDef }): boolean {
return !!Object.values(interfaces).find(i => i.ui && i['lan-config'])
const int = getUiInterfaceValue(interfaces)
return !!int?.['lan-config']
}
export function torUiAddress (pkg: PackageDataEntry): string {
return pkg.installed?.['interface-addresses']?.ui?.['tor-address']
const key = getUiInterfaceKey(pkg.manifest.interfaces)
return pkg.installed['interface-addresses'][key]['tor-address']
}
export function lanUiAddress (pkg: PackageDataEntry): string {
return pkg.installed?.['interface-addresses']?.ui?.['lan-address']
const key = getUiInterfaceKey(pkg.manifest.interfaces)
return pkg.installed['interface-addresses'][key]['lan-address']
}
export function hasUi (interfaces: { [id: string]: InterfaceDef }): boolean {
return hasTorUi(interfaces) || hasLanUi(interfaces)
}
function removeProtocol (str: string): string {
export function removeProtocol (str: string): string {
if (str.startsWith('http://')) return str.slice(7)
if (str.startsWith('https://')) return str.slice(8)
return str
}
function removePort (str: string): string {
export function removePort (str: string): string {
return str.split(':')[0]
}
export function getUiInterfaceKey (interfaces: { [id: string]: InterfaceDef }): string {
return Object.keys(interfaces).find(key => interfaces[key].ui)
}
export function getUiInterfaceValue (interfaces: { [id: string]: InterfaceDef }): InterfaceDef {
return Object.values(interfaces).find(i => i.ui)
}

View File

@@ -79,7 +79,6 @@ export class HttpService {
case Method.PATCH: req = this.http.patch(url, httpOpts.body, options) as any; break
case Method.DELETE: req = this.http.delete(url, options) as any; break
}
console.log('REQUEST', options)
return (httpOpts.timeout ? withTimeout(req, httpOpts.timeout) : req)
.toPromise()