hermes-web-angular/src/app/auth/tts-login/tts-login.component.ts

42 lines
1.2 KiB
TypeScript
Raw Normal View History

import { Component, inject, OnInit } from '@angular/core';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { MatSelectModule } from '@angular/material/select';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatButtonModule } from '@angular/material/button';
import { ActivatedRoute } from '@angular/router';
import { HermesClientService } from '../../hermes-client.service';
import { MatCardModule } from '@angular/material/card';
@Component({
selector: 'tts-login',
standalone: true,
imports: [
MatButtonModule,
MatCardModule,
MatFormFieldModule,
MatSelectModule,
ReactiveFormsModule,
],
templateUrl: './tts-login.component.html',
styleUrl: './tts-login.component.scss'
})
export class TtsLoginComponent implements OnInit {
private readonly client = inject(HermesClientService);
private readonly route = inject(ActivatedRoute);
keyControl = new FormControl<string | null>('');
api_keys: { id: string, label: string }[] = [];
ngOnInit(): void {
this.route.data.subscribe(d => this.api_keys = d['keys']);
}
login(): void {
if (!this.keyControl.value)
return;
this.client.login(this.keyControl.value);
}
}