mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 05:13:18 -07:00
Finished the couchpotato settings
This commit is contained in:
parent
ba13f141aa
commit
d05d76be4b
7 changed files with 45 additions and 12 deletions
|
@ -74,7 +74,7 @@ namespace Ombi.Api.CouchPotato
|
||||||
|
|
||||||
public async Task<CouchPotatoApiKey> GetApiKey(string baseUrl, string username, string password)
|
public async Task<CouchPotatoApiKey> GetApiKey(string baseUrl, string username, string password)
|
||||||
{
|
{
|
||||||
var request = new Request("getkey/",baseUrl, HttpMethod.Get);
|
var request = new Request("getkey",baseUrl, HttpMethod.Get);
|
||||||
request.AddQueryString("u",username.CalcuateMd5Hash());
|
request.AddQueryString("u",username.CalcuateMd5Hash());
|
||||||
request.AddQueryString("p",password.CalcuateMd5Hash());
|
request.AddQueryString("p",password.CalcuateMd5Hash());
|
||||||
|
|
||||||
|
|
|
@ -21,5 +21,5 @@ export interface IProfileList {
|
||||||
|
|
||||||
export interface ICouchPotatoApiKey {
|
export interface ICouchPotatoApiKey {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
apiKey: string;
|
api_key: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { Observable } from "rxjs/Rx";
|
||||||
import { ServiceAuthHelpers } from "../service.helpers";
|
import { ServiceAuthHelpers } from "../service.helpers";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
ICouchPotatoSettings,
|
||||||
IDiscordNotifcationSettings,
|
IDiscordNotifcationSettings,
|
||||||
IEmailNotificationSettings,
|
IEmailNotificationSettings,
|
||||||
IEmbyServer,
|
IEmbyServer,
|
||||||
|
@ -15,7 +16,7 @@ import {
|
||||||
IPushoverNotificationSettings,
|
IPushoverNotificationSettings,
|
||||||
IRadarrSettings,
|
IRadarrSettings,
|
||||||
ISlackNotificationSettings,
|
ISlackNotificationSettings,
|
||||||
ISonarrSettings,
|
ISonarrSettings
|
||||||
} from "../../interfaces";
|
} from "../../interfaces";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -57,5 +58,8 @@ export class TesterService extends ServiceAuthHelpers {
|
||||||
}
|
}
|
||||||
public sonarrTest(settings: ISonarrSettings): Observable<boolean> {
|
public sonarrTest(settings: ISonarrSettings): Observable<boolean> {
|
||||||
return this.http.post(`${this.url}sonarr`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData);
|
return this.http.post(`${this.url}sonarr`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData);
|
||||||
|
}
|
||||||
|
public couchPotatoTest(settings: ICouchPotatoSettings): Observable<boolean> {
|
||||||
|
return this.http.post(`${this.url}couchpotato`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,10 +58,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password" class="control-label">Password</label>
|
<label for="password" class="control-label">Password</label>
|
||||||
<input type="text" class="form-control form-control-custom " formControlName="password" name="password">
|
<input type="password" class="form-control form-control-custom " formControlName="password" name="password">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button class="btn btn-primary-outline" (click)="requestToken(form)">Request Api Key <i class="fa fa-key"></i></button>
|
<button type="button" class="btn btn-primary-outline" (click)="requestToken(form)">Request Api Key <i class="fa fa-key"></i></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,10 @@ export class CouchPotatoComponent implements OnInit {
|
||||||
subDir: [x.subDir],
|
subDir: [x.subDir],
|
||||||
defaultProfileId: [x.defaultProfileId],
|
defaultProfileId: [x.defaultProfileId],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(x.defaultProfileId) {
|
||||||
|
this.getProfiles(this.form);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,11 +72,11 @@ export class CouchPotatoComponent implements OnInit {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const settings = form.value;
|
const settings = form.value;
|
||||||
this.testerService.radarrTest(settings).subscribe(x => {
|
this.testerService.couchPotatoTest(settings).subscribe(x => {
|
||||||
if (x === true) {
|
if (x === true) {
|
||||||
this.notificationService.success("Connected", "Successfully connected to Radarr!");
|
this.notificationService.success("Connected", "Successfully connected to CouchPotato!");
|
||||||
} else {
|
} else {
|
||||||
this.notificationService.error("Connected", "We could not connect to Radarr!");
|
this.notificationService.error("Connected", "We could not connect to CouchPotato!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -80,7 +84,7 @@ export class CouchPotatoComponent implements OnInit {
|
||||||
public requestToken(form: FormGroup) {
|
public requestToken(form: FormGroup) {
|
||||||
this.couchPotatoService.getApiKey(form.value).subscribe(x => {
|
this.couchPotatoService.getApiKey(form.value).subscribe(x => {
|
||||||
if (x.success === true) {
|
if (x.success === true) {
|
||||||
(<FormControl>this.form.controls.apiKey).setValue(x.apiKey);
|
(<FormControl>this.form.controls.apiKey).setValue(x.api_key);
|
||||||
this.notificationService.success("Api Key", "Successfully got the Api Key");
|
this.notificationService.success("Api Key", "Successfully got the Api Key");
|
||||||
} else {
|
} else {
|
||||||
this.notificationService.error("Api Key", "Could not get the Api Key");
|
this.notificationService.error("Api Key", "Could not get the Api Key");
|
||||||
|
|
|
@ -72,8 +72,8 @@
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/About']">About</a></li>
|
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/About']">About</a></li>
|
||||||
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/Update']">Update</a></li>
|
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/Update']">Update</a></li>
|
||||||
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/Logs']">Logs (Not available)</a></li>
|
<!-- <li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/Logs']">Logs (Not available)</a></li>
|
||||||
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/ScheduledJobs']">Scheduled Jobs (Not available)</a></li>
|
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/ScheduledJobs']">Scheduled Jobs (Not available)</a></li> -->
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
||||||
using Hangfire;
|
using Hangfire;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Ombi.Api.CouchPotato;
|
||||||
using Ombi.Api.Emby;
|
using Ombi.Api.Emby;
|
||||||
using Ombi.Api.Plex;
|
using Ombi.Api.Plex;
|
||||||
using Ombi.Api.Radarr;
|
using Ombi.Api.Radarr;
|
||||||
|
@ -44,9 +45,11 @@ namespace Ombi.Controllers.External
|
||||||
/// <param name="po">The pushover.</param>
|
/// <param name="po">The pushover.</param>
|
||||||
/// <param name="mm">The mattermost.</param>
|
/// <param name="mm">The mattermost.</param>
|
||||||
/// <param name="log">The logger.</param>
|
/// <param name="log">The logger.</param>
|
||||||
|
/// <param name="provider"></param>
|
||||||
public TesterController(INotificationService service, IDiscordNotification notification, IEmailNotification emailN,
|
public TesterController(INotificationService service, IDiscordNotification notification, IEmailNotification emailN,
|
||||||
IPushbulletNotification pushbullet, ISlackNotification slack, IPushoverNotification po, IMattermostNotification mm,
|
IPushbulletNotification pushbullet, ISlackNotification slack, IPushoverNotification po, IMattermostNotification mm,
|
||||||
IPlexApi plex, IEmbyApi emby, IRadarrApi radarr, ISonarrApi sonarr, ILogger<TesterController> log, IEmailProvider provider)
|
IPlexApi plex, IEmbyApi emby, IRadarrApi radarr, ISonarrApi sonarr, ILogger<TesterController> log, IEmailProvider provider,
|
||||||
|
ICouchPotatoApi cpApi)
|
||||||
{
|
{
|
||||||
Service = service;
|
Service = service;
|
||||||
DiscordNotification = notification;
|
DiscordNotification = notification;
|
||||||
|
@ -61,6 +64,7 @@ namespace Ombi.Controllers.External
|
||||||
SonarrApi = sonarr;
|
SonarrApi = sonarr;
|
||||||
Log = log;
|
Log = log;
|
||||||
EmailProvider = provider;
|
EmailProvider = provider;
|
||||||
|
CouchPotatoApi = cpApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
private INotificationService Service { get; }
|
private INotificationService Service { get; }
|
||||||
|
@ -74,6 +78,7 @@ namespace Ombi.Controllers.External
|
||||||
private IRadarrApi RadarrApi { get; }
|
private IRadarrApi RadarrApi { get; }
|
||||||
private IEmbyApi EmbyApi { get; }
|
private IEmbyApi EmbyApi { get; }
|
||||||
private ISonarrApi SonarrApi { get; }
|
private ISonarrApi SonarrApi { get; }
|
||||||
|
private ICouchPotatoApi CouchPotatoApi { get; }
|
||||||
private ILogger<TesterController> Log { get; }
|
private ILogger<TesterController> Log { get; }
|
||||||
private IEmailProvider EmailProvider { get; }
|
private IEmailProvider EmailProvider { get; }
|
||||||
|
|
||||||
|
@ -266,5 +271,25 @@ namespace Ombi.Controllers.External
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if we can connect to Sonarr with the provided settings
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="settings"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("couchpotato")]
|
||||||
|
public async Task<bool> CouchPotato([FromBody] CouchPotatoSettings settings)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await CouchPotatoApi.Status(settings.FullUri, settings.ApiKey);
|
||||||
|
return result?.success ?? false;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.LogError(LoggingEvents.Api, e, "Could not test CP");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue