Finished the couchpotato settings

pull/1614/head
tidusjar 7 years ago
parent ba13f141aa
commit d05d76be4b

@ -74,7 +74,7 @@ namespace Ombi.Api.CouchPotato
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("p",password.CalcuateMd5Hash());

@ -21,5 +21,5 @@ export interface IProfileList {
export interface ICouchPotatoApiKey {
success: boolean;
apiKey: string;
api_key: string;
}

@ -6,6 +6,7 @@ import { Observable } from "rxjs/Rx";
import { ServiceAuthHelpers } from "../service.helpers";
import {
ICouchPotatoSettings,
IDiscordNotifcationSettings,
IEmailNotificationSettings,
IEmbyServer,
@ -15,7 +16,7 @@ import {
IPushoverNotificationSettings,
IRadarrSettings,
ISlackNotificationSettings,
ISonarrSettings,
ISonarrSettings
} from "../../interfaces";
@Injectable()
@ -57,5 +58,8 @@ export class TesterService extends ServiceAuthHelpers {
}
public sonarrTest(settings: ISonarrSettings): Observable<boolean> {
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 class="form-group">
<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 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>

@ -34,6 +34,10 @@ export class CouchPotatoComponent implements OnInit {
subDir: [x.subDir],
defaultProfileId: [x.defaultProfileId],
});
if(x.defaultProfileId) {
this.getProfiles(this.form);
}
});
}
@ -68,11 +72,11 @@ export class CouchPotatoComponent implements OnInit {
return;
}
const settings = form.value;
this.testerService.radarrTest(settings).subscribe(x => {
this.testerService.couchPotatoTest(settings).subscribe(x => {
if (x === true) {
this.notificationService.success("Connected", "Successfully connected to Radarr!");
this.notificationService.success("Connected", "Successfully connected to CouchPotato!");
} 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) {
this.couchPotatoService.getApiKey(form.value).subscribe(x => {
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");
} else {
this.notificationService.error("Api Key", "Could not get the Api Key");

@ -72,8 +72,8 @@
<ul class="dropdown-menu">
<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/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/Logs']">Logs (Not available)</a></li>
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/ScheduledJobs']">Scheduled Jobs (Not available)</a></li> -->
</ul>
</li>

@ -4,6 +4,7 @@ using System.Threading.Tasks;
using Hangfire;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Ombi.Api.CouchPotato;
using Ombi.Api.Emby;
using Ombi.Api.Plex;
using Ombi.Api.Radarr;
@ -44,9 +45,11 @@ namespace Ombi.Controllers.External
/// <param name="po">The pushover.</param>
/// <param name="mm">The mattermost.</param>
/// <param name="log">The logger.</param>
/// <param name="provider"></param>
public TesterController(INotificationService service, IDiscordNotification notification, IEmailNotification emailN,
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;
DiscordNotification = notification;
@ -61,6 +64,7 @@ namespace Ombi.Controllers.External
SonarrApi = sonarr;
Log = log;
EmailProvider = provider;
CouchPotatoApi = cpApi;
}
private INotificationService Service { get; }
@ -74,6 +78,7 @@ namespace Ombi.Controllers.External
private IRadarrApi RadarrApi { get; }
private IEmbyApi EmbyApi { get; }
private ISonarrApi SonarrApi { get; }
private ICouchPotatoApi CouchPotatoApi { get; }
private ILogger<TesterController> Log { get; }
private IEmailProvider EmailProvider { get; }
@ -266,5 +271,25 @@ namespace Ombi.Controllers.External
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…
Cancel
Save