mirror of
				https://github.com/Kareadita/Kavita.git
				synced 2025-10-31 10:37:04 -04:00 
			
		
		
		
	* Implemented a new widget to show when operations are occuring in the backend (tasks + progress events). Fixed an oversight on progress reporting where I sent 100F instead of 1F. * Hooked in more progress events for tasks on the backend. Cleaned up code and integrated some RBS into it. CSS needed. * Show a colored icon when events are active * Added some styling to the progress widget
		
			
				
	
	
		
			152 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			152 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using API.DTOs.Update;
 | |
| 
 | |
| namespace API.SignalR
 | |
| {
 | |
|     public static class MessageFactory
 | |
|     {
 | |
|         public static SignalRMessage ScanSeriesEvent(int seriesId, string seriesName)
 | |
|         {
 | |
|             return new SignalRMessage()
 | |
|             {
 | |
|                 Name = SignalREvents.ScanSeries,
 | |
|                 Body = new
 | |
|                 {
 | |
|                     SeriesId = seriesId,
 | |
|                     SeriesName = seriesName
 | |
|                 }
 | |
|             };
 | |
|         }
 | |
| 
 | |
|         public static SignalRMessage SeriesAddedEvent(int seriesId, string seriesName, int libraryId)
 | |
|         {
 | |
|             return new SignalRMessage()
 | |
|             {
 | |
|                 Name = SignalREvents.SeriesAdded,
 | |
|                 Body = new
 | |
|                 {
 | |
|                     SeriesId = seriesId,
 | |
|                     SeriesName = seriesName,
 | |
|                     LibraryId = libraryId
 | |
|                 }
 | |
|             };
 | |
|         }
 | |
| 
 | |
|         public static SignalRMessage SeriesRemovedEvent(int seriesId, string seriesName, int libraryId)
 | |
|         {
 | |
|             return new SignalRMessage()
 | |
|             {
 | |
|                 Name = SignalREvents.SeriesRemoved,
 | |
|                 Body = new
 | |
|                 {
 | |
|                     SeriesId = seriesId,
 | |
|                     SeriesName = seriesName,
 | |
|                     LibraryId = libraryId
 | |
|                 }
 | |
|             };
 | |
|         }
 | |
| 
 | |
|         public static SignalRMessage ScanLibraryProgressEvent(int libraryId, float progress)
 | |
|         {
 | |
|             return new SignalRMessage()
 | |
|             {
 | |
|                 Name = SignalREvents.ScanLibrary,
 | |
|                 Body = new
 | |
|                 {
 | |
|                     LibraryId = libraryId,
 | |
|                     Progress = progress,
 | |
|                     EventTime = DateTime.Now
 | |
|                 }
 | |
|             };
 | |
|         }
 | |
| 
 | |
|         public static SignalRMessage RefreshMetadataProgressEvent(int libraryId, float progress)
 | |
|         {
 | |
|             return new SignalRMessage()
 | |
|             {
 | |
|                 Name = SignalREvents.RefreshMetadataProgress,
 | |
|                 Body = new
 | |
|                 {
 | |
|                     LibraryId = libraryId,
 | |
|                     Progress = progress,
 | |
|                     EventTime = DateTime.Now
 | |
|                 }
 | |
|             };
 | |
|         }
 | |
| 
 | |
| 
 | |
| 
 | |
|         public static SignalRMessage RefreshMetadataEvent(int libraryId, int seriesId)
 | |
|         {
 | |
|             return new SignalRMessage()
 | |
|             {
 | |
|                 Name = SignalREvents.RefreshMetadata,
 | |
|                 Body = new
 | |
|                 {
 | |
|                     SeriesId = seriesId,
 | |
|                     LibraryId = libraryId
 | |
|                 }
 | |
|             };
 | |
|         }
 | |
| 
 | |
|         public static SignalRMessage BackupDatabaseProgressEvent(float progress)
 | |
|         {
 | |
|             return new SignalRMessage()
 | |
|             {
 | |
|                 Name = SignalREvents.BackupDatabaseProgress,
 | |
|                 Body = new
 | |
|                 {
 | |
|                     Progress = progress
 | |
|                 }
 | |
|             };
 | |
|         }
 | |
|         public static SignalRMessage CleanupProgressEvent(float progress)
 | |
|         {
 | |
|             return new SignalRMessage()
 | |
|             {
 | |
|                 Name = SignalREvents.CleanupProgress,
 | |
|                 Body = new
 | |
|                 {
 | |
|                     Progress = progress
 | |
|                 }
 | |
|             };
 | |
|         }
 | |
| 
 | |
| 
 | |
| 
 | |
|         public static SignalRMessage UpdateVersionEvent(UpdateNotificationDto update)
 | |
|         {
 | |
|             return new SignalRMessage
 | |
|             {
 | |
|                 Name = SignalREvents.UpdateVersion,
 | |
|                 Body = update
 | |
|             };
 | |
|         }
 | |
| 
 | |
|         public static SignalRMessage SeriesAddedToCollection(int tagId, int seriesId)
 | |
|         {
 | |
|             return new SignalRMessage
 | |
|             {
 | |
|                 Name = SignalREvents.UpdateVersion,
 | |
|                 Body = new
 | |
|                 {
 | |
|                     TagId = tagId,
 | |
|                     SeriesId = seriesId
 | |
|                 }
 | |
|             };
 | |
|         }
 | |
| 
 | |
|         public static SignalRMessage ScanLibraryError(int libraryId)
 | |
|         {
 | |
|             return new SignalRMessage
 | |
|             {
 | |
|                 Name = SignalREvents.ScanLibraryError,
 | |
|                 Body = new
 | |
|                 {
 | |
|                     LibraryId = libraryId,
 | |
|                 }
 | |
|             };
 | |
|         }
 | |
|     }
 | |
| }
 |