-
-
-
-
-
Server Name
- Auto populated during discovery of the server if left empty.
@@ -62,6 +56,14 @@
+
+ Episode Batch Size
+
+
+ 150 by default, you shouldn't need to change this, this sets how many episodes we request from Plex at a single time.
+
+
+
Libraries
diff --git a/src/Ombi/ClientApp/src/app/settings/plex/plex.component.ts b/src/Ombi/ClientApp/src/app/settings/plex/plex.component.ts
index 712b77dc1..cad3a05bd 100644
--- a/src/Ombi/ClientApp/src/app/settings/plex/plex.component.ts
+++ b/src/Ombi/ClientApp/src/app/settings/plex/plex.component.ts
@@ -1,15 +1,14 @@
-import { Component, OnDestroy, OnInit, ViewChild } from "@angular/core";
-import { Subject } from "rxjs";
-import { takeUntil } from "rxjs/operators";
+import { Component, OnDestroy, OnInit } from "@angular/core";
+import { EMPTY, Subject } from "rxjs";
+import { catchError, takeUntil } from "rxjs/operators";
-import { IPlexLibrariesSettings, IPlexServer, IPlexServerResponse, IPlexServerViewModel, IPlexSettings } from "../../interfaces";
-import { JobService, NotificationService, PlexService, SettingsService, TesterService } from "../../services";
-import { MatTabChangeEvent, MatTabGroup } from "@angular/material/tabs";
+import { IPlexServer, IPlexServerResponse, IPlexServerViewModel, IPlexSettings } from "../../interfaces";
+import { JobService, NotificationService, PlexService, SettingsService } from "../../services";
import {UntypedFormControl} from '@angular/forms';
import { MatDialog } from "@angular/material/dialog";
import { PlexWatchlistComponent } from "./components/watchlist/plex-watchlist.component";
import { PlexServerDialogComponent } from "./components/plex-server-dialog/plex-server-dialog.component";
-import { PlexCreds, PlexServerDialogData, PlexSyncType } from "./components/models";
+import { PlexServerDialogData, PlexSyncType } from "./components/models";
@Component({
templateUrl: "./plex.component.html",
@@ -20,14 +19,10 @@ export class PlexComponent implements OnInit, OnDestroy {
public loadedServers: IPlexServerViewModel; // This comes from the api call for the user to select a server
public serversButton = false;
selected = new UntypedFormControl(0);
- @ViewChild("tabGroup", {static: false}) public tagGroup: MatTabGroup;
-
public username: string;
public password: string;
- public advanced = false;
-
private subscriptions = new Subject();
public PlexSyncType = PlexSyncType;
@@ -35,7 +30,6 @@ export class PlexComponent implements OnInit, OnDestroy {
private settingsService: SettingsService,
private notificationService: NotificationService,
private plexService: PlexService,
- private testerService: TesterService,
private jobService: JobService,
private dialog: MatDialog) { }
@@ -48,6 +42,10 @@ export class PlexComponent implements OnInit, OnDestroy {
public requestServers() {
this.plexService.getServers(this.username, this.password).pipe(
takeUntil(this.subscriptions),
+ catchError(() => {
+ this.notificationService.error("There was an issue. Please make sure your username and password are correct");
+ return EMPTY;
+ })
).subscribe(x => {
if (x.success) {
this.loadedServers = x;
@@ -61,7 +59,7 @@ export class PlexComponent implements OnInit, OnDestroy {
public selectServer(selectedServer: IPlexServerResponse) {
const server = { name: "New" + this.settings.servers.length + "*", id: Math.floor(Math.random() * (99999 - 0 + 1) + 1) };
-
+
var splitServers = selectedServer.localAddresses.split(",");
if (splitServers.length > 1) {
server.ip = splitServers[splitServers.length - 1];
@@ -79,61 +77,6 @@ export class PlexComponent implements OnInit, OnDestroy {
this.newServer(server);
}
- public testPlex(server: IPlexServer) {
- this.testerService.plexTest(server).subscribe(x => {
- if (x === true) {
- this.notificationService.success(`Successfully connected to the Plex server ${server.name}!`);
- } else {
- this.notificationService.error(`We could not connect to the Plex server ${server.name}!`);
- }
- });
- }
-
- public addTab(event: MatTabChangeEvent) {
- const tabName = event.tab.textLabel;
- if (tabName == "Add Server"){
-
- if (this.settings.servers == null) {
- this.settings.servers = [];
- }
- this.settings.servers.push( { name: "New" + this.settings.servers.length + "*", id: Math.floor(Math.random() * (99999 - 0 + 1) + 1) });
-
- //this.tagGroup.selectedIndex = (0);
- this.selected.setValue(this.settings.servers.length - 1);
- }
- }
-
- public removeServer(server: IPlexServer) {
- const index = this.settings.servers.indexOf(server, 0);
- if (index > -1) {
- this.settings.servers.splice(index, 1);
- this.selected.setValue(this.settings.servers.length - 1);
- }
- }
-
- public loadLibraries(server: IPlexServer) {
- if (server.ip == null) {
- this.notificationService.error("Plex is not yet configured correctly");
- return;
- }
- this.plexService.getLibraries(server).subscribe(x => {
- server.plexSelectedLibraries = [];
- if (x.successful) {
- x.data.mediaContainer.directory.forEach((item) => {
- const lib: IPlexLibrariesSettings = {
- key: item.key,
- title: item.title,
- enabled: false,
- };
- server.plexSelectedLibraries.push(lib);
- });
- } else {
- this.notificationService.error(x.message);
- }
- },
- err => { this.notificationService.error(err); });
- }
-
public save() {
const filtered = this.settings.servers.filter(x => x.name !== "");
this.settings.servers = filtered;
@@ -186,7 +129,18 @@ export class PlexComponent implements OnInit, OnDestroy {
panelClass: "modal-panel",
});
dialog.afterClosed().subscribe((x) => {
- console.log(x);
+ if (x.deleted) {
+ this.removeServer(server);
+ }
+ if (x.server) {
+ console.log(x.server);
+ var idx = this.settings.servers.findIndex(server => server.id === x.server.id);
+ if (idx >= 0) {
+ this.settings.servers[idx] = x.server;
+ } else {
+ this.settings.servers.push(x.server);
+ }
+ }
});
}
@@ -200,10 +154,20 @@ export class PlexComponent implements OnInit, OnDestroy {
panelClass: "modal-panel",
});
dialog.afterClosed().subscribe((x) => {
- console.log(x);
+ if (x.server) {
+ this.settings.servers.push(x.server);
+ }
});
}
+ private removeServer(server: IPlexServer) {
+ const index = this.settings.servers.indexOf(server, 0);
+ if (index > -1) {
+ this.settings.servers.splice(index, 1);
+ this.selected.setValue(this.settings.servers.length - 1);
+ }
+ }
+
private runCacher(): void {
this.jobService.runPlexCacher().subscribe(x => {
if (x) {