diff --git a/code/Infrastructure/Configuration/ConfigurationPathProvider.cs b/code/Common/Helpers/ConfigurationPathProvider.cs similarity index 98% rename from code/Infrastructure/Configuration/ConfigurationPathProvider.cs rename to code/Common/Helpers/ConfigurationPathProvider.cs index c4d3b228..b6c3aeb0 100644 --- a/code/Infrastructure/Configuration/ConfigurationPathProvider.cs +++ b/code/Common/Helpers/ConfigurationPathProvider.cs @@ -1,4 +1,4 @@ -namespace Infrastructure.Configuration; +namespace Common.Helpers; /// /// Provides the appropriate configuration path based on the runtime environment. diff --git a/code/Domain/Domain.csproj b/code/Data/Data.csproj similarity index 71% rename from code/Domain/Domain.csproj rename to code/Data/Data.csproj index de7d774e..856dc66d 100644 --- a/code/Domain/Domain.csproj +++ b/code/Data/Data.csproj @@ -7,6 +7,8 @@ + + diff --git a/code/Infrastructure/Events/EventDbContext.cs b/code/Data/DataContext.cs similarity index 81% rename from code/Infrastructure/Events/EventDbContext.cs rename to code/Data/DataContext.cs index 46b8f9f1..1dad7534 100644 --- a/code/Infrastructure/Events/EventDbContext.cs +++ b/code/Data/DataContext.cs @@ -1,20 +1,21 @@ +using Common.Helpers; +using Data.Models.Events; using Microsoft.EntityFrameworkCore; -using Infrastructure.Configuration; -namespace Infrastructure.Events; +namespace Data; /// /// Database context for events /// -public class EventDbContext : DbContext +public class DataContext : DbContext { - public DbSet Events { get; set; } + public DbSet Events { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { if (!optionsBuilder.IsConfigured) { - var dbPath = Path.Combine(ConfigurationPathProvider.GetSettingsPath(), "events.db"); + var dbPath = Path.Combine(ConfigurationPathProvider.GetSettingsPath(), "state.db"); optionsBuilder.UseSqlite($"Data Source={dbPath}"); } } @@ -24,7 +25,7 @@ public class EventDbContext : DbContext base.OnModelCreating(modelBuilder); // Additional configuration if needed - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Timestamp).IsRequired(); diff --git a/code/Domain/Enums/CleanReason.cs b/code/Data/Enums/CleanReason.cs similarity index 74% rename from code/Domain/Enums/CleanReason.cs rename to code/Data/Enums/CleanReason.cs index d9f218f0..610df630 100644 --- a/code/Domain/Enums/CleanReason.cs +++ b/code/Data/Enums/CleanReason.cs @@ -1,4 +1,4 @@ -namespace Domain.Enums; +namespace Data.Enums; public enum CleanReason { diff --git a/code/Domain/Enums/DeleteReason.cs b/code/Data/Enums/DeleteReason.cs similarity index 88% rename from code/Domain/Enums/DeleteReason.cs rename to code/Data/Enums/DeleteReason.cs index ba6ea660..744495dd 100644 --- a/code/Domain/Enums/DeleteReason.cs +++ b/code/Data/Enums/DeleteReason.cs @@ -1,4 +1,4 @@ -namespace Domain.Enums; +namespace Data.Enums; public enum DeleteReason { diff --git a/code/Domain/Enums/InstanceType.cs b/code/Data/Enums/InstanceType.cs similarity index 73% rename from code/Domain/Enums/InstanceType.cs rename to code/Data/Enums/InstanceType.cs index 4ec96a4c..c9dfe8d9 100644 --- a/code/Domain/Enums/InstanceType.cs +++ b/code/Data/Enums/InstanceType.cs @@ -1,4 +1,4 @@ -namespace Domain.Enums; +namespace Data.Enums; public enum InstanceType { diff --git a/code/Domain/Enums/StrikeType.cs b/code/Data/Enums/StrikeType.cs similarity index 79% rename from code/Domain/Enums/StrikeType.cs rename to code/Data/Enums/StrikeType.cs index 71cc8c2f..123ec254 100644 --- a/code/Domain/Enums/StrikeType.cs +++ b/code/Data/Enums/StrikeType.cs @@ -1,4 +1,4 @@ -namespace Domain.Enums; +namespace Data.Enums; public enum StrikeType { diff --git a/code/Domain/Models/Arr/Blocking/BlockedItem.cs b/code/Data/Models/Arr/Blocking/BlockedItem.cs similarity index 75% rename from code/Domain/Models/Arr/Blocking/BlockedItem.cs rename to code/Data/Models/Arr/Blocking/BlockedItem.cs index b7d94687..9ba081b1 100644 --- a/code/Domain/Models/Arr/Blocking/BlockedItem.cs +++ b/code/Data/Models/Arr/Blocking/BlockedItem.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Arr.Blocking; +namespace Data.Models.Arr.Blocking; public record BlockedItem { diff --git a/code/Domain/Models/Arr/Blocking/LidarrBlockedItem.cs b/code/Data/Models/Arr/Blocking/LidarrBlockedItem.cs similarity index 79% rename from code/Domain/Models/Arr/Blocking/LidarrBlockedItem.cs rename to code/Data/Models/Arr/Blocking/LidarrBlockedItem.cs index 6a2b59af..c72f37bd 100644 --- a/code/Domain/Models/Arr/Blocking/LidarrBlockedItem.cs +++ b/code/Data/Models/Arr/Blocking/LidarrBlockedItem.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Arr.Blocking; +namespace Data.Models.Arr.Blocking; public sealed record LidarrBlockedItem : BlockedItem { diff --git a/code/Domain/Models/Arr/Blocking/RadarrBlockedItem.cs b/code/Data/Models/Arr/Blocking/RadarrBlockedItem.cs similarity index 71% rename from code/Domain/Models/Arr/Blocking/RadarrBlockedItem.cs rename to code/Data/Models/Arr/Blocking/RadarrBlockedItem.cs index 16532dab..360c5adb 100644 --- a/code/Domain/Models/Arr/Blocking/RadarrBlockedItem.cs +++ b/code/Data/Models/Arr/Blocking/RadarrBlockedItem.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Arr.Blocking; +namespace Data.Models.Arr.Blocking; public sealed record RadarrBlockedItem : BlockedItem { diff --git a/code/Domain/Models/Arr/Blocking/SonarrBlockedItem.cs b/code/Data/Models/Arr/Blocking/SonarrBlockedItem.cs similarity index 83% rename from code/Domain/Models/Arr/Blocking/SonarrBlockedItem.cs rename to code/Data/Models/Arr/Blocking/SonarrBlockedItem.cs index a42b0acb..1abb0084 100644 --- a/code/Domain/Models/Arr/Blocking/SonarrBlockedItem.cs +++ b/code/Data/Models/Arr/Blocking/SonarrBlockedItem.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Arr.Blocking; +namespace Data.Models.Arr.Blocking; public sealed record SonarrBlockedItem : BlockedItem { diff --git a/code/Domain/Models/Arr/Queue/Image.cs b/code/Data/Models/Arr/Queue/Image.cs similarity index 76% rename from code/Domain/Models/Arr/Queue/Image.cs rename to code/Data/Models/Arr/Queue/Image.cs index 5f7b3300..fb141d47 100644 --- a/code/Domain/Models/Arr/Queue/Image.cs +++ b/code/Data/Models/Arr/Queue/Image.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Arr.Queue; +namespace Data.Models.Arr.Queue; public record Image { diff --git a/code/Domain/Models/Arr/Queue/LidarrImage.cs b/code/Data/Models/Arr/Queue/LidarrImage.cs similarity index 76% rename from code/Domain/Models/Arr/Queue/LidarrImage.cs rename to code/Data/Models/Arr/Queue/LidarrImage.cs index b317d7e1..4ce747bc 100644 --- a/code/Domain/Models/Arr/Queue/LidarrImage.cs +++ b/code/Data/Models/Arr/Queue/LidarrImage.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Arr.Queue; +namespace Data.Models.Arr.Queue; public record LidarrImage { diff --git a/code/Domain/Models/Arr/Queue/QueueAlbum.cs b/code/Data/Models/Arr/Queue/QueueAlbum.cs similarity index 70% rename from code/Domain/Models/Arr/Queue/QueueAlbum.cs rename to code/Data/Models/Arr/Queue/QueueAlbum.cs index f006b172..036311cd 100644 --- a/code/Domain/Models/Arr/Queue/QueueAlbum.cs +++ b/code/Data/Models/Arr/Queue/QueueAlbum.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Arr.Queue; +namespace Data.Models.Arr.Queue; public sealed record QueueAlbum { diff --git a/code/Domain/Models/Arr/Queue/QueueListResponse.cs b/code/Data/Models/Arr/Queue/QueueListResponse.cs similarity index 80% rename from code/Domain/Models/Arr/Queue/QueueListResponse.cs rename to code/Data/Models/Arr/Queue/QueueListResponse.cs index 7198e573..0ae08e4b 100644 --- a/code/Domain/Models/Arr/Queue/QueueListResponse.cs +++ b/code/Data/Models/Arr/Queue/QueueListResponse.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Arr.Queue; +namespace Data.Models.Arr.Queue; public record QueueListResponse { diff --git a/code/Domain/Models/Arr/Queue/QueueMovie.cs b/code/Data/Models/Arr/Queue/QueueMovie.cs similarity index 68% rename from code/Domain/Models/Arr/Queue/QueueMovie.cs rename to code/Data/Models/Arr/Queue/QueueMovie.cs index 990d2e91..72cce6f4 100644 --- a/code/Domain/Models/Arr/Queue/QueueMovie.cs +++ b/code/Data/Models/Arr/Queue/QueueMovie.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Arr.Queue; +namespace Data.Models.Arr.Queue; public sealed record QueueMovie { diff --git a/code/Domain/Models/Arr/Queue/QueueRecord.cs b/code/Data/Models/Arr/Queue/QueueRecord.cs similarity index 96% rename from code/Domain/Models/Arr/Queue/QueueRecord.cs rename to code/Data/Models/Arr/Queue/QueueRecord.cs index 0d98f930..95bdef28 100644 --- a/code/Domain/Models/Arr/Queue/QueueRecord.cs +++ b/code/Data/Models/Arr/Queue/QueueRecord.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Arr.Queue; +namespace Data.Models.Arr.Queue; public sealed record QueueRecord { diff --git a/code/Domain/Models/Arr/Queue/QueueSeries.cs b/code/Data/Models/Arr/Queue/QueueSeries.cs similarity index 69% rename from code/Domain/Models/Arr/Queue/QueueSeries.cs rename to code/Data/Models/Arr/Queue/QueueSeries.cs index 544a0a98..dc453b69 100644 --- a/code/Domain/Models/Arr/Queue/QueueSeries.cs +++ b/code/Data/Models/Arr/Queue/QueueSeries.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Arr.Queue; +namespace Data.Models.Arr.Queue; public sealed record QueueSeries { diff --git a/code/Domain/Models/Arr/Queue/TrackedDownloadStatusMessage.cs b/code/Data/Models/Arr/Queue/TrackedDownloadStatusMessage.cs similarity index 78% rename from code/Domain/Models/Arr/Queue/TrackedDownloadStatusMessage.cs rename to code/Data/Models/Arr/Queue/TrackedDownloadStatusMessage.cs index 6d1f8fdf..c8a6bff2 100644 --- a/code/Domain/Models/Arr/Queue/TrackedDownloadStatusMessage.cs +++ b/code/Data/Models/Arr/Queue/TrackedDownloadStatusMessage.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Arr.Queue; +namespace Data.Models.Arr.Queue; public sealed record TrackedDownloadStatusMessage { diff --git a/code/Domain/Models/Arr/SearchItem.cs b/code/Data/Models/Arr/SearchItem.cs similarity index 90% rename from code/Domain/Models/Arr/SearchItem.cs rename to code/Data/Models/Arr/SearchItem.cs index c65036d8..d458da16 100644 --- a/code/Domain/Models/Arr/SearchItem.cs +++ b/code/Data/Models/Arr/SearchItem.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Arr; +namespace Data.Models.Arr; public class SearchItem { diff --git a/code/Domain/Models/Arr/SonarrSearchItem.cs b/code/Data/Models/Arr/SonarrSearchItem.cs similarity index 94% rename from code/Domain/Models/Arr/SonarrSearchItem.cs rename to code/Data/Models/Arr/SonarrSearchItem.cs index 541d0280..18c996d5 100644 --- a/code/Domain/Models/Arr/SonarrSearchItem.cs +++ b/code/Data/Models/Arr/SonarrSearchItem.cs @@ -1,6 +1,6 @@ using Common.Configuration.Arr; -namespace Domain.Models.Arr; +namespace Data.Models.Arr; public sealed class SonarrSearchItem : SearchItem { diff --git a/code/Domain/Models/Cache/StalledCacheItem.cs b/code/Data/Models/Cache/StalledCacheItem.cs similarity index 83% rename from code/Domain/Models/Cache/StalledCacheItem.cs rename to code/Data/Models/Cache/StalledCacheItem.cs index 7fa99526..9cc85d9d 100644 --- a/code/Domain/Models/Cache/StalledCacheItem.cs +++ b/code/Data/Models/Cache/StalledCacheItem.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Cache; +namespace Data.Models.Cache; public sealed record StalledCacheItem { diff --git a/code/Domain/Models/Deluge/Exceptions/DelugeClientException.cs b/code/Data/Models/Deluge/Exceptions/DelugeClientException.cs similarity index 72% rename from code/Domain/Models/Deluge/Exceptions/DelugeClientException.cs rename to code/Data/Models/Deluge/Exceptions/DelugeClientException.cs index 07986fcb..3b63421e 100644 --- a/code/Domain/Models/Deluge/Exceptions/DelugeClientException.cs +++ b/code/Data/Models/Deluge/Exceptions/DelugeClientException.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Deluge.Exceptions; +namespace Data.Models.Deluge.Exceptions; public class DelugeClientException : Exception { diff --git a/code/Domain/Models/Deluge/Exceptions/DelugeLoginException.cs b/code/Data/Models/Deluge/Exceptions/DelugeLoginException.cs similarity index 74% rename from code/Domain/Models/Deluge/Exceptions/DelugeLoginException.cs rename to code/Data/Models/Deluge/Exceptions/DelugeLoginException.cs index 54212ce5..73518980 100644 --- a/code/Domain/Models/Deluge/Exceptions/DelugeLoginException.cs +++ b/code/Data/Models/Deluge/Exceptions/DelugeLoginException.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Deluge.Exceptions; +namespace Data.Models.Deluge.Exceptions; public sealed class DelugeLoginException : DelugeClientException { diff --git a/code/Domain/Models/Deluge/Exceptions/DelugeLogoutException.cs b/code/Data/Models/Deluge/Exceptions/DelugeLogoutException.cs similarity index 74% rename from code/Domain/Models/Deluge/Exceptions/DelugeLogoutException.cs rename to code/Data/Models/Deluge/Exceptions/DelugeLogoutException.cs index 20a8d9a0..f5764e85 100644 --- a/code/Domain/Models/Deluge/Exceptions/DelugeLogoutException.cs +++ b/code/Data/Models/Deluge/Exceptions/DelugeLogoutException.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Deluge.Exceptions; +namespace Data.Models.Deluge.Exceptions; public sealed class DelugeLogoutException : DelugeClientException { diff --git a/code/Domain/Models/Deluge/Request/DelugeRequest.cs b/code/Data/Models/Deluge/Request/DelugeRequest.cs similarity index 94% rename from code/Domain/Models/Deluge/Request/DelugeRequest.cs rename to code/Data/Models/Deluge/Request/DelugeRequest.cs index d1838cf2..7ab05ada 100644 --- a/code/Domain/Models/Deluge/Request/DelugeRequest.cs +++ b/code/Data/Models/Deluge/Request/DelugeRequest.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Domain.Models.Deluge.Request; +namespace Data.Models.Deluge.Request; public class DelugeRequest { diff --git a/code/Domain/Models/Deluge/Response/DelugeContents.cs b/code/Data/Models/Deluge/Response/DelugeContents.cs similarity index 87% rename from code/Domain/Models/Deluge/Response/DelugeContents.cs rename to code/Data/Models/Deluge/Response/DelugeContents.cs index 8ecf21d5..c597dfd1 100644 --- a/code/Domain/Models/Deluge/Response/DelugeContents.cs +++ b/code/Data/Models/Deluge/Response/DelugeContents.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace Domain.Models.Deluge.Response; +namespace Data.Models.Deluge.Response; public sealed record DelugeContents { diff --git a/code/Domain/Models/Deluge/Response/DelugeError.cs b/code/Data/Models/Deluge/Response/DelugeError.cs similarity index 84% rename from code/Domain/Models/Deluge/Response/DelugeError.cs rename to code/Data/Models/Deluge/Response/DelugeError.cs index 2ec19ddd..861af5e6 100644 --- a/code/Domain/Models/Deluge/Response/DelugeError.cs +++ b/code/Data/Models/Deluge/Response/DelugeError.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Domain.Models.Deluge.Response; +namespace Data.Models.Deluge.Response; public sealed record DelugeError { diff --git a/code/Domain/Models/Deluge/Response/DelugeFileOrDirectory.cs b/code/Data/Models/Deluge/Response/DelugeFileOrDirectory.cs similarity index 95% rename from code/Domain/Models/Deluge/Response/DelugeFileOrDirectory.cs rename to code/Data/Models/Deluge/Response/DelugeFileOrDirectory.cs index 51941094..382b6d7e 100644 --- a/code/Domain/Models/Deluge/Response/DelugeFileOrDirectory.cs +++ b/code/Data/Models/Deluge/Response/DelugeFileOrDirectory.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace Domain.Models.Deluge.Response; +namespace Data.Models.Deluge.Response; public class DelugeFileOrDirectory { diff --git a/code/Domain/Models/Deluge/Response/DelugeResponse.cs b/code/Data/Models/Deluge/Response/DelugeResponse.cs similarity index 88% rename from code/Domain/Models/Deluge/Response/DelugeResponse.cs rename to code/Data/Models/Deluge/Response/DelugeResponse.cs index e82f6614..1761d1ff 100644 --- a/code/Domain/Models/Deluge/Response/DelugeResponse.cs +++ b/code/Data/Models/Deluge/Response/DelugeResponse.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Domain.Models.Deluge.Response; +namespace Data.Models.Deluge.Response; public sealed record DelugeResponse { diff --git a/code/Domain/Models/Deluge/Response/DelugeTorrent.cs b/code/Data/Models/Deluge/Response/DelugeTorrent.cs similarity index 94% rename from code/Domain/Models/Deluge/Response/DelugeTorrent.cs rename to code/Data/Models/Deluge/Response/DelugeTorrent.cs index 38270786..a1295399 100644 --- a/code/Domain/Models/Deluge/Response/DelugeTorrent.cs +++ b/code/Data/Models/Deluge/Response/DelugeTorrent.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Domain.Models.Deluge.Response; +namespace Data.Models.Deluge.Response; public record DelugeTorrent { diff --git a/code/Domain/Models/Deluge/Response/DelugeTorrentExtended.cs b/code/Data/Models/Deluge/Response/DelugeTorrentExtended.cs similarity index 98% rename from code/Domain/Models/Deluge/Response/DelugeTorrentExtended.cs rename to code/Data/Models/Deluge/Response/DelugeTorrentExtended.cs index efdbf02c..0acb36a6 100644 --- a/code/Domain/Models/Deluge/Response/DelugeTorrentExtended.cs +++ b/code/Data/Models/Deluge/Response/DelugeTorrentExtended.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Domain.Models.Deluge.Response; +namespace Data.Models.Deluge.Response; public sealed record DelugeTorrentExtended : DelugeTorrent { diff --git a/code/Domain/Models/Deluge/Response/DownloadStatus.cs b/code/Data/Models/Deluge/Response/DownloadStatus.cs similarity index 95% rename from code/Domain/Models/Deluge/Response/DownloadStatus.cs rename to code/Data/Models/Deluge/Response/DownloadStatus.cs index b86d5330..080c44f0 100644 --- a/code/Domain/Models/Deluge/Response/DownloadStatus.cs +++ b/code/Data/Models/Deluge/Response/DownloadStatus.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Domain.Models.Deluge.Response; +namespace Data.Models.Deluge.Response; public sealed record DownloadStatus { diff --git a/code/Infrastructure/Events/Event.cs b/code/Data/Models/Events/AppEvent.cs similarity index 95% rename from code/Infrastructure/Events/Event.cs rename to code/Data/Models/Events/AppEvent.cs index b5009c05..e0aba6b2 100644 --- a/code/Infrastructure/Events/Event.cs +++ b/code/Data/Models/Events/AppEvent.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using Microsoft.EntityFrameworkCore; -namespace Infrastructure.Events; +namespace Data.Models.Events; /// /// Represents an event in the system @@ -10,7 +10,7 @@ namespace Infrastructure.Events; [Index(nameof(EventType))] [Index(nameof(Severity))] [Index(nameof(Source))] -public class Event +public class AppEvent { [Key] public string Id { get; set; } = Guid.NewGuid().ToString(); diff --git a/code/Domain/Models/Lidarr/Album.cs b/code/Data/Models/Lidarr/Album.cs similarity index 84% rename from code/Domain/Models/Lidarr/Album.cs rename to code/Data/Models/Lidarr/Album.cs index bfd0f67d..52f935a9 100644 --- a/code/Domain/Models/Lidarr/Album.cs +++ b/code/Data/Models/Lidarr/Album.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Lidarr; +namespace Data.Models.Lidarr; public sealed record Album { diff --git a/code/Domain/Models/Lidarr/Artist.cs b/code/Data/Models/Lidarr/Artist.cs similarity index 75% rename from code/Domain/Models/Lidarr/Artist.cs rename to code/Data/Models/Lidarr/Artist.cs index 483c0ad3..ce29fbb6 100644 --- a/code/Domain/Models/Lidarr/Artist.cs +++ b/code/Data/Models/Lidarr/Artist.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Lidarr; +namespace Data.Models.Lidarr; public sealed record Artist { diff --git a/code/Domain/Models/Lidarr/LidarrCommand.cs b/code/Data/Models/Lidarr/LidarrCommand.cs similarity index 82% rename from code/Domain/Models/Lidarr/LidarrCommand.cs rename to code/Data/Models/Lidarr/LidarrCommand.cs index 63c140c5..5ad54f50 100644 --- a/code/Domain/Models/Lidarr/LidarrCommand.cs +++ b/code/Data/Models/Lidarr/LidarrCommand.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Lidarr; +namespace Data.Models.Lidarr; public sealed record LidarrCommand { diff --git a/code/Domain/Models/Radarr/Movie.cs b/code/Data/Models/Radarr/Movie.cs similarity index 77% rename from code/Domain/Models/Radarr/Movie.cs rename to code/Data/Models/Radarr/Movie.cs index a9a839e6..6f8c657f 100644 --- a/code/Domain/Models/Radarr/Movie.cs +++ b/code/Data/Models/Radarr/Movie.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Radarr; +namespace Data.Models.Radarr; public sealed record Movie { diff --git a/code/Domain/Models/Radarr/RadarrCommand.cs b/code/Data/Models/Radarr/RadarrCommand.cs similarity index 80% rename from code/Domain/Models/Radarr/RadarrCommand.cs rename to code/Data/Models/Radarr/RadarrCommand.cs index f32a6855..691b5cea 100644 --- a/code/Domain/Models/Radarr/RadarrCommand.cs +++ b/code/Data/Models/Radarr/RadarrCommand.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Radarr; +namespace Data.Models.Radarr; public sealed record RadarrCommand { diff --git a/code/Domain/Models/Sonarr/Episode.cs b/code/Data/Models/Sonarr/Episode.cs similarity index 85% rename from code/Domain/Models/Sonarr/Episode.cs rename to code/Data/Models/Sonarr/Episode.cs index 2667b73d..2a403847 100644 --- a/code/Domain/Models/Sonarr/Episode.cs +++ b/code/Data/Models/Sonarr/Episode.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Sonarr; +namespace Data.Models.Sonarr; public sealed record Episode { diff --git a/code/Domain/Models/Sonarr/Series.cs b/code/Data/Models/Sonarr/Series.cs similarity index 78% rename from code/Domain/Models/Sonarr/Series.cs rename to code/Data/Models/Sonarr/Series.cs index c24cbb58..aaba6102 100644 --- a/code/Domain/Models/Sonarr/Series.cs +++ b/code/Data/Models/Sonarr/Series.cs @@ -1,4 +1,4 @@ -namespace Domain.Models.Sonarr; +namespace Data.Models.Sonarr; public sealed record Series { diff --git a/code/Domain/Models/Sonarr/SonarrCommand.cs b/code/Data/Models/Sonarr/SonarrCommand.cs similarity index 90% rename from code/Domain/Models/Sonarr/SonarrCommand.cs rename to code/Data/Models/Sonarr/SonarrCommand.cs index a0f8cc4b..df536aef 100644 --- a/code/Domain/Models/Sonarr/SonarrCommand.cs +++ b/code/Data/Models/Sonarr/SonarrCommand.cs @@ -1,6 +1,6 @@ using Common.Configuration.Arr; -namespace Domain.Models.Sonarr; +namespace Data.Models.Sonarr; public sealed record SonarrCommand { diff --git a/code/Executable/Controllers/EventsController.cs b/code/Executable/Controllers/EventsController.cs index 72948b6c..ef34ed3a 100644 --- a/code/Executable/Controllers/EventsController.cs +++ b/code/Executable/Controllers/EventsController.cs @@ -1,3 +1,5 @@ +using Data; +using Data.Models.Events; using Infrastructure.Events; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -8,9 +10,9 @@ namespace Executable.Controllers; [Route("api/[controller]")] public class EventsController : ControllerBase { - private readonly EventDbContext _context; + private readonly DataContext _context; - public EventsController(EventDbContext context) + public EventsController(DataContext context) { _context = context; } @@ -19,7 +21,7 @@ public class EventsController : ControllerBase /// Gets recent events /// [HttpGet] - public async Task>> GetEvents( + public async Task>> GetEvents( [FromQuery] int count = 100, [FromQuery] string? severity = null, [FromQuery] string? eventType = null, @@ -50,7 +52,7 @@ public class EventsController : ControllerBase /// Gets a specific event by ID /// [HttpGet("{id}")] - public async Task> GetEvent(string id) + public async Task> GetEvent(string id) { var eventEntity = await _context.Events.FindAsync(id); @@ -64,7 +66,7 @@ public class EventsController : ControllerBase /// Gets events by correlation ID /// [HttpGet("correlation/{correlationId}")] - public async Task>> GetEventsByCorrelation(string correlationId) + public async Task>> GetEventsByCorrelation(string correlationId) { var events = await _context.Events .Where(e => e.CorrelationId == correlationId) @@ -107,9 +109,13 @@ public class EventsController : ControllerBase [HttpPost("cleanup")] public async Task> CleanupOldEvents([FromQuery] int retentionDays = 30) { - var removedCount = await _context.CleanupOldEventsAsync(retentionDays); + var cutoffDate = DateTime.UtcNow.AddDays(-retentionDays); - return Ok(new { RemovedCount = removedCount, RetentionDays = retentionDays }); + await _context.Events + .Where(e => e.Timestamp < cutoffDate) + .ExecuteDeleteAsync(); + + return Ok(); } /// diff --git a/code/Executable/Controllers/StatusController.cs b/code/Executable/Controllers/StatusController.cs index c584b625..c4241fb8 100644 --- a/code/Executable/Controllers/StatusController.cs +++ b/code/Executable/Controllers/StatusController.cs @@ -5,6 +5,7 @@ using Infrastructure.Verticals.Arr; using Infrastructure.Verticals.DownloadClient; using Microsoft.AspNetCore.Mvc; using System.Diagnostics; +using Data.Enums; namespace Executable.Controllers; @@ -143,7 +144,7 @@ public class StatusController : ControllerBase { try { - var sonarrClient = _arrClientFactory.GetClient(Domain.Enums.InstanceType.Sonarr); + var sonarrClient = _arrClientFactory.GetClient(InstanceType.Sonarr); await sonarrClient.TestConnectionAsync(instance); sonarrStatus.Add(new @@ -178,7 +179,7 @@ public class StatusController : ControllerBase { try { - var radarrClient = _arrClientFactory.GetClient(Domain.Enums.InstanceType.Radarr); + var radarrClient = _arrClientFactory.GetClient(InstanceType.Radarr); await radarrClient.TestConnectionAsync(instance); radarrStatus.Add(new @@ -213,7 +214,7 @@ public class StatusController : ControllerBase { try { - var lidarrClient = _arrClientFactory.GetClient(Domain.Enums.InstanceType.Lidarr); + var lidarrClient = _arrClientFactory.GetClient(InstanceType.Lidarr); await lidarrClient.TestConnectionAsync(instance); lidarrStatus.Add(new diff --git a/code/Executable/DependencyInjection/LoggingDI.cs b/code/Executable/DependencyInjection/LoggingDI.cs index 6376d1c3..6fe56997 100644 --- a/code/Executable/DependencyInjection/LoggingDI.cs +++ b/code/Executable/DependencyInjection/LoggingDI.cs @@ -1,4 +1,5 @@ -using Domain.Enums; +using Common.Helpers; +using Data.Enums; using Infrastructure.Configuration; using Infrastructure.Verticals.ContentBlocker; using Infrastructure.Verticals.DownloadCleaner; diff --git a/code/Executable/DependencyInjection/MainDI.cs b/code/Executable/DependencyInjection/MainDI.cs index a5a98aa3..14c0bc0f 100644 --- a/code/Executable/DependencyInjection/MainDI.cs +++ b/code/Executable/DependencyInjection/MainDI.cs @@ -1,11 +1,8 @@ using System.Net; using Common.Configuration.General; -using Common.Helpers; -using Domain.Models.Arr; -using Infrastructure.Configuration; +using Data.Models.Arr; using Infrastructure.Health; using Infrastructure.Http; -using Infrastructure.Services; using Infrastructure.Verticals.DownloadClient.Factory; using Infrastructure.Verticals.DownloadClient.Deluge; using Infrastructure.Verticals.DownloadClient.QBittorrent; @@ -14,7 +11,6 @@ using Infrastructure.Verticals.DownloadRemover.Consumers; using Infrastructure.Verticals.Notifications.Consumers; using Infrastructure.Verticals.Notifications.Models; using MassTransit; -using MassTransit.Configuration; using Polly; using Polly.Extensions.Http; diff --git a/code/Executable/DependencyInjection/ServicesDI.cs b/code/Executable/DependencyInjection/ServicesDI.cs index 7c09c2ed..d324ef8c 100644 --- a/code/Executable/DependencyInjection/ServicesDI.cs +++ b/code/Executable/DependencyInjection/ServicesDI.cs @@ -1,3 +1,5 @@ +using Data; +using Infrastructure.Events; using Infrastructure.Interceptors; using Infrastructure.Services; using Infrastructure.Services.Interfaces; @@ -20,6 +22,9 @@ public static class ServicesDI { public static IServiceCollection AddServices(this IServiceCollection services) => services + .AddTransient() + .AddTransient() + .AddHostedService() // API services .AddSingleton() // Core services diff --git a/code/Executable/Executable.csproj b/code/Executable/Executable.csproj index 2e895ecf..b7462bfc 100644 --- a/code/Executable/Executable.csproj +++ b/code/Executable/Executable.csproj @@ -10,9 +10,13 @@ - - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/code/Executable/HostExtensions.cs b/code/Executable/HostExtensions.cs index d0b0331a..9264c19c 100644 --- a/code/Executable/HostExtensions.cs +++ b/code/Executable/HostExtensions.cs @@ -1,5 +1,8 @@ using System.Reflection; +using Data; using Infrastructure.Configuration; +using Infrastructure.Events; +using Microsoft.EntityFrameworkCore; namespace Executable; @@ -30,6 +33,13 @@ public static class HostExtensions logger.LogError(ex, "Failed to initialize configuration files"); } + // Apply db migrations + var dbContext = host.Services.GetRequiredService(); + if ((await dbContext.Database.GetPendingMigrationsAsync()).Any()) + { + await dbContext.Database.MigrateAsync(); + } + return host; } } \ No newline at end of file diff --git a/code/Executable/Program.cs b/code/Executable/Program.cs index 588393bd..4ed4a9a9 100644 --- a/code/Executable/Program.cs +++ b/code/Executable/Program.cs @@ -22,9 +22,6 @@ builder.Services.AddCors(options => }); }); -// Register SignalR - ensure this is before logging initialization -builder.Services.AddSignalR(); - // Register services needed for logging first builder.Services .AddSingleton() diff --git a/code/Infrastructure.Tests/Verticals/DownloadClient/DownloadServiceTests.cs b/code/Infrastructure.Tests/Verticals/DownloadClient/DownloadServiceTests.cs index 1c0be68e..9aee0831 100644 --- a/code/Infrastructure.Tests/Verticals/DownloadClient/DownloadServiceTests.cs +++ b/code/Infrastructure.Tests/Verticals/DownloadClient/DownloadServiceTests.cs @@ -1,6 +1,6 @@ // using Common.Configuration.DownloadCleaner; -// using Domain.Enums; -// using Domain.Models.Cache; +// using Data.Enums; +// using Data.Models.Cache; // using Infrastructure.Helpers; // using Infrastructure.Verticals.Context; // using Infrastructure.Verticals.DownloadClient; diff --git a/code/Infrastructure/Configuration/CachedConfigurationProvider.cs b/code/Infrastructure/Configuration/CachedConfigurationProvider.cs index 7223ae6c..2aed258b 100644 --- a/code/Infrastructure/Configuration/CachedConfigurationProvider.cs +++ b/code/Infrastructure/Configuration/CachedConfigurationProvider.cs @@ -1,4 +1,5 @@ using System.Collections.Concurrent; +using Common.Helpers; using Microsoft.Extensions.Logging; namespace Infrastructure.Configuration; diff --git a/code/Infrastructure/Configuration/ConfigManager.cs b/code/Infrastructure/Configuration/ConfigManager.cs index a6b1ef65..ddf84591 100644 --- a/code/Infrastructure/Configuration/ConfigManager.cs +++ b/code/Infrastructure/Configuration/ConfigManager.cs @@ -7,6 +7,7 @@ using Common.Configuration.General; using Common.Configuration.IgnoredDownloads; using Common.Configuration.Notification; using Common.Configuration.QueueCleaner; +using Common.Helpers; using Microsoft.Extensions.Logging; namespace Infrastructure.Configuration; diff --git a/code/Infrastructure/Configuration/JsonConfigurationProvider.cs b/code/Infrastructure/Configuration/JsonConfigurationProvider.cs index c935c483..cb2ae799 100644 --- a/code/Infrastructure/Configuration/JsonConfigurationProvider.cs +++ b/code/Infrastructure/Configuration/JsonConfigurationProvider.cs @@ -1,6 +1,7 @@ using System.Text.Json; using System.Text.Json.Nodes; using System.Text.Json.Serialization; +using Common.Helpers; using Microsoft.Extensions.Logging; namespace Infrastructure.Configuration; diff --git a/code/Infrastructure/Events/EventCleanupService.cs b/code/Infrastructure/Events/EventCleanupService.cs index 4ff88f3c..0cd73052 100644 --- a/code/Infrastructure/Events/EventCleanupService.cs +++ b/code/Infrastructure/Events/EventCleanupService.cs @@ -1,3 +1,4 @@ +using Data; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -30,12 +31,14 @@ public class EventCleanupService : BackgroundService { try { - await Task.Delay(_cleanupInterval, stoppingToken); - if (stoppingToken.IsCancellationRequested) + { break; + } await PerformCleanupAsync(); + + await Task.Delay(_cleanupInterval, stoppingToken); } catch (OperationCanceledException) { @@ -56,39 +59,12 @@ public class EventCleanupService : BackgroundService try { using var scope = _serviceProvider.CreateScope(); - var context = scope.ServiceProvider.GetRequiredService(); + var context = scope.ServiceProvider.GetRequiredService(); var cutoffDate = DateTime.UtcNow.AddDays(-_retentionDays); - var oldEventsQuery = context.Events.Where(e => e.Timestamp < cutoffDate); - var count = await oldEventsQuery.CountAsync(); - - if (count > 0) - { - _logger.LogInformation("Cleaning up {count} events older than {cutoffDate:yyyy-MM-dd}", count, cutoffDate); - - // Remove in batches to avoid large transactions - const int batchSize = 1000; - var totalRemoved = 0; - - while (true) - { - var batch = await oldEventsQuery.Take(batchSize).ToListAsync(); - if (batch.Count == 0) - break; - - context.Events.RemoveRange(batch); - await context.SaveChangesAsync(); - totalRemoved += batch.Count; - - _logger.LogTrace("Removed batch of {batchCount} events, total removed: {totalRemoved}", batch.Count, totalRemoved); - } - - _logger.LogInformation("Event cleanup completed. Removed {totalRemoved} old events", totalRemoved); - } - else - { - _logger.LogTrace("No old events to clean up"); - } + await context.Events + .Where(e => e.Timestamp < cutoffDate) + .ExecuteDeleteAsync(); } catch (Exception ex) { diff --git a/code/Infrastructure/Events/EventExtensions.cs b/code/Infrastructure/Events/EventExtensions.cs deleted file mode 100644 index 8ecd8e6b..00000000 --- a/code/Infrastructure/Events/EventExtensions.cs +++ /dev/null @@ -1,170 +0,0 @@ -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; - -namespace Infrastructure.Events; - -/// -/// Extension methods for easy event publishing -/// -public static class EventExtensions -{ - /// - /// Publishes an information event - /// - public static async Task PublishInfoEventAsync(this EventDbContext context, string source, string message, object? data = null, string? correlationId = null) - { - await PublishEventAsync(context, "Information", source, message, "Info", data, correlationId); - } - - /// - /// Publishes a warning event - /// - public static async Task PublishWarningEventAsync(this EventDbContext context, string source, string message, object? data = null, string? correlationId = null) - { - await PublishEventAsync(context, "Warning", source, message, "Warning", data, correlationId); - } - - /// - /// Publishes an error event - /// - public static async Task PublishErrorEventAsync(this EventDbContext context, string source, string message, object? data = null, string? correlationId = null) - { - await PublishEventAsync(context, "Error", source, message, "Error", data, correlationId); - } - - /// - /// Publishes a custom event - /// - public static async Task PublishEventAsync(this EventDbContext context, string eventType, string source, string message, string severity = "Info", object? data = null, string? correlationId = null) - { - var eventEntity = new Event - { - EventType = eventType, - Source = source, - Message = message, - Severity = severity, - Data = data != null ? JsonSerializer.Serialize(data) : null, - CorrelationId = correlationId - }; - - context.Events.Add(eventEntity); - await context.SaveChangesAsync(); - } - - /// - /// Publishes an information event synchronously - /// - public static void PublishInfoEvent(this EventDbContext context, string source, string message, object? data = null, string? correlationId = null) - { - PublishEvent(context, "Information", source, message, "Info", data, correlationId); - } - - /// - /// Publishes a warning event synchronously - /// - public static void PublishWarningEvent(this EventDbContext context, string source, string message, object? data = null, string? correlationId = null) - { - PublishEvent(context, "Warning", source, message, "Warning", data, correlationId); - } - - /// - /// Publishes an error event synchronously - /// - public static void PublishErrorEvent(this EventDbContext context, string source, string message, object? data = null, string? correlationId = null) - { - PublishEvent(context, "Error", source, message, "Error", data, correlationId); - } - - /// - /// Publishes a custom event synchronously - /// - public static void PublishEvent(this EventDbContext context, string eventType, string source, string message, string severity = "Info", object? data = null, string? correlationId = null) - { - var eventEntity = new Event - { - EventType = eventType, - Source = source, - Message = message, - Severity = severity, - Data = data != null ? JsonSerializer.Serialize(data) : null, - CorrelationId = correlationId - }; - - context.Events.Add(eventEntity); - context.SaveChanges(); - } - - /// - /// Gets recent events - /// - public static async Task> GetRecentEventsAsync(this EventDbContext context, int count = 100) - { - return await context.Events - .OrderByDescending(e => e.Timestamp) - .Take(count) - .ToListAsync(); - } - - /// - /// Gets events by type - /// - public static async Task> GetEventsByTypeAsync(this EventDbContext context, string eventType, int count = 100) - { - return await context.Events - .Where(e => e.EventType == eventType) - .OrderByDescending(e => e.Timestamp) - .Take(count) - .ToListAsync(); - } - - /// - /// Gets events by severity - /// - public static async Task> GetEventsBySeverityAsync(this EventDbContext context, string severity, int count = 100) - { - return await context.Events - .Where(e => e.Severity == severity) - .OrderByDescending(e => e.Timestamp) - .Take(count) - .ToListAsync(); - } - - /// - /// Cleans up events older than the specified number of days - /// - public static async Task CleanupOldEventsAsync(this EventDbContext context, int retentionDays = 30) - { - var cutoffDate = DateTime.UtcNow.AddDays(-retentionDays); - var oldEvents = context.Events.Where(e => e.Timestamp < cutoffDate); - var count = await oldEvents.CountAsync(); - - if (count > 0) - { - context.Events.RemoveRange(oldEvents); - await context.SaveChangesAsync(); - } - - return count; - } -} - -/// -/// Service collection extensions for event system -/// -public static class EventServiceExtensions -{ - /// - /// Adds event system with SQLite database - /// - public static IServiceCollection AddEventSystem(this IServiceCollection services) - { - services.AddDbContext(); - services.AddScoped(); - services.AddSingleton(); - services.AddHostedService(); - services.AddSignalR(); - return services; - } -} \ No newline at end of file diff --git a/code/Infrastructure/Events/EventHub.cs b/code/Infrastructure/Events/EventHub.cs index 8ebac76f..752edb31 100644 --- a/code/Infrastructure/Events/EventHub.cs +++ b/code/Infrastructure/Events/EventHub.cs @@ -1,3 +1,4 @@ +using Data; using Microsoft.AspNetCore.SignalR; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; @@ -9,10 +10,10 @@ namespace Infrastructure.Events; /// public class EventHub : Hub { - private readonly EventDbContext _context; + private readonly DataContext _context; private readonly ILogger _logger; - public EventHub(EventDbContext context, ILogger logger) + public EventHub(DataContext context, ILogger logger) { _context = context; _logger = logger; @@ -31,7 +32,6 @@ public class EventHub : Hub .ToListAsync(); await Clients.Caller.SendAsync("RecentEventsReceived", events); - _logger.LogTrace("Sent {count} recent events to client {connectionId}", events.Count, Context.ConnectionId); } catch (Exception ex) { @@ -44,7 +44,6 @@ public class EventHub : Hub /// public override async Task OnConnectedAsync() { - _logger.LogTrace("Client {connectionId} connected to EventHub", Context.ConnectionId); await base.OnConnectedAsync(); } @@ -53,7 +52,6 @@ public class EventHub : Hub /// public override async Task OnDisconnectedAsync(Exception? exception) { - _logger.LogTrace("Client {connectionId} disconnected from EventHub", Context.ConnectionId); await base.OnDisconnectedAsync(exception); } } \ No newline at end of file diff --git a/code/Infrastructure/Events/EventPublisher.cs b/code/Infrastructure/Events/EventPublisher.cs index 182c5c17..238ceaf8 100644 --- a/code/Infrastructure/Events/EventPublisher.cs +++ b/code/Infrastructure/Events/EventPublisher.cs @@ -1,6 +1,8 @@ using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.Logging; using System.Text.Json; +using Data; +using Data.Models.Events; namespace Infrastructure.Events; @@ -9,12 +11,12 @@ namespace Infrastructure.Events; /// public class EventPublisher { - private readonly EventDbContext _context; + private readonly DataContext _context; private readonly IHubContext _hubContext; private readonly ILogger _logger; public EventPublisher( - EventDbContext context, + DataContext context, IHubContext hubContext, ILogger logger) { @@ -28,7 +30,7 @@ public class EventPublisher /// public async Task PublishAsync(string eventType, string source, string message, string severity = "Info", object? data = null, string? correlationId = null) { - var eventEntity = new Event + var eventEntity = new AppEvent { EventType = eventType, Source = source, @@ -96,18 +98,18 @@ public class EventPublisher await PublishAsync(eventType, "HttpClient", message, severity, data, correlationId); } - private async Task NotifyClientsAsync(Event eventEntity) + private async Task NotifyClientsAsync(AppEvent appEventEntity) { try { // Send to all connected clients (self-hosted app with single client) - await _hubContext.Clients.All.SendAsync("EventReceived", eventEntity); + await _hubContext.Clients.All.SendAsync("EventReceived", appEventEntity); - _logger.LogTrace("Sent event {eventId} to SignalR clients", eventEntity.Id); + _logger.LogTrace("Sent event {eventId} to SignalR clients", appEventEntity.Id); } catch (Exception ex) { - _logger.LogError(ex, "Failed to send event {eventId} to SignalR clients", eventEntity.Id); + _logger.LogError(ex, "Failed to send event {eventId} to SignalR clients", appEventEntity.Id); } } } \ No newline at end of file diff --git a/code/Infrastructure/Extensions/DelugeExtensions.cs b/code/Infrastructure/Extensions/DelugeExtensions.cs index 93656906..0b4348eb 100644 --- a/code/Infrastructure/Extensions/DelugeExtensions.cs +++ b/code/Infrastructure/Extensions/DelugeExtensions.cs @@ -1,4 +1,4 @@ -using Domain.Models.Deluge.Response; +using Data.Models.Deluge.Response; using Infrastructure.Helpers; using Infrastructure.Services; diff --git a/code/Infrastructure/Helpers/CacheKeys.cs b/code/Infrastructure/Helpers/CacheKeys.cs index 84cdffc3..4df43f58 100644 --- a/code/Infrastructure/Helpers/CacheKeys.cs +++ b/code/Infrastructure/Helpers/CacheKeys.cs @@ -1,4 +1,4 @@ -using Domain.Enums; +using Data.Enums; namespace Infrastructure.Helpers; diff --git a/code/Infrastructure/Infrastructure.csproj b/code/Infrastructure/Infrastructure.csproj index 7b801276..d1c3086c 100644 --- a/code/Infrastructure/Infrastructure.csproj +++ b/code/Infrastructure/Infrastructure.csproj @@ -8,7 +8,7 @@ - + @@ -17,14 +17,8 @@ - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + diff --git a/code/Infrastructure/Logging/LoggingInitializer.cs b/code/Infrastructure/Logging/LoggingInitializer.cs index 970268d0..002247c4 100644 --- a/code/Infrastructure/Logging/LoggingInitializer.cs +++ b/code/Infrastructure/Logging/LoggingInitializer.cs @@ -1,3 +1,4 @@ +using Infrastructure.Events; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; @@ -7,10 +8,12 @@ namespace Infrastructure.Logging; public class LoggingInitializer : BackgroundService { private readonly ILogger _logger; + private readonly EventPublisher _eventPublisher; - public LoggingInitializer(ILogger logger) + public LoggingInitializer(ILogger logger, EventPublisher eventPublisher) { _logger = logger; + _eventPublisher = eventPublisher; } protected override async Task ExecuteAsync(CancellationToken stoppingToken) @@ -19,6 +22,12 @@ public class LoggingInitializer : BackgroundService { try { + await _eventPublisher.PublishAsync( + "strike", + "test", + "Item '{item}' has been struck {1} times for reason '{stalled}'", + severity: "Warning", + data: new { Hash = "hash", Name = "name", StrikeCount = "1", Type = "stalled" }); throw new Exception("test exception"); } catch (Exception exception) diff --git a/code/Infrastructure/Verticals/Arr/ArrClient.cs b/code/Infrastructure/Verticals/Arr/ArrClient.cs index 54b90780..777e5eb6 100644 --- a/code/Infrastructure/Verticals/Arr/ArrClient.cs +++ b/code/Infrastructure/Verticals/Arr/ArrClient.cs @@ -2,9 +2,9 @@ using Common.Attributes; using Common.Configuration.Arr; using Common.Configuration.QueueCleaner; using Common.Helpers; -using Domain.Enums; -using Domain.Models.Arr; -using Domain.Models.Arr.Queue; +using Data.Enums; +using Data.Models.Arr; +using Data.Models.Arr.Queue; using Infrastructure.Interceptors; using Infrastructure.Verticals.Arr.Interfaces; using Infrastructure.Verticals.ItemStriker; diff --git a/code/Infrastructure/Verticals/Arr/ArrClientFactory.cs b/code/Infrastructure/Verticals/Arr/ArrClientFactory.cs index a270a206..ffec5dc5 100644 --- a/code/Infrastructure/Verticals/Arr/ArrClientFactory.cs +++ b/code/Infrastructure/Verticals/Arr/ArrClientFactory.cs @@ -1,4 +1,4 @@ -using Domain.Enums; +using Data.Enums; using Infrastructure.Verticals.Arr.Interfaces; namespace Infrastructure.Verticals.Arr; diff --git a/code/Infrastructure/Verticals/Arr/ArrQueueIterator.cs b/code/Infrastructure/Verticals/Arr/ArrQueueIterator.cs index 2ea9b14a..347dd9c2 100644 --- a/code/Infrastructure/Verticals/Arr/ArrQueueIterator.cs +++ b/code/Infrastructure/Verticals/Arr/ArrQueueIterator.cs @@ -1,6 +1,6 @@ using Common.Configuration; using Common.Configuration.Arr; -using Domain.Models.Arr.Queue; +using Data.Models.Arr.Queue; using Infrastructure.Verticals.Arr.Interfaces; using Microsoft.Extensions.Logging; diff --git a/code/Infrastructure/Verticals/Arr/Interfaces/IArrClient.cs b/code/Infrastructure/Verticals/Arr/Interfaces/IArrClient.cs index d445c54a..d9966d94 100644 --- a/code/Infrastructure/Verticals/Arr/Interfaces/IArrClient.cs +++ b/code/Infrastructure/Verticals/Arr/Interfaces/IArrClient.cs @@ -1,7 +1,7 @@ using Common.Configuration.Arr; -using Domain.Enums; -using Domain.Models.Arr; -using Domain.Models.Arr.Queue; +using Data.Enums; +using Data.Models.Arr; +using Data.Models.Arr.Queue; namespace Infrastructure.Verticals.Arr.Interfaces; diff --git a/code/Infrastructure/Verticals/Arr/LidarrClient.cs b/code/Infrastructure/Verticals/Arr/LidarrClient.cs index 92efea29..db24235f 100644 --- a/code/Infrastructure/Verticals/Arr/LidarrClient.cs +++ b/code/Infrastructure/Verticals/Arr/LidarrClient.cs @@ -1,8 +1,8 @@ using System.Text; using Common.Configuration.Arr; -using Domain.Models.Arr; -using Domain.Models.Arr.Queue; -using Domain.Models.Lidarr; +using Data.Models.Arr; +using Data.Models.Arr.Queue; +using Data.Models.Lidarr; using Infrastructure.Interceptors; using Infrastructure.Verticals.Arr.Interfaces; using Infrastructure.Verticals.ItemStriker; diff --git a/code/Infrastructure/Verticals/Arr/RadarrClient.cs b/code/Infrastructure/Verticals/Arr/RadarrClient.cs index 709c0922..f7f65d3a 100644 --- a/code/Infrastructure/Verticals/Arr/RadarrClient.cs +++ b/code/Infrastructure/Verticals/Arr/RadarrClient.cs @@ -1,8 +1,8 @@ using System.Text; using Common.Configuration.Arr; -using Domain.Models.Arr; -using Domain.Models.Arr.Queue; -using Domain.Models.Radarr; +using Data.Models.Arr; +using Data.Models.Arr.Queue; +using Data.Models.Radarr; using Infrastructure.Interceptors; using Infrastructure.Verticals.Arr.Interfaces; using Infrastructure.Verticals.ItemStriker; diff --git a/code/Infrastructure/Verticals/Arr/SonarrClient.cs b/code/Infrastructure/Verticals/Arr/SonarrClient.cs index 5f37fd63..41d2d4ed 100644 --- a/code/Infrastructure/Verticals/Arr/SonarrClient.cs +++ b/code/Infrastructure/Verticals/Arr/SonarrClient.cs @@ -1,15 +1,15 @@ using System.Text; using Common.Configuration.Arr; -using Domain.Models.Arr; -using Domain.Models.Arr.Queue; -using Domain.Models.Sonarr; +using Data.Models.Arr; +using Data.Models.Arr.Queue; +using Data.Models.Sonarr; using Infrastructure.Interceptors; using Infrastructure.Verticals.Arr.Interfaces; using Infrastructure.Verticals.ItemStriker; using Microsoft.Extensions.Logging; using Infrastructure.Configuration; using Newtonsoft.Json; -using Series = Domain.Models.Sonarr.Series; +using Series = Data.Models.Sonarr.Series; namespace Infrastructure.Verticals.Arr; diff --git a/code/Infrastructure/Verticals/ContentBlocker/BlocklistProvider.cs b/code/Infrastructure/Verticals/ContentBlocker/BlocklistProvider.cs index ac544ca9..74c453cc 100644 --- a/code/Infrastructure/Verticals/ContentBlocker/BlocklistProvider.cs +++ b/code/Infrastructure/Verticals/ContentBlocker/BlocklistProvider.cs @@ -3,7 +3,7 @@ using System.Diagnostics; using System.Text.RegularExpressions; using Common.Configuration.ContentBlocker; using Common.Helpers; -using Domain.Enums; +using Data.Enums; using Infrastructure.Configuration; using Infrastructure.Helpers; using Microsoft.Extensions.Caching.Memory; diff --git a/code/Infrastructure/Verticals/ContentBlocker/ContentBlocker.cs b/code/Infrastructure/Verticals/ContentBlocker/ContentBlocker.cs index 869e4634..7c7bcfe8 100644 --- a/code/Infrastructure/Verticals/ContentBlocker/ContentBlocker.cs +++ b/code/Infrastructure/Verticals/ContentBlocker/ContentBlocker.cs @@ -3,8 +3,8 @@ using System.Text.RegularExpressions; using Common.Configuration.Arr; using Common.Configuration.ContentBlocker; using Common.Configuration.DownloadClient; -using Domain.Enums; -using Domain.Models.Arr.Queue; +using Data.Enums; +using Data.Models.Arr.Queue; using Infrastructure.Configuration; using Infrastructure.Helpers; using Infrastructure.Services; diff --git a/code/Infrastructure/Verticals/DownloadCleaner/DownloadCleaner.cs b/code/Infrastructure/Verticals/DownloadCleaner/DownloadCleaner.cs index 9855259c..fe6b0239 100644 --- a/code/Infrastructure/Verticals/DownloadCleaner/DownloadCleaner.cs +++ b/code/Infrastructure/Verticals/DownloadCleaner/DownloadCleaner.cs @@ -1,8 +1,8 @@ using Common.Configuration.Arr; using Common.Configuration.DownloadCleaner; using Common.Configuration.DownloadClient; -using Domain.Enums; -using Domain.Models.Arr.Queue; +using Data.Enums; +using Data.Models.Arr.Queue; using Infrastructure.Configuration; using Infrastructure.Services; using Infrastructure.Verticals.Arr; diff --git a/code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeClient.cs b/code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeClient.cs index 10e075d4..cbed1407 100644 --- a/code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeClient.cs +++ b/code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeClient.cs @@ -3,9 +3,9 @@ using System.Text.Json.Serialization; using Common.Configuration; using Common.Configuration.DownloadClient; using Common.Exceptions; -using Domain.Models.Deluge.Exceptions; -using Domain.Models.Deluge.Request; -using Domain.Models.Deluge.Response; +using Data.Models.Deluge.Exceptions; +using Data.Models.Deluge.Request; +using Data.Models.Deluge.Response; using Infrastructure.Verticals.DownloadClient.Deluge.Extensions; using Microsoft.Extensions.Options; using Newtonsoft.Json; diff --git a/code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeService.cs b/code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeService.cs index 73b32300..90280380 100644 --- a/code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeService.cs +++ b/code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeService.cs @@ -6,8 +6,8 @@ using Common.Configuration.DownloadCleaner; using Common.Configuration.DownloadClient; using Common.CustomDataTypes; using Common.Exceptions; -using Domain.Enums; -using Domain.Models.Deluge.Response; +using Data.Enums; +using Data.Models.Deluge.Response; using Infrastructure.Extensions; using Infrastructure.Interceptors; using Infrastructure.Verticals.ContentBlocker; diff --git a/code/Infrastructure/Verticals/DownloadClient/DownloadCheckResult.cs b/code/Infrastructure/Verticals/DownloadClient/DownloadCheckResult.cs index 9215f581..0fd6f36c 100644 --- a/code/Infrastructure/Verticals/DownloadClient/DownloadCheckResult.cs +++ b/code/Infrastructure/Verticals/DownloadClient/DownloadCheckResult.cs @@ -1,4 +1,4 @@ -using Domain.Enums; +using Data.Enums; namespace Infrastructure.Verticals.DownloadClient; diff --git a/code/Infrastructure/Verticals/DownloadClient/DownloadService.cs b/code/Infrastructure/Verticals/DownloadClient/DownloadService.cs index c56fcce3..d5f7388b 100644 --- a/code/Infrastructure/Verticals/DownloadClient/DownloadService.cs +++ b/code/Infrastructure/Verticals/DownloadClient/DownloadService.cs @@ -6,8 +6,8 @@ using Common.Configuration.DownloadClient; using Common.Configuration.QueueCleaner; using Common.CustomDataTypes; using Common.Helpers; -using Domain.Enums; -using Domain.Models.Cache; +using Data.Enums; +using Data.Models.Cache; using Infrastructure.Configuration; using Infrastructure.Helpers; using Infrastructure.Http; diff --git a/code/Infrastructure/Verticals/DownloadClient/QBittorrent/QBitService.cs b/code/Infrastructure/Verticals/DownloadClient/QBittorrent/QBitService.cs index 297ee03c..ed8ecbd7 100644 --- a/code/Infrastructure/Verticals/DownloadClient/QBittorrent/QBitService.cs +++ b/code/Infrastructure/Verticals/DownloadClient/QBittorrent/QBitService.cs @@ -7,7 +7,7 @@ using Common.Configuration.DownloadClient; using Common.Configuration.QueueCleaner; using Common.CustomDataTypes; using Common.Helpers; -using Domain.Enums; +using Data.Enums; using Infrastructure.Configuration; using Infrastructure.Extensions; using Infrastructure.Http; diff --git a/code/Infrastructure/Verticals/DownloadClient/SeedingCheckResult.cs b/code/Infrastructure/Verticals/DownloadClient/SeedingCheckResult.cs index 5fa65492..802481c6 100644 --- a/code/Infrastructure/Verticals/DownloadClient/SeedingCheckResult.cs +++ b/code/Infrastructure/Verticals/DownloadClient/SeedingCheckResult.cs @@ -1,4 +1,4 @@ -using Domain.Enums; +using Data.Enums; namespace Infrastructure.Verticals.DownloadClient; diff --git a/code/Infrastructure/Verticals/DownloadClient/Transmission/TransmissionService.cs b/code/Infrastructure/Verticals/DownloadClient/Transmission/TransmissionService.cs index 1eabc24d..b9ea8343 100644 --- a/code/Infrastructure/Verticals/DownloadClient/Transmission/TransmissionService.cs +++ b/code/Infrastructure/Verticals/DownloadClient/Transmission/TransmissionService.cs @@ -7,7 +7,7 @@ using Common.Configuration.DownloadClient; using Common.Configuration.QueueCleaner; using Common.CustomDataTypes; using Common.Helpers; -using Domain.Enums; +using Data.Enums; using Infrastructure.Extensions; using Infrastructure.Interceptors; using Infrastructure.Verticals.ContentBlocker; diff --git a/code/Infrastructure/Verticals/DownloadRemover/Consumers/DownloadRemoverConsumer.cs b/code/Infrastructure/Verticals/DownloadRemover/Consumers/DownloadRemoverConsumer.cs index 390538ed..37fdd5ab 100644 --- a/code/Infrastructure/Verticals/DownloadRemover/Consumers/DownloadRemoverConsumer.cs +++ b/code/Infrastructure/Verticals/DownloadRemover/Consumers/DownloadRemoverConsumer.cs @@ -1,4 +1,4 @@ -using Domain.Models.Arr; +using Data.Models.Arr; using Infrastructure.Verticals.DownloadRemover.Interfaces; using Infrastructure.Verticals.DownloadRemover.Models; using MassTransit; diff --git a/code/Infrastructure/Verticals/DownloadRemover/Interfaces/IQueueItemRemover.cs b/code/Infrastructure/Verticals/DownloadRemover/Interfaces/IQueueItemRemover.cs index f7012e9d..e99e6e18 100644 --- a/code/Infrastructure/Verticals/DownloadRemover/Interfaces/IQueueItemRemover.cs +++ b/code/Infrastructure/Verticals/DownloadRemover/Interfaces/IQueueItemRemover.cs @@ -1,4 +1,4 @@ -using Domain.Models.Arr; +using Data.Models.Arr; using Infrastructure.Verticals.DownloadRemover.Models; namespace Infrastructure.Verticals.DownloadRemover.Interfaces; diff --git a/code/Infrastructure/Verticals/DownloadRemover/Models/QueueItemRemoveRequest.cs b/code/Infrastructure/Verticals/DownloadRemover/Models/QueueItemRemoveRequest.cs index b696819b..6061f628 100644 --- a/code/Infrastructure/Verticals/DownloadRemover/Models/QueueItemRemoveRequest.cs +++ b/code/Infrastructure/Verticals/DownloadRemover/Models/QueueItemRemoveRequest.cs @@ -1,7 +1,7 @@ using Common.Configuration.Arr; -using Domain.Enums; -using Domain.Models.Arr; -using Domain.Models.Arr.Queue; +using Data.Enums; +using Data.Models.Arr; +using Data.Models.Arr.Queue; namespace Infrastructure.Verticals.DownloadRemover.Models; diff --git a/code/Infrastructure/Verticals/DownloadRemover/QueueItemRemover.cs b/code/Infrastructure/Verticals/DownloadRemover/QueueItemRemover.cs index 3e47ef11..59579ae4 100644 --- a/code/Infrastructure/Verticals/DownloadRemover/QueueItemRemover.cs +++ b/code/Infrastructure/Verticals/DownloadRemover/QueueItemRemover.cs @@ -1,8 +1,8 @@ using Common.Configuration.Arr; using Common.Configuration.General; -using Domain.Enums; -using Domain.Models.Arr; -using Domain.Models.Arr.Queue; +using Data.Enums; +using Data.Models.Arr; +using Data.Models.Arr.Queue; using Infrastructure.Helpers; using Infrastructure.Verticals.Arr; using Infrastructure.Verticals.Context; diff --git a/code/Infrastructure/Verticals/ItemStriker/IStriker.cs b/code/Infrastructure/Verticals/ItemStriker/IStriker.cs index 5973bbac..acb3b4d5 100644 --- a/code/Infrastructure/Verticals/ItemStriker/IStriker.cs +++ b/code/Infrastructure/Verticals/ItemStriker/IStriker.cs @@ -1,4 +1,4 @@ -using Domain.Enums; +using Data.Enums; namespace Infrastructure.Verticals.ItemStriker; diff --git a/code/Infrastructure/Verticals/ItemStriker/Striker.cs b/code/Infrastructure/Verticals/ItemStriker/Striker.cs index a5e2c96c..3458602f 100644 --- a/code/Infrastructure/Verticals/ItemStriker/Striker.cs +++ b/code/Infrastructure/Verticals/ItemStriker/Striker.cs @@ -1,5 +1,6 @@ using Common.Helpers; -using Domain.Enums; +using Data.Enums; +using Infrastructure.Events; using Infrastructure.Helpers; using Infrastructure.Interceptors; using Infrastructure.Verticals.Context; @@ -15,12 +16,14 @@ public sealed class Striker : IStriker private readonly IMemoryCache _cache; private readonly MemoryCacheEntryOptions _cacheOptions; private readonly INotificationPublisher _notifier; + private readonly EventPublisher _eventPublisher; - public Striker(ILogger logger, IMemoryCache cache, INotificationPublisher notifier) + public Striker(ILogger logger, IMemoryCache cache, INotificationPublisher notifier, EventPublisher eventPublisher) { _logger = logger; _cache = cache; _notifier = notifier; + _eventPublisher = eventPublisher; _cacheOptions = new MemoryCacheEntryOptions() .SetSlidingExpiration(StaticConfiguration.TriggerValue + Constants.CacheLimitBuffer); } @@ -46,6 +49,12 @@ public sealed class Striker : IStriker _logger.LogInformation("item on strike number {strike} | reason {reason} | {name}", strikeCount, strikeType.ToString(), itemName); await _notifier.NotifyStrike(strikeType, strikeCount); + await _eventPublisher.PublishAsync( + "strike", + nameof(Striker), + $"Item '{itemName}' has been struck {strikeCount} times for reason '{strikeType}'", + severity: "Warning", + data: new { hash, itemName, strikeCount, strikeType }); _cache.Set(key, strikeCount, _cacheOptions); diff --git a/code/Infrastructure/Verticals/Jobs/GenericHandler.cs b/code/Infrastructure/Verticals/Jobs/GenericHandler.cs index ee9827b6..e9eab841 100644 --- a/code/Infrastructure/Verticals/Jobs/GenericHandler.cs +++ b/code/Infrastructure/Verticals/Jobs/GenericHandler.cs @@ -1,8 +1,8 @@ using Common.Configuration.Arr; using Common.Configuration.DownloadClient; -using Domain.Enums; -using Domain.Models.Arr; -using Domain.Models.Arr.Queue; +using Data.Enums; +using Data.Models.Arr; +using Data.Models.Arr.Queue; using Infrastructure.Configuration; using Infrastructure.Verticals.Arr; using Infrastructure.Verticals.DownloadClient; diff --git a/code/Infrastructure/Verticals/Notifications/INotificationPublisher.cs b/code/Infrastructure/Verticals/Notifications/INotificationPublisher.cs index 65bfb3e3..2c3ed654 100644 --- a/code/Infrastructure/Verticals/Notifications/INotificationPublisher.cs +++ b/code/Infrastructure/Verticals/Notifications/INotificationPublisher.cs @@ -1,4 +1,4 @@ -using Domain.Enums; +using Data.Enums; namespace Infrastructure.Verticals.Notifications; diff --git a/code/Infrastructure/Verticals/Notifications/Models/ArrNotification.cs b/code/Infrastructure/Verticals/Notifications/Models/ArrNotification.cs index 43886ed9..dd340cba 100644 --- a/code/Infrastructure/Verticals/Notifications/Models/ArrNotification.cs +++ b/code/Infrastructure/Verticals/Notifications/Models/ArrNotification.cs @@ -1,4 +1,4 @@ -using Domain.Enums; +using Data.Enums; namespace Infrastructure.Verticals.Notifications.Models; diff --git a/code/Infrastructure/Verticals/Notifications/NotificationPublisher.cs b/code/Infrastructure/Verticals/Notifications/NotificationPublisher.cs index db941893..33c12e08 100644 --- a/code/Infrastructure/Verticals/Notifications/NotificationPublisher.cs +++ b/code/Infrastructure/Verticals/Notifications/NotificationPublisher.cs @@ -1,8 +1,8 @@ using System.Globalization; using Common.Attributes; using Common.Configuration.Arr; -using Domain.Enums; -using Domain.Models.Arr.Queue; +using Data.Enums; +using Data.Models.Arr.Queue; using Infrastructure.Interceptors; using Infrastructure.Verticals.Context; using Infrastructure.Verticals.Notifications.Models; diff --git a/code/Infrastructure/Verticals/QueueCleaner/QueueCleaner.cs b/code/Infrastructure/Verticals/QueueCleaner/QueueCleaner.cs index 7c401530..b1f61aeb 100644 --- a/code/Infrastructure/Verticals/QueueCleaner/QueueCleaner.cs +++ b/code/Infrastructure/Verticals/QueueCleaner/QueueCleaner.cs @@ -1,9 +1,9 @@ using Common.Configuration.Arr; using Common.Configuration.DownloadClient; using Common.Configuration.QueueCleaner; -using Domain.Enums; -using Domain.Models.Arr; -using Domain.Models.Arr.Queue; +using Data.Enums; +using Data.Models.Arr; +using Data.Models.Arr.Queue; using Infrastructure.Configuration; using Infrastructure.Helpers; using Infrastructure.Services; diff --git a/code/UI/src/app/app.routes.ts b/code/UI/src/app/app.routes.ts index b9227638..b2f9e549 100644 --- a/code/UI/src/app/app.routes.ts +++ b/code/UI/src/app/app.routes.ts @@ -4,5 +4,6 @@ export const routes: Routes = [ { path: '', redirectTo: 'dashboard', pathMatch: 'full' }, { path: 'dashboard', loadComponent: () => import('./dashboard/dashboard-page/dashboard-page.component').then(m => m.DashboardPageComponent) }, { path: 'logs', loadComponent: () => import('./logging/logs-viewer/logs-viewer.component').then(m => m.LogsViewerComponent) }, + { path: 'events', loadComponent: () => import('./events/events-viewer/events-viewer.component').then(m => m.EventsViewerComponent) }, { path: 'settings', loadComponent: () => import('./settings/settings-page/settings-page.component').then(m => m.SettingsPageComponent) } ]; diff --git a/code/UI/src/app/events/events-viewer/events-viewer.component.ts b/code/UI/src/app/events/events-viewer/events-viewer.component.ts index fbe86dad..a24eac48 100644 --- a/code/UI/src/app/events/events-viewer/events-viewer.component.ts +++ b/code/UI/src/app/events/events-viewer/events-viewer.component.ts @@ -20,7 +20,7 @@ import { MenuItem } from 'primeng/api'; // Services & Models import { EventHubService } from '../../core/services/event-hub.service'; -import { Event } from '../../core/models/event.models'; +import { Event as EventModel } from '../../core/models/event.models'; @Component({ selector: 'app-events-viewer', @@ -57,7 +57,7 @@ export class EventsViewerComponent implements OnInit, OnDestroy { @ViewChild('exportMenu') exportMenu: any; // Signals for reactive state - events = signal([]); + events = signal([]); isConnected = signal(false); autoScroll = signal(true); expandedEvents: { [key: number]: boolean } = {}; @@ -129,7 +129,7 @@ export class EventsViewerComponent implements OnInit, OnDestroy { // Subscribe to events this.eventHubService.getEvents() .pipe(takeUntil(this.destroy$)) - .subscribe((events: Event[]) => { + .subscribe((events: EventModel[]) => { this.events.set(events); if (this.autoScroll()) { this.scrollToBottom(); @@ -242,9 +242,9 @@ export class EventsViewerComponent implements OnInit, OnDestroy { /** * Toggle expansion of an event entry */ - toggleEventExpansion(index: number, event?: Event): void { - if (event) { - event.stopPropagation(); + toggleEventExpansion(index: number, domEvent?: MouseEvent): void { + if (domEvent) { + domEvent.stopPropagation(); } this.expandedEvents[index] = !this.expandedEvents[index]; } @@ -252,8 +252,8 @@ export class EventsViewerComponent implements OnInit, OnDestroy { /** * Copy a specific event entry to clipboard */ - copyEventEntry(event: Event, clickEvent: Event): void { - clickEvent.stopPropagation(); + copyEventEntry(event: EventModel, domEvent: MouseEvent): void { + domEvent.stopPropagation(); const timestamp = new Date(event.timestamp).toISOString(); let content = `[${timestamp}] [${event.severity}] [${event.eventType}] [${event.source}] ${event.message}`; diff --git a/code/UI/src/app/layout/sidebar-content/sidebar-content.component.html b/code/UI/src/app/layout/sidebar-content/sidebar-content.component.html index e2c7d6ad..a152826e 100644 --- a/code/UI/src/app/layout/sidebar-content/sidebar-content.component.html +++ b/code/UI/src/app/layout/sidebar-content/sidebar-content.component.html @@ -34,6 +34,12 @@ Logs + + + Events +