diff --git a/src/Ombi/ClientApp/app/issues/issueDetails.component.ts b/src/Ombi/ClientApp/app/issues/issueDetails.component.ts index 641ca1cf4..d9c694933 100644 --- a/src/Ombi/ClientApp/app/issues/issueDetails.component.ts +++ b/src/Ombi/ClientApp/app/issues/issueDetails.component.ts @@ -6,6 +6,7 @@ import { ImageService, IssuesService, NotificationService, SettingsService } fro import { DomSanitizer } from "@angular/platform-browser"; import { IIssues, IIssuesChat, IIssueSettings, INewIssueComments, IssueStatus } from "../interfaces"; +import { PlatformLocation } from "@angular/common"; @Component({ templateUrl: "issueDetails.component.html", @@ -35,7 +36,8 @@ export class IssueDetailsComponent implements OnInit { private settingsService: SettingsService, private notificationService: NotificationService, private imageService: ImageService, - private sanitizer: DomSanitizer) { + private sanitizer: DomSanitizer, + private readonly platformLocation: PlatformLocation) { this.route.params .subscribe((params: any) => { this.issueId = parseInt(params.id); @@ -43,13 +45,13 @@ export class IssueDetailsComponent implements OnInit { this.isAdmin = this.authService.hasRole("Admin") || this.authService.hasRole("PowerUser"); this.settingsService.getIssueSettings().subscribe(x => this.settings = x); - this.settingsService.getOmbi().subscribe(x => { - if (x.baseUrl) { - this.defaultPoster = "../../.." + x.baseUrl + "/images/"; - } else { - this.defaultPoster = "../../../images/"; - } - }); + + const base = this.platformLocation.getBaseHrefFromDOM(); + if (base) { + this.defaultPoster = "../../.." + base + "/images/"; + } else { + this.defaultPoster = "../../../images/"; + } } public ngOnInit() { diff --git a/src/Ombi/ClientApp/app/requests/movierequests.component.ts b/src/Ombi/ClientApp/app/requests/movierequests.component.ts index b75339bb1..35688ec72 100644 --- a/src/Ombi/ClientApp/app/requests/movierequests.component.ts +++ b/src/Ombi/ClientApp/app/requests/movierequests.component.ts @@ -6,9 +6,10 @@ import "rxjs/add/operator/map"; import { Subject } from "rxjs/Subject"; import { AuthService } from "../auth/auth.service"; -import { NotificationService, RadarrService, RequestService, SettingsService } from "../services"; +import { NotificationService, RadarrService, RequestService } from "../services"; import { FilterType, IFilter, IIssueCategory, IMovieRequests, IPagenator, IRadarrProfile, IRadarrRootFolder } from "../interfaces"; +import { PlatformLocation } from "@angular/common"; @Component({ selector: "movie-requests", @@ -49,7 +50,7 @@ export class MovieRequestsComponent implements OnInit { private notificationService: NotificationService, private radarrService: RadarrService, private sanitizer: DomSanitizer, - private settingsService: SettingsService) { + private readonly platformLocation: PlatformLocation) { this.searchChanged .debounceTime(600) // Wait Xms after the last event before emitting last event .distinctUntilChanged() // only emit if value is different from previous value @@ -65,12 +66,11 @@ export class MovieRequestsComponent implements OnInit { this.movieRequests = m; }); }); - this.defaultPoster = "../../../images/default_movie_poster.png" - this.settingsService.getOmbi().subscribe(x => { - if (x.baseUrl) { - this.defaultPoster = "../../.." + x.baseUrl + "/images/default_movie_poster.png"; - } - }); + this.defaultPoster = "../../../images/default_movie_poster.png"; + const base = this.platformLocation.getBaseHrefFromDOM(); + if (base) { + this.defaultPoster = "../../.." + base + "/images/default_movie_poster.png"; + } } public ngOnInit() { diff --git a/src/Ombi/ClientApp/app/requests/tvrequests.component.ts b/src/Ombi/ClientApp/app/requests/tvrequests.component.ts index a7c010458..c84be2682 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequests.component.ts +++ b/src/Ombi/ClientApp/app/requests/tvrequests.component.ts @@ -11,10 +11,11 @@ import "rxjs/add/operator/distinctUntilChanged"; import "rxjs/add/operator/map"; import { AuthService } from "../auth/auth.service"; -import { NotificationService, RequestService, SettingsService, SonarrService } from "../services"; +import { NotificationService, RequestService, SonarrService } from "../services"; import { TreeNode } from "primeng/primeng"; import { IIssueCategory, IPagenator, ISonarrProfile, ISonarrRootFolder, ITvRequests } from "../interfaces"; +import { PlatformLocation } from "@angular/common"; @Component({ selector: "tv-requests", @@ -51,7 +52,7 @@ export class TvRequestsComponent implements OnInit { private imageService: ImageService, private sonarrService: SonarrService, private notificationService: NotificationService, - private settingsService: SettingsService) { + private readonly platformLocation: PlatformLocation) { this.searchChanged .debounceTime(600) // Wait Xms after the last event before emitting last event .distinctUntilChanged() // only emit if value is different from previous value @@ -68,12 +69,11 @@ export class TvRequestsComponent implements OnInit { this.tvRequests.forEach((val) => this.setOverride(val.data)); }); }); - this.defaultPoster = "../../../images/default_tv_poster.png" - this.settingsService.getOmbi().subscribe(x => { - if (x.baseUrl) { - this.defaultPoster = "../../.." + x.baseUrl + "/images/default_tv_poster.png"; - } - }); + this.defaultPoster = "../../../images/default_tv_poster.png"; + const base = this.platformLocation.getBaseHrefFromDOM(); + if (base) { + this.defaultPoster = "../../.." + base + "/images/default_tv_poster.png"; + } } public openClosestTab(el: any) { diff --git a/src/Ombi/ClientApp/app/search/moviesearch.component.ts b/src/Ombi/ClientApp/app/search/moviesearch.component.ts index 292eb7bb1..41fae6f2f 100644 --- a/src/Ombi/ClientApp/app/search/moviesearch.component.ts +++ b/src/Ombi/ClientApp/app/search/moviesearch.component.ts @@ -8,7 +8,8 @@ import { Subject } from "rxjs/Subject"; import { AuthService } from "../auth/auth.service"; import { IIssueCategory, IRequestEngineResult, ISearchMovieResult } from "../interfaces"; -import { NotificationService, RequestService, SearchService, SettingsService } from "../services"; +import { NotificationService, RequestService, SearchService } from "../services"; +import { PlatformLocation } from "@angular/common"; @Component({ selector: "movie-search", @@ -33,8 +34,8 @@ export class MovieSearchComponent implements OnInit { constructor(private searchService: SearchService, private requestService: RequestService, private notificationService: NotificationService, private authService: AuthService, - private readonly translate: TranslateService, private sanitizer: DomSanitizer, - private settingsService: SettingsService) { + private readonly translate: TranslateService, private sanitizer: DomSanitizer, + private readonly platformLocation: PlatformLocation) { this.searchChanged .debounceTime(600) // Wait Xms after the last event before emitting last event @@ -54,12 +55,11 @@ export class MovieSearchComponent implements OnInit { this.getExtraInfo(); }); }); - this.defaultPoster = "../../../images/default_movie_poster.png" - this.settingsService.getOmbi().subscribe(x => { - if (x.baseUrl) { - this.defaultPoster = "../../.." + x.baseUrl + "/images/default_movie_poster.png"; - } - }); + this.defaultPoster = "../../../images/default_movie_poster.png"; + const base = this.platformLocation.getBaseHrefFromDOM(); + if (base) { + this.defaultPoster = "../../.." + base + "/images/default_movie_poster.png"; + } } public ngOnInit() { diff --git a/src/Ombi/ClientApp/app/search/tvsearch.component.ts b/src/Ombi/ClientApp/app/search/tvsearch.component.ts index 770ff483d..051dc5239 100644 --- a/src/Ombi/ClientApp/app/search/tvsearch.component.ts +++ b/src/Ombi/ClientApp/app/search/tvsearch.component.ts @@ -3,11 +3,12 @@ import { DomSanitizer } from "@angular/platform-browser"; import { Subject } from "rxjs/Subject"; import { AuthService } from "../auth/auth.service"; -import { ImageService, NotificationService, RequestService, SearchService, SettingsService } from "../services"; +import { ImageService, NotificationService, RequestService, SearchService } from "../services"; import { TreeNode } from "primeng/primeng"; import { IRequestEngineResult } from "../interfaces"; import { IIssueCategory, ISearchTvResult, ISeasonsViewModel, ITvRequestViewModel } from "../interfaces"; +import { PlatformLocation } from "@angular/common"; @Component({ selector: "tv-search", @@ -34,7 +35,7 @@ export class TvSearchComponent implements OnInit { constructor(private searchService: SearchService, private requestService: RequestService, private notificationService: NotificationService, private authService: AuthService, private imageService: ImageService, private sanitizer: DomSanitizer, - private settingsService: SettingsService) { + private readonly platformLocation: PlatformLocation) { this.searchChanged .debounceTime(600) // Wait Xms after the last event before emitting last event @@ -52,12 +53,11 @@ export class TvSearchComponent implements OnInit { this.getExtraInfo(); }); }); - this.defaultPoster = "../../../images/default_tv_poster.png" - this.settingsService.getOmbi().subscribe(x => { - if (x.baseUrl) { - this.defaultPoster = "../../.." + x.baseUrl + "/images/default_tv_poster.png"; - } - }); + this.defaultPoster = "../../../images/default_tv_poster.png"; + const base = this.platformLocation.getBaseHrefFromDOM(); + if(base) { + this.defaultPoster = "../../.." + base + "/images/default_tv_poster.png"; + } } public openClosestTab(el: any) { el.preventDefault();