feat: add setup/welcome page

This commit is contained in:
2024-06-11 00:24:25 +03:00
parent 7e7b8b6c8f
commit d6f51a5d1c
2 changed files with 99 additions and 0 deletions

View File

@ -0,0 +1,45 @@
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 "@/config/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);
});
}
}