diff --git a/frontend/src/app/core/services/collection.service.ts b/frontend/src/app/core/services/collection.service.ts index b7c9eda..3f2b4be 100644 --- a/frontend/src/app/core/services/collection.service.ts +++ b/frontend/src/app/core/services/collection.service.ts @@ -4,16 +4,18 @@ import { Observable } from 'rxjs'; import { Collection } from '../../shared/models/collection.model'; import { CollectionEntry } from '../../shared/models/collection-entry.model'; import { Entry } from '../../shared/models/entry.model'; -import { environment } from '../../../environments/environment.prod'; +import { ConfigService } from './config.service'; @Injectable({ providedIn: 'root', }) export class CollectionService { - private backend_apiUrl = environment.API_URL; + private backend_apiUrl; private apiAction = 'collections'; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient, private configService: ConfigService) { + this.backend_apiUrl = this.configService.getBackendApiUrl(); + } // get all collections getCollections(): Observable { diff --git a/frontend/src/app/core/services/custom-media.service.ts b/frontend/src/app/core/services/custom-media.service.ts index d4be87b..6e2e777 100644 --- a/frontend/src/app/core/services/custom-media.service.ts +++ b/frontend/src/app/core/services/custom-media.service.ts @@ -1,17 +1,19 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; -import { environment } from '../../../environments/environment.prod'; import { Observable } from 'rxjs'; import { Media } from '../../shared/models/media.model'; +import { ConfigService } from './config.service'; @Injectable({ providedIn: 'root', }) export class CustomMediaService { - private backend_apiUrl = environment.API_URL; + private backend_apiUrl; private apiAction = 'media'; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient, private configService: ConfigService) { + this.backend_apiUrl = this.configService.getBackendApiUrl(); + } fetchCustomMedia(): Observable { return this.http.get(`${this.backend_apiUrl}/${this.apiAction}`); diff --git a/frontend/src/app/core/services/entry-ratings.service.ts b/frontend/src/app/core/services/entry-ratings.service.ts index 6b8bd90..f918a13 100644 --- a/frontend/src/app/core/services/entry-ratings.service.ts +++ b/frontend/src/app/core/services/entry-ratings.service.ts @@ -1,16 +1,18 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { EntryRating } from '../../shared/models/entry-rating.model'; -import { environment } from '../../../environments/environment.prod'; +import { ConfigService } from './config.service'; @Injectable({ providedIn: 'root', }) export class EntryRatingsService { - private backend_apiUrl = environment.API_URL; + private backend_apiUrl; private apiAction = 'entry-ratings'; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient, private configService: ConfigService) { + this.backend_apiUrl = this.configService.getBackendApiUrl(); + } updateEntryRatings(entryRatings: EntryRating) { return this.http.put( diff --git a/frontend/src/app/core/services/entry-seen.service.ts b/frontend/src/app/core/services/entry-seen.service.ts index c7849c7..61405dc 100644 --- a/frontend/src/app/core/services/entry-seen.service.ts +++ b/frontend/src/app/core/services/entry-seen.service.ts @@ -1,16 +1,18 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { EntrySeen } from '../../shared/models/entry-seen.model'; -import { environment } from '../../../environments/environment.prod'; +import { ConfigService } from './config.service'; @Injectable({ providedIn: 'root', }) export class EntrySeenService { - private backend_apiUrl = environment.API_URL; + private backend_apiUrl; private apiAction = 'entry-seen'; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient, private configService: ConfigService) { + this.backend_apiUrl = this.configService.getBackendApiUrl(); + } createEntrySeen(entryId: string, dateSeen: Date, seenWith: string) { return this.http.post( @@ -45,5 +47,4 @@ export class EntrySeenService { `${this.backend_apiUrl}/${this.apiAction}/${id}` ); } - } diff --git a/frontend/src/app/core/services/entry.service.ts b/frontend/src/app/core/services/entry.service.ts index 6d9ef18..c77c8de 100644 --- a/frontend/src/app/core/services/entry.service.ts +++ b/frontend/src/app/core/services/entry.service.ts @@ -4,21 +4,19 @@ import { Observable, map } from 'rxjs'; import { Entry } from '../../shared/models/entry.model'; import { EntryId } from '../../shared/models/entryId.model'; import { EntryRating } from '../../shared/models/entry-rating.model'; -import { environment } from '../../../environments/environment.prod'; import { Media } from '../../shared/models/media.model'; -import { LibraryService } from './library.service'; +import { ConfigService } from './config.service'; @Injectable({ providedIn: 'root', }) export class EntryService { - private backend_apiUrl = environment.API_URL; + private backend_apiUrl; private apiAction = 'entries'; - constructor( - private http: HttpClient, - private libraryService: LibraryService - ) {} + constructor(private http: HttpClient, private configService: ConfigService) { + this.backend_apiUrl = this.configService.getBackendApiUrl(); + } // get entries getEntries(): Observable { diff --git a/frontend/src/app/core/services/episode-seen.service.ts b/frontend/src/app/core/services/episode-seen.service.ts index 5f9c55d..e24008f 100644 --- a/frontend/src/app/core/services/episode-seen.service.ts +++ b/frontend/src/app/core/services/episode-seen.service.ts @@ -2,16 +2,18 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { EpisodeSeen } from '../../shared/models/episode-seen.model'; import { EpisodeSeenDto } from '../../shared/models/dtos/episode-seen.dto'; -import { environment } from '../../../environments/environment.prod'; +import { ConfigService } from './config.service'; @Injectable({ providedIn: 'root', }) export class EpisodeSeenService { - private backend_apiUrl = environment.API_URL; + private backend_apiUrl; private apiAction = 'episode-seen'; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient, private configService: ConfigService) { + this.backend_apiUrl = this.configService.getBackendApiUrl(); + } createEpisodeSeen( entryId: number, @@ -59,5 +61,4 @@ export class EpisodeSeenService { `${this.backend_apiUrl}/${this.apiAction}/${id}` ); } - } diff --git a/frontend/src/app/core/services/episode.service.ts b/frontend/src/app/core/services/episode.service.ts index 6c15138..5762366 100644 --- a/frontend/src/app/core/services/episode.service.ts +++ b/frontend/src/app/core/services/episode.service.ts @@ -1,17 +1,19 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; -import { environment } from '../../../environments/environment.prod'; import { EpisodeDTO } from '../../shared/models/dtos/episode.dto'; import { Observable } from 'rxjs'; +import { ConfigService } from './config.service'; @Injectable({ providedIn: 'root', }) export class EpisodeService { - private backend_apiUrl = environment.API_URL; + private backend_apiUrl; private apiAction = 'episodes'; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient, private configService: ConfigService) { + this.backend_apiUrl = this.configService.getBackendApiUrl(); + } getMonthEpisodes( startDate: string, diff --git a/frontend/src/app/core/services/history.service.ts b/frontend/src/app/core/services/history.service.ts index dbd06ed..7357c00 100644 --- a/frontend/src/app/core/services/history.service.ts +++ b/frontend/src/app/core/services/history.service.ts @@ -1,17 +1,19 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; -import { environment } from '../../../environments/environment.prod'; import { SearchItem } from '../../shared/models/search-item.model'; import { Observable, of } from 'rxjs'; +import { ConfigService } from './config.service'; @Injectable({ providedIn: 'root', }) export class HistoryService { - private backend_apiUrl = environment.API_URL; + private backend_apiUrl; private apiAction = 'history'; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient, private configService: ConfigService) { + this.backend_apiUrl = this.configService.getBackendApiUrl(); + } getSearchHistory(): Observable { return of([] as SearchItem[]); diff --git a/frontend/src/app/core/services/importer.service.ts b/frontend/src/app/core/services/importer.service.ts index 56e18d8..d736225 100644 --- a/frontend/src/app/core/services/importer.service.ts +++ b/frontend/src/app/core/services/importer.service.ts @@ -2,16 +2,18 @@ import { Injectable } from '@angular/core'; import { MovieDateSeen } from '../../shared/models/dtos/movie-dateSeen.model'; import { HttpClient } from '@angular/common/http'; import { Entry } from '../../shared/models/entry.model'; -import { environment } from '../../../environments/environment.prod'; +import { ConfigService } from './config.service'; @Injectable({ providedIn: 'root', }) export class ImporterService { - private backend_apiUrl = environment.API_URL; + private backend_apiUrl; private apiAction = 'entries'; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient, private configService: ConfigService) { + this.backend_apiUrl = this.configService.getBackendApiUrl(); + } bulkAddEntries(values: any) { return this.http.post( diff --git a/frontend/src/app/core/services/library.service.ts b/frontend/src/app/core/services/library.service.ts index 28c2226..26b2804 100644 --- a/frontend/src/app/core/services/library.service.ts +++ b/frontend/src/app/core/services/library.service.ts @@ -3,7 +3,7 @@ import { HttpClient, HttpParams } from '@angular/common/http'; import { Observable, throwError, map, of, BehaviorSubject } from 'rxjs'; import { catchError, tap } from 'rxjs/operators'; import { Entry } from '../../shared/models/entry.model'; -import { environment } from '../../../environments/environment.prod'; +import { ConfigService } from './config.service'; @Injectable({ providedIn: 'root', @@ -14,13 +14,11 @@ export class LibraryService implements OnInit { >([]); public entries$: Observable = this.entriesSubject.asObservable(); - // private oldEntries: Entry[] = []; - // private entriesLoaded = false; - - private backend_apiUrl = environment.API_URL; + private backend_apiUrl; private apiAction = 'entries'; - constructor(private http: HttpClient) { + constructor(private http: HttpClient, private configService: ConfigService) { + this.backend_apiUrl = this.configService.getBackendApiUrl(); this.fetchAllEntries().subscribe(() => { console.log( `Library Service: Loaded ${ @@ -119,9 +117,7 @@ export class LibraryService implements OnInit { public setEntry(entry: Entry) { const currentEntries = this.entriesSubject.getValue(); - let updatedEntries = currentEntries.filter( - (e) => e.id != entry.id - ); + let updatedEntries = currentEntries.filter((e) => e.id != entry.id); updatedEntries.push(entry); @@ -139,36 +135,4 @@ export class LibraryService implements OnInit { }) ); } - - // private mapMovieToEntry(movie: any): Entry { - // const entryId = { - // tmdb_id: movie.entryId.tmdb_id, - // } as EntryId; - // const entryRating = { - // tmdb_rating: movie.entryRating.tmdb_rating, - // } as EntryRating; - - // var is_tvseries = movie.release_date == null ? true : false; - // var release_date = movie.release_date || movie.first_air_date; - - // return { - // entryId: entryId, - // entryRating: entryRating, - - // title: movie.title, - // original_title: movie.original_title, - // release_date: release_date, - - // storyline: movie.storyline, - - // watchlist: movie.storyline, - // favorit: false, - // hidden: false, - - // is_tvseries: is_tvseries, - // status: movie.status, - - // poster_path: movie.poster_path, - // } as Entry; - // } } diff --git a/frontend/src/app/core/services/maintenance.service.ts b/frontend/src/app/core/services/maintenance.service.ts index c50cd70..89b73b6 100644 --- a/frontend/src/app/core/services/maintenance.service.ts +++ b/frontend/src/app/core/services/maintenance.service.ts @@ -1,16 +1,18 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; -import { environment } from '../../../environments/environment.prod'; import { MaintenanceResult } from '../../shared/models/maintenance-result.model'; +import { ConfigService } from './config.service'; @Injectable({ providedIn: 'root', }) export class MaintenanceService { - private backend_apiUrl = environment.API_URL; + private backend_apiUrl; private apiAction = 'maintenance'; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient, private configService: ConfigService) { + this.backend_apiUrl = this.configService.getBackendApiUrl(); + } getOrphanFiles() { return this.http.get( diff --git a/frontend/src/app/core/services/ping.service.ts b/frontend/src/app/core/services/ping.service.ts index 1b80879..a6782c0 100644 --- a/frontend/src/app/core/services/ping.service.ts +++ b/frontend/src/app/core/services/ping.service.ts @@ -1,19 +1,19 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; -import { environment } from '../../../environments/environment.prod'; +import { ConfigService } from './config.service'; @Injectable({ providedIn: 'root', }) export class PingService { - private backend_apiUrl = environment.API_URL; + private backend_apiUrl; private apiAction = 'ping'; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient, private configService: ConfigService) { + this.backend_apiUrl = this.configService.getBackendApiUrl(); + } ping() { - return this.http.get( - `${this.backend_apiUrl}/${this.apiAction}` - ); + return this.http.get(`${this.backend_apiUrl}/${this.apiAction}`); } } diff --git a/frontend/src/app/core/services/season.service.ts b/frontend/src/app/core/services/season.service.ts index b5f9d0e..844b064 100644 --- a/frontend/src/app/core/services/season.service.ts +++ b/frontend/src/app/core/services/season.service.ts @@ -2,16 +2,18 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Season } from '../../shared/models/season.model'; import { Episode } from '../../shared/models/episode.models'; -import { environment } from '../../../environments/environment.prod'; +import { ConfigService } from './config.service'; @Injectable({ providedIn: 'root', }) export class SeasonService { - private backend_apiUrl = environment.API_URL; + private backend_apiUrl ; private apiAction = 'seasons'; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient, private configService: ConfigService) { + this.backend_apiUrl = this.configService.getBackendApiUrl(); + } // get season by id getSeasonById(id: number) { diff --git a/frontend/src/app/core/services/settings.service.ts b/frontend/src/app/core/services/settings.service.ts index d115295..08cf614 100644 --- a/frontend/src/app/core/services/settings.service.ts +++ b/frontend/src/app/core/services/settings.service.ts @@ -1,16 +1,18 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; -import { environment } from '../../../environments/environment.prod'; import { Settings } from '../../shared/models/settings.model'; +import { ConfigService } from './config.service'; @Injectable({ providedIn: 'root', }) export class SettingsService { - private backend_apiUrl = environment.API_URL; + private backend_apiUrl; private apiAction = 'settings'; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient, private configService: ConfigService) { + this.backend_apiUrl = this.configService.getBackendApiUrl(); + } getSettings() { return this.http.get(`${this.backend_apiUrl}/${this.apiAction}`); diff --git a/frontend/src/app/core/services/statistics.service.ts b/frontend/src/app/core/services/statistics.service.ts index a8c7335..49ae5d3 100644 --- a/frontend/src/app/core/services/statistics.service.ts +++ b/frontend/src/app/core/services/statistics.service.ts @@ -1,15 +1,17 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; -import { environment } from '../../../environments/environment.prod'; +import { ConfigService } from './config.service'; @Injectable({ providedIn: 'root', }) export class StatisticsService { - private backend_apiUrl = environment.API_URL; + private backend_apiUrl; private apiAction = 'statistics'; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient, private configService: ConfigService) { + this.backend_apiUrl = this.configService.getBackendApiUrl(); + } fetchYearlyWatchCount(year: number) { return this.http.get( @@ -28,5 +30,4 @@ export class StatisticsService { `${this.backend_apiUrl}/${this.apiAction}/watch-time/year/${year}` ); } - } diff --git a/frontend/src/app/core/services/tmdb.service.ts b/frontend/src/app/core/services/tmdb.service.ts index 33d08bc..1fb2134 100644 --- a/frontend/src/app/core/services/tmdb.service.ts +++ b/frontend/src/app/core/services/tmdb.service.ts @@ -4,23 +4,21 @@ import { Observable, filter, from, map, of, switchMap, toArray } from 'rxjs'; import { Entry } from '../../shared/models/entry.model'; import { EntryId } from '../../shared/models/entryId.model'; import { EntryRating } from '../../shared/models/entry-rating.model'; -import { environment } from '../../../environments/environment.prod'; -import { LibraryService } from './library.service'; +import { ConfigService } from './config.service'; @Injectable({ providedIn: 'root', }) export class TmdbService { + private tmdb_apiUrl; + private tmdb_apiKey; + cach: Record = {}; - constructor( - private http: HttpClient, - private libraryService: LibraryService - ) {} - - // private apiUrl = environment.apiBaseUrl; - private tmdb_apiUrl = environment.TMDB_API_URL; - private tmdb_apiKey = environment.TMDB_API_KEY; + constructor(private http: HttpClient, private configService: ConfigService) { + this.tmdb_apiUrl = this.configService.getTmdbApiUrl(); + this.tmdb_apiKey = this.configService.getTmdbApiKey(); + } fetchdata(endPoint: string): Observable { if (this.cach[endPoint]) {