mirror of https://github.com/Sonarr/Sonarr
Test buttons for XBMC
New: Added buttons to test XBMC configuration
This commit is contained in:
parent
d070401f20
commit
cacd86b4ef
|
@ -31,6 +31,11 @@ namespace NzbDrone.Core.Providers
|
|||
_eventClientProvider = eventClientProvider;
|
||||
}
|
||||
|
||||
public XbmcProvider()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void Notify(string header, string message)
|
||||
{
|
||||
//Always use EventServer, until Json has real support for it
|
||||
|
@ -41,11 +46,6 @@ namespace NzbDrone.Core.Providers
|
|||
}
|
||||
}
|
||||
|
||||
public XbmcProvider()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void Update(Series series)
|
||||
{
|
||||
//Use Json for Eden/Nightly or depricated HTTP for 10.x (Dharma) to get the proper path
|
||||
|
@ -376,6 +376,26 @@ namespace NzbDrone.Core.Providers
|
|||
return false;
|
||||
}
|
||||
|
||||
public virtual void TestNotification(string hosts)
|
||||
{
|
||||
foreach (var host in hosts.Split(','))
|
||||
{
|
||||
Logger.Trace("Sending Test Notifcation to XBMC Host: {0}", host);
|
||||
_eventClientProvider.SendNotification("Test Notification", "Success! Notifications are setup correctly", IconType.Jpeg, "NzbDrone.jpg", GetHostWithoutPort(host));
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void TestJsonApi(string hosts, string username, string password)
|
||||
{
|
||||
foreach (var host in hosts.Split(','))
|
||||
{
|
||||
Logger.Trace("Sending Test Notifcation to XBMC Host: {0}", host);
|
||||
var version = GetJsonVersion(host, username, password);
|
||||
if (version == 0)
|
||||
throw new Exception("Failed to get JSON version in test");
|
||||
}
|
||||
}
|
||||
|
||||
private string GetHostWithoutPort(string address)
|
||||
{
|
||||
return address.Split(':')[0];
|
||||
|
|
|
@ -18,11 +18,13 @@ namespace NzbDrone.Web.Controllers
|
|||
private readonly GrowlProvider _growlProvider;
|
||||
private readonly SeasonProvider _seasonProvider;
|
||||
private readonly ProwlProvider _prowlProvider;
|
||||
private readonly XbmcProvider _xbmcProvider;
|
||||
|
||||
public CommandController(JobProvider jobProvider, SabProvider sabProvider,
|
||||
SmtpProvider smtpProvider, TwitterProvider twitterProvider,
|
||||
EpisodeProvider episodeProvider, GrowlProvider growlProvider,
|
||||
SeasonProvider seasonProvider, ProwlProvider prowlProvider)
|
||||
SeasonProvider seasonProvider, ProwlProvider prowlProvider,
|
||||
XbmcProvider xbmcProvider)
|
||||
{
|
||||
_jobProvider = jobProvider;
|
||||
_sabProvider = sabProvider;
|
||||
|
@ -32,6 +34,7 @@ namespace NzbDrone.Web.Controllers
|
|||
_growlProvider = growlProvider;
|
||||
_seasonProvider = seasonProvider;
|
||||
_prowlProvider = prowlProvider;
|
||||
_xbmcProvider = xbmcProvider;
|
||||
}
|
||||
|
||||
public JsonResult RssSync()
|
||||
|
@ -164,5 +167,33 @@ namespace NzbDrone.Web.Controllers
|
|||
|
||||
return JsonNotificationResult.Info("Success!", "SABnzbd settings have been verified successfully! Version: " + version);
|
||||
}
|
||||
|
||||
public JsonResult TestXbmcNotification(string hosts)
|
||||
{
|
||||
try
|
||||
{
|
||||
_xbmcProvider.TestNotification(hosts);
|
||||
return JsonNotificationResult.Info("Success!", "Test Notification Sent Successfully");
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
}
|
||||
|
||||
return JsonNotificationResult.Oops("Failed to send test notification, please review your settings.");
|
||||
}
|
||||
|
||||
public JsonResult TestXbmcJsonApi(string hosts, string username, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
_xbmcProvider.TestJsonApi(hosts, username, password);
|
||||
return JsonNotificationResult.Info("Success!", "Successfully tested JSON API");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
|
||||
return JsonNotificationResult.Oops("Failed to test JSON API, please review your settings.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@ $('#MultiEpisodeStyle').live('change', function () { createExamples(); });
|
|||
var testProwlUrl = '../Command/TestProwl';
|
||||
var testSabUrl = '../Command/TestSabnzbd';
|
||||
var testEmailUrl = '../Command/TestEmail';
|
||||
|
||||
var testXbmcNotificationUrl = '../Command/TestXbmcNotification';
|
||||
var testXbmcJsonApiUrl = '../Command/TestXbmcJsonApi';
|
||||
|
||||
function createExamples() {
|
||||
createSingleEpisodeExample();
|
||||
|
@ -200,10 +201,7 @@ function testSmtpSettings() {
|
|||
password: password,
|
||||
fromAddress: fromAddress,
|
||||
toAddresses: toAddresses
|
||||
}),
|
||||
error: function (req, status, error) {
|
||||
alert("Sorry! We could send a test email at this time. " + error);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
return false;
|
||||
|
@ -222,11 +220,34 @@ function registerGrowl() {
|
|||
data: jQuery.param({
|
||||
host: host,
|
||||
password: password
|
||||
}),
|
||||
error: function (req, status, error) {
|
||||
alert("Sorry! We could send a test email at this time. " + error);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//XBMC
|
||||
$(document).on('click', '#xbmc-test-notification', function() {
|
||||
var hosts = $('#XbmcHosts').val();
|
||||
|
||||
$.ajax({
|
||||
url: testXbmcNotificationUrl,
|
||||
data: jQuery.param({ hosts: hosts })
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '#xbmc-test-jsonapi', function () {
|
||||
var hosts = $('#XbmcHosts').val();
|
||||
var username = $('#XbmcUsername').val();
|
||||
var password = $('#XbmcPassword').val();
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: testXbmcJsonApiUrl,
|
||||
data: jQuery.param({
|
||||
hosts: hosts,
|
||||
username: username,
|
||||
password: password
|
||||
})
|
||||
});
|
||||
});
|
|
@ -51,4 +51,14 @@
|
|||
<span class="small">@Html.DescriptionFor(m => m.XbmcPassword)</span>
|
||||
</label>
|
||||
@Html.TextBoxFor(m => m.XbmcPassword, new { @class = "inputClass", type = "password" })
|
||||
|
||||
<label class="labelClass">Test Notification
|
||||
<span class="small">Sends a test notification to your XBMC client(s)</span>
|
||||
</label>
|
||||
<input type="button" id="xbmc-test-notification" value="Test Notification" class="inputClass"/>
|
||||
|
||||
<label class="labelClass">Test JSON-API
|
||||
<span class="small">Test that library updates will work</span>
|
||||
</label>
|
||||
<input type="button" id="xbmc-test-jsonapi" value="Test JSON-API" class="inputClass"/>
|
||||
</div>
|
Loading…
Reference in New Issue