New programming screen
This commit is contained in:
@@ -4,6 +4,7 @@ import { FormsModule } from '@angular/forms';
|
||||
import { BehaviorSubject, firstValueFrom } from 'rxjs';
|
||||
|
||||
import { Program } from '../interfaces/program';
|
||||
import { Show } from '../interfaces/show';
|
||||
import { Event } from '../interfaces/event';
|
||||
import { Tier } from '../interfaces/tier';
|
||||
import { StationConfig } from '../interfaces/station-config';
|
||||
@@ -11,6 +12,7 @@ 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 { ShowService } from '../services/show.service';
|
||||
import { EventService } from '../services/event.service';
|
||||
import { TierService } from '../services/tier.service';
|
||||
import { StationConfigService } from '../services/station-config.service';
|
||||
@@ -18,6 +20,7 @@ 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 { AdminShowFormComponent } from './admin-show-form.component';
|
||||
import { AdminEventFormComponent } from './admin-event-form.component';
|
||||
import { AdminTierFormComponent } from './admin-tier-form.component';
|
||||
import { AdminStationFormComponent } from './admin-station-form.component';
|
||||
@@ -25,7 +28,7 @@ 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' | 'history' | 'team' | 'community';
|
||||
type TabKey = 'shows' | 'programs' | 'events' | 'tiers' | 'station' | 'history' | 'team' | 'community';
|
||||
|
||||
@Component({
|
||||
selector: 'app-admin',
|
||||
@@ -34,6 +37,7 @@ type TabKey = 'programs' | 'events' | 'tiers' | 'station' | 'history' | 'team' |
|
||||
CommonModule,
|
||||
AsyncPipe,
|
||||
FormsModule,
|
||||
AdminShowFormComponent,
|
||||
AdminProgramFormComponent,
|
||||
AdminEventFormComponent,
|
||||
AdminTierFormComponent,
|
||||
@@ -47,6 +51,7 @@ type TabKey = 'programs' | 'events' | 'tiers' | 'station' | 'history' | 'team' |
|
||||
})
|
||||
export class AdminComponent implements OnInit {
|
||||
private programService = inject(ProgramService);
|
||||
private showService = inject(ShowService);
|
||||
private eventService = inject(EventService);
|
||||
private tierService = inject(TierService);
|
||||
private stationConfigService = inject(StationConfigService);
|
||||
@@ -54,9 +59,10 @@ export class AdminComponent implements OnInit {
|
||||
private teamMemberService = inject(TeamMemberService);
|
||||
private communityHighlightService = inject(CommunityHighlightService);
|
||||
|
||||
activeTab = signal<TabKey>('programs');
|
||||
activeTab = signal<TabKey>('shows');
|
||||
|
||||
/** Item currently being edited (set by editXxx, cleared on save/close). */
|
||||
editingShow: Show | null = null;
|
||||
editingProgram: Program | null = null;
|
||||
editingEvent: Event | null = null;
|
||||
editingTier: Tier | null = null;
|
||||
@@ -65,6 +71,7 @@ export class AdminComponent implements OnInit {
|
||||
editingCommunity: CommunityHighlight | null = null;
|
||||
|
||||
/** BehaviorSubjects guarantee change detection via the async pipe — start empty, populated on load. */
|
||||
readonly shows$ = new BehaviorSubject<Show[]>([]);
|
||||
readonly programs$ = new BehaviorSubject<Program[]>([]);
|
||||
readonly events$ = new BehaviorSubject<Event[]>([]);
|
||||
readonly tiers$ = new BehaviorSubject<Tier[]>([]);
|
||||
@@ -73,6 +80,7 @@ export class AdminComponent implements OnInit {
|
||||
readonly teamMembers$ = new BehaviorSubject<TeamMember[]>([]);
|
||||
readonly communityHighlights$ = new BehaviorSubject<CommunityHighlight[]>([]);
|
||||
|
||||
showShowForm = false;
|
||||
showProgramForm = false;
|
||||
showEventForm = false;
|
||||
showTierForm = false;
|
||||
@@ -85,6 +93,11 @@ export class AdminComponent implements OnInit {
|
||||
this.loadAll();
|
||||
}
|
||||
|
||||
async reloadShows(): Promise<void> {
|
||||
const data = await firstValueFrom(this.showService.getShows());
|
||||
this.shows$.next(data);
|
||||
}
|
||||
|
||||
async reloadPrograms(): Promise<void> {
|
||||
const data = await firstValueFrom(this.programService.getPrograms());
|
||||
this.programs$.next(data);
|
||||
@@ -122,6 +135,7 @@ export class AdminComponent implements OnInit {
|
||||
|
||||
async loadAll(): Promise<void> {
|
||||
await Promise.all([
|
||||
this.reloadShows(),
|
||||
this.reloadPrograms(),
|
||||
this.reloadEvents(),
|
||||
this.reloadTiers(),
|
||||
@@ -132,6 +146,35 @@ export class AdminComponent implements OnInit {
|
||||
]);
|
||||
}
|
||||
|
||||
// ── Show CRUD ───────────────────────────────────────────
|
||||
|
||||
openShowForm(): void {
|
||||
this.editingShow = null;
|
||||
this.showShowForm = true;
|
||||
}
|
||||
|
||||
editShow(show: Show): void {
|
||||
this.editingShow = show;
|
||||
this.showShowForm = true;
|
||||
}
|
||||
|
||||
onShowSaved(): void {
|
||||
this.reloadShows();
|
||||
this.showShowForm = false;
|
||||
this.editingShow = null;
|
||||
}
|
||||
|
||||
onShowClosed(): void {
|
||||
this.showShowForm = false;
|
||||
this.editingShow = null;
|
||||
}
|
||||
|
||||
async deleteShow(id: number): Promise<void> {
|
||||
if (!confirm('Delete this show?')) return;
|
||||
await firstValueFrom(this.showService.deleteShow(id));
|
||||
await this.reloadShows();
|
||||
}
|
||||
|
||||
// ── Program CRUD ────────────────────────────────────────
|
||||
|
||||
openProgramForm(): void {
|
||||
|
||||
Reference in New Issue
Block a user