Implimented a theme changer, waiting for the Plex theme

pull/231/head
tidusjar 9 years ago
parent 7c41f448a8
commit c41944c933

@ -46,7 +46,7 @@ namespace PlexRequests.Core
public const string CouchPotatoQualityProfiles = "CouchPotatoQualityProfiles"; public const string CouchPotatoQualityProfiles = "CouchPotatoQualityProfiles";
public const string CouchPotatoQueued = "CouchPotatoQueued"; public const string CouchPotatoQueued = "CouchPotatoQueued";
public const string GetBaseUrl = "GetBaseUrl"; public const string GetPlexRequestSettings = "GetPlexRequestSettings";
public const string LastestProductVersion = "LatestProductVersion"; public const string LastestProductVersion = "LatestProductVersion";
} }

@ -43,10 +43,13 @@ namespace PlexRequests.Core.SettingModels
public bool UsersCanViewOnlyOwnRequests { get; set; } public bool UsersCanViewOnlyOwnRequests { get; set; }
public int WeeklyRequestLimit { get; set; } public int WeeklyRequestLimit { get; set; }
public string NoApprovalUsers { get; set; } public string NoApprovalUsers { get; set; }
public string ApiKey {
get; /// <summary>
set; /// The CSS name of the theme we want
} /// </summary>
public string ThemeName { get; set; }
public string ApiKey { get; set; }
[JsonIgnore] [JsonIgnore]
public List<string> ApprovalWhiteList public List<string> ApprovalWhiteList

@ -52,8 +52,13 @@ namespace PlexRequests.UI.Helpers
var assetLocation = GetBaseUrl(); var assetLocation = GetBaseUrl();
var content = GetContentUrl(assetLocation); var content = GetContentUrl(assetLocation);
var settings = GetSettings();
if (string.IsNullOrEmpty(settings.ThemeName))
{
settings.ThemeName = Themes.OriginalTheme;
}
sb.AppendLine($"<link rel=\"stylesheet\" href=\"{content}/Content/bootstrap.css\" type=\"text/css\"/>"); sb.AppendLine($"<link rel=\"stylesheet\" href=\"{content}/Content/Themes/{settings.ThemeName}\" type=\"text/css\"/>");
sb.AppendLine($"<link rel=\"stylesheet\" href=\"{content}/Content/custom.min.css\" type=\"text/css\" />"); sb.AppendLine($"<link rel=\"stylesheet\" href=\"{content}/Content/custom.min.css\" type=\"text/css\" />");
sb.AppendLine($"<link rel=\"stylesheet\" href=\"{content}/Content/font-awesome.css\" type=\"text/css\"/>"); sb.AppendLine($"<link rel=\"stylesheet\" href=\"{content}/Content/font-awesome.css\" type=\"text/css\"/>");
sb.AppendLine($"<link rel=\"stylesheet\" href=\"{content}/Content/pace.min.css\" type=\"text/css\"/>"); sb.AppendLine($"<link rel=\"stylesheet\" href=\"{content}/Content/pace.min.css\" type=\"text/css\"/>");
@ -156,11 +161,15 @@ namespace PlexRequests.UI.Helpers
private static string GetBaseUrl() private static string GetBaseUrl()
{ {
var returnValue = Cache.GetOrSet(CacheKeys.GetBaseUrl, () => return GetSettings().BaseUrl;
}
private static PlexRequestSettings GetSettings()
{
var returnValue = Cache.GetOrSet(CacheKeys.GetPlexRequestSettings, () =>
{ {
var settings = Locator.Resolve<ISettingsService<PlexRequestSettings>>().GetSettings(); var settings = Locator.Resolve<ISettingsService<PlexRequestSettings>>().GetSettings();
var assetLocation = settings.BaseUrl; return settings;
return assetLocation;
}); });
return returnValue; return returnValue;
} }

@ -0,0 +1,34 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: Themes.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
namespace PlexRequests.UI.Helpers
{
public static class Themes
{
public const string OriginalTheme = "OriginalBootstrap.css";
public const string PlexTheme = "PlexBootstrap.css";
}
}

@ -161,6 +161,7 @@
<Compile Include="Helpers\HeadphonesSender.cs" /> <Compile Include="Helpers\HeadphonesSender.cs" />
<Compile Include="Helpers\ServiceLocator.cs" /> <Compile Include="Helpers\ServiceLocator.cs" />
<Compile Include="Helpers\StringHelper.cs" /> <Compile Include="Helpers\StringHelper.cs" />
<Compile Include="Helpers\Themes.cs" />
<Compile Include="Helpers\TvSender.cs" /> <Compile Include="Helpers\TvSender.cs" />
<Compile Include="Helpers\ValidationHelper.cs" /> <Compile Include="Helpers\ValidationHelper.cs" />
<Compile Include="Jobs\CustomJobFactory.cs" /> <Compile Include="Jobs\CustomJobFactory.cs" />
@ -210,7 +211,7 @@
<Content Include="Content\bootstrap-notify.min.js"> <Content Include="Content\bootstrap-notify.min.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Content\bootstrap.css"> <Content Include="Content\Themes\OriginalBootstrap.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Compile Include="Models\JsonResponseModel.cs" /> <Compile Include="Models\JsonResponseModel.cs" />

@ -18,7 +18,18 @@
{ {
formAction = "/" + baseUrl.ToHtmlString() + formAction; formAction = "/" + baseUrl.ToHtmlString() + formAction;
} }
var plexTheme = string.Empty;
var originalTheme = string.Empty;
if (!string.IsNullOrEmpty(Model.ThemeName))
{
plexTheme = Model.ThemeName.Equals(Themes.PlexTheme) ? "selected=\"selected\"" : string.Empty;
originalTheme = Model.ThemeName.Equals(Themes.OriginalTheme) ? "selected=\"selected\"" : string.Empty;
}
else
{
plexTheme = "selected=\"selected\"";
}
} }
<div class="col-sm-8 col-sm-push-1"> <div class="col-sm-8 col-sm-push-1">
<form class="form-horizontal" method="POST" id="mainForm"> <form class="form-horizontal" method="POST" id="mainForm">
@ -53,6 +64,16 @@
</div> </div>
</div> </div>
<div class="form-group">
<label for="select" class="control-label">Theme</label>
<div id="themes">
<select class="form-control form-control-custom" id="select">
<option @plexTheme class="form-control form-control-custom" value="@Themes.PlexTheme">Plex Dark</option>
<option @originalTheme class="form-control form-control-custom" value="@Themes.OriginalTheme">Original Blue</option>
</select>
</div>
</div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
@ -188,11 +209,13 @@
<script> <script>
$(function() { $(function() {
$('#save').click(function (e) { $('#save').click(function (e) {
e.preventDefault(); e.preventDefault();
var theme = $("#themes option:selected").val();
var $form = $("#mainForm"); var $form = $("#mainForm");
var data = $form.serialize(); var data = $form.serialize();
data = data + "&themeName=" + theme;
$.ajax({ $.ajax({
type: $form.prop("method"), type: $form.prop("method"),

Loading…
Cancel
Save