46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import {Component} from '@angular/core';
|
|
import {MatButton} from "@angular/material/button";
|
|
import {NavigationService} from "@service/navigation.service";
|
|
import {MatFormFieldModule} from "@angular/material/form-field";
|
|
import {MatInput} from "@angular/material/input";
|
|
import {AsyncPipe} from "@angular/common";
|
|
import {FormControl, ReactiveFormsModule, Validators} from "@angular/forms";
|
|
import SetupService from "@api/v1/setup.service";
|
|
import {environment} from "@environment";
|
|
import {AvailableVersion} from "@api/api.service";
|
|
|
|
@Component({
|
|
selector: 'app-welcome',
|
|
standalone: true,
|
|
imports: [
|
|
MatButton,
|
|
MatFormFieldModule,
|
|
MatInput,
|
|
AsyncPipe,
|
|
ReactiveFormsModule
|
|
],
|
|
templateUrl: './welcome.component.html'
|
|
})
|
|
|
|
export class WelcomeComponent {
|
|
protected tokenControl = new FormControl('', [
|
|
Validators.required,
|
|
Validators.pattern(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{4}|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}={2})$/),
|
|
Validators.minLength(16)
|
|
]);
|
|
|
|
protected apiToGetToken: string = environment.apiUrl;
|
|
|
|
constructor(private navigationService: NavigationService, private api: SetupService) {
|
|
this.apiToGetToken += AvailableVersion[this.api.version];
|
|
this.navigationService.nextButtonAction = () => {
|
|
return this.api.checkToken(this.tokenControl.value ?? '');
|
|
};
|
|
|
|
this.navigationService.setNextButtonState(false);
|
|
this.tokenControl.valueChanges.subscribe(() => {
|
|
this.navigationService.setNextButtonState(this.tokenControl.valid);
|
|
});
|
|
}
|
|
}
|