Add support for server notices

This commit is contained in:
kaso17 2017-02-27 12:19:36 +01:00
parent 799d435f2a
commit 1f97d543df
3 changed files with 41 additions and 6 deletions

View File

@ -63,6 +63,11 @@ function loadJackettSettings() {
$("#logoutBtn").show();
}
$.each(data.config.notices, function (index, value) {
console.log(value);
doNotify(value, "danger", "glyphicon glyphicon-alert", false);
})
reloadIndexers();
});
}
@ -570,12 +575,21 @@ function resolveUrl(url) {
return url;
}
function doNotify(message, type, icon) {
function doNotify(message, type, icon, autoHide) {
if (typeof autoHide === "undefined" || autoHide === null)
autoHide = true;
var delay = 5000;
if (!autoHide)
delay = -1;
$.notify({
message: message,
icon: icon
}, {
element: 'body',
autoHide: autoHide,
delay: delay,
type: type,
allow_dismiss: true,
z_index: 9000,

View File

@ -319,6 +319,7 @@ namespace Jackett.Controllers
try
{
var cfg = new JObject();
cfg["notices"] = JToken.FromObject(serverService.notices);
cfg["port"] = serverService.Config.Port;
cfg["external"] = serverService.Config.AllowExternal;
cfg["api_key"] = serverService.Config.APIKey;

View File

@ -39,6 +39,7 @@ namespace Jackett.Services
void SaveConfig();
Uri ConvertToProxyLink(Uri link, string serverUrl, string indexerId, string action = "dl", string file = "t.torrent");
string BasePath();
List<string> notices { get; }
}
public class ServerService : IServerService
@ -54,6 +55,7 @@ namespace Jackett.Services
private Logger logger;
private IWebClient client;
private IUpdateService updater;
private List<string> _notices = new List<string>();
public ServerService(IIndexerManagerService i, IProcessService p, ISerializeService s, IConfigurationService c, Logger l, IWebClient w, IUpdateService u)
{
@ -71,8 +73,16 @@ namespace Jackett.Services
public ServerConfig Config
{
get { return config; }
}
}
public List<string> notices
{
get
{
return _notices;
}
}
public Uri ConvertToProxyLink(Uri link, string serverUrl, string indexerId, string action = "dl", string file = "t.torrent")
{
if (link == null || (link.IsAbsoluteUri && link.Scheme == "magnet"))
@ -207,7 +217,9 @@ namespace Jackett.Services
}
else if (monoVersionO.Major == 4 && monoVersionO.Minor == 2)
{
logger.Error("mono version 4.2.* is known to cause problems with Jackett. If you experience any problems please try updating to the latest mono version from http://www.mono-project.com/download/ first.");
var notice = "mono version 4.2.* is known to cause problems with Jackett. If you experience any problems please try updating to the latest mono version from http://www.mono-project.com/download/ first.";
_notices.Add(notice);
logger.Error(notice);
}
try
@ -217,7 +229,9 @@ namespace Jackett.Services
var mono_devel_file = Path.Combine(runtimedir, "mono-api-info.exe");
if (!File.Exists(mono_devel_file))
{
logger.Error("It looks like the mono-devel package is not installed, please make sure it's installed to avoid crashes.");
var notice = "It looks like the mono-devel package is not installed, please make sure it's installed to avoid crashes.";
_notices.Add(notice);
logger.Error(notice);
}
}
catch (Exception e)
@ -233,7 +247,9 @@ namespace Jackett.Services
{
if (monoVersionO.Major >= 4 && monoVersionO.Minor >= 8)
{
logger.Error("The ca-certificates-mono package is not installed, HTTPS trackers won't work. Please install it.");
var notice = "The ca-certificates-mono package is not installed, HTTPS trackers won't work. Please install it.";
_notices.Add(notice);
logger.Error(notice);
}
else
{
@ -263,6 +279,10 @@ namespace Jackett.Services
{
logger.Error("Error while getting environment details: " + e);
}
var notice1 = "The ca-certificates-mono package is not installed, HTTPS trackers won't work. Please install it.";
_notices.Add(notice1);
var notice2 = "The ca-certificates-mono package is not installed, HTTPS trackers won't work. Please install it2.";
_notices.Add(notice2);
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
// Load indexers