Changed the way additional validation details get sent the UI.
This commit is contained in:
parent
232a2b9422
commit
822de39a9e
|
@ -11,6 +11,7 @@ using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.Indexers;
|
using NzbDrone.Core.Indexers;
|
||||||
using NzbDrone.Core.Parser;
|
using NzbDrone.Core.Parser;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
using NzbDrone.Core.Validation;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||||
{
|
{
|
||||||
|
@ -312,14 +313,22 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||||
{
|
{
|
||||||
if (category.Dir.EndsWith("*"))
|
if (category.Dir.EndsWith("*"))
|
||||||
{
|
{
|
||||||
return new ValidationFailure(String.Empty, String.Format("Remove * from Sabnzbd <a class=\"no-router\" target=\"_blank\" href=\"http://{0}:{1}/sabnzbd/config/categories/\">'{2}' category</a> Folder/Path so job folders will be created", Settings.Host, Settings.Port, Settings.TvCategory));
|
return new NzbDroneValidationFailure("TvCategory", "Enable Job folders")
|
||||||
|
{
|
||||||
|
InfoLink = String.Format("http://{0}:{1}/sabnzbd/config/categories/", Settings.Host, Settings.Port),
|
||||||
|
DetailedDescription = "NzbDrone prefers each download to have a separate folder. With * appended to the Folder/Path Sabnzbd will not create these job folders. Go to Sabnzbd to fix it."
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!Settings.TvCategory.IsNullOrWhiteSpace())
|
if (!Settings.TvCategory.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
return new ValidationFailure("TvCategory", String.Format("<a class=\"no-router\" target=\"_blank\" href=\"http://{0}:{1}/sabnzbd/config/categories/\">Category</a> does not exist", Settings.Host, Settings.Port));
|
return new NzbDroneValidationFailure("TvCategory", "Category does not exist")
|
||||||
|
{
|
||||||
|
InfoLink = String.Format("http://{0}:{1}/sabnzbd/config/categories/", Settings.Host, Settings.Port),
|
||||||
|
DetailedDescription = "The Category your entered doesn't exist in Sabnzbd. Go to Sabnzbd to create it."
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +338,11 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||||
config.Misc.tv_categories.Contains(Settings.TvCategory) ||
|
config.Misc.tv_categories.Contains(Settings.TvCategory) ||
|
||||||
(Settings.TvCategory.IsNullOrWhiteSpace() && config.Misc.tv_categories.Contains("Default")))
|
(Settings.TvCategory.IsNullOrWhiteSpace() && config.Misc.tv_categories.Contains("Default")))
|
||||||
{
|
{
|
||||||
return new ValidationFailure(String.Empty, String.Format("Disable <a class=\"no-router\" target=\"_blank\" href=\"http://{0}:{1}/sabnzbd/config/sorting/\">TV Sorting</a> for the '{2}' category", Settings.Host, Settings.Port, Settings.TvCategory));
|
return new NzbDroneValidationFailure("TvCategory", "Disable TV Sorting")
|
||||||
|
{
|
||||||
|
InfoLink = String.Format("http://{0}:{1}/sabnzbd/config/sorting/", Settings.Host, Settings.Port),
|
||||||
|
DetailedDescription = "You must disable Sabnzbd TV Sorting for the category NzbDrone uses to prevent import issues. Go to Sabnzbd to fix it."
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -725,6 +725,7 @@
|
||||||
<Compile Include="Validation\Paths\PathExistsValidator.cs" />
|
<Compile Include="Validation\Paths\PathExistsValidator.cs" />
|
||||||
<Compile Include="Validation\FolderValidator.cs" />
|
<Compile Include="Validation\FolderValidator.cs" />
|
||||||
<Compile Include="Validation\RuleBuilderExtensions.cs" />
|
<Compile Include="Validation\RuleBuilderExtensions.cs" />
|
||||||
|
<Compile Include="Validation\NzbDroneValidationFailure.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
|
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using FluentValidation.Results;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Validation
|
||||||
|
{
|
||||||
|
public class NzbDroneValidationFailure : ValidationFailure
|
||||||
|
{
|
||||||
|
public String DetailedDescription { get; set; }
|
||||||
|
public String InfoLink { get; set; }
|
||||||
|
|
||||||
|
public NzbDroneValidationFailure(String propertyName, String error)
|
||||||
|
: base(propertyName, error)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -88,6 +88,13 @@ h3 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.validation-error {
|
||||||
|
i {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #b94a48;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tooltips
|
// Tooltips
|
||||||
|
|
||||||
.help-inline-checkbox, .help-inline {
|
.help-inline-checkbox, .help-inline {
|
||||||
|
|
|
@ -8,9 +8,16 @@ define(
|
||||||
|
|
||||||
var validationName = error.propertyName.toLowerCase();
|
var validationName = error.propertyName.toLowerCase();
|
||||||
|
|
||||||
|
var errorMessage = this.formatErrorMessage(error);
|
||||||
|
|
||||||
this.find('.validation-errors')
|
this.find('.validation-errors')
|
||||||
.addClass('alert alert-danger')
|
.addClass('alert alert-danger')
|
||||||
.append('<div><i class="icon-exclamation-sign"></i>' + error.errorMessage + '</div>');
|
.append('<div><i class="icon-exclamation-sign"></i>' + errorMessage + '</div>');
|
||||||
|
|
||||||
|
if (!validationName || validationName === "") {
|
||||||
|
this.addFormError(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var input = this.find('[name]').filter(function () {
|
var input = this.find('[name]').filter(function () {
|
||||||
return this.name.toLowerCase() === validationName;
|
return this.name.toLowerCase() === validationName;
|
||||||
|
@ -38,11 +45,11 @@ define(
|
||||||
var inputGroup = controlGroup.find('.input-group');
|
var inputGroup = controlGroup.find('.input-group');
|
||||||
|
|
||||||
if (inputGroup.length === 0) {
|
if (inputGroup.length === 0) {
|
||||||
controlGroup.append('<span class="help-inline error-message">' + error.errorMessage + '</span>');
|
controlGroup.append('<span class="help-inline validation-error">' + errorMessage + '</span>');
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
inputGroup.parent().append('<span class="help-block error-message">' + error.errorMessage + '</span>');
|
inputGroup.parent().append('<span class="help-block validation-error">' + errorMessage + '</span>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,12 +64,15 @@ define(
|
||||||
};
|
};
|
||||||
|
|
||||||
$.fn.addFormError = function (error) {
|
$.fn.addFormError = function (error) {
|
||||||
|
|
||||||
|
var errorMessage = this.formatErrorMessage(error);
|
||||||
|
|
||||||
if (this.find('.modal-body')) {
|
if (this.find('.modal-body')) {
|
||||||
this.find('.modal-body').prepend('<div class="alert alert-danger validation-error">' + error.errorMessage + '</div>');
|
this.find('.modal-body').prepend('<div class="alert alert-danger validation-error">' + errorMessage + '</div>');
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
this.prepend('<div class="alert alert-danger validation-error">' + error.errorMessage + '</div>');
|
this.prepend('<div class="alert alert-danger validation-error">' + errorMessage + '</div>');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,4 +84,24 @@ define(
|
||||||
return this.find('.help-inline.error-message').remove();
|
return this.find('.help-inline.error-message').remove();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$.fn.formatErrorMessage = function (error) {
|
||||||
|
|
||||||
|
var errorMessage = error.errorMessage;
|
||||||
|
var infoLink = "";
|
||||||
|
|
||||||
|
if (error.infoLink) {
|
||||||
|
if (error.detailedDescription) {
|
||||||
|
errorMessage += " <a class=\"no-router\" target=\"_blank\" href=\"" + error.infoLink + "\"><i class=\"icon-external-link\" title=\"" + error.detailedDescription + "\"></i></a>";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errorMessage += " <a class=\"no-router\" target=\"_blank\" href=\"" + error.infoLink + "\"><i class=\"icon-external-link\"></i></a>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (error.detailedDescription) {
|
||||||
|
errorMessage += " <i class=\"icon-nd-form-info\" title=\"" + error.detailedDescription + "\"></i>";
|
||||||
|
}
|
||||||
|
|
||||||
|
return errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue