data driven about us screen
This commit is contained in:
@@ -7,16 +7,25 @@ import { Program } from '../interfaces/program';
|
||||
import { Event } from '../interfaces/event';
|
||||
import { Tier } from '../interfaces/tier';
|
||||
import { StationConfig } from '../interfaces/station-config';
|
||||
import { HistoryEntry } from '../interfaces/history-entry';
|
||||
import { TeamMember } from '../interfaces/team-member';
|
||||
import { CommunityHighlight } from '../interfaces/community-highlight';
|
||||
import { ProgramService } from '../services/program.service';
|
||||
import { EventService } from '../services/event.service';
|
||||
import { TierService } from '../services/tier.service';
|
||||
import { StationConfigService } from '../services/station-config.service';
|
||||
import { HistoryEntryService } from '../services/history-entry.service';
|
||||
import { TeamMemberService } from '../services/team-member.service';
|
||||
import { CommunityHighlightService } from '../services/community-highlight.service';
|
||||
import { AdminProgramFormComponent } from './admin-program-form.component';
|
||||
import { AdminEventFormComponent } from './admin-event-form.component';
|
||||
import { AdminTierFormComponent } from './admin-tier-form.component';
|
||||
import { AdminStationFormComponent } from './admin-station-form.component';
|
||||
import { AdminHistoryFormComponent } from './admin-history-form.component';
|
||||
import { AdminTeamFormComponent } from './admin-team-form.component';
|
||||
import { AdminCommunityFormComponent } from './admin-community-form.component';
|
||||
|
||||
type TabKey = 'programs' | 'events' | 'tiers' | 'station';
|
||||
type TabKey = 'programs' | 'events' | 'tiers' | 'station' | 'history' | 'team' | 'community';
|
||||
|
||||
@Component({
|
||||
selector: 'app-admin',
|
||||
@@ -29,6 +38,9 @@ type TabKey = 'programs' | 'events' | 'tiers' | 'station';
|
||||
AdminEventFormComponent,
|
||||
AdminTierFormComponent,
|
||||
AdminStationFormComponent,
|
||||
AdminHistoryFormComponent,
|
||||
AdminTeamFormComponent,
|
||||
AdminCommunityFormComponent,
|
||||
],
|
||||
templateUrl: './admin.component.html',
|
||||
styleUrl: './admin.component.scss',
|
||||
@@ -38,6 +50,9 @@ export class AdminComponent implements OnInit {
|
||||
private eventService = inject(EventService);
|
||||
private tierService = inject(TierService);
|
||||
private stationConfigService = inject(StationConfigService);
|
||||
private historyEntryService = inject(HistoryEntryService);
|
||||
private teamMemberService = inject(TeamMemberService);
|
||||
private communityHighlightService = inject(CommunityHighlightService);
|
||||
|
||||
activeTab = signal<TabKey>('programs');
|
||||
|
||||
@@ -45,17 +60,26 @@ export class AdminComponent implements OnInit {
|
||||
editingProgram: Program | null = null;
|
||||
editingEvent: Event | null = null;
|
||||
editingTier: Tier | null = null;
|
||||
editingHistory: HistoryEntry | null = null;
|
||||
editingTeam: TeamMember | null = null;
|
||||
editingCommunity: CommunityHighlight | null = null;
|
||||
|
||||
/** BehaviorSubjects guarantee change detection via the async pipe — start empty, populated on load. */
|
||||
readonly programs$ = new BehaviorSubject<Program[]>([]);
|
||||
readonly events$ = new BehaviorSubject<Event[]>([]);
|
||||
readonly tiers$ = new BehaviorSubject<Tier[]>([]);
|
||||
readonly stationConfig$ = new BehaviorSubject<StationConfig | null>(null);
|
||||
readonly historyEntries$ = new BehaviorSubject<HistoryEntry[]>([]);
|
||||
readonly teamMembers$ = new BehaviorSubject<TeamMember[]>([]);
|
||||
readonly communityHighlights$ = new BehaviorSubject<CommunityHighlight[]>([]);
|
||||
|
||||
showProgramForm = false;
|
||||
showEventForm = false;
|
||||
showTierForm = false;
|
||||
showStationForm = false;
|
||||
showHistoryForm = false;
|
||||
showTeamForm = false;
|
||||
showCommunityForm = false;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.loadAll();
|
||||
@@ -81,12 +105,30 @@ export class AdminComponent implements OnInit {
|
||||
this.stationConfig$.next(this.stationConfigService.config());
|
||||
}
|
||||
|
||||
async reloadHistoryEntries(): Promise<void> {
|
||||
const data = await firstValueFrom(this.historyEntryService.getHistoryEntries());
|
||||
this.historyEntries$.next(data);
|
||||
}
|
||||
|
||||
async reloadTeamMembers(): Promise<void> {
|
||||
const data = await firstValueFrom(this.teamMemberService.getTeamMembers());
|
||||
this.teamMembers$.next(data);
|
||||
}
|
||||
|
||||
async reloadCommunityHighlights(): Promise<void> {
|
||||
const data = await firstValueFrom(this.communityHighlightService.getCommunityHighlights());
|
||||
this.communityHighlights$.next(data);
|
||||
}
|
||||
|
||||
async loadAll(): Promise<void> {
|
||||
await Promise.all([
|
||||
this.reloadPrograms(),
|
||||
this.reloadEvents(),
|
||||
this.reloadTiers(),
|
||||
this.reloadStationConfig(),
|
||||
this.reloadHistoryEntries(),
|
||||
this.reloadTeamMembers(),
|
||||
this.reloadCommunityHighlights(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -191,4 +233,91 @@ export class AdminComponent implements OnInit {
|
||||
onStationClosed(): void {
|
||||
this.showStationForm = false;
|
||||
}
|
||||
|
||||
// ── History CRUD ────────────────────────────────────────
|
||||
|
||||
openHistoryForm(): void {
|
||||
this.editingHistory = null;
|
||||
this.showHistoryForm = true;
|
||||
}
|
||||
|
||||
editHistory(entry: HistoryEntry): void {
|
||||
this.editingHistory = entry;
|
||||
this.showHistoryForm = true;
|
||||
}
|
||||
|
||||
onHistorySaved(): void {
|
||||
this.reloadHistoryEntries();
|
||||
this.showHistoryForm = false;
|
||||
this.editingHistory = null;
|
||||
}
|
||||
|
||||
onHistoryClosed(): void {
|
||||
this.showHistoryForm = false;
|
||||
this.editingHistory = null;
|
||||
}
|
||||
|
||||
async deleteHistory(id: number): Promise<void> {
|
||||
if (!confirm('Delete this history entry?')) return;
|
||||
await firstValueFrom(this.historyEntryService.deleteHistoryEntry(id));
|
||||
await this.reloadHistoryEntries();
|
||||
}
|
||||
|
||||
// ── Team CRUD ───────────────────────────────────────────
|
||||
|
||||
openTeamForm(): void {
|
||||
this.editingTeam = null;
|
||||
this.showTeamForm = true;
|
||||
}
|
||||
|
||||
editTeam(member: TeamMember): void {
|
||||
this.editingTeam = member;
|
||||
this.showTeamForm = true;
|
||||
}
|
||||
|
||||
onTeamSaved(): void {
|
||||
this.reloadTeamMembers();
|
||||
this.showTeamForm = false;
|
||||
this.editingTeam = null;
|
||||
}
|
||||
|
||||
onTeamClosed(): void {
|
||||
this.showTeamForm = false;
|
||||
this.editingTeam = null;
|
||||
}
|
||||
|
||||
async deleteTeam(id: number): Promise<void> {
|
||||
if (!confirm('Delete this team member?')) return;
|
||||
await firstValueFrom(this.teamMemberService.deleteTeamMember(id));
|
||||
await this.reloadTeamMembers();
|
||||
}
|
||||
|
||||
// ── Community CRUD ──────────────────────────────────────
|
||||
|
||||
openCommunityForm(): void {
|
||||
this.editingCommunity = null;
|
||||
this.showCommunityForm = true;
|
||||
}
|
||||
|
||||
editCommunity(highlight: CommunityHighlight): void {
|
||||
this.editingCommunity = highlight;
|
||||
this.showCommunityForm = true;
|
||||
}
|
||||
|
||||
onCommunitySaved(): void {
|
||||
this.reloadCommunityHighlights();
|
||||
this.showCommunityForm = false;
|
||||
this.editingCommunity = null;
|
||||
}
|
||||
|
||||
onCommunityClosed(): void {
|
||||
this.showCommunityForm = false;
|
||||
this.editingCommunity = null;
|
||||
}
|
||||
|
||||
async deleteCommunity(id: number): Promise<void> {
|
||||
if (!confirm('Delete this community highlight?')) return;
|
||||
await firstValueFrom(this.communityHighlightService.deleteCommunityHighlight(id));
|
||||
await this.reloadCommunityHighlights();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user