mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
Fixed the SignalR notification base url
This commit is contained in:
parent
11f91de16b
commit
e7422d8845
3 changed files with 13 additions and 43 deletions
|
@ -83,7 +83,7 @@ const routes: Routes = [
|
||||||
// AoT requires an exported function for factories
|
// AoT requires an exported function for factories
|
||||||
export function HttpLoaderFactory(http: HttpClient, platformLocation: PlatformLocation) {
|
export function HttpLoaderFactory(http: HttpClient, platformLocation: PlatformLocation) {
|
||||||
// const base = getBaseLocation();
|
// const base = getBaseLocation();
|
||||||
const base = '/' + (window.location.pathname.split('/')[1] || '')
|
const base = platformLocation.getBaseHrefFromDOM();
|
||||||
const version = Math.floor(Math.random() * 999999999);
|
const version = Math.floor(Math.random() * 999999999);
|
||||||
if (base !== null && base.length > 1) {
|
if (base !== null && base.length > 1) {
|
||||||
return new TranslateHttpLoader(http, `${base}/translations/`, `.json?v=${version}`);
|
return new TranslateHttpLoader(http, `${base}/translations/`, `.json?v=${version}`);
|
||||||
|
|
|
@ -3,6 +3,8 @@ import { AuthService } from '../auth/auth.service';
|
||||||
|
|
||||||
import { HubConnection } from '@aspnet/signalr';
|
import { HubConnection } from '@aspnet/signalr';
|
||||||
import * as signalR from '@aspnet/signalr';
|
import * as signalR from '@aspnet/signalr';
|
||||||
|
import { PlatformLocation } from '@angular/common';
|
||||||
|
import { platformBrowser } from '@angular/platform-browser';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SignalRNotificationService {
|
export class SignalRNotificationService {
|
||||||
|
@ -10,15 +12,19 @@ export class SignalRNotificationService {
|
||||||
private hubConnection: HubConnection | undefined;
|
private hubConnection: HubConnection | undefined;
|
||||||
public Notification: EventEmitter<any>;
|
public Notification: EventEmitter<any>;
|
||||||
|
|
||||||
constructor(private authService: AuthService) {
|
constructor(private authService: AuthService, private platform: PlatformLocation) {
|
||||||
this.Notification = new EventEmitter<any>();
|
this.Notification = new EventEmitter<any>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public initialize(): void {
|
public initialize(): void {
|
||||||
|
|
||||||
this.stopConnection();
|
this.stopConnection();
|
||||||
|
let url = "/hubs/notification";
|
||||||
this.hubConnection = new signalR.HubConnectionBuilder().withUrl("/hubs/notification", {
|
const baseUrl = this.platform.getBaseHrefFromDOM();
|
||||||
|
if(baseUrl !== null && baseUrl.length > 1) {
|
||||||
|
url = baseUrl + url;
|
||||||
|
}
|
||||||
|
this.hubConnection = new signalR.HubConnectionBuilder().withUrl(url, {
|
||||||
accessTokenFactory: () => {
|
accessTokenFactory: () => {
|
||||||
return this.authService.getToken();
|
return this.authService.getToken();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,45 +3,9 @@
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<script>
|
<script>
|
||||||
// manually sets the <base> tag's href attribute so the app can be located in places other than root
|
|
||||||
|
var base = "/"+ (window.location.pathname.split('/')[1] || '');
|
||||||
// var split = location.pathname.split('/');
|
document.write("<base href='" + base + "' />");
|
||||||
// var base = "";
|
|
||||||
// var invalidProxies = ['DISCOVER',
|
|
||||||
// 'REQUESTS-LIST',
|
|
||||||
// 'DETAILS',
|
|
||||||
// 'SETTINGS',
|
|
||||||
// 'ISSUES',
|
|
||||||
// 'USERMANAGEMENT',
|
|
||||||
// 'RECENTLYADDED',
|
|
||||||
// 'DETAILS',
|
|
||||||
// 'VOTE',
|
|
||||||
// 'LOGIN',
|
|
||||||
// 'LANDINGPAGE',
|
|
||||||
// 'TOKEN',
|
|
||||||
// 'RESET',
|
|
||||||
// 'CUSTOM',
|
|
||||||
// 'AUTH',
|
|
||||||
// 'WIZARD',
|
|
||||||
// "CALENDAR"
|
|
||||||
// ]
|
|
||||||
// for (var i = 0; i < split.length - 1; i++) {
|
|
||||||
// if( invalidProxies.indexOf(split[i].toUpperCase()) !== -1) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// base += split[i];
|
|
||||||
// if(base.length > 1) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// if (i < split.length - 2) {
|
|
||||||
// base += "/";
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if(base === "") {
|
|
||||||
// base = "/";
|
|
||||||
// }
|
|
||||||
// window['_app_base'] = base;
|
|
||||||
// document.write("<base href='" + base + "' />");
|
|
||||||
</script>
|
</script>
|
||||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
<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">
|
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue