Test buttons for Plex

New: Added buttons to test Plex configuration
pull/3113/head
Mark McDowall 12 years ago
parent cacd86b4ef
commit 7065898165

@ -93,5 +93,15 @@ namespace NzbDrone.Core.Providers
return _httpProvider.DownloadString(url);
}
public virtual void TestNotification(string hosts, string username, string password)
{
foreach (var host in hosts.Split(','))
{
logger.Trace("Sending Test Notifcation to XBMC Host: {0}", host);
var command = String.Format("ExecBuiltIn(Notification({0}, {1}))", "Test Notification", "Success! Notifications are setup correctly");
SendCommand(host.Trim(), command, _configProvider.PlexUsername, _configProvider.PlexPassword);
}
}
}
}

@ -19,12 +19,13 @@ namespace NzbDrone.Web.Controllers
private readonly SeasonProvider _seasonProvider;
private readonly ProwlProvider _prowlProvider;
private readonly XbmcProvider _xbmcProvider;
private readonly PlexProvider _plexProvider;
public CommandController(JobProvider jobProvider, SabProvider sabProvider,
SmtpProvider smtpProvider, TwitterProvider twitterProvider,
EpisodeProvider episodeProvider, GrowlProvider growlProvider,
SeasonProvider seasonProvider, ProwlProvider prowlProvider,
XbmcProvider xbmcProvider)
XbmcProvider xbmcProvider, PlexProvider plexProvider)
{
_jobProvider = jobProvider;
_sabProvider = sabProvider;
@ -35,6 +36,7 @@ namespace NzbDrone.Web.Controllers
_seasonProvider = seasonProvider;
_prowlProvider = prowlProvider;
_xbmcProvider = xbmcProvider;
_plexProvider = plexProvider;
}
public JsonResult RssSync()
@ -173,7 +175,7 @@ namespace NzbDrone.Web.Controllers
try
{
_xbmcProvider.TestNotification(hosts);
return JsonNotificationResult.Info("Success!", "Test Notification Sent Successfully");
return JsonNotificationResult.Info("Success!", "Test Notification sent successfully");
}
catch(Exception)
{
@ -195,5 +197,33 @@ namespace NzbDrone.Web.Controllers
return JsonNotificationResult.Oops("Failed to test JSON API, please review your settings.");
}
public JsonResult TestPlexNotification(string hosts, string username, string password)
{
try
{
_plexProvider.TestNotification(hosts, username, password);
return JsonNotificationResult.Info("Success!", "Test Notification sent successfully");
}
catch (Exception)
{
}
return JsonNotificationResult.Oops("Failed to send test notification, please review your settings.");
}
public JsonResult TestPlexServer(string host)
{
try
{
_plexProvider.GetSectionKeys(host);
return JsonNotificationResult.Info("Success!", "Successfully tested Server settings");
}
catch (Exception)
{
}
return JsonNotificationResult.Oops("Failed to connect to server, please review your settings.");
}
}
}

@ -11,6 +11,8 @@ var testSabUrl = '../Command/TestSabnzbd';
var testEmailUrl = '../Command/TestEmail';
var testXbmcNotificationUrl = '../Command/TestXbmcNotification';
var testXbmcJsonApiUrl = '../Command/TestXbmcJsonApi';
var testPlexNotificationUrl = '../Command/TestPlexNotification';
var testPlexServerUrl = '../Command/TestPlexServer';
function createExamples() {
createSingleEpisodeExample();
@ -251,3 +253,30 @@ $(document).on('click', '#xbmc-test-jsonapi', function () {
})
});
});
//Plex
$(document).on('click', '#plex-test-notification', function () {
var hosts = $('#PlexsClientHosts').val();
var username = $('#PlexUsername').val();
var password = $('#PlexPassword').val();
$.ajax({
url: testPlexNotificationUrl,
data: jQuery.param({
hosts: hosts,
username: username,
password: password
})
});
});
$(document).on('click', '#plex-test-server', function () {
var host = $('#PlexServerHost').val();
$.ajax({
url: testPlexServerUrl,
data: jQuery.param({
host: host
})
});
});

@ -47,4 +47,14 @@
<span class="small">@Html.DescriptionFor(m => m.PlexPassword)</span>
</label>
@Html.TextBoxFor(m => m.PlexPassword, new { @class = "inputClass", type = "password" })
<label class="labelClass">Test Notification
<span class="small">Sends a test notification to your Plex client(s)</span>
</label>
<input type="button" id="plex-test-notification" value="Test Notification" class="inputClass"/>
<label class="labelClass">Test Server
<span class="small">Test Plex server settings</span>
</label>
<input type="button" id="plex-test-server" value="Test Server" class="inputClass"/>
</div>
Loading…
Cancel
Save