From a65bd3f9482b62bfb29014a77569dab3bcc8fe4c Mon Sep 17 00:00:00 2001 From: tidusjar Date: Fri, 8 Feb 2019 15:48:24 +0000 Subject: [PATCH] Think i fixed the base url? pffft no idea --- src/Ombi/ClientApp/src/app/app.component.html | 5 +- src/Ombi/ClientApp/src/app/app.component.ts | 7 +-- src/Ombi/ClientApp/src/app/app.module.ts | 31 +++++++---- .../movie-details.component.scss | 1 + src/Ombi/ClientApp/src/index.html | 35 +++++++++++-- src/Ombi/ClientApp/src/main.ts | 4 +- src/Ombi/Controllers/V1/SettingsController.cs | 21 ++++++++ src/Ombi/Startup.cs | 51 ++++--------------- src/Ombi/wwwroot/baseUrl.json | 0 9 files changed, 93 insertions(+), 62 deletions(-) create mode 100644 src/Ombi/wwwroot/baseUrl.json diff --git a/src/Ombi/ClientApp/src/app/app.component.html b/src/Ombi/ClientApp/src/app/app.component.html index 0aa7d2612..64a2beffe 100644 --- a/src/Ombi/ClientApp/src/app/app.component.html +++ b/src/Ombi/ClientApp/src/app/app.component.html @@ -1,4 +1,4 @@ -
+ + + +
diff --git a/src/Ombi/ClientApp/src/app/app.component.ts b/src/Ombi/ClientApp/src/app/app.component.ts index ca4b4262c..0f368e28d 100644 --- a/src/Ombi/ClientApp/src/app/app.component.ts +++ b/src/Ombi/ClientApp/src/app/app.component.ts @@ -38,9 +38,10 @@ export class AppComponent implements OnInit { private readonly platformLocation: PlatformLocation) { const base = this.platformLocation.getBaseHrefFromDOM(); - if (base.length > 1) { - __webpack_public_path__ = base + "/dist/"; - } + debugger; + // if (base.length > 1) { + // __webpack_public_path__ = base + "/dist/"; + // } this.translate.addLangs(["en", "de", "fr", "da", "es", "it", "nl", "sv", "no", "pl", "pt"]); // this language will be used as a fallback when a translation isn't found in the current language diff --git a/src/Ombi/ClientApp/src/app/app.module.ts b/src/Ombi/ClientApp/src/app/app.module.ts index 7d33aa6fa..6d7a271ea 100644 --- a/src/Ombi/ClientApp/src/app/app.module.ts +++ b/src/Ombi/ClientApp/src/app/app.module.ts @@ -1,4 +1,4 @@ -import { CommonModule, PlatformLocation } from "@angular/common"; +import { CommonModule, PlatformLocation, APP_BASE_HREF } from "@angular/common"; import { HttpClient, HttpClientModule } from "@angular/common/http"; import { NgModule } from "@angular/core"; import { FormsModule, ReactiveFormsModule } from "@angular/forms"; @@ -15,12 +15,15 @@ import { TranslateHttpLoader } from "@ngx-translate/http-loader"; import { CookieService } from "ng2-cookies"; import { NgxEditorModule } from "ngx-editor"; import { GrowlModule } from "primeng/components/growl/growl"; -import { ButtonModule, CaptchaModule, ConfirmationService, ConfirmDialogModule, DataTableModule, DialogModule, OverlayPanelModule, SharedModule, SidebarModule, - TooltipModule } from "primeng/primeng"; +import { + ButtonModule, CaptchaModule, ConfirmationService, ConfirmDialogModule, DataTableModule, DialogModule, OverlayPanelModule, SharedModule, SidebarModule, + TooltipModule +} from "primeng/primeng"; - import { - MatButtonModule, MatNativeDateModule, MatIconModule, MatSidenavModule, MatListModule, MatToolbarModule, MatAutocompleteModule, MatCheckboxModule} from '@angular/material'; - import { MatCardModule, MatInputModule, MatTabsModule } from "@angular/material"; +import { + MatButtonModule, MatNativeDateModule, MatIconModule, MatSidenavModule, MatListModule, MatToolbarModule, MatAutocompleteModule, MatCheckboxModule +} from '@angular/material'; +import { MatCardModule, MatInputModule, MatTabsModule } from "@angular/material"; import { MDBBootstrapModule, CardsFreeModule, NavbarModule } from "angular-bootstrap-md"; @@ -39,10 +42,9 @@ import { TokenResetPasswordComponent } from "./login/tokenresetpassword.componen // Services import { AuthGuard } from "./auth/auth.guard"; import { AuthService } from "./auth/auth.service"; -import { ImageService } from "./services"; +import { ImageService, SettingsService } from "./services"; import { LandingPageService } from "./services"; import { NotificationService } from "./services"; -import { SettingsService } from "./services"; import { IssuesService, JobService, PlexTvService, StatusService, SearchService, IdentityService } from "./services"; import { MyNavComponent } from './my-nav/my-nav.component'; import { LayoutModule } from '@angular/cdk/layout'; @@ -82,6 +84,12 @@ export function HttpLoaderFactory(http: HttpClient, platformLocation: PlatformLo return new TranslateHttpLoader(http, "/translations/", `.json?v=${version}`); } +export function baseurlFact() { + + console.log(window['_app_base']); + return "/" + window['_app_base']; +} + export function JwtTokenGetter() { const token = localStorage.getItem("id_token"); if (!token) { @@ -90,6 +98,7 @@ export function JwtTokenGetter() { return token; } + @NgModule({ imports: [ RouterModule.forRoot(routes), @@ -163,7 +172,11 @@ export function JwtTokenGetter() { IssuesService, PlexTvService, SearchService, - SearchV2Service, + SearchV2Service, + { + provide: APP_BASE_HREF, + useFactory: baseurlFact + } ], bootstrap: [AppComponent], }) diff --git a/src/Ombi/ClientApp/src/app/media-details/movie-details.component.scss b/src/Ombi/ClientApp/src/app/media-details/movie-details.component.scss index 039ba0b91..1c77b1063 100644 --- a/src/Ombi/ClientApp/src/app/media-details/movie-details.component.scss +++ b/src/Ombi/ClientApp/src/app/media-details/movie-details.component.scss @@ -168,6 +168,7 @@ section { } .grow:hover { transform: scale(1.1); + color: black; } .media-icons { diff --git a/src/Ombi/ClientApp/src/index.html b/src/Ombi/ClientApp/src/index.html index 8ec531e73..9b9bedde5 100644 --- a/src/Ombi/ClientApp/src/index.html +++ b/src/Ombi/ClientApp/src/index.html @@ -1,17 +1,42 @@ + + Ombi - - - + + + + + -

Loading...

+ + +

Loading...

+
- + + \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/main.ts b/src/Ombi/ClientApp/src/main.ts index 738e001df..7c308f746 100644 --- a/src/Ombi/ClientApp/src/main.ts +++ b/src/Ombi/ClientApp/src/main.ts @@ -1,7 +1,7 @@ // Main -import * as Pace from "pace"; -Pace.start(); +// import * as Pace from "pace"; +// Pace.start(); import "jquery"; diff --git a/src/Ombi/Controllers/V1/SettingsController.cs b/src/Ombi/Controllers/V1/SettingsController.cs index 3deb77e8b..2e9f52507 100644 --- a/src/Ombi/Controllers/V1/SettingsController.cs +++ b/src/Ombi/Controllers/V1/SettingsController.cs @@ -78,6 +78,27 @@ namespace Ombi.Controllers.V1 return await Get(); } + /// + /// Gets the base url. + /// + /// + [HttpGet("baseurl")] + [AllowAnonymous] + public async Task GetBaseUrl() + { + var s = await Get(); + var baseUrl = s?.BaseUrl ?? string.Empty; + if (!baseUrl.EndsWith("/")) + { + baseUrl = baseUrl.TrimEnd('/'); + } + if (baseUrl.StartsWith("/")) + { + baseUrl = baseUrl.TrimStart('/'); + } + return baseUrl; + } + /// /// Save the Ombi settings. /// diff --git a/src/Ombi/Startup.cs b/src/Ombi/Startup.cs index 2211bcbd3..c8644e977 100644 --- a/src/Ombi/Startup.cs +++ b/src/Ombi/Startup.cs @@ -37,13 +37,6 @@ namespace Ombi { public static StoragePathSingleton StoragePath => StoragePathSingleton.Instance; - private static readonly Action ConfigureSpaDefaults = - spa => - { - spa.Options.SourcePath = "ClientApp"; - spa.UseProxyToSpaDevelopmentServer("http://localhost:3578"); - }; - public Startup(IHostingEnvironment env) { Console.WriteLine(env.ContentRootPath); @@ -251,10 +244,16 @@ namespace Ombi }); app.UseMvcWithDefaultRoute(); - if (env.IsDevelopment()) + + app.UseSpa(spa => { - app.MapWhen(IsSpaRoute, spaApp => { UseSpaWithoutIndexHtml(spaApp, ConfigureSpaDefaults); }); - } + if (env.IsDevelopment()) + { + spa.Options.SourcePath = "ClientApp"; + spa.UseProxyToSpaDevelopmentServer("http://localhost:3578"); + } + }); + } private static bool IsSpaRoute(HttpContext context) @@ -267,38 +266,6 @@ namespace Ombi || path.ToString().Contains(".hot-update."); } - private static void UseSpaWithoutIndexHtml(IApplicationBuilder app, Action configuration) - { - if (configuration == null) - { - throw new ArgumentNullException(nameof(configuration)); - } - - // Use the options configured in DI (or blank if none was configured). We have to clone it - // otherwise if you have multiple UseSpa calls, their configurations would interfere with one another. - var optionsProvider = app.ApplicationServices.GetService>(); - var options = new SpaOptions(); - - var spaBuilder = new DefaultSpaBuilder(app, options); - configuration.Invoke(spaBuilder); - } - - private class DefaultSpaBuilder : ISpaBuilder - { - public IApplicationBuilder ApplicationBuilder { get; } - - public SpaOptions Options { get; } - - public DefaultSpaBuilder(IApplicationBuilder applicationBuilder, SpaOptions options) - { - ApplicationBuilder = applicationBuilder - ?? throw new ArgumentNullException(nameof(applicationBuilder)); - - Options = options - ?? throw new ArgumentNullException(nameof(options)); - } - } - public class HangfireAuthorizationFilter : IDashboardAuthorizationFilter { public bool Authorize(DashboardContext context) diff --git a/src/Ombi/wwwroot/baseUrl.json b/src/Ombi/wwwroot/baseUrl.json new file mode 100644 index 000000000..e69de29bb