diff --git a/src/Ombi.Api.Sonarr/ISonarrApi.cs b/src/Ombi.Api.Sonarr/ISonarrApi.cs index ebb70618d..adde47b58 100644 --- a/src/Ombi.Api.Sonarr/ISonarrApi.cs +++ b/src/Ombi.Api.Sonarr/ISonarrApi.cs @@ -19,6 +19,6 @@ namespace Ombi.Api.Sonarr Task EpisodeSearch(int[] episodeIds, string apiKey, string baseUrl); Task SeasonSearch(int seriesId, int seasonNumber, string apiKey, string baseUrl); Task SeriesSearch(int seriesId, string apiKey, string baseUrl); - + Task SystemStatus(string apiKey, string baseUrl); } } \ No newline at end of file diff --git a/src/Ombi.Api.Sonarr/Models/SystemStatus.cs b/src/Ombi.Api.Sonarr/Models/SystemStatus.cs new file mode 100644 index 000000000..778570a4c --- /dev/null +++ b/src/Ombi.Api.Sonarr/Models/SystemStatus.cs @@ -0,0 +1,25 @@ +namespace Ombi.Api.Sonarr +{ + public class SystemStatus + { + public string version { get; set; } + public string buildTime { get; set; } + public bool isDebug { get; set; } + public bool isProduction { get; set; } + public bool isAdmin { get; set; } + public bool isUserInteractive { get; set; } + public string startupPath { get; set; } + public string appData { get; set; } + public string osVersion { get; set; } + public bool isMonoRuntime { get; set; } + public bool isMono { get; set; } + public bool isLinux { get; set; } + public bool isOsx { get; set; } + public bool isWindows { get; set; } + public string branch { get; set; } + public string authentication { get; set; } + public string sqliteVersion { get; set; } + public string urlBase { get; set; } + public string runtimeVersion { get; set; } + } +} \ No newline at end of file diff --git a/src/Ombi.Api.Sonarr/SonarrApi.cs b/src/Ombi.Api.Sonarr/SonarrApi.cs index b4e3e3302..ba78c4f11 100644 --- a/src/Ombi.Api.Sonarr/SonarrApi.cs +++ b/src/Ombi.Api.Sonarr/SonarrApi.cs @@ -188,5 +188,13 @@ namespace Ombi.Api.Sonarr request.AddJsonBody(body); return await Api.Request(request); } + + public async Task SystemStatus(string apiKey, string baseUrl) + { + var request = new Request("/api/system/status", baseUrl, HttpMethod.Get); + request.AddHeader("X-Api-Key", apiKey); + + return await Api.Request(request); + } } } diff --git a/src/Ombi.Core/Engine/TvRequestEngine.cs b/src/Ombi.Core/Engine/TvRequestEngine.cs index 4390b0674..a1bf27512 100644 --- a/src/Ombi.Core/Engine/TvRequestEngine.cs +++ b/src/Ombi.Core/Engine/TvRequestEngine.cs @@ -149,8 +149,19 @@ namespace Ombi.Core.Engine public async Task RemoveTvChild(int requestId) { var request = await TvRepository.GetChild().FirstOrDefaultAsync(x => x.Id == requestId); + var all = TvRepository.Db.TvRequests.Include(x => x.ChildRequests); + var parent = all.FirstOrDefault(x => x.Id == request.ParentRequestId); + + // Is this the only child? If so delete the parent + if (parent.ChildRequests.Count <= 1) + { + // Delete the parent + TvRepository.Db.TvRequests.Remove(parent); + } await Audit.Record(AuditType.Deleted, AuditArea.TvRequest, $"Deleting Request {request.Title}", Username); - await TvRepository.DeleteChild(request); + + TvRepository.Db.ChildRequests.Remove(request); + await TvRepository.Db.SaveChangesAsync(); } public async Task RemoveTvRequest(int requestId) diff --git a/src/Ombi.Schedule/Jobs/Emby/EmbyContentCacher.cs b/src/Ombi.Schedule/Jobs/Emby/EmbyContentCacher.cs index 26c5672b2..7bda46a41 100644 --- a/src/Ombi.Schedule/Jobs/Emby/EmbyContentCacher.cs +++ b/src/Ombi.Schedule/Jobs/Emby/EmbyContentCacher.cs @@ -37,7 +37,7 @@ namespace Ombi.Schedule.Jobs.Emby public async Task Start() { - var embySettings = await _settings.GetSettingsAsync(); + var embySettings = await _settings.GetSettingsAsync(); if (!embySettings.Enable) return; diff --git a/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs b/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs index 906f30e44..588792ad9 100644 --- a/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs +++ b/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs @@ -1,11 +1,13 @@ using System.Linq; using System.Threading.Tasks; +using Ombi.Store.Context; using Ombi.Store.Entities.Requests; namespace Ombi.Store.Repository.Requests { public interface ITvRequestRepository { + IOmbiContext Db { get; } Task Add(TvRequests request); Task AddChild(ChildRequests request); Task Delete(TvRequests request); diff --git a/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs b/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs index 8ad975db3..a89a88dec 100644 --- a/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs +++ b/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs @@ -13,7 +13,7 @@ namespace Ombi.Store.Repository.Requests Db = ctx; } - private IOmbiContext Db { get; } + public IOmbiContext Db { get; } public async Task GetRequestAsync(int tvDbId) { diff --git a/src/Ombi/ClientApp/app/auth/auth.service.ts b/src/Ombi/ClientApp/app/auth/auth.service.ts index e1350715e..4c9c4f88e 100644 --- a/src/Ombi/ClientApp/app/auth/auth.service.ts +++ b/src/Ombi/ClientApp/app/auth/auth.service.ts @@ -51,7 +51,7 @@ export class AuthService extends ServiceHelpers { hasRole(role: string): boolean { - return this.claims().roles.some(r => r === role); + return this.claims().roles.some(r => r.toUpperCase() === role.toUpperCase()); } logout() { diff --git a/src/Ombi/ClientApp/app/requests/tvrequests.component.html b/src/Ombi/ClientApp/app/requests/tvrequests.component.html index d49a48198..ec81ee0bd 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequests.component.html +++ b/src/Ombi/ClientApp/app/requests/tvrequests.component.html @@ -68,6 +68,7 @@ Available Denied Processing Request + Pending Approval @@ -95,7 +96,7 @@ -
+ # @@ -125,7 +126,7 @@ Processing Request
- Pending Approval + Pending Approval diff --git a/src/Ombi/ClientApp/app/requests/tvrequests.component.scss b/src/Ombi/ClientApp/app/requests/tvrequests.component.scss index 5fd85eddd..401207f28 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequests.component.scss +++ b/src/Ombi/ClientApp/app/requests/tvrequests.component.scss @@ -11,4 +11,8 @@ .ui-treetable-toggler.fa.fa-fw.ui-c.fa-caret-right, .ui-treetable-toggler.fa.fa-fw.ui-c.fa-caret-down { display: none; +} + +th { + text-align: left !important; } \ No newline at end of file diff --git a/src/Ombi/ClientApp/app/requests/tvrequests.component.ts b/src/Ombi/ClientApp/app/requests/tvrequests.component.ts index a5459cdff..f45427d5a 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequests.component.ts +++ b/src/Ombi/ClientApp/app/requests/tvrequests.component.ts @@ -11,7 +11,6 @@ import 'rxjs/add/operator/map'; import { RequestService } from '../services/request.service'; import { AuthService } from '../auth/auth.service'; -import { IdentityService } from '../services/identity.service'; import { ITvRequests, IChildRequests, INewSeasonRequests, IEpisodesRequests } from '../interfaces/IRequestModel'; import { TreeNode, } from "primeng/primeng"; @@ -27,7 +26,9 @@ import { TreeNode, } from "primeng/primeng"; }) export class TvRequestsComponent implements OnInit, OnDestroy { constructor(private requestService: RequestService, - private identityService: IdentityService, private authService : AuthService) { + private authService: AuthService) { + + this.admin = this.authService.hasRole("admin"); this.searchChanged .debounceTime(600) // Wait Xms afterthe last event before emitting last event .distinctUntilChanged() // only emit if value is different from previous value @@ -49,7 +50,6 @@ export class TvRequestsComponent implements OnInit, OnDestroy { this.currentlyLoaded = 5; this.tvRequests = []; this.loadInit(); - this.admin = this.authService.hasRole("admin"); } public admin = false; @@ -157,14 +157,27 @@ export class TvRequestsComponent implements OnInit, OnDestroy { public approve(request: IChildRequests) { request.approved = true; request.denied = false; + + // Mark all the episodes as approved now + request.seasonRequests.forEach((val) => { + val.episodes.forEach((ep) => { + ep.approved = true; + }); + }); this.requestService.updateChild(request) .subscribe(); } public deny(request: IChildRequests) { - debugger; request.approved = false; request.denied = true; + + // Mark all the episodes as not approved now + request.seasonRequests.forEach((val) => { + val.episodes.forEach((ep) => { + ep.approved = false; + }); + }); this.requestService.updateChild(request) .subscribe(); } @@ -214,10 +227,8 @@ export class TvRequestsComponent implements OnInit, OnDestroy { this.requestService.getTvRequests(this.amountToLoad, 0) .takeUntil(this.subscriptions) .subscribe(x => { - debugger; this.tvRequests = this.transformData(x); }); - this.isAdmin = this.identityService.hasRole("Admin"); } private resetSearch() { @@ -236,7 +247,12 @@ export class TvRequestsComponent implements OnInit, OnDestroy { var data = (val).data; var index = data.childRequests.indexOf(key, 0); if (index > -1) { - data.childRequests.splice(index, 1); + // Check if we need to remove the parent (if this is the only child) + if (data.childRequests.length <= 1) { + this.removeRequestFromUi(val); + } else { + data.childRequests.splice(index, 1); + } } }); } diff --git a/src/Ombi/ClientApp/app/search/seriesinformation.component.ts b/src/Ombi/ClientApp/app/search/seriesinformation.component.ts index 79c2b0128..f539ca434 100644 --- a/src/Ombi/ClientApp/app/search/seriesinformation.component.ts +++ b/src/Ombi/ClientApp/app/search/seriesinformation.component.ts @@ -65,6 +65,10 @@ export class SeriesInformationComponent implements OnInit, OnDestroy { episode.requested = true; } + public removeRequest(episode: IEpisodesRequests) { + episode.requested = false; + } + ngOnDestroy(): void { this.subscriptions.next(); diff --git a/src/Ombi/ClientApp/app/services/applications/tester.service.ts b/src/Ombi/ClientApp/app/services/applications/tester.service.ts index 1c6fa4208..ae92fccc3 100644 --- a/src/Ombi/ClientApp/app/services/applications/tester.service.ts +++ b/src/Ombi/ClientApp/app/services/applications/tester.service.ts @@ -13,6 +13,12 @@ import { IMattermostNotifcationSettings } from '../../interfaces/INotifcationSettings' +import { + IEmbyServer, + IPlexServer, + IRadarrSettings, + ISonarrSettings +} from '../../interfaces/ISettings'; @Injectable() export class TesterService extends ServiceAuthHelpers { @@ -41,5 +47,17 @@ export class TesterService extends ServiceAuthHelpers { emailTest(settings: IEmailNotificationSettings): Observable { return this.http.post(`${this.url}email`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData); + } + plexTest(settings: IPlexServer): Observable { + return this.http.post(`${this.url}plex`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData); + } + embyTest(settings: IEmbyServer): Observable { + return this.http.post(`${this.url}emby`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData); + } + radarrTest(settings: IRadarrSettings): Observable { + return this.http.post(`${this.url}radarr`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData); + } + sonarrTest(settings: ISonarrSettings): Observable { + return this.http.post(`${this.url}sonarr`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData); } } \ No newline at end of file diff --git a/src/Ombi/ClientApp/app/settings/emby/emby.component.ts b/src/Ombi/ClientApp/app/settings/emby/emby.component.ts index 734807bb6..dfa9f98e9 100644 --- a/src/Ombi/ClientApp/app/settings/emby/emby.component.ts +++ b/src/Ombi/ClientApp/app/settings/emby/emby.component.ts @@ -3,14 +3,16 @@ import { IEmbySettings, IEmbyServer } from '../../interfaces/ISettings' import { SettingsService } from '../../services/settings.service'; import { NotificationService } from "../../services/notification.service"; +import { TesterService } from '../../services/applications/tester.service'; @Component({ - - templateUrl: './emby.component.html', + templateUrl: './emby.component.html' }) export class EmbyComponent implements OnInit { - constructor(private settingsService: SettingsService, private notificationService: NotificationService) { } + constructor(private settingsService: SettingsService, + private notificationService: NotificationService, + private testerService : TesterService) { } settings: IEmbySettings; @@ -22,13 +24,37 @@ export class EmbyComponent implements OnInit { if (this.settings.servers == null) { this.settings.servers = []; } - this.settings.servers.push({ name: "New*", id: Math.floor(Math.random() * (99999 - 0 + 1) + 1), apiKey: "", administratorId: "", enableEpisodeSearching: false, ip: "", port: 0, ssl: false, subDir: "" }); + this.settings.servers.push({ + name: "New*", + id: Math.floor(Math.random() * (99999 - 0 + 1) + 1), + apiKey: "", + administratorId: "", + enableEpisodeSearching: false, + ip: "", + port: 0, + ssl: false, + subDir: "" + } as IEmbyServer); } - test() { - // TODO Emby Service + test(server: IEmbyServer) { + this.testerService.embyTest(server).subscribe(x => { + if (x) { + this.notificationService.success("Connected", `Successfully connected to the Emby server ${server.name}!`); + } else { + this.notificationService.error("Connected", `We could not connect to the Emby server ${server.name}!`); + } + }); } + removeServer(server: IEmbyServer) { + var index = this.settings.servers.indexOf(server, 0); + if (index > -1) { + this.settings.servers.splice(index, 1); + } + } + + save() { this.settingsService.saveEmby(this.settings).subscribe(x => { if (x) { diff --git a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html index 82e594a4b..8c9fd0fb1 100644 --- a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html +++ b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html @@ -4,12 +4,12 @@ Ombi Configuration
-
+