2025-04-01 21:12:01 +00:00
|
|
|
import { Component, inject, OnInit } from '@angular/core';
|
|
|
|
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
2024-10-17 08:48:15 +00:00
|
|
|
import { MatSelectModule } from '@angular/material/select';
|
|
|
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
|
|
import { MatButtonModule } from '@angular/material/button';
|
2025-03-20 12:33:27 +00:00
|
|
|
import { ActivatedRoute } from '@angular/router';
|
2025-01-07 17:56:11 +00:00
|
|
|
import { HermesClientService } from '../../hermes-client.service';
|
2025-01-15 20:19:44 +00:00
|
|
|
import { MatCardModule } from '@angular/material/card';
|
2024-10-17 08:48:15 +00:00
|
|
|
|
|
|
|
@Component({
|
2025-01-08 21:50:18 +00:00
|
|
|
selector: 'tts-login',
|
|
|
|
standalone: true,
|
2025-04-01 21:12:01 +00:00
|
|
|
imports: [
|
|
|
|
MatButtonModule,
|
|
|
|
MatCardModule,
|
|
|
|
MatFormFieldModule,
|
|
|
|
MatSelectModule,
|
|
|
|
ReactiveFormsModule,
|
|
|
|
],
|
2025-01-08 21:50:18 +00:00
|
|
|
templateUrl: './tts-login.component.html',
|
|
|
|
styleUrl: './tts-login.component.scss'
|
2024-10-17 08:48:15 +00:00
|
|
|
})
|
2025-04-01 21:12:01 +00:00
|
|
|
export class TtsLoginComponent implements OnInit {
|
2025-03-20 12:33:27 +00:00
|
|
|
private readonly client = inject(HermesClientService);
|
|
|
|
private readonly route = inject(ActivatedRoute);
|
2025-01-15 20:19:44 +00:00
|
|
|
|
2025-04-01 21:12:01 +00:00
|
|
|
keyControl = new FormControl<string | null>('');
|
2025-01-15 20:19:44 +00:00
|
|
|
api_keys: { id: string, label: string }[] = [];
|
2024-10-17 08:48:15 +00:00
|
|
|
|
|
|
|
|
2025-01-08 21:50:18 +00:00
|
|
|
ngOnInit(): void {
|
2025-01-15 20:19:44 +00:00
|
|
|
this.route.data.subscribe(d => this.api_keys = d['keys']);
|
2025-01-08 21:50:18 +00:00
|
|
|
}
|
2024-10-17 08:48:15 +00:00
|
|
|
|
2025-03-20 12:33:27 +00:00
|
|
|
login(): void {
|
2025-04-01 21:12:01 +00:00
|
|
|
if (!this.keyControl.value)
|
2025-01-08 21:50:18 +00:00
|
|
|
return;
|
2024-10-17 08:48:15 +00:00
|
|
|
|
2025-04-01 21:12:01 +00:00
|
|
|
this.client.login(this.keyControl.value);
|
2025-01-08 21:50:18 +00:00
|
|
|
}
|
2024-10-17 08:48:15 +00:00
|
|
|
}
|