mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 20:43:41 +00:00
fix password input for backups and add adjective noun randomizer
This commit is contained in:
@@ -7,7 +7,13 @@ import {
|
||||
Validators,
|
||||
} from '@angular/forms'
|
||||
import { Router } from '@angular/router'
|
||||
import { ErrorService, i18nPipe, normalizeHostname } from '@start9labs/shared'
|
||||
import {
|
||||
ErrorService,
|
||||
i18nPipe,
|
||||
normalizeHostname,
|
||||
randomServerName,
|
||||
serverNameValidator,
|
||||
} from '@start9labs/shared'
|
||||
import { TuiAutoFocus, TuiMapperPipe, TuiValidator } from '@taiga-ui/cdk'
|
||||
import {
|
||||
TuiButton,
|
||||
@@ -42,10 +48,17 @@ import { StateService } from '../services/state.service'
|
||||
@if (isFresh) {
|
||||
<tui-textfield>
|
||||
<label tuiLabel>{{ 'Server Name' | i18n }}</label>
|
||||
<input tuiInput tuiAutoFocus formControlName="name" />
|
||||
<input tuiInput formControlName="name" />
|
||||
<button
|
||||
tuiIconButton
|
||||
type="button"
|
||||
appearance="icon"
|
||||
iconStart="@tui.refresh-cw"
|
||||
(click)="randomizeName()"
|
||||
></button>
|
||||
</tui-textfield>
|
||||
<tui-error formControlName="name" />
|
||||
@if (form.controls.name.value?.trim()) {
|
||||
@if (form.controls.name.value?.trim() && !form.controls.name.errors) {
|
||||
<tui-error class="g-secondary" error="{{ derivedHostname }}.local" />
|
||||
}
|
||||
}
|
||||
@@ -127,6 +140,8 @@ import { StateService } from '../services/state.service'
|
||||
minlength: 'Must be 12 characters or greater',
|
||||
maxlength: 'Must be 64 character or less',
|
||||
match: 'Passwords do not match',
|
||||
hostnameMinLength: 'Hostname must be at least 4 characters',
|
||||
hostnameMaxLength: 'Hostname must be 63 characters or less',
|
||||
}),
|
||||
],
|
||||
})
|
||||
@@ -147,7 +162,10 @@ export default class PasswordPage {
|
||||
Validators.maxLength(64),
|
||||
]),
|
||||
confirm: new FormControl(''),
|
||||
name: new FormControl('', this.isFresh ? [Validators.required] : []),
|
||||
name: new FormControl(
|
||||
this.isFresh ? randomServerName() : '',
|
||||
this.isFresh ? [Validators.required, serverNameValidator] : [],
|
||||
),
|
||||
})
|
||||
|
||||
readonly validator = (value: string) => (control: AbstractControl) =>
|
||||
@@ -155,6 +173,10 @@ export default class PasswordPage {
|
||||
? null
|
||||
: { match: this.i18n.transform('Passwords do not match') }
|
||||
|
||||
randomizeName() {
|
||||
this.form.controls.name.setValue(randomServerName())
|
||||
}
|
||||
|
||||
get derivedHostname(): string {
|
||||
return normalizeHostname(this.form.controls.name.value || '')
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import {
|
||||
import { T } from '@start9labs/start-sdk'
|
||||
import * as jose from 'node-jose'
|
||||
import { interval, map, Observable } from 'rxjs'
|
||||
import { ApiService } from './api.service'
|
||||
import { InstallOsParams, InstallOsRes } from '../types'
|
||||
import { ApiService } from './api.service'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -127,7 +127,7 @@ export class MockApiService extends ApiService {
|
||||
return {
|
||||
'9876-5432-1234-5678': {
|
||||
hostname: 'adjective-noun',
|
||||
version: '0.3.6',
|
||||
version: '0.4.0',
|
||||
timestamp: new Date().toISOString(),
|
||||
passwordHash:
|
||||
'$argon2d$v=19$m=1024,t=1,p=1$YXNkZmFzZGZhc2RmYXNkZg$Ceev1I901G6UwU+hY0sHrFZ56D+o+LNJ',
|
||||
@@ -135,7 +135,7 @@ export class MockApiService extends ApiService {
|
||||
},
|
||||
'9876-5432-1234-5671': {
|
||||
hostname: 'adjective-noun',
|
||||
version: '0.3.6',
|
||||
version: '0.4.0',
|
||||
timestamp: new Date().toISOString(),
|
||||
passwordHash:
|
||||
'$argon2d$v=19$m=1024,t=1,p=1$YXNkZmFzZGZhc2RmYXNkZg$Ceev1I901G6UwU+hY0sHrFZ56D+o+LNJ',
|
||||
@@ -299,7 +299,7 @@ const MOCK_DISKS: DiskInfo[] = [
|
||||
startOs: {
|
||||
'small-server-id': {
|
||||
hostname: 'small-server',
|
||||
version: '0.3.6',
|
||||
version: '0.4.0',
|
||||
timestamp: new Date().toISOString(),
|
||||
passwordHash:
|
||||
'$argon2d$v=19$m=1024,t=1,p=1$YXNkZmFzZGZhc2RmYXNkZg$Ceev1I901G6UwU+hY0sHrFZ56D+o+LNJ',
|
||||
@@ -348,7 +348,7 @@ const MOCK_DISKS: DiskInfo[] = [
|
||||
startOs: {
|
||||
'1234-5678-9876-5432': {
|
||||
hostname: 'existing-server',
|
||||
version: '0.3.6',
|
||||
version: '0.4.0',
|
||||
timestamp: new Date().toISOString(),
|
||||
passwordHash:
|
||||
'$argon2d$v=19$m=1024,t=1,p=1$YXNkZmFzZGZhc2RmYXNkZg$Ceev1I901G6UwU+hY0sHrFZ56D+o+LNJ',
|
||||
|
||||
Reference in New Issue
Block a user