1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 10:32:35 +01:00

Test buttons for XBMC

New: Added buttons to test XBMC configuration
This commit is contained in:
Mark McDowall 2012-10-21 20:44:16 -07:00
parent d070401f20
commit cacd86b4ef
4 changed files with 98 additions and 16 deletions

View File

@ -31,6 +31,11 @@ public XbmcProvider(ConfigProvider configProvider, HttpProvider httpProvider, Ev
_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 @@ public virtual void Notify(string header, string message)
}
}
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 @@ public virtual bool CheckForJsonError(string response)
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];

View File

@ -18,11 +18,13 @@ public class CommandController : Controller
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 @@ public CommandController(JobProvider jobProvider, SabProvider sabProvider,
_growlProvider = growlProvider;
_seasonProvider = seasonProvider;
_prowlProvider = prowlProvider;
_xbmcProvider = xbmcProvider;
}
public JsonResult RssSync()
@ -164,5 +167,33 @@ public JsonResult TestSabnzbd(string host, int port, string apiKey, string usern
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.");
}
}
}

View File

@ -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
})
});
});

View File

@ -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>