notification improvements

This commit is contained in:
tidusjar 2016-09-25 01:03:23 +01:00
parent 5816ddef98
commit 9c789363f6
17 changed files with 712 additions and 160 deletions

View file

@ -94,6 +94,7 @@ namespace PlexRequests.UI.Modules
private ISlackApi SlackApi { get; }
private IJobRecord JobRecorder { get; }
private IAnalytics Analytics { get; }
private ISettingsService<NotificationSettingsV2> NotifySettings { get; }
private static Logger Log = LogManager.GetCurrentClassLogger();
public AdminModule(ISettingsService<PlexRequestSettings> prService,
@ -116,7 +117,8 @@ namespace PlexRequests.UI.Modules
ISettingsService<LogSettings> logs,
ICacheProvider cache, ISettingsService<SlackNotificationSettings> slackSettings,
ISlackApi slackApi, ISettingsService<LandingPageSettings> lp,
ISettingsService<ScheduledJobsSettings> scheduler, IJobRecord rec, IAnalytics analytics) : base("admin", prService)
ISettingsService<ScheduledJobsSettings> scheduler, IJobRecord rec, IAnalytics analytics,
ISettingsService<NotificationSettingsV2> notifyService) : base("admin", prService)
{
PrService = prService;
CpService = cpService;
@ -143,6 +145,7 @@ namespace PlexRequests.UI.Modules
ScheduledJobSettings = scheduler;
JobRecorder = rec;
Analytics = analytics;
NotifySettings = notifyService;
this.RequiresClaims(UserClaims.Admin);
@ -210,6 +213,9 @@ namespace PlexRequests.UI.Modules
Post["/scheduledjobs", true] = async (x, ct) => await SaveScheduledJobs();
Post["/clearlogs", true] = async (x, ct) => await ClearLogs();
Get["/notificationsettings", true] = async (x, ct) => await NotificationSettings();
Post["/notificationsettings", true] = async (x, ct) => await SaveNotificationSettings();
}
private async Task<Negotiator> Authentication()
@ -489,7 +495,8 @@ namespace PlexRequests.UI.Modules
var notificationModel = new NotificationModel
{
NotificationType = NotificationType.Test,
DateTime = DateTime.Now
DateTime = DateTime.Now,
ImgSrc = "http://3.bp.blogspot.com/-EFM-XoKoZ0o/UznF567wCRI/AAAAAAAAALM/6ut7MCF2LrU/s1600/xkcd.png"
};
try
{
@ -966,5 +973,17 @@ namespace PlexRequests.UI.Modules
return Response.AsJson(new JsonResponseModel { Result = false, Message = e.Message });
}
}
private async Task<Negotiator> NotificationSettings()
{
var s = await NotifySettings.GetSettingsAsync();
return View["NotificationSettings", s];
}
private async Task<Negotiator> SaveNotificationSettings()
{
var model = this.Bind<NotificationSettingsV2>();
return View["NotificationSettings", model];
}
}
}