add an option to stop sending notifications for requests that don't require approval #345

This commit is contained in:
Drewster727 2016-06-21 19:43:31 -05:00
parent 4e10acbb51
commit 96f27f8f1a
5 changed files with 1595 additions and 1579 deletions

View file

@ -1,77 +1,78 @@
#region Copyright #region Copyright
// /************************************************************************ // /************************************************************************
// Copyright (c) 2016 Jamie Rees // Copyright (c) 2016 Jamie Rees
// File: PlexRequestSettings.cs // File: PlexRequestSettings.cs
// Created By: Jamie Rees // Created By: Jamie Rees
// //
// Permission is hereby granted, free of charge, to any person obtaining // Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the // a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including // "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish, // without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to // distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to // permit persons to whom the Software is furnished to do so, subject to
// the following conditions: // the following conditions:
// //
// The above copyright notice and this permission notice shall be // The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software. // included in all copies or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/ // ************************************************************************/
#endregion #endregion
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace PlexRequests.Core.SettingModels namespace PlexRequests.Core.SettingModels
{ {
public class PlexRequestSettings : Settings public class PlexRequestSettings : Settings
{ {
public int Port { get; set; } public int Port { get; set; }
public string BaseUrl { get; set; } public string BaseUrl { get; set; }
public bool SearchForMovies { get; set; } public bool SearchForMovies { get; set; }
public bool SearchForTvShows { get; set; } public bool SearchForTvShows { get; set; }
public bool SearchForMusic { get; set; } public bool SearchForMusic { get; set; }
public bool RequireMovieApproval { get; set; } public bool RequireMovieApproval { get; set; }
public bool RequireTvShowApproval { get; set; } public bool RequireTvShowApproval { get; set; }
public bool RequireMusicApproval { get; set; } public bool RequireMusicApproval { get; set; }
public bool UsersCanViewOnlyOwnRequests { get; set; } public bool UsersCanViewOnlyOwnRequests { get; set; }
public bool UsersCanViewOnlyOwnIssues { get; set; } public bool UsersCanViewOnlyOwnIssues { get; set; }
public int WeeklyRequestLimit { get; set; } public int WeeklyRequestLimit { get; set; }
public string NoApprovalUsers { get; set; } public string NoApprovalUsers { get; set; }
public bool CollectAnalyticData { get; set; } public bool CollectAnalyticData { get; set; }
public bool IgnoreNotifyForAutoApprovedRequests { get; set; }
/// <summary>
/// The CSS name of the theme we want /// <summary>
/// </summary> /// The CSS name of the theme we want
public string ThemeName { get; set; } /// </summary>
public string ThemeName { get; set; }
public string ApiKey { get; set; }
public string ApiKey { get; set; }
[JsonIgnore]
public List<string> ApprovalWhiteList [JsonIgnore]
{ public List<string> ApprovalWhiteList
get {
{ get
var users = new List<string>(); {
if (string.IsNullOrEmpty(NoApprovalUsers)) var users = new List<string>();
{ if (string.IsNullOrEmpty(NoApprovalUsers))
return users; {
} return users;
}
var splitUsers = NoApprovalUsers.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var user in splitUsers) var splitUsers = NoApprovalUsers.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
{ foreach (var user in splitUsers)
if (!string.IsNullOrWhiteSpace(user)) {
users.Add(user.Trim()); if (!string.IsNullOrWhiteSpace(user))
} users.Add(user.Trim());
return users; }
} return users;
} }
} }
} }
}

View file

@ -1,201 +1,201 @@
#region Copyright #region Copyright
// /************************************************************************ // /************************************************************************
// Copyright (c) 2016 Jamie Rees // Copyright (c) 2016 Jamie Rees
// File: EmailMessageNotification.cs // File: EmailMessageNotification.cs
// Created By: Jamie Rees // Created By: Jamie Rees
// //
// Permission is hereby granted, free of charge, to any person obtaining // Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the // a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including // "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish, // without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to // distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to // permit persons to whom the Software is furnished to do so, subject to
// the following conditions: // the following conditions:
// //
// The above copyright notice and this permission notice shall be // The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software. // included in all copies or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/ // ************************************************************************/
#endregion #endregion
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using MailKit.Security; using MailKit.Security;
using MimeKit; using MimeKit;
using NLog; using NLog;
using PlexRequests.Core; using PlexRequests.Core;
using PlexRequests.Core.SettingModels; using PlexRequests.Core.SettingModels;
using PlexRequests.Services.Interfaces; using PlexRequests.Services.Interfaces;
using SmtpClient = MailKit.Net.Smtp.SmtpClient; using SmtpClient = MailKit.Net.Smtp.SmtpClient;
namespace PlexRequests.Services.Notification namespace PlexRequests.Services.Notification
{ {
public class EmailMessageNotification : INotification public class EmailMessageNotification : INotification
{ {
public EmailMessageNotification(ISettingsService<EmailNotificationSettings> settings) public EmailMessageNotification(ISettingsService<EmailNotificationSettings> settings)
{ {
EmailNotificationSettings = settings; EmailNotificationSettings = settings;
} }
private static readonly Logger Log = LogManager.GetCurrentClassLogger(); private static readonly Logger Log = LogManager.GetCurrentClassLogger();
private ISettingsService<EmailNotificationSettings> EmailNotificationSettings { get; } private ISettingsService<EmailNotificationSettings> EmailNotificationSettings { get; }
public string NotificationName => "EmailMessageNotification"; public string NotificationName => "EmailMessageNotification";
public async Task NotifyAsync(NotificationModel model) public async Task NotifyAsync(NotificationModel model)
{ {
var configuration = GetConfiguration(); var configuration = GetConfiguration();
await NotifyAsync(model, configuration); await NotifyAsync(model, configuration);
} }
public async Task NotifyAsync(NotificationModel model, Settings settings) public async Task NotifyAsync(NotificationModel model, Settings settings)
{ {
if (settings == null) await NotifyAsync(model); if (settings == null) await NotifyAsync(model);
var emailSettings = (EmailNotificationSettings)settings; var emailSettings = (EmailNotificationSettings)settings;
if (!ValidateConfiguration(emailSettings)) if (!ValidateConfiguration(emailSettings))
{ {
return; return;
} }
switch (model.NotificationType) switch (model.NotificationType)
{ {
case NotificationType.NewRequest: case NotificationType.NewRequest:
await EmailNewRequest(model, emailSettings); await EmailNewRequest(model, emailSettings);
break; break;
case NotificationType.Issue: case NotificationType.Issue:
await EmailIssue(model, emailSettings); await EmailIssue(model, emailSettings);
break; break;
case NotificationType.RequestAvailable: case NotificationType.RequestAvailable:
await EmailAvailableRequest(model, emailSettings); await EmailAvailableRequest(model, emailSettings);
break; break;
case NotificationType.RequestApproved: case NotificationType.RequestApproved:
throw new NotImplementedException(); throw new NotImplementedException();
case NotificationType.AdminNote: case NotificationType.AdminNote:
throw new NotImplementedException(); throw new NotImplementedException();
case NotificationType.Test: case NotificationType.Test:
await EmailTest(model, emailSettings); await EmailTest(model, emailSettings);
break; break;
} }
} }
private EmailNotificationSettings GetConfiguration() private EmailNotificationSettings GetConfiguration()
{ {
var settings = EmailNotificationSettings.GetSettings(); var settings = EmailNotificationSettings.GetSettings();
return settings; return settings;
} }
private bool ValidateConfiguration(EmailNotificationSettings settings) private bool ValidateConfiguration(EmailNotificationSettings settings)
{ {
if (string.IsNullOrEmpty(settings.EmailHost) || string.IsNullOrEmpty(settings.EmailUsername) || string.IsNullOrEmpty(settings.EmailPassword) || string.IsNullOrEmpty(settings.RecipientEmail) || string.IsNullOrEmpty(settings.EmailPort.ToString())) if (string.IsNullOrEmpty(settings.EmailHost) || string.IsNullOrEmpty(settings.EmailUsername) || string.IsNullOrEmpty(settings.EmailPassword) || string.IsNullOrEmpty(settings.RecipientEmail) || string.IsNullOrEmpty(settings.EmailPort.ToString()))
{ {
return false; return false;
} }
if (!settings.EnableUserEmailNotifications) if (!settings.EnableUserEmailNotifications)
{ {
if (!settings.Enabled) if (!settings.Enabled)
{ {
return false; return false;
} }
} }
return true; return true;
} }
private async Task EmailNewRequest(NotificationModel model, EmailNotificationSettings settings) private async Task EmailNewRequest(NotificationModel model, EmailNotificationSettings settings)
{ {
var message = new MimeMessage var message = new MimeMessage
{ {
Body = new TextPart("plain") { Text = $"Hello! The user '{model.User}' has requested {model.Title}! Please log in to approve this request. Request Date: {model.DateTime.ToString("f")}" }, Body = new TextPart("plain") { Text = $"Hello! The user '{model.User}' has requested {model.Title}! Please log in to approve this request. Request Date: {model.DateTime.ToString("f")}" },
Subject = $"Plex Requests: New request for {model.Title}!" Subject = $"Plex Requests: New request for {model.Title}!"
}; };
message.From.Add(new MailboxAddress(settings.EmailSender, settings.EmailSender)); message.From.Add(new MailboxAddress(settings.EmailSender, settings.EmailSender));
message.To.Add(new MailboxAddress(settings.RecipientEmail, settings.RecipientEmail)); message.To.Add(new MailboxAddress(settings.RecipientEmail, settings.RecipientEmail));
await Send(message, settings); await Send(message, settings);
} }
private async Task EmailIssue(NotificationModel model, EmailNotificationSettings settings) private async Task EmailIssue(NotificationModel model, EmailNotificationSettings settings)
{ {
var message = new MimeMessage var message = new MimeMessage
{ {
Body = new TextPart("plain") { Text = $"Hello! The user '{model.User}' has reported a new issue {model.Body} for the title {model.Title}!" }, Body = new TextPart("plain") { Text = $"Hello! The user '{model.User}' has reported a new issue {model.Body} for the title {model.Title}!" },
Subject = $"Plex Requests: New issue for {model.Title}!" Subject = $"Plex Requests: New issue for {model.Title}!"
}; };
message.From.Add(new MailboxAddress(settings.EmailSender, settings.EmailSender)); message.From.Add(new MailboxAddress(settings.EmailSender, settings.EmailSender));
message.To.Add(new MailboxAddress(settings.RecipientEmail, settings.RecipientEmail)); message.To.Add(new MailboxAddress(settings.RecipientEmail, settings.RecipientEmail));
await Send(message, settings); await Send(message, settings);
} }
private async Task EmailAvailableRequest(NotificationModel model, EmailNotificationSettings settings) private async Task EmailAvailableRequest(NotificationModel model, EmailNotificationSettings settings)
{ {
if (!settings.EnableUserEmailNotifications) if (!settings.EnableUserEmailNotifications)
{ {
await Task.FromResult(false); await Task.FromResult(false);
} }
var message = new MimeMessage var message = new MimeMessage
{ {
Body = new TextPart("plain") { Text = $"Hello! You requested {model.Title} on PlexRequests! This is now available on Plex! :)" }, Body = new TextPart("plain") { Text = $"Hello! You requested {model.Title} on PlexRequests! This is now available on Plex! :)" },
Subject = $"Plex Requests: {model.Title} is now available!" Subject = $"Plex Requests: {model.Title} is now available!"
}; };
message.From.Add(new MailboxAddress(settings.EmailSender, settings.EmailSender)); message.From.Add(new MailboxAddress(settings.EmailSender, settings.EmailSender));
message.To.Add(new MailboxAddress(model.UserEmail, model.UserEmail)); message.To.Add(new MailboxAddress(model.UserEmail, model.UserEmail));
await Send(message, settings); await Send(message, settings);
} }
private async Task Send(MimeMessage message, EmailNotificationSettings settings) private async Task Send(MimeMessage message, EmailNotificationSettings settings)
{ {
try try
{ {
using (var client = new SmtpClient()) using (var client = new SmtpClient())
{ {
client.Connect(settings.EmailHost, settings.EmailPort, SecureSocketOptions.Auto); // Let MailKit figure out the correct SecureSocketOptions. client.Connect(settings.EmailHost, settings.EmailPort, SecureSocketOptions.Auto); // Let MailKit figure out the correct SecureSocketOptions.
// Note: since we don't have an OAuth2 token, disable // Note: since we don't have an OAuth2 token, disable
// the XOAUTH2 authentication mechanism. // the XOAUTH2 authentication mechanism.
client.AuthenticationMechanisms.Remove("XOAUTH2"); client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Authenticate(settings.EmailUsername, settings.EmailPassword); client.Authenticate(settings.EmailUsername, settings.EmailPassword);
await client.SendAsync(message); await client.SendAsync(message);
await client.DisconnectAsync(true); await client.DisconnectAsync(true);
} }
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e); Log.Error(e);
} }
} }
private async Task EmailTest(NotificationModel model, EmailNotificationSettings settings) private async Task EmailTest(NotificationModel model, EmailNotificationSettings settings)
{ {
var message = new MimeMessage var message = new MimeMessage
{ {
Body = new TextPart("plain") { Text = "This is just a test! Success!" }, Body = new TextPart("plain") { Text = "This is just a test! Success!" },
Subject = "Plex Requests: Test Message!", Subject = "Plex Requests: Test Message!",
}; };
message.From.Add(new MailboxAddress(settings.EmailSender, settings.EmailSender)); message.From.Add(new MailboxAddress(settings.EmailSender, settings.EmailSender));
message.To.Add(new MailboxAddress(settings.RecipientEmail, settings.RecipientEmail)); message.To.Add(new MailboxAddress(settings.RecipientEmail, settings.RecipientEmail));
await Send(message, settings); await Send(message, settings);
} }
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -1,294 +1,309 @@
@using PlexRequests.UI.Helpers @using PlexRequests.UI.Helpers
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<PlexRequests.Core.SettingModels.PlexRequestSettings> @inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<PlexRequests.Core.SettingModels.PlexRequestSettings>
@Html.Partial("_Sidebar") @Html.Partial("_Sidebar")
@{ @{
int port; int port;
if (Model.Port == 0) if (Model.Port == 0)
{ {
port = 3579; port = 3579;
} }
else else
{ {
port = Model.Port; port = Model.Port;
} }
var baseUrl = Html.GetBaseUrl(); var baseUrl = Html.GetBaseUrl();
var formAction = "/admin"; var formAction = "/admin";
if (!string.IsNullOrEmpty(baseUrl.ToHtmlString())) if (!string.IsNullOrEmpty(baseUrl.ToHtmlString()))
{ {
formAction = "/" + baseUrl.ToHtmlString() + formAction; formAction = "/" + baseUrl.ToHtmlString() + formAction;
} }
var plexTheme = string.Empty; var plexTheme = string.Empty;
var originalTheme = string.Empty; var originalTheme = string.Empty;
if (!string.IsNullOrEmpty(Model.ThemeName)) if (!string.IsNullOrEmpty(Model.ThemeName))
{ {
plexTheme = Model.ThemeName.Equals(Themes.PlexTheme) ? "selected=\"selected\"" : string.Empty; plexTheme = Model.ThemeName.Equals(Themes.PlexTheme) ? "selected=\"selected\"" : string.Empty;
originalTheme = Model.ThemeName.Equals(Themes.OriginalTheme) ? "selected=\"selected\"" : string.Empty; originalTheme = Model.ThemeName.Equals(Themes.OriginalTheme) ? "selected=\"selected\"" : string.Empty;
} }
else else
{ {
plexTheme = "selected=\"selected\""; 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">
<fieldset> <fieldset>
<legend>Plex Request Settings</legend> <legend>Plex Request Settings</legend>
<div class="form-group"> <div class="form-group">
<label for="portNumber" class="control-label">Port</label> <label for="portNumber" class="control-label">Port</label>
<div> <div>
<input type="text" class="form-control form-control-custom " id="portNumber" name="Port" placeholder="Port Number" value="@port"> <input type="text" class="form-control form-control-custom " id="portNumber" name="Port" placeholder="Port Number" value="@port">
</div> </div>
</div> </div>
<small class="control-label">You will have to restart after changing the port.</small> <small class="control-label">You will have to restart after changing the port.</small>
<div class="form-group"> <div class="form-group">
<label for="BaseUrl" class="control-label">Base Url</label> <label for="BaseUrl" class="control-label">Base Url</label>
<div> <div>
<input type="text" class="form-control form-control-custom " id="BaseUrl" name="BaseUrl" placeholder="Base Url" value="@Model.BaseUrl"> <input type="text" class="form-control form-control-custom " id="BaseUrl" name="BaseUrl" placeholder="Base Url" value="@Model.BaseUrl">
</div> </div>
</div> </div>
<small class="control-label">You will have to restart after changing the url base.</small> <small class="control-label">You will have to restart after changing the url base.</small>
<div class="form-group"> <div class="form-group">
<label for="ApiKey" class="control-label">Api Key</label> <label for="ApiKey" class="control-label">Api Key</label>
<div class="input-group"> <div class="input-group">
<input type="text" disabled="disabled" class="form-control form-control-custom" id="apiKey" name="ApiKey" value="@Model.ApiKey"> <input type="text" disabled="disabled" class="form-control form-control-custom" id="apiKey" name="ApiKey" value="@Model.ApiKey">
<div class="input-group-addon"> <div class="input-group-addon">
<div id="refreshKey" class="fa fa-refresh" title="Reset API Key"></div> <div id="refreshKey" class="fa fa-refresh" title="Reset API Key"></div>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="select" class="control-label">Theme</label> <label for="select" class="control-label">Theme</label>
<div id="themes"> <div id="themes">
<select class="form-control form-control-custom" id="select"> <select class="form-control form-control-custom" id="select">
<option @plexTheme class="form-control form-control-custom" value="@Themes.PlexTheme">Plex</option> <option @plexTheme class="form-control form-control-custom" value="@Themes.PlexTheme">Plex</option>
<option @originalTheme class="form-control form-control-custom" value="@Themes.OriginalTheme">Original Blue</option> <option @originalTheme class="form-control form-control-custom" value="@Themes.OriginalTheme">Original Blue</option>
</select> </select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
@if (Model.SearchForMovies) @if (Model.SearchForMovies)
{ {
<input type="checkbox" id="SearchForMovies" name="SearchForMovies" checked="checked"><label for="SearchForMovies">Search for Movies</label> <input type="checkbox" id="SearchForMovies" name="SearchForMovies" checked="checked"><label for="SearchForMovies">Search for Movies</label>
} }
else else
{ {
<input type="checkbox" id="SearchForMovies" name="SearchForMovies"><label for="SearchForMovies">Search for Movies</label> <input type="checkbox" id="SearchForMovies" name="SearchForMovies"><label for="SearchForMovies">Search for Movies</label>
} }
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
@if (Model.SearchForTvShows) @if (Model.SearchForTvShows)
{ {
<input type="checkbox" id="SearchForTvShows" name="SearchForTvShows" checked="checked"><label for="SearchForTvShows">Search for TV Shows</label> <input type="checkbox" id="SearchForTvShows" name="SearchForTvShows" checked="checked"><label for="SearchForTvShows">Search for TV Shows</label>
} }
else else
{ {
<input type="checkbox" id="SearchForTvShows" name="SearchForTvShows"><label for="SearchForTvShows">Search for TV Shows</label> <input type="checkbox" id="SearchForTvShows" name="SearchForTvShows"><label for="SearchForTvShows">Search for TV Shows</label>
} }
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
@if (Model.SearchForMusic) @if (Model.SearchForMusic)
{ {
<input type="checkbox" id="SearchForMusic" name="SearchForMusic" checked="checked"><label for="SearchForMusic">Search for Music</label> <input type="checkbox" id="SearchForMusic" name="SearchForMusic" checked="checked"><label for="SearchForMusic">Search for Music</label>
} }
else else
{ {
<input type="checkbox" id="SearchForMusic" name="SearchForMusic"><label for="SearchForMusic">Search for Music</label> <input type="checkbox" id="SearchForMusic" name="SearchForMusic"><label for="SearchForMusic">Search for Music</label>
} }
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
@if (Model.RequireMovieApproval) @if (Model.RequireMovieApproval)
{ {
<input type="checkbox" id="RequireMovieApproval" name="RequireMovieApproval" checked="checked"><label for="RequireMovieApproval">Require approval of Movie requests</label> <input type="checkbox" id="RequireMovieApproval" name="RequireMovieApproval" checked="checked"><label for="RequireMovieApproval">Require approval of Movie requests</label>
} }
else else
{ {
<input type="checkbox" id="RequireMovieApproval" name="RequireMovieApproval"><label for="RequireMovieApproval">Require approval of Movie requests</label> <input type="checkbox" id="RequireMovieApproval" name="RequireMovieApproval"><label for="RequireMovieApproval">Require approval of Movie requests</label>
} }
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
@if (Model.RequireTvShowApproval) @if (Model.RequireTvShowApproval)
{ {
<input type="checkbox" id="RequireTvShowApproval" name="RequireTvShowApproval" checked="checked"><label for="RequireTvShowApproval">Require approval of TV show requests</label> <input type="checkbox" id="RequireTvShowApproval" name="RequireTvShowApproval" checked="checked"><label for="RequireTvShowApproval">Require approval of TV show requests</label>
} }
else else
{ {
<input type="checkbox" id="RequireTvShowApproval" name="RequireTvShowApproval"><label for="RequireTvShowApproval">Require approval of TV show requests</label> <input type="checkbox" id="RequireTvShowApproval" name="RequireTvShowApproval"><label for="RequireTvShowApproval">Require approval of TV show requests</label>
} }
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
@if (Model.RequireMusicApproval) @if (Model.RequireMusicApproval)
{ {
<input type="checkbox" id="RequireMusicApproval" name="RequireMusicApproval" checked="checked"><label for="RequireMusicApproval">Require approval of Music requests</label> <input type="checkbox" id="RequireMusicApproval" name="RequireMusicApproval" checked="checked"><label for="RequireMusicApproval">Require approval of Music requests</label>
} }
else else
{ {
<input type="checkbox" id="RequireMusicApproval" name="RequireMusicApproval"><label for="RequireMusicApproval">Require approval of Music requests</label> <input type="checkbox" id="RequireMusicApproval" name="RequireMusicApproval"><label for="RequireMusicApproval">Require approval of Music requests</label>
} }
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
@if (Model.UsersCanViewOnlyOwnRequests) @if (Model.UsersCanViewOnlyOwnRequests)
{ {
<input type="checkbox" id="UsersCanViewOnlyOwnRequests" name="UsersCanViewOnlyOwnRequests" checked="checked"> <input type="checkbox" id="UsersCanViewOnlyOwnRequests" name="UsersCanViewOnlyOwnRequests" checked="checked">
<label for="UsersCanViewOnlyOwnRequests">Users can view their own requests only</label> <label for="UsersCanViewOnlyOwnRequests">Users can view their own requests only</label>
} }
else else
{ {
<input type="checkbox" id="UsersCanViewOnlyOwnRequests" name="UsersCanViewOnlyOwnRequests"><label for="UsersCanViewOnlyOwnRequests">Users can view their own requests only</label> <input type="checkbox" id="UsersCanViewOnlyOwnRequests" name="UsersCanViewOnlyOwnRequests"><label for="UsersCanViewOnlyOwnRequests">Users can view their own requests only</label>
} }
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
@if (Model.UsersCanViewOnlyOwnIssues) @if (Model.UsersCanViewOnlyOwnIssues)
{ {
<input type="checkbox" id="UsersCanViewOnlyOwnIssues" name="UsersCanViewOnlyOwnIssues" checked="checked"> <input type="checkbox" id="UsersCanViewOnlyOwnIssues" name="UsersCanViewOnlyOwnIssues" checked="checked">
<label for="UsersCanViewOnlyOwnIssues">Users can view their own issues only</label> <label for="UsersCanViewOnlyOwnIssues">Users can view their own issues only</label>
} }
else else
{ {
<input type="checkbox" id="UsersCanViewOnlyOwnIssues" name="UsersCanViewOnlyOwnIssues"><label for="UsersCanViewOnlyOwnIssues">Users can view their own issues only</label> <input type="checkbox" id="UsersCanViewOnlyOwnIssues" name="UsersCanViewOnlyOwnIssues"><label for="UsersCanViewOnlyOwnIssues">Users can view their own issues only</label>
} }
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
@if (Model.CollectAnalyticData) @if (Model.IgnoreNotifyForAutoApprovedRequests)
{ {
<input type="checkbox" id="CollectAnalyticData" name="CollectAnalyticData" checked="checked"> <input type="checkbox" id="IgnoreNotifyForAutoApprovedRequests" name="IgnoreNotifyForAutoApprovedRequests" checked="checked">
<label for="CollectAnalyticData">Allow us to collect anonymous analytical data e.g. browser used</label> <label for="IgnoreNotifyForAutoApprovedRequests">Do not send notifications for requests that don't require approval</label>
} }
else else
{ {
<input type="checkbox" id="CollectAnalyticData" name="CollectAnalyticData"><label for="CollectAnalyticData">Allow us to collect anonymous analytical data e.g. browser</label> <input type="checkbox" id="IgnoreNotifyForAutoApprovedRequests" name="IgnoreNotifyForAutoApprovedRequests"><label for="IgnoreNotifyForAutoApprovedRequests">Do not send notifications for requests that don't require approval</label>
} }
</div> </div>
</div> </div>
<div class="form-group">
<div class="checkbox">
<p class="form-group">A comma separated list of users whose requests do not require approval.</p>
<div class="form-group"> @if (Model.CollectAnalyticData)
<label for="noApprovalUsers" class="control-label">Approval White listed Users</label> {
<div> <input type="checkbox" id="CollectAnalyticData" name="CollectAnalyticData" checked="checked">
<input type="text" class="form-control-custom form-control " id="NoApprovalUsers" name="NoApprovalUsers" placeholder="e.g. John, Bobby" value="@Model.NoApprovalUsers"> <label for="CollectAnalyticData">Allow us to collect anonymous analytical data e.g. browser used</label>
</div> }
</div> else
{
@*<div class="form-group"> <input type="checkbox" id="CollectAnalyticData" name="CollectAnalyticData"><label for="CollectAnalyticData">Allow us to collect anonymous analytical data e.g. browser</label>
<label for="WeeklyRequestLimit" class="control-label">Weekly Request Limit</label> }
<div> </div>
<label> </div>
<input type="number" id="WeeklyRequestLimit" name="WeeklyRequestLimit" class="form-control form-control-custom " value="@Model.WeeklyRequestLimit">
</label>
</div>
</div> //TODO: Need to implement this*@ <p class="form-group">A comma separated list of users whose requests do not require approval.</p>
<div class="form-group">
<div> <label for="noApprovalUsers" class="control-label">Approval White listed Users</label>
</div> <div>
<div class="form-group"> <input type="text" class="form-control-custom form-control " id="NoApprovalUsers" name="NoApprovalUsers" placeholder="e.g. John, Bobby" value="@Model.NoApprovalUsers">
<div> </div>
<button type="submit" id="save" class="btn btn-primary-outline">Submit</button> </div>
</div>
</div> @*<div class="form-group">
</fieldset> <label for="WeeklyRequestLimit" class="control-label">Weekly Request Limit</label>
</form> <div>
</div> <label>
<input type="number" id="WeeklyRequestLimit" name="WeeklyRequestLimit" class="form-control form-control-custom " value="@Model.WeeklyRequestLimit">
<script> </label>
$(function() { </div>
$('#save').click(function (e) { </div> //TODO: Need to implement this*@
e.preventDefault();
<div>
var theme = $("#themes option:selected").val(); </div>
var $form = $("#mainForm"); <div class="form-group">
<div>
var data = $form.serialize(); <button type="submit" id="save" class="btn btn-primary-outline">Submit</button>
data = data + "&themeName=" + theme; </div>
</div>
$.ajax({ </fieldset>
type: $form.prop("method"), </form>
data: data, </div>
url: $form.prop("action"),
dataType: "json", <script>
success: function (response) { $(function() {
if (response.result === true) { $('#save').click(function (e) {
generateNotify("Success!", "success"); e.preventDefault();
} else {
generateNotify(response.message, "warning"); var theme = $("#themes option:selected").val();
} var $form = $("#mainForm");
},
error: function (e) { var data = $form.serialize();
console.log(e); data = data + "&themeName=" + theme;
generateNotify("Something went wrong!", "danger");
} $.ajax({
}); type: $form.prop("method"),
}); data: data,
url: $form.prop("action"),
$('#refreshKey').click(function (e) { dataType: "json",
e.preventDefault(); success: function (response) {
var base = '@Html.GetBaseUrl()'; if (response.result === true) {
var url = createBaseUrl(base, '/admin/createapikey'); generateNotify("Success!", "success");
} else {
$.ajax({ generateNotify(response.message, "warning");
type: "post", }
url: url, },
dataType: "json", error: function (e) {
success: function (response) { console.log(e);
if (response) { generateNotify("Something went wrong!", "danger");
generateNotify("Success!", "success"); }
$('#apiKey').val(response); });
} });
},
error: function (e) { $('#refreshKey').click(function (e) {
console.log(e); e.preventDefault();
generateNotify("Something went wrong!", "danger"); var base = '@Html.GetBaseUrl()';
} var url = createBaseUrl(base, '/admin/createapikey');
});
}); $.ajax({
}); type: "post",
url: url,
dataType: "json",
success: function (response) {
if (response) {
generateNotify("Success!", "success");
$('#apiKey').val(response);
}
},
error: function (e) {
console.log(e);
generateNotify("Something went wrong!", "danger");
}
});
});
});
</script> </script>

View file

@ -1,26 +1,26 @@
version: 1.8.{build} version: 1.8.{build}
configuration: Release configuration: Release
assembly_info: assembly_info:
patch: true patch: true
file: '**\AssemblyInfo.*' file: '**\AssemblyInfo.*'
assembly_version: '1.8.1' assembly_version: '1.8.1'
assembly_file_version: '{version}' assembly_file_version: '{version}'
assembly_informational_version: '1.8.1' assembly_informational_version: '1.8.1'
before_build: before_build:
- cmd: appveyor-retry nuget restore - cmd: appveyor-retry nuget restore
build: build:
verbosity: minimal verbosity: minimal
after_build: after_build:
- cmd: >- - cmd: >-
7z a PlexRequests.zip %APPVEYOR_BUILD_FOLDER%\PlexRequests.UI\bin\Release\ 7z a PlexRequests.zip %APPVEYOR_BUILD_FOLDER%\PlexRequests.UI\bin\Release\
appveyor PushArtifact PlexRequests.zip appveyor PushArtifact PlexRequests.zip
deploy: deploy:
- provider: GitHub - provider: GitHub
release: PlexRequests v$(appveyor_build_version) release: PlexRequests v$(appveyor_build_version)
auth_token: auth_token:
secure: jDpp1/WUQl3uN41fNI3VeZoRZbDiDfs3GPQ1v+C5ZNE3cWdnUvuJfCCfUbYUV1Rp secure: jDpp1/WUQl3uN41fNI3VeZoRZbDiDfs3GPQ1v+C5ZNE3cWdnUvuJfCCfUbYUV1Rp
draft: true draft: true
on: on:
branch: master branch: master