mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 00:06:05 -07:00
Think i fixed the base url? pffft no idea
This commit is contained in:
parent
d31fd6f5a2
commit
a65bd3f948
9 changed files with 93 additions and 62 deletions
|
@ -1,4 +1,4 @@
|
|||
<div [ngClass]="user.name && roleClass()">
|
||||
|
||||
<!-- <p-growl [value]="notificationService.messages" [life]="3000"></p-growl>
|
||||
<nav *ngIf="showNav" class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="container-fluid">
|
||||
|
@ -165,6 +165,9 @@
|
|||
</nav> -->
|
||||
|
||||
|
||||
|
||||
|
||||
<div [ngClass]="user.name && roleClass()">
|
||||
<app-my-nav [showNav]="showNav" [username]="user.name" (logoutClick)="logOut();"></app-my-nav>
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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],
|
||||
})
|
||||
|
|
|
@ -168,6 +168,7 @@ section {
|
|||
}
|
||||
.grow:hover {
|
||||
transform: scale(1.1);
|
||||
color: black;
|
||||
}
|
||||
|
||||
.media-icons {
|
||||
|
|
|
@ -1,17 +1,42 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Ombi</title>
|
||||
<base href="/" />
|
||||
<link rel="stylesheet" href="/loading.css" />
|
||||
<script src="//maps.google.com/maps/api/js?libraries=visualization&key=AIzaSyBDar8LXU5vbURGTMcNLI0f9AsoSnpiV3I" async defer></script>
|
||||
|
||||
<script src="//maps.google.com/maps/api/js?libraries=visualization&key=AIzaSyBDar8LXU5vbURGTMcNLI0f9AsoSnpiV3I" async
|
||||
defer></script>
|
||||
|
||||
|
||||
</head>
|
||||
<script async defer>
|
||||
var xmlhttp = new XMLHttpRequest();
|
||||
// xmlhttp.onreadystatechange = function () {
|
||||
// if (this.readyState == 4 && this.status == 200) {
|
||||
// var myObj = JSON.parse(this.responseText);
|
||||
// window['_app_base'] = myObj;
|
||||
|
||||
// document.write('<base href="/' + window['_app_base'] + '" />');
|
||||
// }
|
||||
// };
|
||||
xmlhttp.open("GET", "api/v1/Settings/baseurl", false);
|
||||
xmlhttp.send();
|
||||
var myObj = JSON.parse(xmlhttp.responseText);
|
||||
window['_app_base'] = myObj;
|
||||
|
||||
document.write('<base href="/' + window['_app_base'] + '" />');
|
||||
</script>
|
||||
|
||||
<body>
|
||||
<app-ombi><p class="loading">Loading<span>.</span><span>.</span><span>.</span></p></app-ombi>
|
||||
|
||||
<app-ombi>
|
||||
<p class="loading">Loading<span>.</span><span>.</span><span>.</span></p>
|
||||
</app-ombi>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
|
@ -1,7 +1,7 @@
|
|||
// Main
|
||||
|
||||
import * as Pace from "pace";
|
||||
Pace.start();
|
||||
// import * as Pace from "pace";
|
||||
// Pace.start();
|
||||
|
||||
import "jquery";
|
||||
|
||||
|
|
|
@ -78,6 +78,27 @@ namespace Ombi.Controllers.V1
|
|||
return await Get<OmbiSettings>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the base url.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("baseurl")]
|
||||
[AllowAnonymous]
|
||||
public async Task<string> GetBaseUrl()
|
||||
{
|
||||
var s = await Get<OmbiSettings>();
|
||||
var baseUrl = s?.BaseUrl ?? string.Empty;
|
||||
if (!baseUrl.EndsWith("/"))
|
||||
{
|
||||
baseUrl = baseUrl.TrimEnd('/');
|
||||
}
|
||||
if (baseUrl.StartsWith("/"))
|
||||
{
|
||||
baseUrl = baseUrl.TrimStart('/');
|
||||
}
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save the Ombi settings.
|
||||
/// </summary>
|
||||
|
|
|
@ -37,13 +37,6 @@ namespace Ombi
|
|||
{
|
||||
public static StoragePathSingleton StoragePath => StoragePathSingleton.Instance;
|
||||
|
||||
private static readonly Action<ISpaBuilder> 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<ISpaBuilder> 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<IOptions<SpaOptions>>();
|
||||
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)
|
||||
|
|
0
src/Ombi/wwwroot/baseUrl.json
Normal file
0
src/Ombi/wwwroot/baseUrl.json
Normal file
Loading…
Add table
Add a link
Reference in a new issue