Archive
This commit is contained in:
@@ -1,24 +1,27 @@
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { ApiService } from '../../../shared/api.service';
|
||||
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { map, Observable, startWith } from 'rxjs';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { HotToastService } from '@ngxpert/hot-toast';
|
||||
|
||||
@Component({
|
||||
selector: 'app-create',
|
||||
standalone: true,
|
||||
imports: [MatDialogModule, MatButtonModule, ReactiveFormsModule, FormsModule, MatFormFieldModule, MatInputModule, MatSelectModule],
|
||||
imports: [MatDialogModule, MatButtonModule, ReactiveFormsModule, FormsModule, MatFormFieldModule, MatInputModule, MatSelectModule, MatDialogModule],
|
||||
templateUrl: './create.component.html',
|
||||
styleUrl: './create.component.scss'
|
||||
})
|
||||
export class CreateKeyComponent {
|
||||
|
||||
private api: ApiService = inject(ApiService);
|
||||
private toast: HotToastService = inject(HotToastService);
|
||||
readonly dialogRef = inject(MatDialogRef<CreateKeyComponent>);
|
||||
|
||||
createForm = new FormGroup({
|
||||
name: new FormControl(null, Validators.required),
|
||||
@@ -54,7 +57,19 @@ export class CreateKeyComponent {
|
||||
}
|
||||
|
||||
save() {
|
||||
console.log(this.createForm.value)
|
||||
this.api.createKey(this.createForm.value as any)
|
||||
.pipe(
|
||||
this.toast.observe({
|
||||
error: 'Konnte nicht angelegt werden...',
|
||||
loading: 'Speichern...',
|
||||
success: 'Gespeichert'
|
||||
})
|
||||
)
|
||||
.subscribe({
|
||||
next: key => {
|
||||
this.createForm.reset();
|
||||
this.dialogRef.close(key);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user