Settings done for #298

pull/332/head
tidusjar 9 years ago
parent 0dd30968d5
commit 66bede34f4

@ -191,7 +191,7 @@ namespace PlexRequests.UI.Modules
Post["/slacknotification"] = _ => SaveSlackNotifications();
Get["/landingpage", true] = async (x,ct) => await LandingPage();
Post["/landingpage"] = _ => SaveSlackNotifications();
Post["/landingpage", true] = async (x, ct) => await SaveLandingPage();
}
private Negotiator Authentication()
@ -819,5 +819,21 @@ namespace PlexRequests.UI.Modules
return View["LandingPage", settings];
}
private async Task<Response> SaveLandingPage()
{
var settings = this.Bind<LandingPageSettings>();
if (settings.Enabled && settings.EnabledNoticeTime && string.IsNullOrEmpty(settings.NoticeMessage))
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = "If you are going to enabled the notice, then we need a message!"});
}
var result = await LandingSettings.SaveSettingsAsync(settings);
return Response.AsJson(result
? new JsonResponseModel { Result = true }
: new JsonResponseModel { Result = false, Message = "Could not save to Db Please check the logs"});
}
}
}

@ -24,6 +24,10 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
using System.Threading.Tasks;
using Nancy.Responses.Negotiation;
using PlexRequests.Core;
using PlexRequests.Core.SettingModels;
@ -34,8 +38,16 @@ namespace PlexRequests.UI.Modules
public LandingPageModule(ISettingsService<PlexRequestSettings> settingsService, ISettingsService<LandingPageSettings> landing) : base("landing", settingsService)
{
LandingSettings = landing;
Get["/", true] = async (x, ct) => await Index();
}
private ISettingsService<LandingPageSettings> LandingSettings { get; }
private async Task<Negotiator> Index()
{
var model = await LandingSettings.GetSettingsAsync();
return View["Index", model];
}
}
}

@ -352,8 +352,6 @@ namespace PlexRequests.UI.Modules
viewTv.Add(viewT);
}
Log.Trace("Returning TV Show results: ");
Log.Trace(viewTv.DumpJson());
return Response.AsJson(viewTv);
}
@ -788,12 +786,6 @@ namespace PlexRequests.UI.Modules
var img = GetMusicBrainzCoverArt(albumInfo.id);
Log.Trace("Album Details:");
Log.Trace(albumInfo.DumpJson());
Log.Trace("CoverArt Details:");
Log.Trace(img.DumpJson());
var model = new RequestedModel
{
Title = albumInfo.title,
@ -816,9 +808,6 @@ namespace PlexRequests.UI.Modules
Log.Debug("We don't require approval OR the user is in the whitelist");
var hpSettings = HeadphonesService.GetSettings();
Log.Trace("Headphone Settings:");
Log.Trace(hpSettings.DumpJson());
if (!hpSettings.Enabled)
{
await RequestService.AddRequestAsync(model);

@ -1,13 +1,6 @@
@using PlexRequests.UI.Helpers
@Html.Partial("_Sidebar")
@{
var baseUrl = Html.GetBaseUrl();
var formAction = "/admin";
if (!string.IsNullOrEmpty(baseUrl.ToHtmlString()))
{
formAction = "/" + baseUrl.ToHtmlString() + formAction;
}
}
<div class="col-sm-8 col-sm-push-1">
<form class="form-horizontal" method="POST" id="mainForm">
<fieldset>
@ -70,7 +63,7 @@
<div class="form-group">
<div class='input-group date' id='datetimepicker6'>
<div class='input-group date' id='startDate'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
@ -80,7 +73,7 @@
</div>
<div class="form-group">
<div class='input-group date' id='datetimepicker7'>
<div class='input-group date' id='endDate'>
<input type='text' class="form-control"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
@ -103,14 +96,24 @@
<script>
$(function () {
var $startDate = $('#startDate').datetimepicker();
var $endDate = $('#endDate').datetimepicker({
useCurrent: false //Important! See issue #1075
});
$("#startDate").on("dp.change", function (e) {
$('#endDate').data("DateTimePicker").minDate(e.date);
});
$("#endDate").on("dp.change", function (e) {
$('#startDate').data("DateTimePicker").maxDate(e.date);
});
$('#save').click(function (e) {
e.preventDefault();
var theme = $("#themes option:selected").val();
var $form = $("#mainForm");
var data = $form.serialize();
data = data + "&themeName=" + theme;
data = data + "&noticeStart=" + $startDate.data("DateTimePicker").date().toISOString() + "&noticeEnd=" + $endDate.data("DateTimePicker").date().toISOString();
$.ajax({
type: $form.prop("method"),
@ -130,17 +133,6 @@
}
});
});
$('#datetimepicker6').datetimepicker({
dayViewHeaderFormat: 'MMMM YYYY'
});
$('#datetimepicker7').datetimepicker({
useCurrent: false //Important! See issue #1075
});
$("#datetimepicker6").on("dp.change", function (e) {
$('#datetimepicker7').data("DateTimePicker").minDate(e.date);
});
$("#datetimepicker7").on("dp.change", function (e) {
$('#datetimepicker6').data("DateTimePicker").maxDate(e.date);
});
});
</script>
Loading…
Cancel
Save