Refactors admin page design to move each 'facet' of admin into its own component.
This commit is contained in:
1 parent
a4093e86b1
commit
c02c0cdde9
30 files changed
+1970
-1757
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import { Component, inject, output } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
import { HistoryEntry } from '../interfaces/history-entry';
|
||||
import { HistoryEntryService } from '../services/history-entry.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-admin-history-tab',
|
||||
standalone: true,
|
||||
imports: [CommonModule],
|
||||
templateUrl: './admin-history-tab.component.html',
|
||||
styleUrl: './admin-history-tab.component.scss',
|
||||
})
|
||||
export class AdminHistoryTabComponent {
|
||||
private historyEntryService = inject(HistoryEntryService);
|
||||
|
||||
readonly openForm = output<void>();
|
||||
readonly editItem = output<HistoryEntry>();
|
||||
readonly deleteItem = output<number>();
|
||||
|
||||
readonly entries$ = this.historyEntryService.getHistoryEntries();
|
||||
|
||||
ngOnInit(): void {
|
||||
this.load();
|
||||
}
|
||||
|
||||
async load(): Promise<void> {
|
||||
await firstValueFrom(this.historyEntryService.getHistoryEntries());
|
||||
}
|
||||
|
||||
onAdd(): void {
|
||||
this.openForm.emit();
|
||||
}
|
||||
|
||||
onEdit(entry: HistoryEntry): void {
|
||||
this.editItem.emit(entry);
|
||||
}
|
||||
|
||||
async onDelete(id: number): Promise<void> {
|
||||
if (!confirm('Delete this history entry?')) return;
|
||||
await firstValueFrom(this.historyEntryService.deleteHistoryEntry(id));
|
||||
await this.load();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user