mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
Fixed #1640
This commit is contained in:
parent
016c409ace
commit
2a842e3786
6 changed files with 35 additions and 49 deletions
|
@ -1,16 +1,11 @@
|
|||
import { ICutoff, IItem } from "./ICommon";
|
||||
|
||||
export interface IRadarrRootFolder {
|
||||
export interface IRadarrRootFolder {
|
||||
id: number;
|
||||
path: string;
|
||||
freespace: number;
|
||||
}
|
||||
|
||||
export interface IRadarrProfile {
|
||||
name: string;
|
||||
id: number;
|
||||
cutoff: ICutoff;
|
||||
items: IItem[];
|
||||
}
|
||||
|
||||
export interface IMinimumAvailability {
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
import { ICutoff, IItem } from "./ICommon";
|
||||
|
||||
export interface ISonarrRootFolder {
|
||||
export interface ISonarrRootFolder {
|
||||
id: number;
|
||||
path: string;
|
||||
freespace: number;
|
||||
}
|
||||
|
||||
export interface ISonarrProfile {
|
||||
name: string;
|
||||
id: number;
|
||||
cutoff: ICutoff;
|
||||
items: IItem[];
|
||||
}
|
||||
|
|
|
@ -56,14 +56,14 @@
|
|||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<button type="submit" (click)="getProfiles(form)" class="btn btn-primary-outline">Get Quality Profiles <span *ngIf="profilesRunning" class="fa fa-spinner fa-spin"> </span></button>
|
||||
<button (click)="getProfiles(form)" class="btn btn-primary-outline">Get Quality Profiles <span *ngIf="profilesRunning" class="fa fa-spinner fa-spin"> </span></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="select" class="control-label">Quality Profiles</label>
|
||||
<div id="profiles">
|
||||
<select formControlName="defaultQualityProfile" class="form-control form-control-custom" id="select" [ngClass]="{'form-error': form.get('defaultQualityProfile').hasError('required')}">
|
||||
<option *ngFor="let quality of qualities" value="{{quality.id}}">{{quality.name}}</option>
|
||||
<option *ngFor="let quality of qualities" value="{{quality.id}}" [selected]="quality.id == -1">{{quality.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<small *ngIf="form.get('defaultQualityProfile').hasError('required')" class="error-text">A Default Quality Profile is required</small>
|
||||
|
@ -71,7 +71,7 @@
|
|||
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<button type="submit" (click)="getRootFolders(form)" class="btn btn-primary-outline">Get Root Folders <span *ngIf="rootFoldersRunning" class="fa fa-spinner fa-spin"></span></button>
|
||||
<button (click)="getRootFolders(form)" class="btn btn-primary-outline">Get Root Folders <span *ngIf="rootFoldersRunning" class="fa fa-spinner fa-spin"></span></button>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -80,7 +80,7 @@
|
|||
<label for="rootFolders" class="control-label">Default Root Folders</label>
|
||||
<div id="rootFolders">
|
||||
<select formControlName="defaultRootPath" class="form-control form-control-custom" [ngClass]="{'form-error': form.get('defaultRootPath').hasError('required')}">
|
||||
<option *ngFor="let folder of rootFolders" value="{{folder.path}}">{{folder.path}}</option>
|
||||
<option *ngFor="let folder of rootFolders" value="{{folder.path}}" [selected]="folder.id == -1">{{folder.path}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<small *ngIf="form.get('defaultRootPath').hasError('required')" class="error-text">A Default Root Path is required</small>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { Component, OnInit } from "@angular/core";
|
||||
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
||||
import "rxjs/add/operator/takeUntil";
|
||||
import { Subject } from "rxjs/Subject";
|
||||
|
||||
import { IMinimumAvailability, IRadarrProfile, IRadarrRootFolder } from "../../interfaces";
|
||||
import { IRadarrSettings } from "../../interfaces";
|
||||
|
@ -23,8 +21,6 @@ export class RadarrComponent implements OnInit {
|
|||
public advanced = false;
|
||||
public form: FormGroup;
|
||||
|
||||
private subscriptions = new Subject<void>();
|
||||
|
||||
constructor(private settingsService: SettingsService,
|
||||
private radarrService: RadarrService,
|
||||
private notificationService: NotificationService,
|
||||
|
@ -33,7 +29,6 @@ export class RadarrComponent implements OnInit {
|
|||
|
||||
public ngOnInit() {
|
||||
this.settingsService.getRadarr()
|
||||
.takeUntil(this.subscriptions)
|
||||
.subscribe(x => {
|
||||
|
||||
this.form = this.fb.group({
|
||||
|
@ -57,6 +52,11 @@ export class RadarrComponent implements OnInit {
|
|||
}
|
||||
});
|
||||
|
||||
this.qualities = [];
|
||||
this.qualities.push({ name: "Please Select", id: -1 });
|
||||
|
||||
this.rootFolders = [];
|
||||
this.rootFolders.push({ path: "Please Select", id: -1 });
|
||||
this.minimumAvailabilityOptions = [
|
||||
{ name: "Announced", value: "Announced" },
|
||||
{ name: "In Cinemas", value: "InCinemas" },
|
||||
|
@ -70,9 +70,10 @@ export class RadarrComponent implements OnInit {
|
|||
this.profilesRunning = true;
|
||||
this.radarrService.getQualityProfiles(form.value).subscribe(x => {
|
||||
this.qualities = x;
|
||||
this.qualities.unshift({ name: "Please Select", id: -1 });
|
||||
|
||||
this.profilesRunning = false;
|
||||
this.notificationService.success("Quality Profiles", "Successfully retrevied the Quality Profiles");
|
||||
this.notificationService.success("Quality Profiles", "Successfully retrieved the Quality Profiles");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -80,9 +81,10 @@ export class RadarrComponent implements OnInit {
|
|||
this.rootFoldersRunning = true;
|
||||
this.radarrService.getRootFolders(form.value).subscribe(x => {
|
||||
this.rootFolders = x;
|
||||
this.rootFolders.unshift({ path: "Please Select", id: -1 });
|
||||
|
||||
this.rootFoldersRunning = false;
|
||||
this.notificationService.success("Settings Saved", "Successfully retrevied the Root Folders");
|
||||
this.notificationService.success("Settings Saved", "Successfully retrieved the Root Folders");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -106,6 +108,10 @@ public onSubmit(form: FormGroup) {
|
|||
this.notificationService.error("Please check your entered values");
|
||||
return;
|
||||
}
|
||||
if(form.controls.defaultQualityProfile.value === "-1" || form.controls.defaultRootPath.value === "Please Select") {
|
||||
this.notificationService.error("Please check your entered values");
|
||||
return;
|
||||
}
|
||||
|
||||
const settings = <IRadarrSettings>form.value;
|
||||
this.settingsService.saveRadarr(settings).subscribe(x => {
|
||||
|
@ -117,9 +123,4 @@ public onSubmit(form: FormGroup) {
|
|||
});
|
||||
|
||||
}
|
||||
|
||||
public ngOnDestroy() {
|
||||
this.subscriptions.next();
|
||||
this.subscriptions.complete();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
<label for="select" class="control-label">Quality Profiles</label>
|
||||
<div id="profiles">
|
||||
<select class="form-control form-control-custom" [ngClass]="{'form-error': form.get('qualityProfile').hasError('required')}" id="select" formControlName="qualityProfile">
|
||||
<option *ngFor="let quality of qualities" value="{{quality.id}}">{{quality.name}}</option>
|
||||
<option *ngFor="let quality of qualities" value="{{quality.id}}" [selected]="quality.id == -1">{{quality.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<small *ngIf="form.get('qualityProfile').hasError('required')" class="error-text">A Default Quality Profile is required</small>
|
||||
|
@ -72,7 +72,6 @@
|
|||
<div class="form-group">
|
||||
<div>
|
||||
<button type="button" (click)="getRootFolders(form)" class="btn btn-primary-outline">Get Root Folders <span *ngIf="rootFoldersRunning" class="fa fa-spinner fa-spin"></span></button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -80,7 +79,7 @@
|
|||
<label for="rootFolders" class="control-label">Default Root Folders</label>
|
||||
<div id="rootFolders">
|
||||
<select class="form-control form-control-custom" formControlName="rootPath" [ngClass]="{'form-error': form.get('rootPath').hasError('required')}">
|
||||
<option *ngFor="let folder of rootFolders" value="{{folder.id}}">{{folder.path}}</option>
|
||||
<option *ngFor="let folder of rootFolders" value="{{folder.id}}" [selected]="folder.id == -1">{{folder.path}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<small *ngIf="form.get('rootPath').hasError('required')" class="error-text">A Default Root Path is required</small>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { Component, OnDestroy, OnInit } from "@angular/core";
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
||||
import "rxjs/add/operator/takeUntil";
|
||||
import { Subject } from "rxjs/Subject";
|
||||
|
||||
import { ISonarrProfile, ISonarrRootFolder } from "../../interfaces";
|
||||
|
||||
|
@ -14,7 +12,7 @@ import { SettingsService } from "../../services";
|
|||
@Component({
|
||||
templateUrl: "./sonarr.component.html",
|
||||
})
|
||||
export class SonarrComponent implements OnInit, OnDestroy {
|
||||
export class SonarrComponent implements OnInit {
|
||||
|
||||
public qualities: ISonarrProfile[];
|
||||
public rootFolders: ISonarrRootFolder[];
|
||||
|
@ -25,8 +23,6 @@ export class SonarrComponent implements OnInit, OnDestroy {
|
|||
public form: FormGroup;
|
||||
public advanced = false;
|
||||
|
||||
private subscriptions = new Subject<void>();
|
||||
|
||||
constructor(private settingsService: SettingsService,
|
||||
private sonarrService: SonarrService,
|
||||
private notificationService: NotificationService,
|
||||
|
@ -36,9 +32,7 @@ export class SonarrComponent implements OnInit, OnDestroy {
|
|||
public ngOnInit() {
|
||||
|
||||
this.settingsService.getSonarr()
|
||||
.takeUntil(this.subscriptions)
|
||||
.subscribe(x => {
|
||||
|
||||
this.form = this.fb.group({
|
||||
enabled: [x.enabled],
|
||||
apiKey: [x.apiKey, [Validators.required]],
|
||||
|
@ -59,29 +53,33 @@ export class SonarrComponent implements OnInit, OnDestroy {
|
|||
this.getRootFolders(this.form);
|
||||
}
|
||||
});
|
||||
this.rootFolders = [];
|
||||
this.qualities = [];
|
||||
this.rootFolders.push({ path: "Please Select", id: -1 });
|
||||
this.qualities.push({ name: "Please Select", id: -1 });
|
||||
}
|
||||
|
||||
public getProfiles(form: FormGroup) {
|
||||
this.profilesRunning = true;
|
||||
this.sonarrService.getQualityProfiles(form.value)
|
||||
.takeUntil(this.subscriptions)
|
||||
.subscribe(x => {
|
||||
this.qualities = x;
|
||||
this.qualities.unshift({ name: "Please Select", id: -1 });
|
||||
|
||||
this.profilesRunning = false;
|
||||
this.notificationService.success("Quality Profiles", "Successfully retrevied the Quality Profiles");
|
||||
this.notificationService.success("Quality Profiles", "Successfully retrieved the Quality Profiles");
|
||||
});
|
||||
}
|
||||
|
||||
public getRootFolders(form: FormGroup) {
|
||||
this.rootFoldersRunning = true;
|
||||
this.sonarrService.getRootFolders(form.value)
|
||||
.takeUntil(this.subscriptions)
|
||||
.subscribe(x => {
|
||||
this.rootFolders = x;
|
||||
this.rootFolders.unshift({ path: "Please Select", id: -1 });
|
||||
|
||||
this.rootFoldersRunning = false;
|
||||
this.notificationService.success("Settings Saved", "Successfully retrevied the Root Folders");
|
||||
this.notificationService.success("Settings Saved", "Successfully retrieved the Root Folders");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -105,8 +103,11 @@ export class SonarrComponent implements OnInit, OnDestroy {
|
|||
this.notificationService.error("Please check your entered values");
|
||||
return;
|
||||
}
|
||||
if(form.controls.defaultQualityProfile.value === "-1" || form.controls.defaultRootPath.value === "Please Select") {
|
||||
this.notificationService.error("Please check your entered values");
|
||||
return;
|
||||
}
|
||||
this.settingsService.saveSonarr(form.value)
|
||||
.takeUntil(this.subscriptions)
|
||||
.subscribe(x => {
|
||||
if (x) {
|
||||
this.notificationService.success("Settings Saved", "Successfully saved Sonarr settings");
|
||||
|
@ -115,9 +116,4 @@ export class SonarrComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ngOnDestroy() {
|
||||
this.subscriptions.next();
|
||||
this.subscriptions.complete();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue