mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 10:36:54 -07:00
- Added a visual indication on the UI to tell the admin there is a update available.
- We are now also recording the last scheduled run in the database
This commit is contained in:
parent
af028f0b56
commit
df3dc4ac04
28 changed files with 392 additions and 45 deletions
|
@ -295,8 +295,8 @@ namespace PlexRequests.UI.Modules
|
|||
}
|
||||
|
||||
var result = CpService.SaveSettings(couchPotatoSettings);
|
||||
return Response.AsJson(result
|
||||
? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for CouchPotato!" }
|
||||
return Response.AsJson(result
|
||||
? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for CouchPotato!" }
|
||||
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||
}
|
||||
|
||||
|
@ -429,7 +429,7 @@ namespace PlexRequests.UI.Modules
|
|||
finally
|
||||
{
|
||||
NotificationService.UnSubscribe(new EmailMessageNotification(EmailService));
|
||||
}
|
||||
}
|
||||
return Response.AsJson(new JsonResponseModel { Result = true, Message = "Successfully sent a test Email Notification!" });
|
||||
}
|
||||
|
||||
|
@ -464,7 +464,7 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
var checker = new StatusChecker();
|
||||
var status = checker.GetStatus();
|
||||
var md = new Markdown();
|
||||
var md = new Markdown(new MarkdownOptions { AutoNewLines = true });
|
||||
status.ReleaseNotes = md.Transform(status.ReleaseNotes);
|
||||
return View["Status", status];
|
||||
}
|
||||
|
@ -623,7 +623,7 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
JsonSettings.MaxJsonLength = int.MaxValue;
|
||||
var allLogs = LogsRepo.GetAll().OrderByDescending(x => x.Id).Take(200);
|
||||
var model = new DatatablesModel<LogEntity> {Data = new List<LogEntity>()};
|
||||
var model = new DatatablesModel<LogEntity> { Data = new List<LogEntity>() };
|
||||
foreach (var l in allLogs)
|
||||
{
|
||||
l.DateString = l.Date.ToString("G");
|
||||
|
@ -650,7 +650,7 @@ namespace PlexRequests.UI.Modules
|
|||
settings.Level = level;
|
||||
LogService.SaveSettings(settings);
|
||||
|
||||
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"The new log level is now {newLevel}"});
|
||||
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"The new log level is now {newLevel}" });
|
||||
}
|
||||
|
||||
private Negotiator Headphones()
|
||||
|
@ -673,7 +673,7 @@ namespace PlexRequests.UI.Modules
|
|||
Log.Trace(settings.DumpJson());
|
||||
|
||||
var result = HeadphonesService.SaveSettings(settings);
|
||||
|
||||
|
||||
Log.Info("Saved headphones settings, result: {0}", result);
|
||||
return Response.AsJson(result
|
||||
? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for Headphones!" }
|
||||
|
|
|
@ -30,8 +30,11 @@ using Nancy.Extensions;
|
|||
using PlexRequests.UI.Models;
|
||||
using System;
|
||||
|
||||
using Nancy.Security;
|
||||
|
||||
using PlexRequests.Core;
|
||||
using PlexRequests.Core.SettingModels;
|
||||
using PlexRequests.Helpers;
|
||||
|
||||
namespace PlexRequests.UI.Modules
|
||||
{
|
||||
|
@ -52,6 +55,8 @@ namespace PlexRequests.UI.Modules
|
|||
}
|
||||
}
|
||||
|
||||
protected bool IsAdmin => Context.CurrentUser.IsAuthenticated();
|
||||
|
||||
protected int DateTimeOffset
|
||||
{
|
||||
get
|
||||
|
@ -87,5 +92,7 @@ namespace PlexRequests.UI.Modules
|
|||
: null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -124,14 +124,6 @@ namespace PlexRequests.UI.Modules
|
|||
private IHeadphonesApi HeadphonesApi { get; }
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private bool IsAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
return Context.CurrentUser.IsAuthenticated();
|
||||
}
|
||||
}
|
||||
|
||||
private Negotiator RequestLoad()
|
||||
{
|
||||
var settings = PrService.GetSettings();
|
||||
|
@ -626,7 +618,7 @@ namespace PlexRequests.UI.Modules
|
|||
Status = showInfo.status,
|
||||
RequestedDate = DateTime.UtcNow,
|
||||
Approved = false,
|
||||
RequestedUsers = new List<string>() { Username },
|
||||
RequestedUsers = new List<string> { Username },
|
||||
Issues = IssueState.None,
|
||||
ImdbId = showInfo.externals?.imdb ?? string.Empty,
|
||||
SeasonCount = showInfo.seasonCount
|
||||
|
@ -802,7 +794,7 @@ namespace PlexRequests.UI.Modules
|
|||
}
|
||||
|
||||
var sender = new HeadphonesSender(HeadphonesApi, hpSettings, RequestService);
|
||||
sender.AddAlbum(model);
|
||||
sender.AddAlbum(model).Wait();
|
||||
model.Approved = true;
|
||||
RequestService.AddRequest(model);
|
||||
|
||||
|
|
79
PlexRequests.UI/Modules/UpdateCheckerModule.cs
Normal file
79
PlexRequests.UI/Modules/UpdateCheckerModule.cs
Normal file
|
@ -0,0 +1,79 @@
|
|||
#region Copyright
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2016 Jamie Rees
|
||||
// File: UpdateCheckerModule.cs
|
||||
// Created By: Jamie Rees
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
#endregion
|
||||
using System;
|
||||
|
||||
using Nancy;
|
||||
|
||||
using NLog;
|
||||
|
||||
using PlexRequests.Core;
|
||||
using PlexRequests.Helpers;
|
||||
using PlexRequests.UI.Models;
|
||||
|
||||
namespace PlexRequests.UI.Modules
|
||||
{
|
||||
public class UpdateCheckerModule : BaseAuthModule
|
||||
{
|
||||
public UpdateCheckerModule(ICacheProvider provider) : base("updatechecker")
|
||||
{
|
||||
Cache = provider;
|
||||
|
||||
Get["/"] = _ => CheckLatestVersion();
|
||||
}
|
||||
|
||||
private ICacheProvider Cache { get; }
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private Response CheckLatestVersion()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!IsAdmin)
|
||||
{
|
||||
return Response.AsJson(new JsonUpdateAvailableModel { UpdateAvailable = false });
|
||||
}
|
||||
|
||||
var checker = new StatusChecker();
|
||||
var release = Cache.GetOrSet(CacheKeys.LastestProductVersion, () => checker.GetStatus(), 30);
|
||||
|
||||
if (release.UpdateAvailable)
|
||||
{
|
||||
return Response.AsJson(new JsonUpdateAvailableModel { UpdateAvailable = true});
|
||||
}
|
||||
|
||||
return Response.AsJson(new JsonUpdateAvailableModel { UpdateAvailable = false });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Warn("Exception Thrown when attempting to check the status");
|
||||
Log.Warn(e);
|
||||
return Response.AsJson(new JsonUpdateAvailableModel { UpdateAvailable = false });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue