diff --git a/PlexRequests.Core.Migration/MigrationRunner.cs b/PlexRequests.Core.Migration/MigrationRunner.cs index 5535782a6..d53ab8d3d 100644 --- a/PlexRequests.Core.Migration/MigrationRunner.cs +++ b/PlexRequests.Core.Migration/MigrationRunner.cs @@ -23,37 +23,30 @@ namespace PlexRequests.Core.Migration { var con = Db.DbConnection(); var versions = GetMigrations(); - - var dbVersion = con.GetVersionInfo().OrderByDescending(x => x.Version).FirstOrDefault(); - if (dbVersion == null) - { - dbVersion = new TableCreation.VersionInfo { Version = 0 }; - } + + var dbVersion = con.GetVersionInfo().OrderByDescending(x => x.Version).FirstOrDefault() ?? + new TableCreation.VersionInfo { Version = 0 }; foreach (var v in versions) { +#if !DEBUG if (v.Value.Version > dbVersion.Version) { - // Assuming only one constructor - var ctor = v.Key.GetConstructors().FirstOrDefault(); - var dependencies = new List(); - - foreach (var param in ctor.GetParameters()) - { - var dep = Kernel.Get(param.ParameterType); - dependencies.Add(dep); - } +#endif + // Assuming only one constructor + var ctor = v.Key.GetConstructors().FirstOrDefault(); + var dependencies = ctor.GetParameters().Select(param => Kernel.Get(param.ParameterType)).ToList(); - var method = v.Key.GetMethod("Start"); - if (method != null) - { - object result = null; - var classInstance = Activator.CreateInstance(v.Key, dependencies.Any() ? dependencies.ToArray() : null); - - var parametersArray = new object[] { Db.DbConnection() }; + var method = v.Key.GetMethod("Start"); + if (method != null) + { + var classInstance = Activator.CreateInstance(v.Key, dependencies.Any() ? dependencies.ToArray() : null); + var parametersArray = new object[] { Db.DbConnection() }; - method.Invoke(classInstance, parametersArray); - } + method.Invoke(classInstance, parametersArray); + } +#if !DEBUG } +#endif } } diff --git a/PlexRequests.Core.Migration/Migrations/Version1100.cs b/PlexRequests.Core.Migration/Migrations/Version1100.cs index a631b05d6..d4365f357 100644 --- a/PlexRequests.Core.Migration/Migrations/Version1100.cs +++ b/PlexRequests.Core.Migration/Migrations/Version1100.cs @@ -27,7 +27,10 @@ using System; using System.Data; +using NLog; using System.Linq; +using PlexRequests.Core.SettingModels; +using PlexRequests.Helpers; using PlexRequests.Helpers.Permissions; using PlexRequests.Store; using PlexRequests.Store.Repository; @@ -37,14 +40,16 @@ namespace PlexRequests.Core.Migration.Migrations [Migration(11000, "v1.10.0.0")] public class Version1100 : BaseMigration, IMigration { - public Version1100(IUserRepository userRepo, IRequestService requestService) + public Version1100(IUserRepository userRepo, IRequestService requestService, ISettingsService log) { UserRepo = userRepo; RequestService = requestService; + Log = log; } public int Version => 11000; private IUserRepository UserRepo { get; } private IRequestService RequestService { get; } + private ISettingsService Log { get; } public void Start(IDbConnection con) { @@ -52,9 +57,17 @@ namespace PlexRequests.Core.Migration.Migrations // Update the current admin permissions set UpdateAdmin(); + ResetLogLevel(); + UpdateSchema(con, Version); + } + private void ResetLogLevel() + { + var logSettings = Log.GetSettings(); + logSettings.Level = LogLevel.Error.Ordinal; + Log.SaveSettings(logSettings); - UpdateSchema(con, Version); + LoggingHelper.ReconfigureLogLevel(LogLevel.FromOrdinal(logSettings.Level)); } private void UpdateDb(IDbConnection con) @@ -63,11 +76,6 @@ namespace PlexRequests.Core.Migration.Migrations con.AlterTable("Users", "ADD", "Permissions", true, "INTEGER"); con.AlterTable("Users", "ADD", "Features", true, "INTEGER"); - // Add the new 'running' item into the scheduled jobs so we can check if the cachers are running - con.AlterTable("ScheduledJobs", "ADD", "Running", true, "INTEGER"); - - - //https://image.tmdb.org/t/p/w150/https://image.tmdb.org/t/p/w150//aqhAqttDq7zgsTaBHtCD8wmTk6k.jpg // UI = https://image.tmdb.org/t/p/w150/{{posterPath}} diff --git a/PlexRequests.Core.Migration/PlexRequests.Core.Migration.csproj b/PlexRequests.Core.Migration/PlexRequests.Core.Migration.csproj index e724145c4..fa934dfc0 100644 --- a/PlexRequests.Core.Migration/PlexRequests.Core.Migration.csproj +++ b/PlexRequests.Core.Migration/PlexRequests.Core.Migration.csproj @@ -45,6 +45,10 @@ ..\packages\Ninject.3.2.0.0\lib\net45-full\Ninject.dll + + ..\packages\NLog.4.3.11\lib\net45\NLog.dll + True + ..\packages\Quartz.2.3.3\lib\net40\Quartz.dll True diff --git a/PlexRequests.Core.Migration/packages.config b/PlexRequests.Core.Migration/packages.config index dfdfc5ae9..6d547be19 100644 --- a/PlexRequests.Core.Migration/packages.config +++ b/PlexRequests.Core.Migration/packages.config @@ -2,5 +2,6 @@ + \ No newline at end of file diff --git a/PlexRequests.Core/Setup.cs b/PlexRequests.Core/Setup.cs index 56f3ab95e..b9f2b7518 100644 --- a/PlexRequests.Core/Setup.cs +++ b/PlexRequests.Core/Setup.cs @@ -60,52 +60,13 @@ namespace PlexRequests.Core // Shrink DB TableCreation.Vacuum(Db.DbConnection()); } - - - // The below code is obsolete, we should use PlexRequests.Core.Migrations.MigrationRunner - var version = CheckSchema(); - if (version > 0) - { - if (version > 1899 && version <= 1900) - { - MigrateToVersion1900(); - } - - if(version > 1899 && version <= 1910) - { - MigrateToVersion1910(); - } - } - + + // Add the new 'running' item into the scheduled jobs so we can check if the cachers are running + Db.DbConnection().AlterTable("ScheduledJobs", "ADD", "Running", true, "INTEGER"); + return Db.DbConnection().ConnectionString; } - public static string ConnectionString => Db.DbConnection().ConnectionString; - - - private int CheckSchema() - { - var productVersion = AssemblyHelper.GetProductVersion(); - var trimStatus = new Regex("[^0-9]", RegexOptions.Compiled).Replace(productVersion, string.Empty).PadRight(4, '0'); - var version = int.Parse(trimStatus); - - var connection = Db.DbConnection(); - var schema = connection.GetSchemaVersion(); - if (schema == null) - { - connection.CreateSchema(version); // Set the default. - schema = connection.GetSchemaVersion(); - } - if (version > schema.SchemaVersion) - { - Db.DbConnection().UpdateSchemaVersion(version); - schema = connection.GetSchemaVersion(); - } - version = schema.SchemaVersion; - - return version; - } - private void CreateDefaultSettingsPage(string baseUrl) { var defaultSettings = new PlexRequestSettings @@ -148,7 +109,6 @@ namespace PlexRequests.Core Task.Run(() => { CacheSonarrQualityProfiles(mc); }); Task.Run(() => { CacheCouchPotatoQualityProfiles(mc); }); // we don't need to cache sickrage profiles, those are static - // TODO: cache headphones profiles? } catch (Exception) { @@ -156,12 +116,12 @@ namespace PlexRequests.Core } } - private void CacheSonarrQualityProfiles(MemoryCacheProvider cacheProvider) + private void CacheSonarrQualityProfiles(ICacheProvider cacheProvider) { try { Log.Info("Executing GetSettings call to Sonarr for quality profiles"); - var sonarrSettingsService = new SettingsServiceV2(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider())); + var sonarrSettingsService = new SettingsServiceV2(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), cacheProvider)); var sonarrSettings = sonarrSettingsService.GetSettings(); if (sonarrSettings.Enabled) { @@ -178,12 +138,12 @@ namespace PlexRequests.Core } } - private void CacheCouchPotatoQualityProfiles(MemoryCacheProvider cacheProvider) + private void CacheCouchPotatoQualityProfiles(ICacheProvider cacheProvider) { try { Log.Info("Executing GetSettings call to CouchPotato for quality profiles"); - var cpSettingsService = new SettingsServiceV2(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider())); + var cpSettingsService = new SettingsServiceV2(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), cacheProvider)); var cpSettings = cpSettingsService.GetSettings(); if (cpSettings.Enabled) { @@ -199,102 +159,5 @@ namespace PlexRequests.Core Log.Error(ex, "Failed to cache CouchPotato quality profiles!"); } } - - - /// - /// Migrates to version 1.9. - /// Move the Plex auth token to the new field. - /// Reconfigure the log level - /// Set the wizard flag to true if we already have settings - /// - public void MigrateToVersion1900() - { - // Need to change the Plex Token location - var authSettings = new SettingsServiceV2(new SettingsJsonRepository(Db, new MemoryCacheProvider())); - var auth = authSettings.GetSettings(); - var plexSettings = new SettingsServiceV2(new SettingsJsonRepository(Db, new MemoryCacheProvider())); - - if (auth != null) - { - //If we have an authToken we do not need to go through the setup - if (!string.IsNullOrEmpty(auth.OldPlexAuthToken)) - { - var prServuce = new SettingsServiceV2(new SettingsJsonRepository(Db, new MemoryCacheProvider())); - var settings = prServuce.GetSettings(); - settings.Wizard = true; - prServuce.SaveSettings(settings); - } - - // Clear out the old token and save it to the new field - var currentSettings = plexSettings.GetSettings(); - if (!string.IsNullOrEmpty(auth.OldPlexAuthToken)) - { - currentSettings.PlexAuthToken = auth.OldPlexAuthToken; - plexSettings.SaveSettings(currentSettings); - - // Clear out the old value - auth.OldPlexAuthToken = string.Empty; - authSettings.SaveSettings(auth); - } - - } - - - // Set the log level - try - { - var settingsService = new SettingsServiceV2(new SettingsJsonRepository(Db, new MemoryCacheProvider())); - var logSettings = settingsService.GetSettings(); - logSettings.Level = LogLevel.Error.Ordinal; - settingsService.SaveSettings(logSettings); - - LoggingHelper.ReconfigureLogLevel(LogLevel.FromOrdinal(logSettings.Level)); - } - catch (Exception e) - { - Log.Error(e); - } - - - // Enable analytics; - try - { - - var prSettings = new SettingsServiceV2(new SettingsJsonRepository(Db, new MemoryCacheProvider())); - var settings = prSettings.GetSettings(); - settings.CollectAnalyticData = true; - var updated = prSettings.SaveSettings(settings); - - } - catch (Exception e) - { - Log.Error(e); - } - } - - /// - /// Migrates to version1910. - /// - public void MigrateToVersion1910() - { - try - { - // Get the new machine Identifier - var settings = new SettingsServiceV2(new SettingsJsonRepository(Db, new MemoryCacheProvider())); - var plex = settings.GetSettings(); - if (!string.IsNullOrEmpty(plex.PlexAuthToken)) - { - var api = new PlexApi(new ApiRequest()); - var server = api.GetServer(plex.PlexAuthToken); // Get the server info - plex.MachineIdentifier = server.Server.FirstOrDefault(x => x.AccessToken == plex.PlexAuthToken)?.MachineIdentifier; - - settings.SaveSettings(plex); // Save the new settings - } - } - catch (Exception e) - { - Log.Error(e); - } - } } } diff --git a/PlexRequests.Services/Jobs/CouchPotatoCacher.cs b/PlexRequests.Services/Jobs/CouchPotatoCacher.cs index 3977f277f..a45e74509 100644 --- a/PlexRequests.Services/Jobs/CouchPotatoCacher.cs +++ b/PlexRequests.Services/Jobs/CouchPotatoCacher.cs @@ -65,6 +65,7 @@ namespace PlexRequests.Services.Jobs var settings = CpSettings.GetSettings(); if (settings.Enabled) { + Job.SetRunning(true, JobNames.CpCacher); Log.Trace("Getting all movies from CouchPotato"); try { @@ -109,7 +110,6 @@ namespace PlexRequests.Services.Jobs public void Execute(IJobExecutionContext context) { - Job.SetRunning(true, JobNames.CpCacher); Queued(); } } diff --git a/PlexRequests.Services/Jobs/PlexAvailabilityChecker.cs b/PlexRequests.Services/Jobs/PlexAvailabilityChecker.cs index 108b115dd..8ecb00bb5 100644 --- a/PlexRequests.Services/Jobs/PlexAvailabilityChecker.cs +++ b/PlexRequests.Services/Jobs/PlexAvailabilityChecker.cs @@ -87,7 +87,6 @@ namespace PlexRequests.Services.Jobs Log.Debug("Validation of the plex settings failed."); return; } - var libraries = CachedLibraries(plexSettings, true); //force setting the cache (10 min intervals via scheduler) if (libraries == null || !libraries.Any()) @@ -156,9 +155,6 @@ namespace PlexRequests.Services.Jobs NotificationEngine.NotifyUsers(modifiedModel, plexSettings.PlexAuthToken, NotificationType.RequestAvailable); RequestService.BatchUpdate(modifiedModel); } - - Job.Record(JobNames.PlexChecker); - Job.SetRunning(false, JobNames.CpCacher); } public List GetPlexMovies() @@ -504,7 +500,7 @@ namespace PlexRequests.Services.Jobs public void Execute(IJobExecutionContext context) { - Job.SetRunning(true, JobNames.CpCacher); + Job.SetRunning(true, JobNames.PlexChecker); try { CheckAndUpdateAll(); @@ -513,6 +509,11 @@ namespace PlexRequests.Services.Jobs { Log.Error(e); } + finally + { + Job.Record(JobNames.PlexChecker); + Job.SetRunning(false, JobNames.PlexChecker); + } } } } \ No newline at end of file diff --git a/PlexRequests.Services/Jobs/PlexEpisodeCacher.cs b/PlexRequests.Services/Jobs/PlexEpisodeCacher.cs index 3bf086752..e91d61e3e 100644 --- a/PlexRequests.Services/Jobs/PlexEpisodeCacher.cs +++ b/PlexRequests.Services/Jobs/PlexEpisodeCacher.cs @@ -145,7 +145,7 @@ namespace PlexRequests.Services.Jobs public void Execute(IJobExecutionContext context) { - Job.SetRunning(true, JobNames.CpCacher); + try { var s = Plex.GetSettings(); @@ -163,6 +163,7 @@ namespace PlexRequests.Services.Jobs return; } } + Job.SetRunning(true, JobNames.EpisodeCacher); CacheEpisodes(s); } catch (Exception e) @@ -172,7 +173,7 @@ namespace PlexRequests.Services.Jobs finally { Job.Record(JobNames.EpisodeCacher); - Job.SetRunning(false, JobNames.CpCacher); + Job.SetRunning(false, JobNames.EpisodeCacher); } } } diff --git a/PlexRequests.Services/Jobs/RecentlyAdded.cs b/PlexRequests.Services/Jobs/RecentlyAdded.cs index 204b851be..fb1d22c1b 100644 --- a/PlexRequests.Services/Jobs/RecentlyAdded.cs +++ b/PlexRequests.Services/Jobs/RecentlyAdded.cs @@ -78,8 +78,6 @@ namespace PlexRequests.Services.Jobs public void Execute(IJobExecutionContext context) { - - JobRecord.SetRunning(true, JobNames.CpCacher); try { var settings = NewsletterSettings.GetSettings(); @@ -87,7 +85,7 @@ namespace PlexRequests.Services.Jobs { return; } - + JobRecord.SetRunning(true, JobNames.RecentlyAddedEmail); Start(settings); } catch (Exception e) @@ -97,7 +95,7 @@ namespace PlexRequests.Services.Jobs finally { JobRecord.Record(JobNames.RecentlyAddedEmail); - JobRecord.SetRunning(false, JobNames.CpCacher); + JobRecord.SetRunning(false, JobNames.RecentlyAddedEmail); } } @@ -264,7 +262,8 @@ namespace PlexRequests.Services.Jobs { foreach (var user in users.User) { - message.Bcc.Add(new MailboxAddress(user.Username, user.Email)); + if (user.Email != null) + message.Bcc.Add(new MailboxAddress(user.Username, user.Email)); } } } diff --git a/PlexRequests.Services/Jobs/SickRageCacher.cs b/PlexRequests.Services/Jobs/SickRageCacher.cs index 10ac125c3..6fedf4b27 100644 --- a/PlexRequests.Services/Jobs/SickRageCacher.cs +++ b/PlexRequests.Services/Jobs/SickRageCacher.cs @@ -58,12 +58,14 @@ namespace PlexRequests.Services.Jobs public void Queued() { - Job.SetRunning(true, JobNames.CpCacher); Log.Trace("Getting the settings"); var settings = SrSettings.GetSettings(); if (settings.Enabled) { + + Job.SetRunning(true, JobNames.SrCacher); + Log.Trace("Getting all shows from SickRage"); try { @@ -80,7 +82,7 @@ namespace PlexRequests.Services.Jobs finally { Job.Record(JobNames.SrCacher); - Job.SetRunning(false, JobNames.CpCacher); + Job.SetRunning(false, JobNames.SrCacher); } } } diff --git a/PlexRequests.Services/Jobs/SonarrCacher.cs b/PlexRequests.Services/Jobs/SonarrCacher.cs index 9c7cd2cc1..9e0304f37 100644 --- a/PlexRequests.Services/Jobs/SonarrCacher.cs +++ b/PlexRequests.Services/Jobs/SonarrCacher.cs @@ -62,10 +62,10 @@ namespace PlexRequests.Services.Jobs public void Queued() { - Job.SetRunning(true, JobNames.CpCacher); var settings = SonarrSettings.GetSettings(); if (settings.Enabled) { + Job.SetRunning(true, JobNames.SonarrCacher); try { var series = SonarrApi.GetSeries(settings.ApiKey, settings.FullUri); @@ -81,7 +81,7 @@ namespace PlexRequests.Services.Jobs finally { Job.Record(JobNames.SonarrCacher); - Job.SetRunning(false, JobNames.CpCacher); + Job.SetRunning(false, JobNames.SonarrCacher); } } } diff --git a/PlexRequests.UI/Content/Themes/plex.css b/PlexRequests.UI/Content/Themes/plex.css index dbd72c8b4..be07c9a3a 100644 --- a/PlexRequests.UI/Content/Themes/plex.css +++ b/PlexRequests.UI/Content/Themes/plex.css @@ -182,3 +182,9 @@ button.list-group-item:focus { #sidebar-wrapper { background: #252424; } +#cacherRunning { + background-color: #333333; + text-align: center; + font-size: 15px; + padding: 3px 0; } + diff --git a/PlexRequests.UI/Content/Themes/plex.min.css b/PlexRequests.UI/Content/Themes/plex.min.css index 006124205..d42c984ba 100644 --- a/PlexRequests.UI/Content/Themes/plex.min.css +++ b/PlexRequests.UI/Content/Themes/plex.min.css @@ -1 +1 @@ -.form-control-custom{background-color:#333 !important;}.form-control-custom-disabled{background-color:#252424 !important;}.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active>a:focus{background:#df691a;}.scroll-top-wrapper{background-color:#333;}.scroll-top-wrapper:hover{background-color:#df691a;}body{font-family:Open Sans Regular,Helvetica Neue,Helvetica,Arial,sans-serif;color:#eee;background-color:#1f1f1f;}.table-striped>tbody>tr:nth-of-type(odd){background-color:#333;}.table-hover>tbody>tr:hover{background-color:#282828;}fieldset{padding:15px;}legend{border-bottom:1px solid #333;}.form-control{color:#fefefe;background-color:#333;}.radio input[type="radio"],.radio-inline input[type="radio"],.checkbox input[type="checkbox"],.checkbox-inline input[type="checkbox"]{margin-left:-0;}.form-horizontal .radio,.form-horizontal .checkbox,.form-horizontal .radio-inline,.form-horizontal .checkbox-inline{margin-top:-15px;}.dropdown-menu{background-color:#282828;}.dropdown-menu .divider{background-color:#333;}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus{background-color:#333;}.input-group-addon{background-color:#333;}.nav>li>a:hover,.nav>li>a:focus{background-color:#df691a;}.nav-tabs>li>a:hover{border-color:#df691a #df691a transparent;}.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active>a:focus{background-color:#df691a;border:1px solid #df691a;}.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:hover,.nav-tabs.nav-justified>.active>a:focus{border:1px solid #df691a;}.navbar-default{background-color:#0a0a0a;}.navbar-default .navbar-brand{color:#df691a;}.navbar-default .navbar-nav>li>a:hover,.navbar-default .navbar-nav>li>a:focus{color:#f0ad4e;background-color:#282828;}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:hover,.navbar-default .navbar-nav>.active>a:focus{background-color:#282828;}.navbar-default .navbar-nav>.open>a,.navbar-default .navbar-nav>.open>a:hover,.navbar-default .navbar-nav>.open>a:focus{background-color:#df691a;color:#fff;}.pagination>li>a,.pagination>li>span{background-color:#282828;}.pagination>li>a:hover,.pagination>li>span:hover,.pagination>li>a:focus,.pagination>li>span:focus{background-color:#333;}.pagination>.disabled>span,.pagination>.disabled>span:hover,.pagination>.disabled>span:focus,.pagination>.disabled>a,.pagination>.disabled>a:hover,.pagination>.disabled>a:focus{color:#fefefe;background-color:#333;}.list-group-item{background-color:#282828;}a.list-group-item:hover,button.list-group-item:hover,a.list-group-item:focus,button.list-group-item:focus{background-color:#333;}.input-addon,.input-group-addon{color:#df691a;}.modal-header,.modal-footer{background-color:#282828;}.modal-content{position:relative;background-color:#282828;border:1px solid transparent;border-radius:0;-webkit-box-shadow:0 3px 9px rgba(0,0,0,.5);box-shadow:0 3px 9px rgba(0,0,0,.5);-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box;outline:0;}.badge{display:inline-block;min-width:10px;padding:3px 7px;font-size:12px;font-weight:300;color:#ebebeb;line-height:1;vertical-align:middle;white-space:nowrap;text-align:center;background-color:#333;border-radius:10px;}.bootstrap-datetimepicker-widget.dropdown-menu{background-color:#333;}.bootstrap-datetimepicker-widget.dropdown-menu.bottom:after{border-bottom:6px solid #333 !important;}#sidebar-wrapper{background:#252424;} \ No newline at end of file +.form-control-custom{background-color:#333 !important;}.form-control-custom-disabled{background-color:#252424 !important;}.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active>a:focus{background:#df691a;}.scroll-top-wrapper{background-color:#333;}.scroll-top-wrapper:hover{background-color:#df691a;}body{font-family:Open Sans Regular,Helvetica Neue,Helvetica,Arial,sans-serif;color:#eee;background-color:#1f1f1f;}.table-striped>tbody>tr:nth-of-type(odd){background-color:#333;}.table-hover>tbody>tr:hover{background-color:#282828;}fieldset{padding:15px;}legend{border-bottom:1px solid #333;}.form-control{color:#fefefe;background-color:#333;}.radio input[type="radio"],.radio-inline input[type="radio"],.checkbox input[type="checkbox"],.checkbox-inline input[type="checkbox"]{margin-left:-0;}.form-horizontal .radio,.form-horizontal .checkbox,.form-horizontal .radio-inline,.form-horizontal .checkbox-inline{margin-top:-15px;}.dropdown-menu{background-color:#282828;}.dropdown-menu .divider{background-color:#333;}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus{background-color:#333;}.input-group-addon{background-color:#333;}.nav>li>a:hover,.nav>li>a:focus{background-color:#df691a;}.nav-tabs>li>a:hover{border-color:#df691a #df691a transparent;}.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active>a:focus{background-color:#df691a;border:1px solid #df691a;}.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:hover,.nav-tabs.nav-justified>.active>a:focus{border:1px solid #df691a;}.navbar-default{background-color:#0a0a0a;}.navbar-default .navbar-brand{color:#df691a;}.navbar-default .navbar-nav>li>a:hover,.navbar-default .navbar-nav>li>a:focus{color:#f0ad4e;background-color:#282828;}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:hover,.navbar-default .navbar-nav>.active>a:focus{background-color:#282828;}.navbar-default .navbar-nav>.open>a,.navbar-default .navbar-nav>.open>a:hover,.navbar-default .navbar-nav>.open>a:focus{background-color:#df691a;color:#fff;}.pagination>li>a,.pagination>li>span{background-color:#282828;}.pagination>li>a:hover,.pagination>li>span:hover,.pagination>li>a:focus,.pagination>li>span:focus{background-color:#333;}.pagination>.disabled>span,.pagination>.disabled>span:hover,.pagination>.disabled>span:focus,.pagination>.disabled>a,.pagination>.disabled>a:hover,.pagination>.disabled>a:focus{color:#fefefe;background-color:#333;}.list-group-item{background-color:#282828;}a.list-group-item:hover,button.list-group-item:hover,a.list-group-item:focus,button.list-group-item:focus{background-color:#333;}.input-addon,.input-group-addon{color:#df691a;}.modal-header,.modal-footer{background-color:#282828;}.modal-content{position:relative;background-color:#282828;border:1px solid transparent;border-radius:0;-webkit-box-shadow:0 3px 9px rgba(0,0,0,.5);box-shadow:0 3px 9px rgba(0,0,0,.5);-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box;outline:0;}.badge{display:inline-block;min-width:10px;padding:3px 7px;font-size:12px;font-weight:300;color:#ebebeb;line-height:1;vertical-align:middle;white-space:nowrap;text-align:center;background-color:#333;border-radius:10px;}.bootstrap-datetimepicker-widget.dropdown-menu{background-color:#333;}.bootstrap-datetimepicker-widget.dropdown-menu.bottom:after{border-bottom:6px solid #333 !important;}#sidebar-wrapper{background:#252424;}#cacherRunning{background-color:#333;text-align:center;font-size:15px;padding:3px 0;} \ No newline at end of file diff --git a/PlexRequests.UI/Content/Themes/plex.scss b/PlexRequests.UI/Content/Themes/plex.scss index 067dad666..8a5ffbe8b 100644 --- a/PlexRequests.UI/Content/Themes/plex.scss +++ b/PlexRequests.UI/Content/Themes/plex.scss @@ -228,3 +228,10 @@ button.list-group-item:focus { #sidebar-wrapper { background: $bg-colour-disabled; } + +#cacherRunning { + background-color: $bg-colour; + text-align: center; + font-size: 15px; + padding: 3px 0; +} \ No newline at end of file diff --git a/PlexRequests.UI/Content/base.css b/PlexRequests.UI/Content/base.css index 602ee6369..d48d329f8 100644 --- a/PlexRequests.UI/Content/base.css +++ b/PlexRequests.UI/Content/base.css @@ -257,6 +257,12 @@ label { font-size: 15px; padding: 3px 0; } +#cacherRunning { + background-color: #4e5d6c; + text-align: center; + font-size: 15px; + padding: 3px 0; } + .checkbox label { display: inline-block; cursor: pointer; diff --git a/PlexRequests.UI/Content/base.min.css b/PlexRequests.UI/Content/base.min.css index 5cd192ff8..b47ab325c 100644 --- a/PlexRequests.UI/Content/base.min.css +++ b/PlexRequests.UI/Content/base.min.css @@ -1 +1 @@ -@media(min-width:768px){.row{position:relative;}.bottom-align-text{position:absolute;bottom:0;right:0;}.landing-block .media{max-width:450px;}}@media(max-width:48em){.home{padding-top:1rem;}}@media(min-width:48em){.home{padding-top:4rem;}}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:hover,.navbar-default .navbar-nav>.active>a:focus{color:#fff;}hr{border:1px dashed #777;}.btn{border-radius:.25rem !important;}.btn-group-separated .btn,.btn-group-separated .btn+.btn{margin-left:3px;}.multiSelect{background-color:#4e5d6c;}.form-control-custom{background-color:#4e5d6c !important;color:#fff !important;border-radius:0;box-shadow:0 0 0 !important;}h1{font-size:3.5rem !important;font-weight:600 !important;}.request-title{margin-top:0 !important;font-size:1.9rem !important;}p{font-size:1.1rem !important;}label{display:inline-block !important;margin-bottom:.5rem !important;font-size:16px !important;}.nav-tabs>li{font-size:13px;line-height:21px;}.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active>a:focus{background:#4e5d6c;}.nav-tabs>li>a>.fa{padding:3px 5px 3px 3px;}.nav-tabs>li.nav-tab-right{float:right;}.nav-tabs>li.nav-tab-right a{margin-right:0;margin-left:2px;}.nav-tabs>li.nav-tab-icononly .fa{padding:3px;}.navbar .nav a .fa,.dropdown-menu a .fa{font-size:130%;top:1px;position:relative;display:inline-block;margin-right:5px;}.dropdown-menu a .fa{top:2px;}.btn-danger-outline{color:#d9534f !important;background-color:transparent;background-image:none;border-color:#d9534f !important;}.btn-danger-outline:focus,.btn-danger-outline.focus,.btn-danger-outline:active,.btn-danger-outline.active,.btn-danger-outline:hover,.open>.btn-danger-outline.dropdown-toggle{color:#fff !important;background-color:#d9534f !important;border-color:#d9534f !important;}.btn-primary-outline{color:#ff761b !important;background-color:transparent;background-image:none;border-color:#ff761b !important;}.btn-primary-outline:focus,.btn-primary-outline.focus,.btn-primary-outline:active,.btn-primary-outline.active,.btn-primary-outline:hover,.open>.btn-primary-outline.dropdown-toggle{color:#fff !important;background-color:#df691a !important;border-color:#df691a !important;}.btn-info-outline{color:#5bc0de !important;background-color:transparent;background-image:none;border-color:#5bc0de !important;}.btn-info-outline:focus,.btn-info-outline.focus,.btn-info-outline:active,.btn-info-outline.active,.btn-info-outline:hover,.open>.btn-info-outline.dropdown-toggle{color:#fff !important;background-color:#5bc0de !important;border-color:#5bc0de !important;}.btn-warning-outline{color:#f0ad4e !important;background-color:transparent;background-image:none;border-color:#f0ad4e !important;}.btn-warning-outline:focus,.btn-warning-outline.focus,.btn-warning-outline:active,.btn-warning-outline.active,.btn-warning-outline:hover,.open>.btn-warning-outline.dropdown-toggle{color:#fff !important;background-color:#f0ad4e !important;border-color:#f0ad4e !important;}.btn-success-outline{color:#5cb85c !important;background-color:transparent;background-image:none;border-color:#5cb85c !important;}.btn-success-outline:focus,.btn-success-outline.focus,.btn-success-outline:active,.btn-success-outline.active,.btn-success-outline:hover,.open>.btn-success-outline.dropdown-toggle{color:#fff !important;background-color:#5cb85c !important;border-color:#5cb85c !important;}#movieList .mix{display:none;}#tvList .mix{display:none;}.scroll-top-wrapper{position:fixed;opacity:0;visibility:hidden;overflow:hidden;text-align:center;z-index:99999999;background-color:#4e5d6c;color:#eee;width:50px;height:48px;line-height:48px;right:30px;bottom:30px;padding-top:2px;border-top-left-radius:10px;border-top-right-radius:10px;border-bottom-right-radius:10px;border-bottom-left-radius:10px;-webkit-transition:all .5s ease-in-out;-moz-transition:all .5s ease-in-out;-ms-transition:all .5s ease-in-out;-o-transition:all .5s ease-in-out;transition:all .5s ease-in-out;}.scroll-top-wrapper:hover{background-color:#637689;}.scroll-top-wrapper.show{visibility:visible;cursor:pointer;opacity:1;}.scroll-top-wrapper i.fa{line-height:inherit;}.no-search-results{text-align:center;}.no-search-results .no-search-results-icon{font-size:10em;color:#4e5d6c;}.no-search-results .no-search-results-text{margin:20px 0;color:#ccc;}.form-control-search{padding:13px 105px 13px 16px;height:100%;}.form-control-withbuttons{padding-right:105px;}.input-group-addon .btn-group{position:absolute;right:45px;z-index:3;top:10px;box-shadow:0 0 0;}.input-group-addon .btn-group .btn{border:1px solid rgba(255,255,255,.7) !important;padding:3px 12px;color:rgba(255,255,255,.7) !important;}.btn-split .btn{border-radius:0 !important;}.btn-split .btn:not(.dropdown-toggle){border-radius:.25rem 0 0 .25rem !important;}.btn-split .btn.dropdown-toggle{border-radius:0 .25rem .25rem 0 !important;padding:12px 8px;}#updateAvailable{background-color:#df691a;text-align:center;font-size:15px;padding:3px 0;}.checkbox label{display:inline-block;cursor:pointer;position:relative;padding-left:25px;margin-right:15px;font-size:13px;margin-bottom:10px;}.checkbox label:before{content:"";display:inline-block;width:18px;height:18px;margin-right:10px;position:absolute;left:0;bottom:1px;border:2px solid #eee;border-radius:3px;}.checkbox input[type=checkbox]{display:none;}.checkbox input[type=checkbox]:checked+label:before{content:"✓";font-size:13px;color:#fafafa;text-align:center;line-height:13px;}.input-group-sm{padding-top:2px;padding-bottom:2px;}.tab-pane .form-horizontal .form-group{margin-right:15px;margin-left:15px;}.bootstrap-datetimepicker-widget.dropdown-menu{background-color:#4e5d6c;}.bootstrap-datetimepicker-widget.dropdown-menu.bottom:after{border-bottom:6px solid #4e5d6c !important;}.bootstrap-datetimepicker-widget table td.active,.bootstrap-datetimepicker-widget table td.active:hover{color:#fff !important;}.landing-header{display:block;margin:60px auto;}.landing-block{background:#2f2f2f !important;padding:5px;}.landing-block .media{margin:30px auto;max-width:450px;}.landing-block .media .media-left{display:inline-block;float:left;width:70px;}.landing-block .media .media-left i.fa{font-size:3em;}.landing-title{font-weight:bold;}.checkbox-custom{margin-top:0 !important;margin-bottom:0 !important;}.tooltip_templates{display:none;}.shadow{-moz-box-shadow:3px 3px 5px 6px #191919;-webkit-box-shadow:3px 3px 5px 6px #191919;box-shadow:3px 3px 5px 6px #191919;}.img-circle{border-radius:50%;}#wrapper{padding-left:0;-webkit-transition:all .5s ease;-moz-transition:all .5s ease;-o-transition:all .5s ease;transition:all .5s ease;}#wrapper.toggled{padding-right:250px;}#sidebar-wrapper{z-index:1000;position:fixed;right:250px;width:0;height:100%;margin-right:-250px;overflow-y:auto;background:#4e5d6c;padding-left:15px;-webkit-transition:all .5s ease;-moz-transition:all .5s ease;-o-transition:all .5s ease;transition:all .5s ease;}#wrapper.toggled #sidebar-wrapper{width:500px;}#page-content-wrapper{width:100%;position:absolute;padding:15px;}#wrapper.toggled #page-content-wrapper{position:absolute;margin-left:-250px;}.sidebar-nav{position:absolute;top:0;width:500px;margin:0;padding-left:0;list-style:none;}.sidebar-nav li{text-indent:20px;line-height:40px;}.sidebar-nav li a{display:block;text-decoration:none;color:#999;}.sidebar-nav li a:hover{text-decoration:none;color:#fff;background:rgba(255,255,255,.2);}.sidebar-nav li a:active,.sidebar-nav li a:focus{text-decoration:none;}.sidebar-nav>.sidebar-brand{height:65px;font-size:18px;line-height:60px;}.sidebar-nav>.sidebar-brand a{color:#999;}.sidebar-nav>.sidebar-brand a:hover{color:#fff;background:none;}@media(min-width:768px){#wrapper{padding-right:250px;}#wrapper.toggled{padding-right:0;}#sidebar-wrapper{width:500px;}#wrapper.toggled #sidebar-wrapper{width:0;}#page-content-wrapper{padding:20px;position:relative;}#wrapper.toggled #page-content-wrapper{position:relative;margin-right:0;}}#lightbox{background-color:#808080;filter:alpha(opacity=50);opacity:.5;-moz-opacity:.5;top:0;left:0;z-index:20;height:100%;width:100%;background-repeat:no-repeat;background-position:center;position:absolute;} \ No newline at end of file +@media(min-width:768px){.row{position:relative;}.bottom-align-text{position:absolute;bottom:0;right:0;}.landing-block .media{max-width:450px;}}@media(max-width:48em){.home{padding-top:1rem;}}@media(min-width:48em){.home{padding-top:4rem;}}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:hover,.navbar-default .navbar-nav>.active>a:focus{color:#fff;}hr{border:1px dashed #777;}.btn{border-radius:.25rem !important;}.btn-group-separated .btn,.btn-group-separated .btn+.btn{margin-left:3px;}.multiSelect{background-color:#4e5d6c;}.form-control-custom{background-color:#4e5d6c !important;color:#fff !important;border-radius:0;box-shadow:0 0 0 !important;}h1{font-size:3.5rem !important;font-weight:600 !important;}.request-title{margin-top:0 !important;font-size:1.9rem !important;}p{font-size:1.1rem !important;}label{display:inline-block !important;margin-bottom:.5rem !important;font-size:16px !important;}.nav-tabs>li{font-size:13px;line-height:21px;}.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active>a:focus{background:#4e5d6c;}.nav-tabs>li>a>.fa{padding:3px 5px 3px 3px;}.nav-tabs>li.nav-tab-right{float:right;}.nav-tabs>li.nav-tab-right a{margin-right:0;margin-left:2px;}.nav-tabs>li.nav-tab-icononly .fa{padding:3px;}.navbar .nav a .fa,.dropdown-menu a .fa{font-size:130%;top:1px;position:relative;display:inline-block;margin-right:5px;}.dropdown-menu a .fa{top:2px;}.btn-danger-outline{color:#d9534f !important;background-color:transparent;background-image:none;border-color:#d9534f !important;}.btn-danger-outline:focus,.btn-danger-outline.focus,.btn-danger-outline:active,.btn-danger-outline.active,.btn-danger-outline:hover,.open>.btn-danger-outline.dropdown-toggle{color:#fff !important;background-color:#d9534f !important;border-color:#d9534f !important;}.btn-primary-outline{color:#ff761b !important;background-color:transparent;background-image:none;border-color:#ff761b !important;}.btn-primary-outline:focus,.btn-primary-outline.focus,.btn-primary-outline:active,.btn-primary-outline.active,.btn-primary-outline:hover,.open>.btn-primary-outline.dropdown-toggle{color:#fff !important;background-color:#df691a !important;border-color:#df691a !important;}.btn-info-outline{color:#5bc0de !important;background-color:transparent;background-image:none;border-color:#5bc0de !important;}.btn-info-outline:focus,.btn-info-outline.focus,.btn-info-outline:active,.btn-info-outline.active,.btn-info-outline:hover,.open>.btn-info-outline.dropdown-toggle{color:#fff !important;background-color:#5bc0de !important;border-color:#5bc0de !important;}.btn-warning-outline{color:#f0ad4e !important;background-color:transparent;background-image:none;border-color:#f0ad4e !important;}.btn-warning-outline:focus,.btn-warning-outline.focus,.btn-warning-outline:active,.btn-warning-outline.active,.btn-warning-outline:hover,.open>.btn-warning-outline.dropdown-toggle{color:#fff !important;background-color:#f0ad4e !important;border-color:#f0ad4e !important;}.btn-success-outline{color:#5cb85c !important;background-color:transparent;background-image:none;border-color:#5cb85c !important;}.btn-success-outline:focus,.btn-success-outline.focus,.btn-success-outline:active,.btn-success-outline.active,.btn-success-outline:hover,.open>.btn-success-outline.dropdown-toggle{color:#fff !important;background-color:#5cb85c !important;border-color:#5cb85c !important;}#movieList .mix{display:none;}#tvList .mix{display:none;}.scroll-top-wrapper{position:fixed;opacity:0;visibility:hidden;overflow:hidden;text-align:center;z-index:99999999;background-color:#4e5d6c;color:#eee;width:50px;height:48px;line-height:48px;right:30px;bottom:30px;padding-top:2px;border-top-left-radius:10px;border-top-right-radius:10px;border-bottom-right-radius:10px;border-bottom-left-radius:10px;-webkit-transition:all .5s ease-in-out;-moz-transition:all .5s ease-in-out;-ms-transition:all .5s ease-in-out;-o-transition:all .5s ease-in-out;transition:all .5s ease-in-out;}.scroll-top-wrapper:hover{background-color:#637689;}.scroll-top-wrapper.show{visibility:visible;cursor:pointer;opacity:1;}.scroll-top-wrapper i.fa{line-height:inherit;}.no-search-results{text-align:center;}.no-search-results .no-search-results-icon{font-size:10em;color:#4e5d6c;}.no-search-results .no-search-results-text{margin:20px 0;color:#ccc;}.form-control-search{padding:13px 105px 13px 16px;height:100%;}.form-control-withbuttons{padding-right:105px;}.input-group-addon .btn-group{position:absolute;right:45px;z-index:3;top:10px;box-shadow:0 0 0;}.input-group-addon .btn-group .btn{border:1px solid rgba(255,255,255,.7) !important;padding:3px 12px;color:rgba(255,255,255,.7) !important;}.btn-split .btn{border-radius:0 !important;}.btn-split .btn:not(.dropdown-toggle){border-radius:.25rem 0 0 .25rem !important;}.btn-split .btn.dropdown-toggle{border-radius:0 .25rem .25rem 0 !important;padding:12px 8px;}#updateAvailable{background-color:#df691a;text-align:center;font-size:15px;padding:3px 0;}#cacherRunning{background-color:#4e5d6c;text-align:center;font-size:15px;padding:3px 0;}.checkbox label{display:inline-block;cursor:pointer;position:relative;padding-left:25px;margin-right:15px;font-size:13px;margin-bottom:10px;}.checkbox label:before{content:"";display:inline-block;width:18px;height:18px;margin-right:10px;position:absolute;left:0;bottom:1px;border:2px solid #eee;border-radius:3px;}.checkbox input[type=checkbox]{display:none;}.checkbox input[type=checkbox]:checked+label:before{content:"✓";font-size:13px;color:#fafafa;text-align:center;line-height:13px;}.input-group-sm{padding-top:2px;padding-bottom:2px;}.tab-pane .form-horizontal .form-group{margin-right:15px;margin-left:15px;}.bootstrap-datetimepicker-widget.dropdown-menu{background-color:#4e5d6c;}.bootstrap-datetimepicker-widget.dropdown-menu.bottom:after{border-bottom:6px solid #4e5d6c !important;}.bootstrap-datetimepicker-widget table td.active,.bootstrap-datetimepicker-widget table td.active:hover{color:#fff !important;}.landing-header{display:block;margin:60px auto;}.landing-block{background:#2f2f2f !important;padding:5px;}.landing-block .media{margin:30px auto;max-width:450px;}.landing-block .media .media-left{display:inline-block;float:left;width:70px;}.landing-block .media .media-left i.fa{font-size:3em;}.landing-title{font-weight:bold;}.checkbox-custom{margin-top:0 !important;margin-bottom:0 !important;}.tooltip_templates{display:none;}.shadow{-moz-box-shadow:3px 3px 5px 6px #191919;-webkit-box-shadow:3px 3px 5px 6px #191919;box-shadow:3px 3px 5px 6px #191919;}.img-circle{border-radius:50%;}#wrapper{padding-left:0;-webkit-transition:all .5s ease;-moz-transition:all .5s ease;-o-transition:all .5s ease;transition:all .5s ease;}#wrapper.toggled{padding-right:250px;}#sidebar-wrapper{z-index:1000;position:fixed;right:250px;width:0;height:100%;margin-right:-250px;overflow-y:auto;background:#4e5d6c;padding-left:15px;-webkit-transition:all .5s ease;-moz-transition:all .5s ease;-o-transition:all .5s ease;transition:all .5s ease;}#wrapper.toggled #sidebar-wrapper{width:500px;}#page-content-wrapper{width:100%;position:absolute;padding:15px;}#wrapper.toggled #page-content-wrapper{position:absolute;margin-left:-250px;}.sidebar-nav{position:absolute;top:0;width:500px;margin:0;padding-left:0;list-style:none;}.sidebar-nav li{text-indent:20px;line-height:40px;}.sidebar-nav li a{display:block;text-decoration:none;color:#999;}.sidebar-nav li a:hover{text-decoration:none;color:#fff;background:rgba(255,255,255,.2);}.sidebar-nav li a:active,.sidebar-nav li a:focus{text-decoration:none;}.sidebar-nav>.sidebar-brand{height:65px;font-size:18px;line-height:60px;}.sidebar-nav>.sidebar-brand a{color:#999;}.sidebar-nav>.sidebar-brand a:hover{color:#fff;background:none;}@media(min-width:768px){#wrapper{padding-right:250px;}#wrapper.toggled{padding-right:0;}#sidebar-wrapper{width:500px;}#wrapper.toggled #sidebar-wrapper{width:0;}#page-content-wrapper{padding:20px;position:relative;}#wrapper.toggled #page-content-wrapper{position:relative;margin-right:0;}}#lightbox{background-color:#808080;filter:alpha(opacity=50);opacity:.5;-moz-opacity:.5;top:0;left:0;z-index:20;height:100%;width:100%;background-repeat:no-repeat;background-position:center;position:absolute;} \ No newline at end of file diff --git a/PlexRequests.UI/Content/base.scss b/PlexRequests.UI/Content/base.scss index 64dd1b83e..b1e7abe3e 100644 --- a/PlexRequests.UI/Content/base.scss +++ b/PlexRequests.UI/Content/base.scss @@ -327,6 +327,13 @@ $border-radius: 10px; padding: 3px 0; } +#cacherRunning { + background-color: $form-color; + text-align: center; + font-size: 15px; + padding: 3px 0; +} + .checkbox label { display: inline-block; cursor: pointer; diff --git a/PlexRequests.UI/Helpers/HtmlSecurityHelper.cs b/PlexRequests.UI/Helpers/HtmlSecurityHelper.cs index 3d1751257..ef8d93bc7 100644 --- a/PlexRequests.UI/Helpers/HtmlSecurityHelper.cs +++ b/PlexRequests.UI/Helpers/HtmlSecurityHelper.cs @@ -25,6 +25,8 @@ // ************************************************************************/ #endregion +using Nancy; +using Nancy.Linker; using Nancy.Security; using Nancy.ViewEngines.Razor; using Ninject; @@ -41,22 +43,37 @@ namespace PlexRequests.UI.Helpers get { var userRepo = ServiceLocator.Instance.Resolve(); - return _security ?? (_security = new SecurityExtensions(userRepo, null)); + var linker = ServiceLocator.Instance.Resolve(); + return _security ?? (_security = new SecurityExtensions(userRepo, null, linker)); } } private static SecurityExtensions _security; - public static bool HasAnyPermission(this HtmlHelpers helper, int permission) + public static bool HasAnyPermission(this HtmlHelpers helper, int permission, bool authenticated = true) { - return helper.CurrentUser.IsAuthenticated() - && Security.HasPermissions(helper.CurrentUser, (Permissions) permission); + if (authenticated) + { + return helper.CurrentUser.IsAuthenticated() + && Security.HasPermissions(helper.CurrentUser, (Permissions) permission); + } + return Security.HasPermissions(helper.CurrentUser, (Permissions)permission); } public static bool DoesNotHavePermission(this HtmlHelpers helper, int permission) { return Security.DoesNotHavePermissions(permission, helper.CurrentUser); } + + public static bool IsAdmin(this HtmlHelpers helper, bool isAuthenticated = true) + { + return HasAnyPermission(helper, (int) Permissions.Administrator, isAuthenticated); + } + + public static bool IsLoggedIn(this HtmlHelpers helper, NancyContext context) + { + return Security.IsLoggedIn(context); + } } } \ No newline at end of file diff --git a/PlexRequests.UI/Helpers/SecurityExtensions.cs b/PlexRequests.UI/Helpers/SecurityExtensions.cs index 36f01a1a5..445aadc9c 100644 --- a/PlexRequests.UI/Helpers/SecurityExtensions.cs +++ b/PlexRequests.UI/Helpers/SecurityExtensions.cs @@ -30,6 +30,8 @@ using System.Collections.Generic; using System.Linq; using Nancy; using Nancy.Extensions; +using Nancy.Linker; +using Nancy.Responses; using Nancy.Security; using Ninject; using PlexRequests.Helpers.Permissions; @@ -40,14 +42,16 @@ namespace PlexRequests.UI.Helpers { public class SecurityExtensions { - public SecurityExtensions(IUserRepository userRepository, NancyModule context) + public SecurityExtensions(IUserRepository userRepository, NancyModule context, IResourceLinker linker) { UserRepository = userRepository; Module = context; + Linker = linker; } private IUserRepository UserRepository { get; } private NancyModule Module { get; } + private IResourceLinker Linker { get; } public bool IsLoggedIn(NancyContext context) { @@ -117,7 +121,7 @@ namespace PlexRequests.UI.Helpers if (dbUser == null) return false; var permissions = (Permissions)dbUser.Permissions; - var result = permissions.HasFlag((Permissions)perm); + var result = permissions.HasFlag(perm); return !result; } @@ -134,10 +138,11 @@ namespace PlexRequests.UI.Helpers return result; } - public void HasPermissionsResponse(Permissions perm) + public Response HasPermissionsRedirect(Permissions perm, NancyContext context, string routeName, HttpStatusCode code) { - Module.AddBeforeHookOrExecute( - ForbiddenIfNot(ctx => + var url = Linker.BuildRelativeUri(context, routeName); + + var response = ForbiddenIfNot(ctx => { if (ctx.CurrentUser == null) return false; @@ -145,13 +150,24 @@ namespace PlexRequests.UI.Helpers if (dbUser == null) return false; - var permissions = (Permissions)dbUser.Permissions; + var permissions = (Permissions) dbUser.Permissions; var result = permissions.HasFlag(perm); return result; - }), "Requires Claims"); + }); + + var r = response(context); + return r.StatusCode == code + ? new RedirectResponse(url.ToString()) + : null; } + public Response AdminLoginRedirect(Permissions perm, NancyContext context) + { + // This will redirect us to the Login Page if we don't have the correct permission passed in (e.g. Admin with Http 403 status code). + return HasPermissionsRedirect(perm, context, "LocalLogin", HttpStatusCode.Forbidden); + } + // BELOW IS A COPY FROM THE SecurityHooks CLASS! /// diff --git a/PlexRequests.UI/Modules/Admin/AdminModule.cs b/PlexRequests.UI/Modules/Admin/AdminModule.cs index 1357d3e7d..f621d99cf 100644 --- a/PlexRequests.UI/Modules/Admin/AdminModule.cs +++ b/PlexRequests.UI/Modules/Admin/AdminModule.cs @@ -66,6 +66,7 @@ using PlexRequests.UI.Helpers; using PlexRequests.UI.Models; using Quartz; using Action = PlexRequests.Helpers.Analytics.Action; +using HttpStatusCode = Nancy.HttpStatusCode; namespace PlexRequests.UI.Modules { @@ -154,8 +155,8 @@ namespace PlexRequests.UI.Modules NotifySettings = notifyService; RecentlyAdded = recentlyAdded; - Security.HasPermissionsResponse(Permissions.Administrator); - + Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx); + Get["/"] = _ => Admin(); Get["/authentication", true] = async (x, ct) => await Authentication(); @@ -826,13 +827,11 @@ namespace PlexRequests.UI.Modules return Response.AsJson(result ? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for Newsletter!" } : new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." }); - } + } private Response CreateApiKey() { - Security.HasPermissionsResponse(Permissions.Administrator); - Analytics.TrackEventAsync(Category.Admin, Action.Create, "Created API Key", Username, CookieHelper.GetAnalyticClientId(Cookies)); var apiKey = Guid.NewGuid().ToString("N"); var settings = PrService.GetSettings(); @@ -978,11 +977,11 @@ namespace PlexRequests.UI.Modules if (!isValid) { return Response.AsJson(new JsonResponseModel - { - Result = false, - Message = + { + Result = false, + Message = $"CRON {settings.RecentlyAddedCron} is not valid. Please ensure you are using a valid CRON." - }); + }); } } var result = await ScheduledJobSettings.SaveSettingsAsync(settings); diff --git a/PlexRequests.UI/Modules/Admin/FaultQueueModule.cs b/PlexRequests.UI/Modules/Admin/FaultQueueModule.cs index 355e823e2..b65238b23 100644 --- a/PlexRequests.UI/Modules/Admin/FaultQueueModule.cs +++ b/PlexRequests.UI/Modules/Admin/FaultQueueModule.cs @@ -46,7 +46,7 @@ namespace PlexRequests.UI.Modules.Admin Cache = cache; RequestQueue = requestQueue; - Security.HasPermissionsResponse(Permissions.Administrator); + Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx); Get["Index", "/faultqueue"] = x => Index(); } diff --git a/PlexRequests.UI/Modules/Admin/SystemStatusModule.cs b/PlexRequests.UI/Modules/Admin/SystemStatusModule.cs index 05ae0f125..7c5c793c5 100644 --- a/PlexRequests.UI/Modules/Admin/SystemStatusModule.cs +++ b/PlexRequests.UI/Modules/Admin/SystemStatusModule.cs @@ -49,8 +49,8 @@ namespace PlexRequests.UI.Modules.Admin Cache = cache; SystemSettings = ss; - Security.HasPermissionsResponse(Permissions.Administrator); - + Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx); + Get["/status", true] = async (x, ct) => await Status(); Post["/save", true] = async (x, ct) => await Save(); diff --git a/PlexRequests.UI/Modules/BaseModule.cs b/PlexRequests.UI/Modules/BaseModule.cs index 35bd4817f..2c2fb7467 100644 --- a/PlexRequests.UI/Modules/BaseModule.cs +++ b/PlexRequests.UI/Modules/BaseModule.cs @@ -30,6 +30,7 @@ using System.Linq; using System.Threading; using Nancy; +using Nancy.Linker; using Nancy.Security; using Ninject; using PlexRequests.Core; @@ -151,14 +152,14 @@ namespace PlexRequests.UI.Modules get { var userRepo = ServiceLocator.Instance.Resolve(); - return _security ?? (_security = new SecurityExtensions(userRepo, this)); + var linker = ServiceLocator.Instance.Resolve(); + return _security ?? (_security = new SecurityExtensions(userRepo, this, linker)); } } private SecurityExtensions _security; - protected bool LoggedIn => Context?.CurrentUser != null; protected string Culture { get; set; } diff --git a/PlexRequests.UI/Modules/UpdateCheckerModule.cs b/PlexRequests.UI/Modules/LayoutModule.cs similarity index 65% rename from PlexRequests.UI/Modules/UpdateCheckerModule.cs rename to PlexRequests.UI/Modules/LayoutModule.cs index 3aa6a657d..03b3a95c6 100644 --- a/PlexRequests.UI/Modules/UpdateCheckerModule.cs +++ b/PlexRequests.UI/Modules/LayoutModule.cs @@ -1,7 +1,7 @@ #region Copyright // /************************************************************************ // Copyright (c) 2016 Jamie Rees -// File: UpdateCheckerModule.cs +// File: LayoutModule.cs // Created By: Jamie Rees // // Permission is hereby granted, free of charge, to any person obtaining @@ -25,6 +25,7 @@ // ************************************************************************/ #endregion using System; +using System.Linq; using System.Threading.Tasks; using Nancy; @@ -35,24 +36,29 @@ using PlexRequests.Core; using PlexRequests.Core.SettingModels; using PlexRequests.Core.StatusChecker; using PlexRequests.Helpers; +using PlexRequests.Services.Interfaces; +using PlexRequests.Services.Jobs; using PlexRequests.UI.Models; namespace PlexRequests.UI.Modules { - public class UpdateCheckerModule : BaseAuthModule + public class LayoutModule : BaseAuthModule { - public UpdateCheckerModule(ICacheProvider provider, ISettingsService pr, ISettingsService settings) : base("updatechecker", pr) + public LayoutModule(ICacheProvider provider, ISettingsService pr, ISettingsService settings, IJobRecord rec) : base("layout", pr) { Cache = provider; SystemSettings = settings; + Job = rec; Get["/", true] = async (x,ct) => await CheckLatestVersion(); + Get["/cacher", true] = async (x,ct) => await CacherRunning(); } private ICacheProvider Cache { get; } private static Logger Log = LogManager.GetCurrentClassLogger(); private ISettingsService SystemSettings { get; } + private IJobRecord Job { get; } private async Task CheckLatestVersion() { @@ -79,5 +85,35 @@ namespace PlexRequests.UI.Modules return Response.AsJson(new JsonUpdateAvailableModel { UpdateAvailable = false }); } } + + private async Task CacherRunning() + { + try + { + var jobs = await Job.GetJobsAsync(); + + // Check to see if any are running + var runningJobs = jobs.Where(x => x.Running); + + // We only want the cachers + var cacherJobs = runningJobs.Where(x => + x.Name.Equals(JobNames.CpCacher) + || x.Name.Equals(JobNames.EpisodeCacher) + || x.Name.Equals(JobNames.PlexChecker) + || x.Name.Equals(JobNames.SonarrCacher) + || x.Name.Equals(JobNames.SrCacher)); + + + return Response.AsJson(cacherJobs.Any() + ? new { CurrentlyRunning = true, IsAdmin} + : new { CurrentlyRunning = false, IsAdmin }); + } + catch (Exception e) + { + Log.Warn("Exception Thrown when attempting to check the status"); + Log.Warn(e); + return Response.AsJson(new { CurrentlyRunning = false, IsAdmin }); + } + } } } \ No newline at end of file diff --git a/PlexRequests.UI/Modules/LoginModule.cs b/PlexRequests.UI/Modules/LoginModule.cs index e6030207f..37ab086a3 100644 --- a/PlexRequests.UI/Modules/LoginModule.cs +++ b/PlexRequests.UI/Modules/LoginModule.cs @@ -52,7 +52,7 @@ namespace PlexRequests.UI.Modules : base(pr) { UserMapper = m; - Get["/login"] = _ => + Get["LocalLogin","/login"] = _ => { if (LoggedIn) { diff --git a/PlexRequests.UI/Modules/UserLoginModule.cs b/PlexRequests.UI/Modules/UserLoginModule.cs index d4e55182c..f377cf2f3 100644 --- a/PlexRequests.UI/Modules/UserLoginModule.cs +++ b/PlexRequests.UI/Modules/UserLoginModule.cs @@ -99,7 +99,7 @@ namespace PlexRequests.UI.Modules { Session["TempMessage"] = Resources.UI.UserLogin_IncorrectUserPass; var uri = Linker.BuildRelativeUri(Context, "UserLoginIndex"); - return Response.AsRedirect(uri.ToString()); // TODO Check this + return Response.AsRedirect(uri.ToString()); } var authenticated = false; @@ -112,7 +112,7 @@ namespace PlexRequests.UI.Modules Log.Debug("User is in denied list, not allowing them to authenticate"); Session["TempMessage"] = Resources.UI.UserLogin_IncorrectUserPass; var uri = Linker.BuildRelativeUri(Context, "UserLoginIndex"); - return Response.AsRedirect(uri.ToString()); // TODO Check this + return Response.AsRedirect(uri.ToString()); } var password = string.Empty; @@ -178,7 +178,7 @@ namespace PlexRequests.UI.Modules { var uri = Linker.BuildRelativeUri(Context, "UserLoginIndex"); Session["TempMessage"] = Resources.UI.UserLogin_IncorrectUserPass; - return Response.AsRedirect(uri.ToString()); // TODO Check this + return Response.AsRedirect(uri.ToString()); } var landingSettings = await LandingPageSettings.GetSettingsAsync(); @@ -192,7 +192,7 @@ namespace PlexRequests.UI.Modules } } var retVal = Linker.BuildRelativeUri(Context, "SearchIndex"); - return Response.AsRedirect(retVal.ToString()); // TODO Check this + return Response.AsRedirect(retVal.ToString()); } diff --git a/PlexRequests.UI/PlexRequests.UI.csproj b/PlexRequests.UI/PlexRequests.UI.csproj index 82f401655..04f4a0cc6 100644 --- a/PlexRequests.UI/PlexRequests.UI.csproj +++ b/PlexRequests.UI/PlexRequests.UI.csproj @@ -258,7 +258,7 @@ - + @@ -747,6 +747,7 @@ PublicResXFileCodeGenerator UI1.Designer.cs + Designer diff --git a/PlexRequests.UI/Resources/UI.da.resx b/PlexRequests.UI/Resources/UI.da.resx index 14e0154ac..5937e76be 100644 --- a/PlexRequests.UI/Resources/UI.da.resx +++ b/PlexRequests.UI/Resources/UI.da.resx @@ -459,4 +459,34 @@ Der er ingen oplysninger om udgivelsesdatoen + + Udsigt I Plex + + + Doner til Bibliotek vedligeholder + + + Tilgængelig på + + + Movie status + + + Ikke anmodet endnu + + + Afventer godkendelse + + + Behandler forespørgsel + + + Anmodning afvist! + + + Tv-show status! + + + En baggrund proces kører i øjeblikket, så der kan være nogle uventede problemer. Dette bør ikke tage for lang tid. + \ No newline at end of file diff --git a/PlexRequests.UI/Resources/UI.de.resx b/PlexRequests.UI/Resources/UI.de.resx index 039e49e46..fa6f71547 100644 --- a/PlexRequests.UI/Resources/UI.de.resx +++ b/PlexRequests.UI/Resources/UI.de.resx @@ -459,4 +459,34 @@ Es gibt noch keine Informationen für diesen Release-Termin - + + Ansicht In Plex + + + Spenden zur Bibliothek Maintainer + + + Verfügbar auf Plex + + + Film-Status! + + + Noch nicht heraus! + + + Genehmigung ausstehend + + + Die Verarbeitung Anfrage + + + Anfrage verweigert. + + + TV-Show-Status + + + Ein Hintergrundprozess gerade läuft, so könnte es einige unerwartete Verhalten sein. Dies sollte nicht zu lange dauern. + + \ No newline at end of file diff --git a/PlexRequests.UI/Resources/UI.es.resx b/PlexRequests.UI/Resources/UI.es.resx index a1706e45d..e7908b3f5 100644 --- a/PlexRequests.UI/Resources/UI.es.resx +++ b/PlexRequests.UI/Resources/UI.es.resx @@ -459,4 +459,31 @@ No hay información disponible para la fecha de lanzamiento + + Donar a la biblioteca Mantenedor + + + Disponible en Plex + + + estado de película + + + No solicitado + + + PENDIENTES DE APROBACIÓN + + + solicitud de procesamiento + + + Solicitud denegada + + + estado de programa de televisión + + + Un proceso en segundo plano se está ejecutando actualmente, por lo que podría ser un comportamiento inesperado. Esto no debería tomar mucho tiempo. + \ No newline at end of file diff --git a/PlexRequests.UI/Resources/UI.fr.resx b/PlexRequests.UI/Resources/UI.fr.resx index e4a54012d..5767fb4d2 100644 --- a/PlexRequests.UI/Resources/UI.fr.resx +++ b/PlexRequests.UI/Resources/UI.fr.resx @@ -459,4 +459,34 @@ Il n'y a pas d'information disponible pour la date de sortie + + Voir Dans Plex + + + Faire un don à la bibliothèque mainteneur! + + + Disponible sur Plex + + + le statut de film + + + Pas encore demandé + + + En attente de validation + + + Traitement de la demande + + + Requête refusée + + + TV show status + + + Un processus d'arrière-plan est en cours d'exécution, de sorte qu'il pourrait y avoir des comportements inattendus. Cela ne devrait pas prendre trop de temps. + \ No newline at end of file diff --git a/PlexRequests.UI/Resources/UI.it.resx b/PlexRequests.UI/Resources/UI.it.resx index fe73d4586..febcf378a 100644 --- a/PlexRequests.UI/Resources/UI.it.resx +++ b/PlexRequests.UI/Resources/UI.it.resx @@ -459,4 +459,34 @@ Non ci sono informazioni disponibili per la data di uscita + + Guarda In Plex + + + Donare alla libreria Maintainer + + + Disponibile su Plex + + + lo stato di film + + + Non ancora richiesto + + + Approvazione in sospeso + + + Elaborazione richiesta + + + Richiesta negata + + + Show televisivo di stato + + + Un processo in background è in esecuzione, quindi ci potrebbero essere alcuni comportamenti imprevisti. Questo non dovrebbe richiedere troppo tempo. + \ No newline at end of file diff --git a/PlexRequests.UI/Resources/UI.nl.resx b/PlexRequests.UI/Resources/UI.nl.resx index 9ddc8688e..e64511a14 100644 --- a/PlexRequests.UI/Resources/UI.nl.resx +++ b/PlexRequests.UI/Resources/UI.nl.resx @@ -459,4 +459,34 @@ Er is geen informatie beschikbaar voor de release datum + + Bekijk In Plex + + + Doneer aan Library Maintainer + + + Beschikbaar vanaf + + + Movie-status! + + + Nog niet gevraagd + + + Wacht op goedkeuring + + + Verwerking verzoek... + + + Aanvraag afgewezen + + + TV-show-status + + + Een achtergrond taak is momenteel actief, dus er misschien een onverwachte gedrag. Dit moet niet te lang duren. + \ No newline at end of file diff --git a/PlexRequests.UI/Resources/UI.pt.resx b/PlexRequests.UI/Resources/UI.pt.resx index 712b779c4..efedc0856 100644 --- a/PlexRequests.UI/Resources/UI.pt.resx +++ b/PlexRequests.UI/Resources/UI.pt.resx @@ -459,4 +459,31 @@ Não há informações disponíveis para a data de lançamento + + Ver Em Plex + + + Doações para Biblioteca Mantenedor + + + Disponível em Plex + + + status de filme + + + Não solicitada ainda + + + B – P/ Aprovação + + + Processando solicitação... + + + Solicitação negada. + + + Programa de TV status + \ No newline at end of file diff --git a/PlexRequests.UI/Resources/UI.resx b/PlexRequests.UI/Resources/UI.resx index ced499673..ca792000b 100644 --- a/PlexRequests.UI/Resources/UI.resx +++ b/PlexRequests.UI/Resources/UI.resx @@ -467,4 +467,7 @@ TV show status + + A background process is currently running, so there might be some unexpected behavior. This shouldn't take too long. + \ No newline at end of file diff --git a/PlexRequests.UI/Resources/UI.sv.resx b/PlexRequests.UI/Resources/UI.sv.resx index 8b3708153..924f2cc70 100644 --- a/PlexRequests.UI/Resources/UI.sv.resx +++ b/PlexRequests.UI/Resources/UI.sv.resx @@ -459,4 +459,34 @@ Det finns ingen information tillgänglig för release datum + + Vy I Plex + + + Donera till bibliotek Ansvarig + + + Tillgänglig den + + + Film status + + + Inte Begärd ännu + + + Väntar på godkännande + + + Bearbetning förfrågan + + + Förfrågan nekad + + + Visa status + + + En bakgrundsprocess är igång, så det kan finnas några oväntade beteende. Detta bör inte ta alltför lång tid. + \ No newline at end of file diff --git a/PlexRequests.UI/Resources/UI1.Designer.cs b/PlexRequests.UI/Resources/UI1.Designer.cs index 548dafff4..0a57c2412 100644 --- a/PlexRequests.UI/Resources/UI1.Designer.cs +++ b/PlexRequests.UI/Resources/UI1.Designer.cs @@ -222,6 +222,15 @@ namespace PlexRequests.UI.Resources { } } + /// + /// Looks up a localized string similar to A background process is currently running, so there might be some unexpected behavior. This shouldn't take too long.. + /// + public static string Layout_CacherRunning { + get { + return ResourceManager.GetString("Layout_CacherRunning", resourceCulture); + } + } + /// /// Looks up a localized string similar to Change Password. /// diff --git a/PlexRequests.UI/Validators/PlexRequestsValidator.cs b/PlexRequests.UI/Validators/PlexRequestsValidator.cs index 7d61eba2c..481364fd9 100644 --- a/PlexRequests.UI/Validators/PlexRequestsValidator.cs +++ b/PlexRequests.UI/Validators/PlexRequestsValidator.cs @@ -44,7 +44,7 @@ namespace PlexRequests.UI.Validators RuleFor(x => x.BaseUrl).NotEqual("login", StringComparer.CurrentCultureIgnoreCase).WithMessage("You cannot use 'login' as this is reserved by the application."); RuleFor(x => x.BaseUrl).NotEqual("test", StringComparer.CurrentCultureIgnoreCase).WithMessage("You cannot use 'test' as this is reserved by the application."); RuleFor(x => x.BaseUrl).NotEqual("approval", StringComparer.CurrentCultureIgnoreCase).WithMessage("You cannot use 'approval' as this is reserved by the application."); - RuleFor(x => x.BaseUrl).NotEqual("updatechecker", StringComparer.CurrentCultureIgnoreCase).WithMessage("You cannot use 'updatechecker' as this is reserved by the application."); + RuleFor(x => x.BaseUrl).NotEqual("layout", StringComparer.CurrentCultureIgnoreCase).WithMessage("You cannot use 'layout' as this is reserved by the application."); RuleFor(x => x.BaseUrl).NotEqual("usermanagement", StringComparer.CurrentCultureIgnoreCase).WithMessage("You cannot use 'usermanagement' as this is reserved by the application."); RuleFor(x => x.BaseUrl).NotEqual("api", StringComparer.CurrentCultureIgnoreCase).WithMessage("You cannot use 'api' as this is reserved by the application."); RuleFor(x => x.BaseUrl).NotEqual("landing", StringComparer.CurrentCultureIgnoreCase).WithMessage("You cannot use 'landing' as this is reserved by the application."); diff --git a/PlexRequests.UI/Views/Shared/Partial/_LayoutScripts.cshtml b/PlexRequests.UI/Views/Shared/Partial/_LayoutScripts.cshtml index 808fc7a91..62e946479 100644 --- a/PlexRequests.UI/Views/Shared/Partial/_LayoutScripts.cshtml +++ b/PlexRequests.UI/Views/Shared/Partial/_LayoutScripts.cshtml @@ -10,7 +10,7 @@ $(function () { // Check for update - var url = createBaseUrl(urlBase, '/updatechecker'); + var url = createBaseUrl(urlBase, '/layout'); $.ajax({ type: "GET", url: url, @@ -20,7 +20,7 @@ var status = createBaseUrl(urlBase, '/admin/status'); $('#updateAvailable').html(" @UI.Layout_UpdateAvailablePart1 @UI.Layout_UpdateAvailablePart2"); $('#updateAvailable').removeAttr("hidden"); - $('body').addClass('update-available'); + //$('body').addClass('update-available'); } }, error: function (e) { @@ -29,6 +29,7 @@ }); // End Check for update + checkCacheInProgress(); // Scroller $(document).on('scroll', function () { @@ -43,9 +44,6 @@ $('.scroll-top-wrapper').on('click', scrollToTop); // End Scroller - - - // Get Issue count var issueUrl = createBaseUrl(urlBase, '/issues/issuecount'); $.ajax({ @@ -66,6 +64,8 @@ // End issue count + + $('#donate').click(function () { ga('send', 'event', 'Navbar', 'Donate', 'Donate Clicked'); }); @@ -80,4 +80,23 @@ offsetTop = offset.top; $('html, body').animate({ scrollTop: offsetTop }, 500, 'linear'); } + + function checkCacheInProgress() { + + var url = createBaseUrl(urlBase, '/layout/cacher'); + $.ajax({ + type: "GET", + url: url, + dataType: "json", + success: function (response) { + if (response.currentlyRunning) { + $('#cacherRunning').html("@UI.Layout_CacherRunning"); + $('#cacherRunning').removeAttr("hidden"); + } + }, + error: function (e) { + console.log(e); + } + }); + } \ No newline at end of file diff --git a/PlexRequests.UI/Views/Shared/Partial/_Navbar.cshtml b/PlexRequests.UI/Views/Shared/Partial/_Navbar.cshtml index 2dba39e5f..e4d75cc75 100644 --- a/PlexRequests.UI/Views/Shared/Partial/_Navbar.cshtml +++ b/PlexRequests.UI/Views/Shared/Partial/_Navbar.cshtml @@ -35,21 +35,21 @@ @Html.GetNavbarUrl(Context, "/search", UI.Layout_Search, "search") @Html.GetNavbarUrl(Context, "/requests", UI.Layout_Requests, "plus-circle") @Html.GetNavbarUrl(Context, "/issues", UI.Layout_Issues, "exclamation", "") - @if (Context.CurrentUser.IsAuthenticated()) // TODO replace with IsAdmin + @*@if (Context.CurrentUser.IsAuthenticated()) // TODO replace with IsAdmin*@ + @if (Html.IsAdmin()) {
  • } } - @if (Context.Request.Session[SessionKeys.UsernameKey] != null && !Context.CurrentUser.IsAuthenticated()) + @*@if (Context.Request.Session[SessionKeys.UsernameKey] != null && !Context.CurrentUser.IsAuthenticated())*@ + else if (Html.IsLoggedIn(Context)) // Logged in but not admin {
  • + + +
  • @@ -104,16 +105,17 @@ var donateLink = $("#customDonateHref"); var donationText = $("#donationText"); donateLink.attr("href", result.url); - if(result.message) { + if (result.message) { donationText.text(result.message); } } }, - error: function(xhr, status, error) { + error: function (xhr, status, error) { console.log("error " + error); $("#customDonate").hide(); } }); + \ No newline at end of file diff --git a/PlexRequests.UI/Views/Shared/_Layout.cshtml b/PlexRequests.UI/Views/Shared/_Layout.cshtml index 86eae181c..fcd6f8d37 100644 --- a/PlexRequests.UI/Views/Shared/_Layout.cshtml +++ b/PlexRequests.UI/Views/Shared/_Layout.cshtml @@ -16,8 +16,6 @@ - - @*@MiniProfiler.RenderIncludes()*@ @Html.GetInformationalVersion()