mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
More work on #298. Everything wired up
This commit is contained in:
parent
81d26a5442
commit
fcf2c84f61
22 changed files with 614 additions and 33 deletions
|
@ -26,6 +26,8 @@
|
|||
#endregion
|
||||
using System;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace PlexRequests.Core.SettingModels
|
||||
{
|
||||
public class LandingPageSettings : Settings
|
||||
|
@ -37,5 +39,8 @@ namespace PlexRequests.Core.SettingModels
|
|||
public bool EnabledNoticeTime { get; set; }
|
||||
public DateTime NoticeStart { get; set; }
|
||||
public DateTime NoticeEnd { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool NoticeActive => DateTime.Now > NoticeEnd || DateTime.Now < NoticeStart;
|
||||
}
|
||||
}
|
|
@ -44,6 +44,7 @@ namespace PlexRequests.Core.SettingModels
|
|||
public bool UsersCanViewOnlyOwnIssues { get; set; }
|
||||
public int WeeklyRequestLimit { get; set; }
|
||||
public string NoApprovalUsers { get; set; }
|
||||
public bool CollectAnalyticData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The CSS name of the theme we want
|
||||
|
|
|
@ -57,13 +57,13 @@ namespace PlexRequests.Core
|
|||
var version = CheckSchema();
|
||||
if (version > 0)
|
||||
{
|
||||
if (version > 1700 && version <= 1759)
|
||||
if (version > 1700 && version <= 1799)
|
||||
{
|
||||
MigrateToVersion1700();
|
||||
}
|
||||
if (version > 1759 && version <= 1799)
|
||||
if (version > 1799 && version <= 1800)
|
||||
{
|
||||
MigrateToVersion1760();
|
||||
MigrateToVersion1800();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,10 +181,13 @@ namespace PlexRequests.Core
|
|||
/// <summary>
|
||||
/// Migrates to version 1.8.
|
||||
/// <para>This includes updating the admin account to have all roles.</para>
|
||||
/// <para>Set the log level to info</para>
|
||||
/// <para>Set the log level to Error</para>
|
||||
/// <para>Enable Analytics by default</para>
|
||||
/// </summary>
|
||||
private void MigrateToVersion1760()
|
||||
private void MigrateToVersion1800()
|
||||
{
|
||||
|
||||
// Give admin all roles/claims
|
||||
try
|
||||
{
|
||||
var userMapper = new UserMapper(new UserRepository<UsersModel>(Db, new MemoryCacheProvider()));
|
||||
|
@ -201,14 +204,15 @@ namespace PlexRequests.Core
|
|||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e);
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
// Set log level
|
||||
try
|
||||
{
|
||||
var settingsService = new SettingsServiceV2<LogSettings>(new SettingsJsonRepository(Db, new MemoryCacheProvider()));
|
||||
var logSettings = settingsService.GetSettings();
|
||||
logSettings.Level = LogLevel.Info.Ordinal;
|
||||
logSettings.Level = LogLevel.Error.Ordinal;
|
||||
settingsService.SaveSettings(logSettings);
|
||||
|
||||
LoggingHelper.ReconfigureLogLevel(LogLevel.FromOrdinal(logSettings.Level));
|
||||
|
@ -217,10 +221,24 @@ namespace PlexRequests.Core
|
|||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e);
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
// Enable analytics;
|
||||
try
|
||||
{
|
||||
|
||||
var prSettings = new SettingsServiceV2<PlexRequestSettings>(new SettingsJsonRepository(Db, new MemoryCacheProvider()));
|
||||
var settings = prSettings.GetSettings();
|
||||
settings.CollectAnalyticData = true;
|
||||
var updated = prSettings.SaveSettings(settings);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue