styling for #298 done, just need to wire up the model and do the actual status check

pull/332/head
tidusjar 9 years ago
parent 9f74d31f1d
commit 46f7a0769e

@ -31,6 +31,7 @@ namespace PlexRequests.Core.SettingModels
public class LandingPageSettings : Settings
{
public bool Enabled { get; set; }
public bool BeforeLogin { get; set; }
public bool NoticeEnable { get; set; }
public string NoticeMessage { get; set; }
public bool EnabledNoticeTime { get; set; }

@ -64,6 +64,7 @@ namespace PlexRequests.UI.Tests
PlexRequestMock = new Mock<ISettingsService<PlexRequestSettings>>();
PlexRequestMock.Setup(x => x.GetSettings()).Returns(new PlexRequestSettings());
PlexRequestMock.Setup(x => x.GetSettingsAsync()).Returns(Task.FromResult(new PlexRequestSettings()));
LandingPageMock.Setup(x => x.GetSettings()).Returns(new LandingPageSettings());
Bootstrapper = new ConfigurableBootstrapper(with =>
{
with.Module<UserLoginModule>();
@ -81,8 +82,6 @@ namespace PlexRequests.UI.Tests
var expectedSettings = new AuthenticationSettings { UserAuthentication = false, PlexAuthToken = "abc" };
AuthMock.Setup(x => x.GetSettings()).Returns(expectedSettings);
Bootstrapper.WithSession(new Dictionary<string, object>());
var browser = new Browser(Bootstrapper);

@ -298,9 +298,22 @@ label {
background-color: #4e5d6c; }
.bootstrap-datetimepicker-widget.dropdown-menu.bottom:after {
border-bottom: 6px solid #df691a !important; }
border-bottom: 6px solid #4e5d6c !important; }
.bootstrap-datetimepicker-widget table td.active,
.bootstrap-datetimepicker-widget table td.active:hover {
color: #fff !important; }
img.center {
display: block;
margin: 0 auto; }
div.landing-block {
background: #424242 !important;
padding-bottom: 30px;
padding-top: 15px; }
span.landing-title {
font-size: 32px;
font-weight: 600; }

File diff suppressed because one or more lines are too long

@ -354,7 +354,7 @@ $border-radius: 10px;
text-align: center;
line-height: 13px; }
.input-group-sm{form
.input-group-sm{
padding-top: 2px;
padding-bottom: 2px;
}
@ -375,3 +375,19 @@ $border-radius: 10px;
.bootstrap-datetimepicker-widget table td.active:hover {
color: #fff !important;
}
img.center {
display: block;
margin: 0 auto;
}
div.landing-block{
background: #424242 !important;
padding-bottom:30px;
padding-top:15px;
}
span.landing-title{
font-size:32px;
font-weight:600;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

@ -0,0 +1,36 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: LandingPageViewModel.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 PlexRequests.Core.SettingModels;
namespace PlexRequests.UI.Models
{
public class LandingPageViewModel : LandingPageSettings
{
public string ContinueUrl { get; set; }
}
}

@ -33,6 +33,7 @@ using Nancy.Responses.Negotiation;
using PlexRequests.Api.Interfaces;
using PlexRequests.Core;
using PlexRequests.Core.SettingModels;
using PlexRequests.UI.Models;
namespace PlexRequests.UI.Modules
{
@ -57,8 +58,20 @@ namespace PlexRequests.UI.Modules
private async Task<Negotiator> Index()
{
var model = await LandingSettings.GetSettingsAsync();
return View["Index", model];
var s = await LandingSettings.GetSettingsAsync();
var model = new LandingPageViewModel
{
Enabled = s.Enabled,
Id = s.Id,
EnabledNoticeTime = s.EnabledNoticeTime,
NoticeEnable = s.NoticeEnable,
NoticeEnd = s.NoticeEnd,
NoticeMessage = s.NoticeMessage,
NoticeStart = s.NoticeStart,
ContinueUrl = s.BeforeLogin ? $"userlogin" : $"search"
};
return View["Landing/Index", model];
}
private async Task<Response> CheckStatus()

@ -71,9 +71,25 @@ namespace PlexRequests.UI.Modules
if (landingCheck)
{
var landingSettings = await LandingPageSettings.GetSettingsAsync();
if (landingSettings.Enabled)
{
return View["Landing/Index", landingSettings];
if (landingSettings.BeforeLogin)
{
var model = new LandingPageViewModel
{
Enabled = landingSettings.Enabled,
Id = landingSettings.Id,
EnabledNoticeTime = landingSettings.EnabledNoticeTime,
NoticeEnable = landingSettings.NoticeEnable,
NoticeEnd = landingSettings.NoticeEnd,
NoticeMessage = landingSettings.NoticeMessage,
NoticeStart = landingSettings.NoticeStart,
ContinueUrl = landingSettings.BeforeLogin ? $"userlogin" : $"search"
};
return View["Landing/Index", model];
}
}
}
var settings = await AuthService.GetSettingsAsync();
@ -84,7 +100,7 @@ namespace PlexRequests.UI.Modules
{
var dateTimeOffset = Request.Form.DateTimeOffset;
var username = Request.Form.username.Value;
Log.Debug("Username \"{0}\" attempting to login",username);
Log.Debug("Username \"{0}\" attempting to login", username);
if (string.IsNullOrWhiteSpace(username))
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Incorrect User or Password" });
@ -127,7 +143,7 @@ namespace PlexRequests.UI.Modules
}
}
}
else if(settings.UserAuthentication) // Check against the users in Plex
else if (settings.UserAuthentication) // Check against the users in Plex
{
Log.Debug("Need to auth");
authenticated = CheckIfUserIsInPlexFriends(username, settings.PlexAuthToken);
@ -138,7 +154,7 @@ namespace PlexRequests.UI.Modules
}
Log.Debug("Friends list result = {0}", authenticated);
}
else if(!settings.UserAuthentication) // No auth, let them pass!
else if (!settings.UserAuthentication) // No auth, let them pass!
{
Log.Debug("No need to auth");
authenticated = true;
@ -153,9 +169,19 @@ namespace PlexRequests.UI.Modules
Session[SessionKeys.ClientDateTimeOffsetKey] = (int)dateTimeOffset;
return Response.AsJson(authenticated
? new JsonResponseModel { Result = true }
: new JsonResponseModel { Result = false, Message = "Incorrect User or Password"});
if (!authenticated)
{
return Response.AsJson(new JsonResponseModel {Result = false, Message = "Incorrect User or Password"});
}
var landingSettings = LandingPageSettings.GetSettings();
if (landingSettings.Enabled)
{
if (!landingSettings.BeforeLogin)
return Response.AsJson(new JsonResponseModel { Result = true, Message = "landing" });
}
return Response.AsJson(new JsonResponseModel {Result = true, Message = "search" });
}

@ -179,6 +179,7 @@
<Compile Include="Models\DatatablesModel.cs" />
<Compile Include="Models\IssuesViewMOdel.cs" />
<Compile Include="Models\JsonUpdateAvailableModel.cs" />
<Compile Include="Models\LandingPageViewModel.cs" />
<Compile Include="Models\MovieSearchType.cs" />
<Compile Include="Models\QualityModel.cs" />
<Compile Include="Models\SearchViewModel.cs" />
@ -331,6 +332,9 @@
<Content Include="Content\bootstrap-datetimepicker.min.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\images\logo.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Scripts\bootstrap-datetimepicker.js" />
<Content Include="Scripts\bootstrap-datetimepicker.min.js" />
<Content Include="Scripts\bootstrap.js" />

@ -9,7 +9,6 @@
<div class="form-group">
<div class="checkbox">
@if (Model.Enabled)
{
<input type="checkbox" id="Enabled" name="Enabled" checked="checked"><label for="Enabled">Enabled</label>
@ -21,6 +20,19 @@
</div>
<small>If enabled then all users will be redirected to the landing page instead of the login page.</small>
</div>
<div class="form-group">
<div class="checkbox">
@if (Model.BeforeLogin)
{
<input type="checkbox" id="BeforeLogin" name="BeforeLogin" checked="checked"><label for="BeforeLogin">Show before the login</label>
}
else
{
<input type="checkbox" id="BeforeLogin" name="BeforeLogin"><label for="BeforeLogin">Show before the login</label>
}
</div>
<small>If enabled then this will show the landing page before the login page, if this is disabled the user will log in first and then see the landing page.</small>
</div>
<br/>
<div class="form-group">

@ -1,3 +1,41 @@
@inherits PlexRequests.UI.Helpers.EmptyViewBase<PlexRequests.Core.SettingModels.LandingPageSettings>

@inherits PlexRequests.UI.Helpers.EmptyViewBase<PlexRequests.UI.Models.LandingPageViewModel>
<img class="center" src="~/Content/images/logo.png" width="300" />
<div id="area" class="landing-block">
@if (Model.NoticeEnable)
{
<div class="row" style="padding-top: 20px">
<div class="col-md-1 col-md-push-4">
<i class="fa fa-bell fa-5x"></i>
</div>
<div class="col-md-5 col-md-push-4">
<span class="landing-title">Notice</span>
<br/>
@Model.NoticeMessage
<br/>
<strong>6/27/2016 @@ 9:00PM CST to 6/27/2016 @@ 9:00PM CST</strong>
</div>
</div>
<br/>
<br/>
<br/>
<br/>
}
<div class="row">
<div class="col-md-1 col-md-push-4">
<i class="fa fa-check-circle fa-5x"></i>
</div>
<div class="col-md-5 col-md-push-4">
<span class="landing-title">Currently Online</span>
<br/>
The Plex server is currently online (check this page for continuous status updates)
</div>
</div>
</div>
<div style="text-align: center; margin-top: 10px">
<a href="@Model.ContinueUrl?landing=false" class="btn btn-success-outline">Continue</a>
</div>

@ -23,9 +23,8 @@
<body>
<div class="container">
@RenderBody()
</div>
</body>
</html>

@ -54,7 +54,7 @@
console.log(response);
if (response.result === true) {
window.location.replace(url);
location.replace(response.message);
} else {
generateNotify(response.message, "warning");

Loading…
Cancel
Save