From 0f315ebe3bf0797f3c0aeca95bbcc5984822ce7e Mon Sep 17 00:00:00 2001 From: Jamie Rees Date: Tue, 14 Jul 2020 22:35:01 +0100 Subject: [PATCH 1/3] Small changes for the mobile notification --- .../Agents/MobileNotification.cs | 23 ++++++++++++- .../NotificationMessageCurlys.cs | 8 +++-- .../usermanagement-user.component.ts | 32 +++++++------------ .../usermanagement.component.ts | 2 +- 4 files changed, 40 insertions(+), 25 deletions(-) diff --git a/src/Ombi.Notifications/Agents/MobileNotification.cs b/src/Ombi.Notifications/Agents/MobileNotification.cs index 778adb7a9..3ac2bd7fe 100644 --- a/src/Ombi.Notifications/Agents/MobileNotification.cs +++ b/src/Ombi.Notifications/Agents/MobileNotification.cs @@ -53,9 +53,11 @@ namespace Ombi.Notifications.Agents _logger.LogInformation($"Template {NotificationType.NewRequest} is disabled for {NotificationAgent.Mobile}"); return; } + var notification = new NotificationMessage { Message = parsed.Message, + Data = GetNotificationData(parsed, NotificationType.NewRequest) }; // Get admin devices @@ -74,6 +76,7 @@ namespace Ombi.Notifications.Agents var notification = new NotificationMessage { Message = parsed.Message, + Data = GetNotificationData(parsed, NotificationType.Issue) }; // Get admin devices @@ -92,6 +95,7 @@ namespace Ombi.Notifications.Agents var notification = new NotificationMessage { Message = parsed.Message, + Data = GetNotificationData(parsed, NotificationType.IssueComment) }; if (model.Substitutes.TryGetValue("AdminComment", out var isAdminString)) { @@ -123,6 +127,7 @@ namespace Ombi.Notifications.Agents var notification = new NotificationMessage { Message = parsed.Message, + Data = GetNotificationData(parsed, NotificationType.IssueResolved) }; // Send to user @@ -144,6 +149,7 @@ namespace Ombi.Notifications.Agents var notification = new NotificationMessage { Message = parsed.Message, + Data = GetNotificationData(parsed, NotificationType.ItemAddedToFaultQueue) }; // Get admin devices @@ -162,6 +168,7 @@ namespace Ombi.Notifications.Agents var notification = new NotificationMessage { Message = parsed.Message, + Data = GetNotificationData(parsed, NotificationType.RequestDeclined) }; // Send to user @@ -181,6 +188,7 @@ namespace Ombi.Notifications.Agents var notification = new NotificationMessage { Message = parsed.Message, + Data = GetNotificationData(parsed, NotificationType.RequestApproved) }; // Send to user @@ -198,9 +206,13 @@ namespace Ombi.Notifications.Agents _logger.LogInformation($"Template {NotificationType.RequestAvailable} is disabled for {NotificationAgent.Mobile}"); return; } + + var data = GetNotificationData(parsed, NotificationType.RequestAvailable); + var notification = new NotificationMessage { Message = parsed.Message, + Data = data }; // Send to user var playerIds = GetUsers(model, NotificationType.RequestAvailable); @@ -208,6 +220,14 @@ namespace Ombi.Notifications.Agents await AddSubscribedUsers(playerIds); await Send(playerIds, notification, settings, model); } + + private static Dictionary GetNotificationData(NotificationMessageContent parsed, NotificationType type) + { + var notificationData = parsed.Data.ToDictionary(x => x.Key, x => x.Value); + notificationData[nameof(NotificationType)] = type.ToString(); + return notificationData; + } + protected override Task Send(NotificationMessage model, MobileNotificationSettings settings) { throw new NotImplementedException(); @@ -225,7 +245,8 @@ namespace Ombi.Notifications.Agents { Body = model.Message, Title = model.Subject, - To = token + To = token, + Data = new Dictionary(model.Data) }); } diff --git a/src/Ombi.Notifications/NotificationMessageCurlys.cs b/src/Ombi.Notifications/NotificationMessageCurlys.cs index 57a36cd87..1bf5b8ee9 100644 --- a/src/Ombi.Notifications/NotificationMessageCurlys.cs +++ b/src/Ombi.Notifications/NotificationMessageCurlys.cs @@ -14,12 +14,12 @@ namespace Ombi.Notifications { public class NotificationMessageCurlys { - public void Setup(NotificationOptions opts, FullBaseRequest req, CustomizationSettings s, UserNotificationPreferences pref) + public void Setup(NotificationOptions opts, MovieRequests req, CustomizationSettings s, UserNotificationPreferences pref) { LoadIssues(opts); RequestId = req?.Id.ToString(); - + ProviderId = req?.TheMovieDbId.ToString() ?? string.Empty; string title; if (req == null) { @@ -73,6 +73,7 @@ namespace Ombi.Notifications LoadIssues(opts); RequestId = req?.Id.ToString(); + ProviderId = req?.ForeignArtistId ?? string.Empty; string title; if (req == null) @@ -122,6 +123,7 @@ namespace Ombi.Notifications { LoadIssues(opts); RequestId = req.Id.ToString(); + ProviderId = req?.ParentRequest?.TvDbId.ToString() ?? string.Empty; string title; if (req == null) { @@ -274,6 +276,7 @@ namespace Ombi.Notifications public string DenyReason { get; set; } public string AvailableDate { get; set; } public string RequestStatus { get; set; } + public string ProviderId { get; set; } // System Defined private string LongDate => DateTime.Now.ToString("D"); @@ -312,6 +315,7 @@ namespace Ombi.Notifications {nameof(DenyReason),DenyReason}, {nameof(AvailableDate),AvailableDate}, {nameof(RequestStatus),RequestStatus}, + {nameof(ProviderId),ProviderId}, }; } } \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement-user.component.ts b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement-user.component.ts index 7d3896372..e9ee08e4f 100644 --- a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement-user.component.ts +++ b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement-user.component.ts @@ -118,28 +118,18 @@ export class UserManagementUserComponent implements OnInit { } public delete() { - // TODO - // this.confirmationService.confirm({ - // message: "Are you sure that you want to delete this user? If this user has any requests they will also be deleted.", - // header: "Are you sure?", - // icon: "fa fa-trash", - // accept: () => { - // this.identityService.deleteUser(this.user).subscribe(x => { - // if (x.successful) { - // this.notificationService.send(`The user ${this.user.userName} was deleted`); - // this.router.navigate(["usermanagement"]); - // } else { - // x.errors.forEach((val) => { - // this.notificationService.send(val); - // }); - // } - // }); - // }, - // reject: () => { - // return; - // }, - // }); + this.identityService.deleteUser(this.user).subscribe(x => { + if (x.successful) { + this.notificationService.send(`The user ${this.user.userName} was deleted`); + this.router.navigate(["usermanagement"]); + } else { + x.errors.forEach((val) => { + this.notificationService.send(val); + }); + } + + }); } public resetPassword() { diff --git a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.ts b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.ts index 2edcc0732..f3a910b1a 100644 --- a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.ts +++ b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.ts @@ -35,7 +35,7 @@ export class UserManagementComponent implements OnInit { public async ngOnInit() { this.users = await this.identityService.getUsers().toPromise(); - + this.dataSource = new MatTableDataSource(this.users); this.dataSource.sort = this.sort; From 0fa400511303a42f122c91b71c01afecd90be7ed Mon Sep 17 00:00:00 2001 From: Jamie Rees Date: Mon, 20 Jul 2020 20:03:37 +0100 Subject: [PATCH 2/3] Fixed #3567 --- src/Ombi/ClientApp/src/app/my-nav/my-nav.component.ts | 2 +- src/Ombi/ClientApp/src/index.html | 1 + src/Ombi/wwwroot/translations/en.json | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.ts b/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.ts index 3b61bc4f8..465cae4e1 100644 --- a/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.ts +++ b/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.ts @@ -46,7 +46,7 @@ export class MyNavComponent implements OnInit { { name: "NavigationBar.Requests", icon: "list", link: "/requests-list", requiresAdmin: false, enabled: true }, { name: "NavigationBar.Issues", icon: "notification_important", link: "/issues", requiresAdmin: false, enabled: this.issuesEnabled }, { name: "NavigationBar.UserManagement", icon: "account_circle", link: "/usermanagement", requiresAdmin: true, enabled: true }, - { name: "NavigationBar.Calendar", icon: "calendar_today", link: "/calendar", requiresAdmin: false, enabled: true }, + // { name: "NavigationBar.Calendar", icon: "calendar_today", link: "/calendar", requiresAdmin: false, enabled: true }, { name: "NavigationBar.Donate", icon: "attach_money", link: "https://www.paypal.me/PlexRequestsNet", donation: true, requiresAdmin: true, enabled: true, toolTip: true, style: "color:red;", toolTipMessage: 'NavigationBar.DonateTooltip' }, { name: "NavigationBar.Settings", icon: "settings", link: "/Settings/About", requiresAdmin: true, enabled: true }, { name: "NavigationBar.UserPreferences", icon: "person", link: "/user-preferences", requiresAdmin: false, enabled: true }, diff --git a/src/Ombi/ClientApp/src/index.html b/src/Ombi/ClientApp/src/index.html index 30a3a0854..2ccfb3db0 100644 --- a/src/Ombi/ClientApp/src/index.html +++ b/src/Ombi/ClientApp/src/index.html @@ -40,6 +40,7 @@ + diff --git a/src/Ombi/wwwroot/translations/en.json b/src/Ombi/wwwroot/translations/en.json index ff21b1ed4..7549a7b61 100644 --- a/src/Ombi/wwwroot/translations/en.json +++ b/src/Ombi/wwwroot/translations/en.json @@ -57,7 +57,7 @@ "Vote": "Vote", "Donate": "Donate!", "DonateLibraryMaintainer": "Donate to Library Maintainer", - "DonateTooltip": "This is how I convince my wife to let me spend my spare time developing Ombi ;)", + "DonateTooltip": "This is how I convince my wife to let me spend my spare time developing Ombi 😁", "UpdateAvailableTooltip": "Update Available!", "Settings": "Settings", "Welcome": "Welcome {{username}}", From e3094d2df11015f36fdc678ddb731156ad663830 Mon Sep 17 00:00:00 2001 From: Jamie Rees Date: Tue, 21 Jul 2020 08:01:08 +0100 Subject: [PATCH 3/3] small tweaks --- .../Settings/ISettingsService.cs | 2 +- src/Ombi.Settings/Settings/SettingsService.cs | 19 ------------------- .../Repository/ISettingsRepository.cs | 2 +- .../Repository/SettingsJsonRepository.cs | 19 ------------------- 4 files changed, 2 insertions(+), 40 deletions(-) diff --git a/src/Ombi.Settings/Settings/ISettingsService.cs b/src/Ombi.Settings/Settings/ISettingsService.cs index 70c5ebeb8..80c8a338f 100644 --- a/src/Ombi.Settings/Settings/ISettingsService.cs +++ b/src/Ombi.Settings/Settings/ISettingsService.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; namespace Ombi.Core.Settings { - public interface ISettingsService : IDisposable + public interface ISettingsService { T GetSettings(); Task GetSettingsAsync(); diff --git a/src/Ombi.Settings/Settings/SettingsService.cs b/src/Ombi.Settings/Settings/SettingsService.cs index 57ae482a2..d2f2fdef6 100644 --- a/src/Ombi.Settings/Settings/SettingsService.cs +++ b/src/Ombi.Settings/Settings/SettingsService.cs @@ -155,24 +155,5 @@ namespace Ombi.Settings.Settings return settings.Content; //return _protector.Unprotect(settings.Content); } - - private bool _disposed; - protected virtual void Dispose(bool disposing) - { - if (_disposed) - return; - - if (disposing) - { - Repo?.Dispose(); - } - _disposed = true; - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } } } \ No newline at end of file diff --git a/src/Ombi.Store/Repository/ISettingsRepository.cs b/src/Ombi.Store/Repository/ISettingsRepository.cs index 1c2729245..c600765f3 100644 --- a/src/Ombi.Store/Repository/ISettingsRepository.cs +++ b/src/Ombi.Store/Repository/ISettingsRepository.cs @@ -5,7 +5,7 @@ using Ombi.Store.Entities; namespace Ombi.Store.Repository { - public interface ISettingsRepository : IDisposable + public interface ISettingsRepository { /// /// Inserts the specified entity. diff --git a/src/Ombi.Store/Repository/SettingsJsonRepository.cs b/src/Ombi.Store/Repository/SettingsJsonRepository.cs index cceb8cdec..8fd3d46da 100644 --- a/src/Ombi.Store/Repository/SettingsJsonRepository.cs +++ b/src/Ombi.Store/Repository/SettingsJsonRepository.cs @@ -121,24 +121,5 @@ namespace Ombi.Store.Repository return r; } } - - private bool _disposed; - protected virtual void Dispose(bool disposing) - { - if (_disposed) - return; - - if (disposing) - { - Db?.Dispose(); - } - _disposed = true; - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } } } \ No newline at end of file