New: Health Check errors now have links to the wiki pages.

pull/80/head
Taloth Saldono 11 years ago
parent 68352e0340
commit 0e7fc2e697

@ -8,5 +8,6 @@ namespace NzbDrone.Api.Health
{
public HealthCheckResult Type { get; set; }
public String Message { get; set; }
public Uri WikiUrl { get; set; }
}
}

@ -28,11 +28,11 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
if (missingRootFolders.Count == 1)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, "Missing root folder: " + missingRootFolders.First());
return new HealthCheck(GetType(), HealthCheckResult.Error, "Missing root folder: " + missingRootFolders.First(), "#missing-root-folder");
}
var message = String.Format("Multiple root folders are missing: {0}", String.Join(" | ", missingRootFolders));
return new HealthCheck(GetType(), HealthCheckResult.Error, message);
return new HealthCheck(GetType(), HealthCheckResult.Error, message, "#missing-root-folder");
}
return new HealthCheck(GetType());

@ -33,8 +33,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
}
catch (Exception)
{
return new HealthCheck(GetType(), HealthCheckResult.Error,
"Unable to update, running from write-protected folder");
return new HealthCheck(GetType(), HealthCheckResult.Error, "Unable to update, running from write-protected folder");
}
}

@ -1,13 +1,17 @@
using System;
using System.Text.RegularExpressions;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.HealthCheck
{
public class HealthCheck : ModelBase
{
private static readonly Regex CleanFragmentRegex = new Regex("[^a-z ]", RegexOptions.Compiled);
public Type Source { get; set; }
public HealthCheckResult Type { get; set; }
public String Message { get; set; }
public Uri WikiUrl { get; set; }
public HealthCheck(Type source)
{
@ -15,11 +19,25 @@ namespace NzbDrone.Core.HealthCheck
Type = HealthCheckResult.Ok;
}
public HealthCheck(Type source, HealthCheckResult type, string message)
public HealthCheck(Type source, HealthCheckResult type, String message, String wikiFragment = null)
{
Source = source;
Type = type;
Message = message;
WikiUrl = MakeWikiUrl(wikiFragment ?? MakeWikiFragment(message));
}
private static String MakeWikiFragment(String message)
{
return "#" + CleanFragmentRegex.Replace(message.ToLower(), String.Empty).Replace(' ', '-');
}
private static Uri MakeWikiUrl(String fragment)
{
var rootUri = new Uri("https://github.com/NzbDrone/NzbDrone/wiki/Health-checks");
var fragmentUri = new Uri(fragment, UriKind.Relative);
return new Uri(rootUri, fragmentUri);
}
}

@ -5,8 +5,9 @@ define(
'backgrid',
'Health/HealthCollection',
'System/Info/Health/HealthCell',
'System/Info/Health/HealthWikiCell',
'System/Info/Health/HealthOkView'
], function (Marionette, Backgrid, HealthCollection, HealthCell, HealthOkView) {
], function (Marionette, Backgrid, HealthCollection, HealthCell, HealthWikiCell, HealthOkView) {
return Marionette.Layout.extend({
template: 'System/Info/Health/HealthLayoutTemplate',
@ -19,12 +20,20 @@ define(
{
name: 'type',
label: '',
cell: HealthCell
cell: HealthCell,
sortable: false
},
{
name: 'message',
label: 'Message',
cell: 'string'
cell: 'string',
sortable: false
},
{
name: 'wikiUrl',
label: '',
cell: HealthWikiCell,
sortable: false
}
],

@ -0,0 +1,29 @@
'use strict';
define(
[
'jquery',
'backgrid'
], function ($, Backgrid) {
return Backgrid.UriCell.extend({
className: 'wiki-link-cell',
title: 'Read the Wiki for more information',
text: 'Wiki',
render: function () {
this.$el.empty();
var rawValue = this.model.get(this.column.get("name"));
var formattedValue = this.formatter.fromRaw(rawValue, this.model);
this.$el.append($("<a>", {
tabIndex: -1,
href: rawValue,
title: this.title || formattedValue,
target: this.target
}).text(this.text));
this.delegateEvents();
return this;
}
});
});

@ -48,13 +48,15 @@ define(
throw 'couldn\'t find route target';
}
if (!href.startsWith('http')) {
var relativeHref = href.replace(StatusModel.get('urlBase'), '');
Backbone.history.navigate(relativeHref, { trigger: true });
}
else if (href.contains('#')) {
//Open in new tab without dereferer (since it doesn't support fragments)
window.open(href, '_blank');
}
else {
//Open in new tab
window.open('http://www.dereferer.org/?' + encodeURI(href), '_blank');

Loading…
Cancel
Save