mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-14 09:12:57 -07:00
!wip
This commit is contained in:
parent
5bb4d133ae
commit
a4cbb24d0f
18 changed files with 152 additions and 16 deletions
|
@ -37,4 +37,10 @@
|
|||
<ProjectReference Include="..\Ombi.TheMovieDbApi\Ombi.Api.TheMovieDb.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.AspNetCore.SignalR.Core">
|
||||
<HintPath>..\..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.signalr.core\1.1.0\lib\netstandard2.0\Microsoft.AspNetCore.SignalR.Core.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -2,6 +2,7 @@
|
|||
using System.Security.Principal;
|
||||
using Hangfire;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
using Ombi.Api.Discord;
|
||||
|
|
|
@ -41,4 +41,10 @@
|
|||
<ProjectReference Include="..\Ombi.Settings\Ombi.Settings.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.AspNetCore.SignalR.Core">
|
||||
<HintPath>..\..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.signalr.core\1.1.0\lib\netstandard2.0\Microsoft.AspNetCore.SignalR.Core.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
17
src/Ombi.Hubs/Ombi.Hubs.csproj
Normal file
17
src/Ombi.Hubs/Ombi.Hubs.csproj
Normal file
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNet.SignalR" Version="2.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.AspNetCore.SignalR.Core">
|
||||
<HintPath>..\..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.signalr.core\1.1.0\lib\netstandard2.0\Microsoft.AspNetCore.SignalR.Core.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
14
src/Ombi.Hubs/ScheduledJobsHub.cs
Normal file
14
src/Ombi.Hubs/ScheduledJobsHub.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace Ombi.Hubs
|
||||
{
|
||||
public class ScheduledJobsHub : Hub
|
||||
{
|
||||
public Task Send(string data)
|
||||
{
|
||||
return Clients.All.SendAsync("Send", data);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -96,7 +96,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Api.Notifications", "O
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Api.Lidarr", "Ombi.Api.Lidarr\Ombi.Api.Lidarr.csproj", "{4FA21A20-92F4-462C-B929-2C517A88CC56}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Helpers.Tests", "Ombi.Helpers.Tests\Ombi.Helpers.Tests.csproj", "{CC8CEFCD-0CB6-45BB-845F-508BCAB5BDC3}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Helpers.Tests", "Ombi.Helpers.Tests\Ombi.Helpers.Tests.csproj", "{CC8CEFCD-0CB6-45BB-845F-508BCAB5BDC3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Hubs", "Ombi.Hubs\Ombi.Hubs.csproj", "{67416CC5-13B2-44BB-98CE-39DA93D6F70E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -256,6 +258,10 @@ Global
|
|||
{CC8CEFCD-0CB6-45BB-845F-508BCAB5BDC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CC8CEFCD-0CB6-45BB-845F-508BCAB5BDC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CC8CEFCD-0CB6-45BB-845F-508BCAB5BDC3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{67416CC5-13B2-44BB-98CE-39DA93D6F70E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{67416CC5-13B2-44BB-98CE-39DA93D6F70E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{67416CC5-13B2-44BB-98CE-39DA93D6F70E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{67416CC5-13B2-44BB-98CE-39DA93D6F70E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
"src/styles/_imports.scss",
|
||||
"node_modules/bootstrap/scss/bootstrap.scss",
|
||||
"node_modules/angular-bootstrap-md/scss/mdb-free.scss",
|
||||
"node_modules/pace/themes/orange/pace-theme-flat-top.css",
|
||||
"node_modules/font-awesome/scss/font-awesome.scss"
|
||||
],
|
||||
"scripts": [
|
||||
|
|
|
@ -164,7 +164,6 @@
|
|||
</div>
|
||||
</nav> -->
|
||||
|
||||
|
||||
<app-my-nav [showNav]="showNav" [username]="user.name" (logoutClick)="logOut();"></app-my-nav>
|
||||
|
||||
|
||||
|
|
|
@ -6,9 +6,14 @@ import { AuthService } from "./auth/auth.service";
|
|||
import { ILocalUser } from "./auth/IUserLogin";
|
||||
import { IdentityService, NotificationService } from "./services";
|
||||
import { JobService, SettingsService } from "./services";
|
||||
import { MatSnackBar } from '@angular/material';
|
||||
|
||||
import { ICustomizationSettings, ICustomPage } from "./interfaces";
|
||||
|
||||
import { HubConnection } from '@aspnet/signalr';
|
||||
import * as signalR from '@aspnet/signalr';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: "app-ombi",
|
||||
templateUrl: "./app.component.html",
|
||||
|
@ -28,6 +33,8 @@ export class AppComponent implements OnInit {
|
|||
|
||||
private checkedForUpdate: boolean;
|
||||
|
||||
private scheduleHubConnection: HubConnection | undefined;
|
||||
|
||||
constructor(public notificationService: NotificationService,
|
||||
public authService: AuthService,
|
||||
private readonly router: Router,
|
||||
|
@ -35,7 +42,8 @@ export class AppComponent implements OnInit {
|
|||
private readonly jobService: JobService,
|
||||
public readonly translate: TranslateService,
|
||||
private readonly identityService: IdentityService,
|
||||
private readonly platformLocation: PlatformLocation) {
|
||||
private readonly platformLocation: PlatformLocation,
|
||||
private readonly snackBar: MatSnackBar) {
|
||||
|
||||
const base = this.platformLocation.getBaseHrefFromDOM();
|
||||
if (base.length > 1) {
|
||||
|
@ -85,6 +93,24 @@ export class AppComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.scheduleHubConnection = new signalR.HubConnectionBuilder().withUrl("/hubs/schedules", {
|
||||
accessTokenFactory: () => {
|
||||
return this.authService.getToken();
|
||||
}
|
||||
})
|
||||
.configureLogging(signalR.LogLevel.Information).build();
|
||||
|
||||
this.scheduleHubConnection
|
||||
.start()
|
||||
.then(() => console.info('Connection started!'))
|
||||
.catch(err => console.error(err));
|
||||
this.scheduleHubConnection.on("Send", (data: any) => {
|
||||
this.snackBar.open(data,"OK", {
|
||||
duration: 3000
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public roleClass() {
|
||||
|
|
|
@ -8,7 +8,6 @@ import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
|
|||
import { RouterModule, Routes } from "@angular/router";
|
||||
|
||||
import { JwtModule } from "@auth0/angular-jwt";
|
||||
|
||||
import { NgbModule } from "@ng-bootstrap/ng-bootstrap";
|
||||
import { TranslateLoader, TranslateModule } from "@ngx-translate/core";
|
||||
import { TranslateHttpLoader } from "@ngx-translate/http-loader";
|
||||
|
@ -19,7 +18,7 @@ import { ButtonModule, CaptchaModule, ConfirmationService, ConfirmDialogModule,
|
|||
TooltipModule } from "primeng/primeng";
|
||||
|
||||
import {
|
||||
MatButtonModule, MatNativeDateModule, MatIconModule, MatSidenavModule, MatListModule, MatToolbarModule, MatAutocompleteModule, MatCheckboxModule} from '@angular/material';
|
||||
MatButtonModule, MatNativeDateModule, MatIconModule, MatSidenavModule, MatListModule, MatToolbarModule, MatAutocompleteModule, MatCheckboxModule, MatSnackBarModule} from '@angular/material';
|
||||
import { MatCardModule, MatInputModule, MatTabsModule } from "@angular/material";
|
||||
|
||||
import { MDBBootstrapModule, CardsFreeModule, NavbarModule } from "angular-bootstrap-md";
|
||||
|
@ -103,6 +102,7 @@ export function JwtTokenGetter() {
|
|||
DataTableModule,
|
||||
SharedModule,
|
||||
NgxEditorModule,
|
||||
MatSnackBarModule,
|
||||
DialogModule,
|
||||
MatButtonModule,
|
||||
NavbarModule,
|
||||
|
|
|
@ -26,6 +26,10 @@ export class AuthService extends ServiceHelpers {
|
|||
return this.http.post<boolean>(`${this.url}/requirePassword`, JSON.stringify(login), {headers: this.headers});
|
||||
}
|
||||
|
||||
public getToken() {
|
||||
return this.jwtHelperService.tokenGetter();
|
||||
}
|
||||
|
||||
public loggedIn() {
|
||||
const token: string = this.jwtHelperService.tokenGetter();
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import { InputSwitchModule, SidebarModule } from "primeng/primeng";
|
|||
|
||||
import {
|
||||
MatButtonModule, MatNativeDateModule, MatIconModule, MatSidenavModule, MatListModule, MatToolbarModule, MatTooltipModule} from '@angular/material';
|
||||
import { MatCardModule, MatInputModule, MatTabsModule, MatAutocompleteModule, MatCheckboxModule, MatExpansionModule, MatDialogModule } from "@angular/material";
|
||||
import { MatCardModule, MatInputModule, MatTabsModule, MatAutocompleteModule, MatCheckboxModule, MatExpansionModule, MatDialogModule, MatSnackBarModule } from "@angular/material";
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
@ -37,6 +37,7 @@ import {
|
|||
MatCheckboxModule,
|
||||
MatExpansionModule,
|
||||
MatDialogModule,
|
||||
MatSnackBarModule,
|
||||
],
|
||||
exports: [
|
||||
TranslateModule,
|
||||
|
@ -52,6 +53,7 @@ import {
|
|||
MatButtonModule,
|
||||
MatNativeDateModule,
|
||||
MatIconModule,
|
||||
MatSnackBarModule,
|
||||
MatSidenavModule,
|
||||
MatListModule,
|
||||
MatToolbarModule,
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
// Main
|
||||
|
||||
import * as Pace from "pace";
|
||||
Pace.start();
|
||||
|
||||
import "jquery";
|
||||
|
||||
import "bootstrap/dist/js/bootstrap";
|
||||
|
|
2
src/Ombi/ClientApp/src/typings/globals.d.ts
vendored
2
src/Ombi/ClientApp/src/typings/globals.d.ts
vendored
|
@ -1,6 +1,4 @@
|
|||
// Globals
|
||||
|
||||
declare module "pace";
|
||||
declare var __webpack_public_path__: any;
|
||||
declare var module: any;
|
||||
|
||||
|
|
40
src/Ombi/Controllers/V2/HubController.cs
Normal file
40
src/Ombi/Controllers/V2/HubController.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Ombi.Api.TheMovieDb.Models;
|
||||
using Ombi.Core.Engine.V2;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Ombi.Core;
|
||||
using Ombi.Core.Engine.Interfaces;
|
||||
using Ombi.Core.Models.Search;
|
||||
using Ombi.Core.Models.Search.V2;
|
||||
using Ombi.Hubs;
|
||||
using Ombi.Models;
|
||||
|
||||
namespace Ombi.Controllers.V2
|
||||
{
|
||||
[ApiV2]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
public class HubController : ControllerBase
|
||||
{
|
||||
public HubController(IHubContext<ScheduledJobsHub> hub)
|
||||
{
|
||||
_hub = hub;
|
||||
}
|
||||
|
||||
private readonly IHubContext<ScheduledJobsHub> _hub;
|
||||
|
||||
/// <summary>
|
||||
/// Returns search results for both TV and Movies
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{searchTerm}")]
|
||||
public async Task MultiSearch(string searchTerm)
|
||||
{
|
||||
await _hub.Clients.All.SendAsync("Send", searchTerm);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -87,6 +87,7 @@
|
|||
<ProjectReference Include="..\Ombi.Api.SickRage\Ombi.Api.SickRage.csproj" />
|
||||
<ProjectReference Include="..\Ombi.Core\Ombi.Core.csproj" />
|
||||
<ProjectReference Include="..\Ombi.DependencyInjection\Ombi.DependencyInjection.csproj" />
|
||||
<ProjectReference Include="..\Ombi.Hubs\Ombi.Hubs.csproj" />
|
||||
<ProjectReference Include="..\Ombi.Mapping\Ombi.Mapping.csproj" />
|
||||
<ProjectReference Include="..\Ombi.Schedule\Ombi.Schedule.csproj" />
|
||||
<ProjectReference Include="..\Ombi.Settings\Ombi.Settings.csproj" />
|
||||
|
|
|
@ -21,6 +21,7 @@ using Ombi.Core.Authentication;
|
|||
using Ombi.Core.Settings;
|
||||
using Ombi.DependencyInjection;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Hubs;
|
||||
using Ombi.Mapping;
|
||||
using Ombi.Schedule;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
|
@ -63,7 +64,6 @@ namespace Ombi
|
|||
}
|
||||
Log.Logger = config;
|
||||
|
||||
|
||||
//}
|
||||
//if (env.IsProduction())
|
||||
//{
|
||||
|
@ -135,10 +135,11 @@ namespace Ombi
|
|||
{
|
||||
builder.AllowAnyOrigin()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader();
|
||||
.AllowAnyHeader().AllowCredentials();
|
||||
}));
|
||||
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
||||
|
||||
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
||||
services.AddSignalR();
|
||||
services.AddSpaStaticFiles(configuration =>
|
||||
{
|
||||
configuration.RootPath = "ClientApp/dist";
|
||||
|
@ -241,6 +242,8 @@ namespace Ombi
|
|||
c.SwaggerEndpoint("/swagger/v2/swagger.json", "API V2");
|
||||
});
|
||||
|
||||
app.UseSignalR(routes => { routes.MapHub<ScheduledJobsHub>("/hubs/schedules"); });
|
||||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute(
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
@ -136,6 +137,23 @@ namespace Ombi
|
|||
{
|
||||
x.Audience = "Ombi";
|
||||
x.TokenValidationParameters = tokenValidationParameters;
|
||||
x.Events = new JwtBearerEvents
|
||||
{
|
||||
OnMessageReceived = context =>
|
||||
{
|
||||
var accessToken = context.Request.Headers["id_token"];
|
||||
|
||||
// If the request is for our hub...
|
||||
var path = context.HttpContext.Request.Path;
|
||||
if (!string.IsNullOrEmpty(accessToken) &&
|
||||
(path.StartsWithSegments("/hubs/")))
|
||||
{
|
||||
// Read the token out of the query string
|
||||
context.Token = accessToken;
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue