Skip to content

Commit

Permalink
experiment #2 with base urls
Browse files Browse the repository at this point in the history
  • Loading branch information
tidusjar committed Mar 22, 2019
1 parent 9fcc312 commit ea58971
Show file tree
Hide file tree
Showing 41 changed files with 183 additions and 157 deletions.
9 changes: 7 additions & 2 deletions src/Ombi/ClientApp/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { LayoutModule } from '@angular/cdk/layout';
import { SearchV2Service } from "./services/searchV2.service";
import { NavSearchComponent } from "./my-nav/nav-search.component";
import { OverlayModule } from "@angular/cdk/overlay";
import { getBaseLocation } from "./shared/functions/common-functions";

const routes: Routes = [
{ path: "*", component: PageNotFoundComponent },
Expand All @@ -77,8 +78,8 @@ const routes: Routes = [
];

// AoT requires an exported function for factories
export function HttpLoaderFactory(http: HttpClient, platformLocation: PlatformLocation) {
const base = platformLocation.getBaseHrefFromDOM();
export function HttpLoaderFactory(http: HttpClient) {
const base = getBaseLocation();
const version = Math.floor(Math.random() * 999999999);
if (base.length > 1) {
return new TranslateHttpLoader(http, `${base}/translations/`, `.json?v=${version}`);
Expand Down Expand Up @@ -173,6 +174,10 @@ export function JwtTokenGetter() {
SearchService,
SearchV2Service,
MessageService,
{
provide: APP_BASE_HREF,
useFactory: getBaseLocation
}
],
bootstrap: [AppComponent],
})
Expand Down
8 changes: 4 additions & 4 deletions src/Ombi/ClientApp/src/app/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PlatformLocation } from "@angular/common";
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { Injectable, Inject } from "@angular/core";
import { JwtHelperService } from "@auth0/angular-jwt";
import { Observable } from "rxjs";

Expand All @@ -10,8 +10,8 @@ import { ILocalUser, IUserLogin } from "./IUserLogin";
@Injectable()
export class AuthService extends ServiceHelpers {

constructor(http: HttpClient, public platformLocation: PlatformLocation, private jwtHelperService: JwtHelperService) {
super(http, "/api/v1/token", platformLocation);
constructor(http: HttpClient, @Inject(APP_BASE_HREF) href:string, private jwtHelperService: JwtHelperService) {
super(http, "/api/v1/token", href);
}

public login(login: IUserLogin): Observable<any> {
Expand Down
8 changes: 4 additions & 4 deletions src/Ombi/ClientApp/src/app/issues/issueDetails.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlatformLocation } from "@angular/common";
import { Component, OnInit } from "@angular/core";
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
import { Component, OnInit, Inject } from "@angular/core";
import { ActivatedRoute } from "@angular/router";

import { AuthService } from "../auth/auth.service";
Expand Down Expand Up @@ -37,7 +37,7 @@ export class IssueDetailsComponent implements OnInit {
private notificationService: NotificationService,
private imageService: ImageService,
private sanitizer: DomSanitizer,
private readonly platformLocation: PlatformLocation) {
@Inject(APP_BASE_HREF) href:string) {
this.route.params
.subscribe((params: any) => {
this.issueId = parseInt(params.id);
Expand All @@ -46,7 +46,7 @@ export class IssueDetailsComponent implements OnInit {
this.isAdmin = this.authService.hasRole("Admin") || this.authService.hasRole("PowerUser");
this.settingsService.getIssueSettings().subscribe(x => this.settings = x);

const base = this.platformLocation.getBaseHrefFromDOM();
const base = href;
if (base) {
this.defaultPoster = "../../.." + base + "/images/";
} else {
Expand Down
10 changes: 6 additions & 4 deletions src/Ombi/ClientApp/src/app/landingpage/landingpage.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlatformLocation } from "@angular/common";
import { Component, OnDestroy, OnInit } from "@angular/core";
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
import { Component, OnDestroy, OnInit, Inject } from "@angular/core";

import { IMediaServerStatus } from "../interfaces";
import { ICustomizationSettings, ILandingPageSettings } from "../interfaces";
Expand All @@ -25,9 +25,11 @@ export class LandingPageComponent implements OnDestroy, OnInit {
public baseUrl: string;
private timer: any;

private href: string;

constructor(private settingsService: SettingsService,
private images: ImageService, private sanitizer: DomSanitizer, private landingPageService: LandingPageService,
private location: PlatformLocation) { }
@Inject(APP_BASE_HREF) href :string) { this.href = href }

public ngOnInit() {
this.settingsService.getCustomization().subscribe(x => this.customizationSettings = x);
Expand All @@ -39,7 +41,7 @@ export class LandingPageComponent implements OnDestroy, OnInit {
this.cycleBackground();
}, 15000);

const base = this.location.getBaseHrefFromDOM();
const base = this.href;
if (base.length > 1) {
this.baseUrl = base;
}
Expand Down
12 changes: 7 additions & 5 deletions src/Ombi/ClientApp/src/app/login/login.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Component, OnDestroy, OnInit } from "@angular/core";
import { Component, OnDestroy, OnInit, Inject } from "@angular/core";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { ActivatedRoute, Router } from "@angular/router";
import { TranslateService } from "@ngx-translate/core";

import { PlatformLocation } from "@angular/common";
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
import { AuthService } from "../auth/auth.service";
import { IAuthenticationSettings, ICustomizationSettings } from "../interfaces";
import { NotificationService, PlexTvService } from "../services";
Expand Down Expand Up @@ -45,11 +45,13 @@ export class LoginComponent implements OnDestroy, OnInit {

private errorBody: string;
private errorValidation: string;
private href: string;

constructor(private authService: AuthService, private router: Router, private notify: NotificationService, private status: StatusService,
private fb: FormBuilder, private settingsService: SettingsService, private images: ImageService, private sanitizer: DomSanitizer,
private route: ActivatedRoute, private location: PlatformLocation, private translate: TranslateService, private plexTv: PlexTvService) {
this.route.params
private route: ActivatedRoute, @Inject(APP_BASE_HREF) href:string, private translate: TranslateService, private plexTv: PlexTvService) {
this.href = href;
this.route.params
.subscribe((params: any) => {
this.landingFlag = params.landing;
if (!this.landingFlag) {
Expand Down Expand Up @@ -89,7 +91,7 @@ export class LoginComponent implements OnDestroy, OnInit {
this.cycleBackground();
}, 15000);

const base = this.location.getBaseHrefFromDOM();
const base = this.href;
if (base.length > 1) {
this.baseUrl = base;
}
Expand Down
10 changes: 6 additions & 4 deletions src/Ombi/ClientApp/src/app/login/resetpassword.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlatformLocation } from "@angular/common";
import { Component, OnInit } from "@angular/core";
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
import { Component, OnInit, Inject } from "@angular/core";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { DomSanitizer } from "@angular/platform-browser";

Expand All @@ -17,10 +17,12 @@ export class ResetPasswordComponent implements OnInit {
public emailSettingsEnabled: boolean;
public baseUrl: string;
public background: any;
private href: string;

constructor(private identityService: IdentityService, private notify: NotificationService,
private fb: FormBuilder, private settingsService: SettingsService, private location: PlatformLocation,
private fb: FormBuilder, private settingsService: SettingsService, @Inject(APP_BASE_HREF) href:string,
private images: ImageService, private sanitizer: DomSanitizer) {
this.href = href;
this.form = this.fb.group({
email: ["", [Validators.required]],
});
Expand All @@ -30,7 +32,7 @@ export class ResetPasswordComponent implements OnInit {
this.images.getRandomBackground().subscribe(x => {
this.background = this.sanitizer.bypassSecurityTrustStyle("linear-gradient(-10deg, transparent 20%, rgba(0,0,0,0.7) 20.0%, rgba(0,0,0,0.7) 80.0%, transparent 80%),url(" + x.url + ")");
});
const base = this.location.getBaseHrefFromDOM();
const base = this.href;
if (base.length > 1) {
this.baseUrl = base;
}
Expand Down
10 changes: 6 additions & 4 deletions src/Ombi/ClientApp/src/app/requests/movierequests.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlatformLocation } from "@angular/common";
import { Component, Input, OnInit } from "@angular/core";
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
import { Component, Input, OnInit, Inject } from "@angular/core";
import { DomSanitizer } from "@angular/platform-browser";
import { Subject } from "rxjs";
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
Expand Down Expand Up @@ -44,14 +44,16 @@ export class MovieRequestsComponent implements OnInit {
public totalMovies: number = 100;
public currentlyLoaded: number;
private amountToLoad: number;
private href: string;

constructor(
private requestService: RequestService,
private auth: AuthService,
private notificationService: NotificationService,
private radarrService: RadarrService,
private sanitizer: DomSanitizer,
private readonly platformLocation: PlatformLocation) {
@Inject(APP_BASE_HREF) href:string) {
this.href = href;
this.searchChanged.pipe(
debounceTime(600), // Wait Xms after the last event before emitting last event
distinctUntilChanged(), // only emit if value is different from previous value
Expand All @@ -68,7 +70,7 @@ export class MovieRequestsComponent implements OnInit {
});
});
this.defaultPoster = "../../../images/default_movie_poster.png";
const base = this.platformLocation.getBaseHrefFromDOM();
const base = this.href;
if (base) {
this.defaultPoster = "../../.." + base + "/images/default_movie_poster.png";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlatformLocation } from "@angular/common";
import { Component, Input, OnInit } from "@angular/core";
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
import { Component, Input, OnInit, Inject } from "@angular/core";
import { DomSanitizer } from "@angular/platform-browser";
import { Subject } from "rxjs";
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
Expand Down Expand Up @@ -41,13 +41,15 @@ export class MusicRequestsComponent implements OnInit {
public totalAlbums: number = 100;
public currentlyLoaded: number;
private amountToLoad: number;
private href: string;

constructor(
private requestService: RequestService,
private auth: AuthService,
private notificationService: NotificationService,
private sanitizer: DomSanitizer,
private readonly platformLocation: PlatformLocation) {
@Inject(APP_BASE_HREF) href:string) {
this.href = href;
this.searchChanged.pipe(
debounceTime(600), // Wait Xms after the last event before emitting last event
distinctUntilChanged(), // only emit if value is different from previous value
Expand All @@ -64,7 +66,7 @@ export class MusicRequestsComponent implements OnInit {
});
});
this.defaultPoster = "../../../images/default-music-placeholder.png";
const base = this.platformLocation.getBaseHrefFromDOM();
const base = this.href;
if (base) {
this.defaultPoster = "../../.." + base + "/images/default-music-placeholder.png";
}
Expand Down
11 changes: 6 additions & 5 deletions src/Ombi/ClientApp/src/app/requests/tvrequests.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlatformLocation } from "@angular/common";
import { Component, Input, OnInit } from "@angular/core";
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
import { Component, Input, OnInit, Inject } from "@angular/core";
import { DomSanitizer } from "@angular/platform-browser";
import { Subject } from "rxjs";
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
Expand Down Expand Up @@ -38,6 +38,7 @@ export class TvRequestsComponent implements OnInit {
public totalTv: number = 100;
private currentlyLoaded: number;
private amountToLoad: number;
private href: string;

constructor(
private requestService: RequestService,
Expand All @@ -46,8 +47,8 @@ export class TvRequestsComponent implements OnInit {
private imageService: ImageService,
private sonarrService: SonarrService,
private notificationService: NotificationService,
private readonly platformLocation: PlatformLocation) {

@Inject(APP_BASE_HREF) href:string) {
this.href= href;
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
this.currentUser = this.auth.claims().name;
if (this.isAdmin) {
Expand Down Expand Up @@ -86,7 +87,7 @@ export class TvRequestsComponent implements OnInit {
});
});
this.defaultPoster = "../../../images/default_tv_poster.png";
const base = this.platformLocation.getBaseHrefFromDOM();
const base = this.href;
if (base) {
this.defaultPoster = "../../.." + base + "/images/default_tv_poster.png";
}
Expand Down
10 changes: 6 additions & 4 deletions src/Ombi/ClientApp/src/app/search/moviesearch.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlatformLocation } from "@angular/common";
import { Component, Input, OnInit } from "@angular/core";
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
import { Component, Input, OnInit, Inject } from "@angular/core";
import { DomSanitizer } from "@angular/platform-browser";
import { TranslateService } from "@ngx-translate/core";
import { Subject } from "rxjs";
Expand Down Expand Up @@ -39,12 +39,14 @@ export class MovieSearchComponent implements OnInit {
public issueProviderId: string;
public issueCategorySelected: IIssueCategory;
public defaultPoster: string;
private href: string;

constructor(
private searchService: SearchService, private requestService: RequestService,
private notificationService: NotificationService, private authService: AuthService,
private readonly translate: TranslateService, private sanitizer: DomSanitizer,
private readonly platformLocation: PlatformLocation, private settingsService: SettingsService) {
@Inject(APP_BASE_HREF) href:string, private settingsService: SettingsService) {
this.href= href;
this.langauges = <ILanguageRefine[]><any>languageData;
this.searchChanged.pipe(
debounceTime(600), // Wait Xms after the last event before emitting last event
Expand All @@ -54,7 +56,7 @@ export class MovieSearchComponent implements OnInit {
this.runSearch();
});
this.defaultPoster = "../../../images/default_movie_poster.png";
const base = this.platformLocation.getBaseHrefFromDOM();
const base = this.href;
if (base) {
this.defaultPoster = "../../.." + base + "/images/default_movie_poster.png";
}
Expand Down
11 changes: 6 additions & 5 deletions src/Ombi/ClientApp/src/app/search/music/musicsearch.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlatformLocation } from "@angular/common";
import { Component, Input, OnInit } from "@angular/core";
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
import { Component, Input, OnInit, Inject } from "@angular/core";
import { DomSanitizer } from "@angular/platform-browser";
import { Subject } from "rxjs";
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
Expand Down Expand Up @@ -31,10 +31,11 @@ export class MusicSearchComponent implements OnInit {
public issueCategorySelected: IIssueCategory;
public defaultPoster: string;

private href: string;
constructor(
private searchService: SearchService, private sanitizer: DomSanitizer,
private platformLocation: PlatformLocation) {

@Inject(APP_BASE_HREF) href:string) {
this.href = href;
this.searchChanged.pipe(
debounceTime(600), // Wait Xms after the last event before emitting last event
distinctUntilChanged(), // only emit if value is different from previous value
Expand Down Expand Up @@ -69,7 +70,7 @@ export class MusicSearchComponent implements OnInit {
}
});
this.defaultPoster = "../../../images/default-music-placeholder.png";
const base = this.platformLocation.getBaseHrefFromDOM();
const base = this.href;
if (base) {
this.defaultPoster = "../../.." + base + "/images/default-music-placeholder.png";
}
Expand Down
11 changes: 6 additions & 5 deletions src/Ombi/ClientApp/src/app/search/tvsearch.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlatformLocation } from "@angular/common";
import { Component, Input, OnInit } from "@angular/core";
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
import { Component, Input, OnInit, Inject } from "@angular/core";
import { DomSanitizer } from "@angular/platform-browser";
import { Subject } from "rxjs";
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
Expand Down Expand Up @@ -30,13 +30,14 @@ export class TvSearchComponent implements OnInit {
public issueRequestId: number;
public issueProviderId: string;
public issueCategorySelected: IIssueCategory;
private href: string;

constructor(
private searchService: SearchService, private requestService: RequestService,
private notificationService: NotificationService, private authService: AuthService,
private imageService: ImageService, private sanitizer: DomSanitizer,
private readonly platformLocation: PlatformLocation) {

@Inject(APP_BASE_HREF) href:string) {
this.href = href;
this.searchChanged.pipe(
debounceTime(600), // Wait Xms after the last event before emitting last event
distinctUntilChanged(), // only emit if value is different from previous value
Expand All @@ -54,7 +55,7 @@ export class TvSearchComponent implements OnInit {
});
});
this.defaultPoster = "../../../images/default_tv_poster.png";
const base = this.platformLocation.getBaseHrefFromDOM();
const base = this.href;
if (base) {
this.defaultPoster = "../../.." + base + "/images/default_tv_poster.png";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PlatformLocation } from "@angular/common";
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { Injectable, Inject } from "@angular/core";
import { Observable } from "rxjs";

import { ServiceHelpers } from "../service.helpers";
Expand All @@ -9,8 +9,8 @@ import { ICouchPotatoApiKey, ICouchPotatoProfiles, ICouchPotatoSettings } from "

@Injectable()
export class CouchPotatoService extends ServiceHelpers {
constructor(http: HttpClient, public platformLocation: PlatformLocation) {
super(http, "/api/v1/CouchPotato/", platformLocation);
constructor(http: HttpClient, @Inject(APP_BASE_HREF) href:string) {
super(http, "/api/v1/CouchPotato/", href);
}

public getProfiles(settings: ICouchPotatoSettings): Observable<ICouchPotatoProfiles> {
Expand Down
Loading

0 comments on commit ea58971

Please sign in to comment.