mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
fix: address comments
This commit is contained in:
@@ -52,6 +52,7 @@ import { getIp, DeviceData, MappedSubnet, subnetValidator } from './utils'
|
||||
<select
|
||||
tuiSelect
|
||||
formControlName="subnet"
|
||||
placeholder="Select Subnet"
|
||||
[items]="context.data.subnets()"
|
||||
></select>
|
||||
} @else {
|
||||
@@ -87,9 +88,7 @@ import { getIp, DeviceData, MappedSubnet, subnetValidator } from './utils'
|
||||
}
|
||||
}
|
||||
<footer>
|
||||
<button tuiButton (click)="onSave()" [disabled]="form.invalid">
|
||||
Save
|
||||
</button>
|
||||
<button tuiButton (click)="onSave()">Save</button>
|
||||
</footer>
|
||||
</form>
|
||||
`,
|
||||
@@ -147,6 +146,7 @@ export class DevicesAdd {
|
||||
protected async onSave() {
|
||||
if (this.form.invalid) {
|
||||
tuiMarkControlAsTouchedAndValidate(this.form)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ export interface DeviceData {
|
||||
}
|
||||
|
||||
export function subnetValidator({ value }: AbstractControl<MappedSubnet>) {
|
||||
return value && getIp(value) ? null : { noHosts: 'No hosts available' }
|
||||
return !value?.clients || getIp(value)
|
||||
? null
|
||||
: { noHosts: 'No hosts available' }
|
||||
}
|
||||
|
||||
export function getIp({ clients, range }: MappedSubnet) {
|
||||
|
||||
@@ -39,6 +39,7 @@ import { MappedDevice, PortForwardsData } from './utils'
|
||||
<select
|
||||
tuiSelect
|
||||
formControlName="externalip"
|
||||
placeholder="Select IP"
|
||||
[items]="context.data.ips()"
|
||||
></select>
|
||||
} @else {
|
||||
@@ -76,6 +77,7 @@ import { MappedDevice, PortForwardsData } from './utils'
|
||||
<select
|
||||
tuiSelect
|
||||
formControlName="device"
|
||||
placeholder="Select Device"
|
||||
[items]="context.data.devices()"
|
||||
></select>
|
||||
} @else {
|
||||
|
||||
@@ -1,8 +1,20 @@
|
||||
import { Injectable, signal } from '@angular/core'
|
||||
import { effect, inject, Injectable, signal } from '@angular/core'
|
||||
import { WA_LOCAL_STORAGE } from '@ng-web-apis/common'
|
||||
|
||||
const KEY = '_startos/tunnel-loggedIn'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthService {
|
||||
readonly authenticated = signal(false)
|
||||
private readonly storage = inject(WA_LOCAL_STORAGE)
|
||||
private readonly effect = effect(() => {
|
||||
if (this.authenticated()) {
|
||||
this.storage.setItem(KEY, JSON.stringify(true))
|
||||
} else {
|
||||
this.storage.removeItem(KEY)
|
||||
}
|
||||
})
|
||||
|
||||
readonly authenticated = signal(Boolean(this.storage.getItem(KEY)))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Inject, Injectable, DOCUMENT } from '@angular/core'
|
||||
import { inject, Injectable } from '@angular/core'
|
||||
import { WA_LOCAL_STORAGE } from '@ng-web-apis/common'
|
||||
|
||||
const PREFIX = '_startos/'
|
||||
|
||||
@@ -6,9 +7,7 @@ const PREFIX = '_startos/'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class StorageService {
|
||||
private readonly storage = this.document.defaultView!.localStorage
|
||||
|
||||
constructor(@Inject(DOCUMENT) private readonly document: Document) {}
|
||||
private readonly storage = inject(WA_LOCAL_STORAGE)
|
||||
|
||||
get<T>(key: string): T {
|
||||
return JSON.parse(String(this.storage.getItem(`${PREFIX}${key}`)))
|
||||
|
||||
Reference in New Issue
Block a user