From 61008262e0f427c46f59f126890c4b396fc55222 Mon Sep 17 00:00:00 2001 From: Peter Bennett Date: Fri, 17 May 2024 09:25:24 -0400 Subject: [PATCH] web app: Support for URL parameters in Program Guide Supports parameters in the URL to invoke the guide at a particular point, and also to open the schedule dialog for a particular channel and time. Fixes #888 --- .../channelicon/channelicon.component.html | 3 +- .../src/app/guide/guide.component.html | 10 ++- .../backend/src/app/guide/guide.component.ts | 64 +++++++++++++++++-- 3 files changed, 68 insertions(+), 9 deletions(-) diff --git a/mythtv/html/backend/src/app/guide/components/channelicon/channelicon.component.html b/mythtv/html/backend/src/app/guide/components/channelicon/channelicon.component.html index 44abe96fea2..4ababb3ef0a 100644 --- a/mythtv/html/backend/src/app/guide/components/channelicon/channelicon.component.html +++ b/mythtv/html/backend/src/app/guide/components/channelicon/channelicon.component.html @@ -1,4 +1,5 @@ -
+
diff --git a/mythtv/html/backend/src/app/guide/guide.component.html b/mythtv/html/backend/src/app/guide/guide.component.html index 908b7599f46..596dba1ec08 100644 --- a/mythtv/html/backend/src/app/guide/guide.component.html +++ b/mythtv/html/backend/src/app/guide/guide.component.html @@ -12,8 +12,8 @@

{{ 'dashboard.programguide' | translate }}

+ [clearButtonStyleClass]="'hidden'" pTooltip="{{ 'dashboard.guide.calendar_tip' | translate }}" + tooltipPosition="top">
@@ -64,6 +64,12 @@

{{ 'dashboard.programguide' | translate }}

+
+ + + +
diff --git a/mythtv/html/backend/src/app/guide/guide.component.ts b/mythtv/html/backend/src/app/guide/guide.component.ts index 4bfd91bdfad..1431bf5902d 100644 --- a/mythtv/html/backend/src/app/guide/guide.component.ts +++ b/mythtv/html/backend/src/app/guide/guide.component.ts @@ -8,6 +8,7 @@ import { ScheduleLink, SchedulerSummary } from '../schedule/schedule.component'; import { ScheduleOrProgram } from '../services/interfaces/program.interface'; import { GetProgramListRequest } from '../services/interfaces/guide.interface'; import { ChannelGroup } from '../services/interfaces/channelgroup.interface'; +import { ActivatedRoute } from '@angular/router'; @Component({ selector: 'app-guide', @@ -47,35 +48,68 @@ export class GuideComponent implements OnInit, SchedulerSummary { displayType = this.GRID; searchValue = ''; showLegend = false; + startChanid?: number; + startTime?: Date; + startSchedule?: boolean; + startGroup?: number; - constructor(private guideService: GuideService, + constructor(private guideService: GuideService, private route: ActivatedRoute, private translate: TranslateService) { this.translate.onLangChange.subscribe((event: TranslationChangeEvent) => { console.log("Event: language change, new language (" + event.lang + ")"); this.switchLanguage(event.lang); - this.fetchData(); + // this.fetchData(); }) } ngOnInit(): void { - this.fetchData(); + this.startChanid = this.route.snapshot.queryParams.Chanid; + let reqDate; + reqDate = new Date(this.route.snapshot.queryParams.StartTime); + if (Number.isNaN(reqDate.valueOf())) { + reqDate = new Date(Number(this.route.snapshot.queryParams.StartTime)); + } + if (Number.isNaN(reqDate.valueOf())) + reqDate = undefined; + if (reqDate) + this.startTime = reqDate; + else + this.startTime = undefined; + // if (this.startChanid) + // this.channelGroup = this.allGroup; + this.startSchedule = this.route.snapshot.queryParams.Schedule; + this.fetchData(this.startTime); } switchLanguage(language: string): void { this.translate.use(language); - // this.setDateFormat(); } fetchData(reqDate?: Date): void { if (this.channelGroups.length == 0) { this.guideService.GetChannelGroupList(false).subscribe( data => { - console.log(data) this.channelGroups = data.ChannelGroupList.ChannelGroups; this.channelGroups.unshift(this.allGroup); + let wantedGroup = localStorage.getItem("ChannelGroup"); + if (!wantedGroup) + wantedGroup = this.allGroup.Name; + if (this.route.snapshot.queryParams.ChannelGroup) + wantedGroup = this.route.snapshot.queryParams.ChannelGroup; + let group = this.channelGroups.find((entry) => + entry.Name == wantedGroup); + if (group) + this.channelGroup = group; + localStorage.setItem("ChannelGroup",this.channelGroup.Name); + this.fetchGuide(reqDate); }); - }; + } + else + this.fetchGuide(reqDate); + } + + fetchGuide(reqDate?: Date) { this.guideService.GetProgramGuide(reqDate, this.channelGroup.GroupId).subscribe(data => { this.m_programGuide = data; this.m_startDate = new Date(data.ProgramGuide.StartTime); @@ -86,6 +120,23 @@ export class GuideComponent implements OnInit, SchedulerSummary { this.loaded = true; this.refreshing = false; this.timeChange = false; + if (this.startChanid) { + setTimeout(() => { + const element = document.getElementById('Chan' + this.startChanid); + element?.scrollIntoView(); + if (this.startSchedule) { + let chan = this.m_programGuide.ProgramGuide.Channels + .find((entry) => entry.ChanId == this.startChanid); + if (chan) { + let prog = chan.Programs.find((entry) => + this.startTime?.valueOf() == new Date(entry.StartTime).valueOf()); + if (prog) + this.inter.sched?.open(prog, chan); + } + } + this.startChanid = undefined; + }, 100); + } }); } @@ -149,6 +200,7 @@ export class GuideComponent implements OnInit, SchedulerSummary { refresh(): void { this.refreshing = true; + localStorage.setItem("ChannelGroup",this.channelGroup.Name); switch (this.displayType) { case this.GRID: if (this.m_startDate) {