SickRage settings UI

pull/1741/head
Jamie 7 years ago
parent f21cd89a74
commit 2cf31fe70d

@ -0,0 +1,26 @@
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Ombi.Settings.Settings.Models.External
{
public class SickRageSettings : ExternalSettings
{
public bool Enabled { get; set; }
public string ApiKey { get; set; }
public string QualityProfile { get; set; }
[JsonIgnore]
public Dictionary<string, string> Qualities => new Dictionary<string, string>
{
{ "default", "Use Default" },
{ "sdtv", "SD TV" },
{ "sddvd", "SD DVD" },
{ "hdtv", "HD TV" },
{ "rawhdtv", "Raw HD TV" },
{ "hdwebdl", "HD Web DL" },
{ "fullhdwebdl", "Full HD Web DL" },
{ "hdbluray", "HD Bluray" },
{ "fullhdbluray", "Full HD Bluray" }
};
}
}

@ -26,3 +26,7 @@ export interface IUsersModel {
id: string;
username: string;
}
export interface IDictionary<T> {
[Key: string]: T;
}

@ -1,4 +1,4 @@
import { ISettings } from "./ICommon";
import { IDictionary, ISettings } from "./ICommon";
export interface IExternalSettings extends ISettings {
ssl: boolean;
@ -154,6 +154,13 @@ export interface ICouchPotatoSettings extends IExternalSettings {
password: string;
}
export interface ISickRageSettings extends IExternalSettings {
enabled: boolean;
apiKey: string;
qualityProfile: string;
qualities: IDictionary<string>;
}
export interface IDogNzbSettings extends ISettings {
enabled: boolean;
apiKey: string;

@ -1,4 +1,5 @@
import { PlatformLocation } from "@angular/common";
import { ISickRageSettings } from './../interfaces/ISettings';
import { PlatformLocation } from "@angular/common";
import { Injectable } from "@angular/core";
import { Http } from "@angular/http";
import { AuthHttp } from "angular2-jwt";
@ -21,6 +22,7 @@ import {
IPushbulletNotificationSettings,
IPushoverNotificationSettings,
IRadarrSettings,
ISickRageSettings,
ISlackNotificationSettings,
ISonarrSettings,
ITelegramNotifcationSettings,
@ -234,7 +236,7 @@ export class SettingsService extends ServiceAuthHelpers {
public getTelegramNotificationSettings(): Observable<ITelegramNotifcationSettings> {
return this.httpAuth.get(`${this.url}/notifications/telegram`).map(this.extractData).catch(this.handleError);
}
}
public saveTelegramNotificationSettings(settings: ITelegramNotifcationSettings): Observable<boolean> {
return this.httpAuth
@ -250,5 +252,15 @@ export class SettingsService extends ServiceAuthHelpers {
return this.httpAuth
.post(`${this.url}/jobs`, JSON.stringify(settings), { headers: this.headers })
.map(this.extractData).catch(this.handleError);
}
public getSickRageSettings(): Observable<ISickRageSettings> {
return this.httpAuth.get(`${this.url}/sickrage`).map(this.extractData).catch(this.handleError);
}
public saveSickRageSettings(settings: ISickRageSettings): Observable<boolean> {
return this.httpAuth
.post(`${this.url}/sickrage`, JSON.stringify(settings), { headers: this.headers })
.map(this.extractData).catch(this.handleError);
}
}

@ -29,6 +29,7 @@ import { TelegramComponent } from "./notifications/telegram.component";
import { OmbiComponent } from "./ombi/ombi.component";
import { PlexComponent } from "./plex/plex.component";
import { RadarrComponent } from "./radarr/radarr.component";
import { SickRageComponent } from "./sickrage/sickrage.component";
import { SonarrComponent } from "./sonarr/sonarr.component";
import { UpdateComponent } from "./update/update.component";
import { UserManagementComponent } from "./usermanagement/usermanagement.component";
@ -59,6 +60,7 @@ const routes: Routes = [
{ path: "Settings/DogNzb", component: DogNzbComponent, canActivate: [AuthGuard] },
{ path: "Settings/Telegram", component: TelegramComponent, canActivate: [AuthGuard] },
{ path: "Settings/Jobs", component: JobsComponent, canActivate: [AuthGuard] },
{ path: "Settings/SickRage", component: SickRageComponent, canActivate: [AuthGuard] },
];
@NgModule({
@ -103,6 +105,7 @@ const routes: Routes = [
WikiComponent,
CouchPotatoComponent,
DogNzbComponent,
SickRageComponent,
TelegramComponent,
],
exports: [

@ -0,0 +1,78 @@

<settings-menu></settings-menu>
<div *ngIf="form">
<fieldset>
<legend>SickRage Settings</legend>
<form novalidate [formGroup]="form" (ngSubmit)="onSubmit(form)" style="padding-top:5%;">
<div class="col-md-6">
<div class="form-group">
<div class="checkbox">
<input type="checkbox" id="enable" formControlName="enabled">
<label for="enable">Enable</label>
</div>
</div>
<div class="form-group">
<label for="Ip" class="control-label">Hostname or IP</label>
<input type="text" class="form-control form-control-custom " formControlName="ip" id="Ip" name="Ip" placeholder="localhost" [ngClass]="{'form-error': form.get('ip').hasError('required')}">
<small *ngIf="form.get('ip').hasError('required')" class="error-text">The IP/Hostname is required</small>
</div>
<div class="form-group">
<label for="portNumber" class="control-label">Port</label>
<input type="text" class="form-control form-control-custom " [ngClass]="{'form-error': form.get('port').hasError('required')}" formControlName="port" id="portNumber" name="Port" placeholder="Port Number">
<small *ngIf="form.get('port').hasError('required')" class="error-text">The Port is required</small>
</div>
<div class="form-group">
<label for="ApiKey" class="control-label">API Key</label>
<input type="text" class="form-control form-control-custom " [ngClass]="{'form-error': form.get('apiKey').hasError('required')}" formControlName="apiKey" id="ApiKey" name="ApiKey">
<small *ngIf="form.get('apiKey').hasError('required')" class="error-text">The API Key is required</small>
</div>
<div class="form-group">
<div class="checkbox">
<input type="checkbox" id="Ssl" name="Ssl" formControlName="ssl"><label for="Ssl">SSL</label>
</div>
</div>
<div class="form-group">
<label for="SubDir" class="control-label">Base Url</label>
<div>
<input type="text" class="form-control form-control-custom" formControlName="subDir" id="SubDir" name="SubDir">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<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>
</select>
</div>
<small *ngIf="form.get('qualityProfile').hasError('required')" class="error-text">A Default Quality Profile is required</small>
</div>
<div class="form-group">
<div>
<button type="button" (click)="test(form)" class="btn btn-primary-outline">Test Connectivity <span id="spinner"> </span></button>
</div>
</div>
<div class="form-group">
<div>
<button type="submit" class="btn btn-primary-outline ">Submit</button>
</div>
</div>
</div>
</form>
</fieldset>
</div>

@ -0,0 +1,77 @@
import { Component, OnInit } from "@angular/core";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { ISonarrProfile, ISonarrRootFolder } from "../../interfaces";
// import { ISickRageSettings } from "../../interfaces";
// import { SonarrService } from "../../services";
// import { TesterService } from "../../services";
import { NotificationService } from "../../services";
import { SettingsService } from "../../services";
@Component({
templateUrl: "./sickrage.component.html",
})
export class SickRageComponent implements OnInit {
public qualities: ISonarrProfile[];
public rootFolders: ISonarrRootFolder[];
public selectedRootFolder: ISonarrRootFolder;
public selectedQuality: ISonarrProfile;
public profilesRunning: boolean;
public rootFoldersRunning: boolean;
public form: FormGroup;
public advanced = false;
constructor(private settingsService: SettingsService,
private notificationService: NotificationService,
private fb: FormBuilder) { }
public ngOnInit() {
this.settingsService.getSickRageSettings()
.subscribe(x => {
this.form = this.fb.group({
enabled: [x.enabled],
apiKey: [x.apiKey, [Validators.required]],
qualityProfile: [x.qualityProfile, [Validators.required]],
qualities: [x.qualities],
ssl: [x.ssl],
subDir: [x.subDir],
ip: [x.ip, [Validators.required]],
port: [x.port, [Validators.required]],
});
});
}
public test(form: FormGroup) {
if (form.invalid) {
this.notificationService.error("Please check your entered values");
return;
}
// const settings = <ISickRageSettings>form.value;
// this.testerService.sonarrTest(settings).subscribe(x => {
// if (x) {
// this.notificationService.success("Successfully connected to SickRage!");
// } else {
// this.notificationService.error("We could not connect to SickRage!");
// }
// });
}
public onSubmit(form: FormGroup) {
if (form.invalid) {
this.notificationService.error("Please check your entered values");
return;
}
this.settingsService.saveSickRageSettings(form.value)
.subscribe(x => {
if (x) {
this.notificationService.success("Successfully saved SickRage settings");
} else {
this.notificationService.error("There was an error when saving the SickRage settings");
}
});
}
}

@ -424,6 +424,27 @@ namespace Ombi.Controllers
return await Save(settings);
}
/// <summary>
/// Save the SickRage settings.
/// </summary>
/// <param name="settings">The settings.</param>
/// <returns></returns>
[HttpPost("SickRage")]
public async Task<bool> SickRageSettings([FromBody]SickRageSettings settings)
{
return await Save(settings);
}
/// <summary>
/// Gets the SickRage Settings.
/// </summary>
/// <returns></returns>
[HttpGet("SickRage")]
public async Task<SickRageSettings> SickRageSettings()
{
return await Get<SickRageSettings>();
}
/// <summary>
/// Gets the JobSettings Settings.
/// </summary>

Loading…
Cancel
Save