-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a8a446
commit f688f39
Showing
5 changed files
with
112 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Program } from './program'; | ||
|
||
export interface ProgramsResult { | ||
programs: Program[]; | ||
pagination: { | ||
page: number; | ||
size: number; | ||
totalhits: number; | ||
totalpages: number; | ||
nextpage: string; | ||
previouspage: string; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { EpisodesResult } from '../models/episodes-result'; | ||
import { SRBaseService } from './sr-base.service'; | ||
import { RightNowEpisodes } from '../models/right-now-episodes'; | ||
import { ScheduleResult } from '../models/schedule-result'; | ||
import { EpisodeResult } from '../models/episode'; | ||
import { SRApiService } from './srapi.service'; | ||
import { lastValueFrom } from 'rxjs'; | ||
import { EpisodesOverviewResult } from '../models/episodes-overview-result'; | ||
import { EpisodeGroupResult } from '../models/episode-group-result'; | ||
import { EpisodeOverview } from '../models/episode-overview'; | ||
import { ProgramsResult } from '../models/programs-result'; | ||
import { Program } from '../models/program'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class ProgramsService extends SRBaseService { | ||
constructor(private readonly http: HttpClient, private readonly srApiService: SRApiService) { | ||
super(); | ||
} | ||
|
||
async fetchPrograms(page: number, pageSize: number, categoryId: number): Promise<ProgramsResult> { | ||
let url = `${this.BaseUrl}programs/?${this.FormatParam}&page=${page}&size=${pageSize}`; | ||
if (categoryId) { | ||
url = `${url}&programcategoryid=${categoryId}`; | ||
} | ||
const res = await lastValueFrom(this.http.get<any>(`${url}`)); | ||
|
||
const progs: Program[] = res.programs.map((p: Program) => ({ | ||
name: p.name, | ||
id: p.id, | ||
fav: false, | ||
channel: { | ||
id: p?.channel.id, | ||
name: p?.channel.name | ||
}, | ||
programimage: p.programimagetemplate + SRApiService.DefaultImagePreset, | ||
description: p.description, | ||
programcategory: p.programcategory | ||
})); | ||
|
||
res.programs = progs; | ||
|
||
return res; | ||
} | ||
|
||
/* | ||
const progs: Program[] = programsRawResult.programs.map((p: Program) => ({ | ||
name: p.name, | ||
id: p.id, | ||
fav: false, | ||
channel: { | ||
id: p?.channel.id, | ||
name: p?.channel.name | ||
}, | ||
programimage: p.programimagetemplate + SRApiService.DefaultImagePreset, | ||
description: p.description, | ||
programcategory: p.programcategory | ||
})); | ||
this.updateProgramsWithFavs(progs); | ||
private async getAllPrograms(): Promise<any> { | ||
const params = `?${this.FormatParam}&page=1&size=10000`; | ||
let url = `${this.BaseUrl}programs/${params}`; | ||
return lastValueFrom(this.http.get<any>(`${url}`)); | ||
} | ||
*/ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters