mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
MERGE
This commit is contained in:
commit
68f8b9cd71
20 changed files with 481 additions and 11 deletions
|
@ -75,6 +75,7 @@ namespace PlexRequests.UI
|
|||
container.Register<ISettingsService<SickRageSettings>, SettingsServiceV2<SickRageSettings>>();
|
||||
container.Register<ISettingsService<EmailNotificationSettings>, SettingsServiceV2<EmailNotificationSettings>>();
|
||||
container.Register<ISettingsService<PushbulletNotificationSettings>, SettingsServiceV2<PushbulletNotificationSettings>>();
|
||||
container.Register<ISettingsService<PushoverNotificationSettings>, SettingsServiceV2<PushoverNotificationSettings>>();
|
||||
|
||||
// Repo's
|
||||
container.Register<IRepository<RequestedModel>, GenericRepository<RequestedModel>>();
|
||||
|
@ -90,6 +91,7 @@ namespace PlexRequests.UI
|
|||
// Api's
|
||||
container.Register<ICouchPotatoApi, CouchPotatoApi>();
|
||||
container.Register<IPushbulletApi, PushbulletApi>();
|
||||
container.Register<IPushoverApi, PushoverApi>();
|
||||
container.Register<ISickRageApi, SickrageApi>();
|
||||
container.Register<ISonarrApi, SonarrApi>();
|
||||
container.Register<IPlexApi, PlexApi>();
|
||||
|
@ -139,7 +141,14 @@ namespace PlexRequests.UI
|
|||
var pushbulletSettings = pushbulletService.GetSettings();
|
||||
if (pushbulletSettings.Enabled)
|
||||
{
|
||||
NotificationService.Subscribe(new PushbulletNotification(container.Resolve<IPushbulletApi>(), container.Resolve<ISettingsService<PushbulletNotificationSettings>>()));
|
||||
NotificationService.Subscribe(new PushbulletNotification(container.Resolve<IPushbulletApi>(), pushbulletService));
|
||||
}
|
||||
|
||||
var pushoverService = container.Resolve<ISettingsService<PushoverNotificationSettings>>();
|
||||
var pushoverSettings = pushoverService.GetSettings();
|
||||
if (pushoverSettings.Enabled)
|
||||
{
|
||||
NotificationService.Subscribe(new PushoverNotification(container.Resolve<IPushoverApi>(), pushoverService));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,9 +62,11 @@ namespace PlexRequests.UI.Modules
|
|||
private ISettingsService<SickRageSettings> SickRageService { get; }
|
||||
private ISettingsService<EmailNotificationSettings> EmailService { get; }
|
||||
private ISettingsService<PushbulletNotificationSettings> PushbulletService { get; }
|
||||
private ISettingsService<PushoverNotificationSettings> PushoverService { get; }
|
||||
private IPlexApi PlexApi { get; }
|
||||
private ISonarrApi SonarrApi { get; }
|
||||
private PushbulletApi PushbulletApi { get; }
|
||||
private IPushbulletApi PushbulletApi { get; }
|
||||
private IPushoverApi PushoverApi { get; }
|
||||
private ICouchPotatoApi CpApi { get; }
|
||||
private IRepository<LogEntity> LogsRepo { get; }
|
||||
|
||||
|
@ -81,6 +83,8 @@ namespace PlexRequests.UI.Modules
|
|||
ISettingsService<PushbulletNotificationSettings> pbSettings,
|
||||
PushbulletApi pbApi,
|
||||
ICouchPotatoApi cpApi,
|
||||
ISettingsService<PushoverNotificationSettings> pushoverSettings,
|
||||
IPushoverApi pushoverApi,
|
||||
IRepository<LogEntity> logsRepo) : base("admin")
|
||||
{
|
||||
RpService = rpService;
|
||||
|
@ -96,6 +100,8 @@ namespace PlexRequests.UI.Modules
|
|||
CpApi = cpApi;
|
||||
SickRageService = sickrage;
|
||||
LogsRepo = logsRepo;
|
||||
PushoverService = pushoverSettings;
|
||||
PushoverApi = pushoverApi;
|
||||
|
||||
#if !DEBUG
|
||||
this.RequiresAuthentication();
|
||||
|
@ -133,6 +139,9 @@ namespace PlexRequests.UI.Modules
|
|||
Get["/pushbulletnotification"] = _ => PushbulletNotifications();
|
||||
Post["/pushbulletnotification"] = _ => SavePushbulletNotifications();
|
||||
|
||||
Get["/pushovernotification"] = _ => PushoverNotifications();
|
||||
Post["/pushovernotification"] = _ => SavePushoverNotifications();
|
||||
|
||||
Get["/logs"] = _ => Logs();
|
||||
Get["/loglevel"] = _ => GetLogLevels();
|
||||
Post["/loglevel"] = _ => UpdateLogLevels(Request.Form.level);
|
||||
|
@ -256,8 +265,8 @@ namespace PlexRequests.UI.Modules
|
|||
}
|
||||
|
||||
var result = CpService.SaveSettings(couchPotatoSettings);
|
||||
return Response.AsJson(result
|
||||
? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for CouchPotato!" }
|
||||
return Response.AsJson(result
|
||||
? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for CouchPotato!" }
|
||||
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||
}
|
||||
|
||||
|
@ -425,6 +434,38 @@ namespace PlexRequests.UI.Modules
|
|||
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||
}
|
||||
|
||||
private Negotiator PushoverNotifications()
|
||||
{
|
||||
var settings = PushoverService.GetSettings();
|
||||
return View["PushoverNotifications", settings];
|
||||
}
|
||||
|
||||
private Response SavePushoverNotifications()
|
||||
{
|
||||
var settings = this.Bind<PushoverNotificationSettings>();
|
||||
var valid = this.Validate(settings);
|
||||
if (!valid.IsValid)
|
||||
{
|
||||
return Response.AsJson(valid.SendJsonError());
|
||||
}
|
||||
Log.Trace(settings.DumpJson());
|
||||
|
||||
var result = PushoverService.SaveSettings(settings);
|
||||
if (settings.Enabled)
|
||||
{
|
||||
NotificationService.Subscribe(new PushoverNotification(PushoverApi, PushoverService));
|
||||
}
|
||||
else
|
||||
{
|
||||
NotificationService.UnSubscribe(new PushoverNotification(PushoverApi, PushoverService));
|
||||
}
|
||||
|
||||
Log.Info("Saved email settings, result: {0}", result);
|
||||
return Response.AsJson(result
|
||||
? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for Pushbullet Notifications!" }
|
||||
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||
}
|
||||
|
||||
private Response GetCpProfiles()
|
||||
{
|
||||
var settings = this.Bind<CouchPotatoSettings>();
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
// ************************************************************************/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -37,6 +38,7 @@ using Nancy.Security;
|
|||
using PlexRequests.Api;
|
||||
using PlexRequests.Core;
|
||||
using PlexRequests.Core.SettingModels;
|
||||
using PlexRequests.Services.Notification;
|
||||
using PlexRequests.Store;
|
||||
using PlexRequests.UI.Models;
|
||||
|
||||
|
@ -166,6 +168,17 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
|
||||
var result = Service.UpdateRequest(originalRequest);
|
||||
|
||||
var model = new NotificationModel
|
||||
{
|
||||
User = Session[SessionKeys.UsernameKey].ToString(),
|
||||
NotificationType = NotificationType.Issue,
|
||||
Title = originalRequest.Title,
|
||||
DateTime = DateTime.Now,
|
||||
Body = issue == IssueState.Other ? comment : issue.Humanize()
|
||||
};
|
||||
NotificationService.Publish(model);
|
||||
|
||||
return Response.AsJson(result
|
||||
? new JsonResponseModel { Result = true }
|
||||
: new JsonResponseModel { Result = false, Message = "Could not add issue, please try again or contact the administrator!" });
|
||||
|
|
|
@ -170,6 +170,7 @@
|
|||
<Compile Include="Bootstrapper.cs" />
|
||||
<Compile Include="Helpers\TvSender.cs" />
|
||||
<Compile Include="Helpers\ValidationHelper.cs" />
|
||||
<Compile Include="Validators\PushoverSettingsValidator.cs" />
|
||||
<Compile Include="Validators\PushbulletSettingsValidator.cs" />
|
||||
<Compile Include="Validators\EmailNotificationSettingsValidator.cs" />
|
||||
<Compile Include="Validators\CouchPotatoValidator.cs" />
|
||||
|
@ -342,6 +343,9 @@
|
|||
<Content Include="Views\Admin\Logs.cshtml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Views\Admin\PushoverNotifications.cshtml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="Web.Debug.config">
|
||||
<DependentUpon>web.config</DependentUpon>
|
||||
</None>
|
||||
|
|
41
PlexRequests.UI/Validators/PushoverSettingsValidator.cs
Normal file
41
PlexRequests.UI/Validators/PushoverSettingsValidator.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
#region Copyright
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2016 Jamie Rees
|
||||
// File: SonarrValidator.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 FluentValidation;
|
||||
|
||||
using PlexRequests.Core.SettingModels;
|
||||
|
||||
namespace PlexRequests.UI.Validators
|
||||
{
|
||||
public class PushoverSettingsValidator : AbstractValidator<PushoverNotificationSettings>
|
||||
{
|
||||
public PushoverSettingsValidator()
|
||||
{
|
||||
RuleFor(request => request.AccessToken).NotEmpty().WithMessage("You must specify a API Token.");
|
||||
RuleFor(request => request.UserToken).NotEmpty().WithMessage("You must specify a User Token.");
|
||||
}
|
||||
}
|
||||
}
|
74
PlexRequests.UI/Views/Admin/PushoverNotifications.cshtml
Normal file
74
PlexRequests.UI/Views/Admin/PushoverNotifications.cshtml
Normal file
|
@ -0,0 +1,74 @@
|
|||
@Html.Partial("_Sidebar")
|
||||
|
||||
<div class="col-sm-8 col-sm-push-1">
|
||||
<form class="form-horizontal" method="POST" id="mainForm">
|
||||
<fieldset>
|
||||
<legend>Pushover Notifications</legend>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
@if (Model.Enabled)
|
||||
{
|
||||
<input type="checkbox" id="Enabled" name="Enabled" checked="checked"><text>Enabled</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<input type="checkbox" id="Enabled" name="Enabled"><text>Enabled</text>
|
||||
}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="AccessToken" class="control-label">API Key</label>
|
||||
<small class="control-label">Enter your API Key from Pushover.</small>
|
||||
<div class="">
|
||||
<input type="text" class="form-control form-control-custom " id="AccessToken" name="AccessToken" value="@Model.AccessToken">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="UserToken" class="control-label">User Token</label>
|
||||
<small class="control-label">Your user or group key from Pushover.</small>
|
||||
<div class="">
|
||||
<input type="text" class="form-control form-control-custom " id="UserToken" name="UserToken" value="@Model.UserToken">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<button id="save" type="submit" class="btn btn-primary-outline">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
|
||||
$('#save').click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var $form = $("#mainForm");
|
||||
$.ajax({
|
||||
type: $form.prop("method"),
|
||||
data: $form.serialize(),
|
||||
url: $form.prop("action"),
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
if (response.result === true) {
|
||||
generateNotify(response.message, "success");
|
||||
} else {
|
||||
generateNotify(response.message, "warning");
|
||||
}
|
||||
},
|
||||
error: function (e) {
|
||||
console.log(e);
|
||||
generateNotify("Something went wrong!", "danger");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -70,14 +70,16 @@
|
|||
{
|
||||
<a class="list-group-item" href="/admin/pushbulletnotification">Pushbullet Notifications</a>
|
||||
}
|
||||
@if (Context.Request.Path == "/admin/logs")
|
||||
|
||||
@if (Context.Request.Path == "/admin/pushovernotification")
|
||||
{
|
||||
<a class="list-group-item active" href="/admin/logs">Logs</a>
|
||||
<a class="list-group-item active" href="/admin/pushovernotification">Pushover Notifications</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a class="list-group-item" href="/admin/logs">Logs</a>
|
||||
<a class="list-group-item" href="/admin/pushovernotification">Pushover Notifications</a>
|
||||
}
|
||||
|
||||
@if (Context.Request.Path == "/admin/status")
|
||||
{
|
||||
<a class="list-group-item active" href="/admin/status">Status</a>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue