Cleanup from the Release (#2127)

* Added an FAQ link on the Kavita+ tab.

* Don't query Kavita+ for ratings on comic libraries as there is no upstream provider yet.

* Jumpbar keys are a little hard to click

* Fixed an issue where libraries that don't allow scrobbling could be scrobbled when generating past history with read events.

* Made the min/max release year on metadata filter number and removed the spin arrows for styling.

* Fixed disable tabs color contrast due to bootstrap undocumented change.

* Refactored whole codebase to unify caching mechanism. Upped the default cache memory amount to 75 to account for the extra data load. Still LRU.

Fixed an issue where Cache key was using Port instead.

Refactored all the Configuration code to use strongly typed deserialization.

* Fixed an issue where get latest progress would throw an exception if there was no progress due to LINQ and MAX query.

* Fixed a bug where Send to Device wasn't present on Series cards.

* Hooked up the ability to change the cache size for Kavita via the UI.
This commit is contained in:
Joe Milazzo 2023-07-12 16:06:30 -05:00 committed by GitHub
parent 1ed8889d08
commit 81da9dc444
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 402 additions and 272 deletions

View File

@ -11,4 +11,11 @@ public static class EasyCacheProfiles
/// If a user's license is valid
/// </summary>
public const string License = "license";
/// <summary>
/// Cache the libraries on the server
/// </summary>
public const string Library = "library";
public const string KavitaPlusReviews = "kavita+reviews";
public const string KavitaPlusRecommendations = "kavita+recommendations";
public const string KavitaPlusRatings = "kavita+ratings";
}

View File

@ -88,7 +88,8 @@ public class DeviceController : BaseApiController
return BadRequest("Send to device cannot be used with Kavita's email service. Please configure your own.");
var userId = await _unitOfWork.UserRepository.GetUserIdByUsernameAsync(User.GetUsername());
await _eventHub.SendMessageToAsync(MessageFactory.NotificationProgress, MessageFactory.SendingToDeviceEvent($"Transferring files to your device", "started"), userId);
await _eventHub.SendMessageToAsync(MessageFactory.NotificationProgress,
MessageFactory.SendingToDeviceEvent($"Transferring files to your device", "started"), userId);
try
{
var success = await _deviceService.SendTo(dto.ChapterIds, dto.DeviceId);
@ -100,7 +101,8 @@ public class DeviceController : BaseApiController
}
finally
{
await _eventHub.SendMessageToAsync(MessageFactory.SendingToDevice, MessageFactory.SendingToDeviceEvent($"Transferring files to your device", "ended"), userId);
await _eventHub.SendMessageToAsync(MessageFactory.SendingToDevice,
MessageFactory.SendingToDeviceEvent($"Transferring files to your device", "ended"), userId);
}
return BadRequest("There was an error sending the file to the device");
@ -108,6 +110,42 @@ public class DeviceController : BaseApiController
[HttpPost("send-series-to")]
public async Task<ActionResult> SendSeriesToDevice(SendSeriesToDeviceDto dto)
{
if (dto.SeriesId <= 0) return BadRequest("SeriesId must be greater than 0");
if (dto.DeviceId < 0) return BadRequest("DeviceId must be greater than 0");
if (await _emailService.IsDefaultEmailService())
return BadRequest("Send to device cannot be used with Kavita's email service. Please configure your own.");
var userId = await _unitOfWork.UserRepository.GetUserIdByUsernameAsync(User.GetUsername());
await _eventHub.SendMessageToAsync(MessageFactory.NotificationProgress, MessageFactory.SendingToDeviceEvent($"Transferring files to your device", "started"), userId);
var series =
await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(dto.SeriesId,
SeriesIncludes.Volumes | SeriesIncludes.Chapters);
if (series == null) return BadRequest("Series doesn't Exist");
var chapterIds = series.Volumes.SelectMany(v => v.Chapters.Select(c => c.Id)).ToList();
try
{
var success = await _deviceService.SendTo(chapterIds, dto.DeviceId);
if (success) return Ok();
}
catch (KavitaException ex)
{
return BadRequest(ex.Message);
}
finally
{
await _eventHub.SendMessageToAsync(MessageFactory.SendingToDevice, MessageFactory.SendingToDeviceEvent($"Transferring files to your device", "ended"), userId);
}
return BadRequest("There was an error sending the file(s) to the device");
}
}

View File

@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using API.Constants;
using API.Data;
using API.Data.Repositories;
using API.DTOs;
@ -18,11 +18,10 @@ using API.Services;
using API.Services.Tasks.Scanner;
using API.SignalR;
using AutoMapper;
using EasyCaching.Core;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using TaskScheduler = API.Services.TaskScheduler;
namespace API.Controllers;
@ -37,12 +36,13 @@ public class LibraryController : BaseApiController
private readonly IUnitOfWork _unitOfWork;
private readonly IEventHub _eventHub;
private readonly ILibraryWatcher _libraryWatcher;
private readonly IMemoryCache _memoryCache;
private readonly IEasyCachingProvider _libraryCacheProvider;
private const string CacheKey = "library_";
public LibraryController(IDirectoryService directoryService,
ILogger<LibraryController> logger, IMapper mapper, ITaskScheduler taskScheduler,
IUnitOfWork unitOfWork, IEventHub eventHub, ILibraryWatcher libraryWatcher, IMemoryCache memoryCache)
IUnitOfWork unitOfWork, IEventHub eventHub, ILibraryWatcher libraryWatcher,
IEasyCachingProviderFactory cachingProviderFactory)
{
_directoryService = directoryService;
_logger = logger;
@ -51,7 +51,8 @@ public class LibraryController : BaseApiController
_unitOfWork = unitOfWork;
_eventHub = eventHub;
_libraryWatcher = libraryWatcher;
_memoryCache = memoryCache;
_libraryCacheProvider = cachingProviderFactory.GetCachingProvider(EasyCacheProfiles.Library);
}
/// <summary>
@ -102,7 +103,7 @@ public class LibraryController : BaseApiController
_taskScheduler.ScanLibrary(library.Id);
await _eventHub.SendMessageAsync(MessageFactory.LibraryModified,
MessageFactory.LibraryModifiedEvent(library.Id, "create"), false);
_memoryCache.RemoveByPrefix(CacheKey);
await _libraryCacheProvider.RemoveByPrefixAsync(CacheKey);
return Ok();
}
@ -134,23 +135,19 @@ public class LibraryController : BaseApiController
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult<IEnumerable<LibraryDto>> GetLibraries()
public async Task<ActionResult<IEnumerable<LibraryDto>>> GetLibraries()
{
var username = User.GetUsername();
if (string.IsNullOrEmpty(username)) return Unauthorized();
var cacheKey = CacheKey + username;
if (_memoryCache.TryGetValue(cacheKey, out string cachedValue))
{
return Ok(JsonConvert.DeserializeObject<IEnumerable<LibraryDto>>(cachedValue));
}
var result = await _libraryCacheProvider.GetAsync<IEnumerable<LibraryDto>>(cacheKey);
if (result.HasValue) return Ok(result.Value);
var ret = _unitOfWork.LibraryRepository.GetLibraryDtosForUsernameAsync(username);
var cacheEntryOptions = new MemoryCacheEntryOptions()
.SetSize(1)
.SetAbsoluteExpiration(TimeSpan.FromHours(24));
_memoryCache.Set(cacheKey, JsonConvert.SerializeObject(ret), cacheEntryOptions);
await _libraryCacheProvider.SetAsync(CacheKey, ret, TimeSpan.FromHours(24));
_logger.LogDebug("Caching libraries for {Key}", cacheKey);
return Ok(ret);
}
@ -211,7 +208,7 @@ public class LibraryController : BaseApiController
{
_logger.LogInformation("Added: {SelectedLibraries} to {Username}",libraryString, updateLibraryForUserDto.Username);
// Bust cache
_memoryCache.RemoveByPrefix(CacheKey);
await _libraryCacheProvider.RemoveByPrefixAsync(CacheKey);
return Ok(_mapper.Map<MemberDto>(user));
}
@ -334,7 +331,7 @@ public class LibraryController : BaseApiController
await _unitOfWork.CommitAsync();
_memoryCache.RemoveByPrefix(CacheKey);
await _libraryCacheProvider.RemoveByPrefixAsync(CacheKey);
if (chapterIds.Any())
{
@ -433,7 +430,7 @@ public class LibraryController : BaseApiController
await _eventHub.SendMessageAsync(MessageFactory.LibraryModified,
MessageFactory.LibraryModifiedEvent(library.Id, "update"), false);
_memoryCache.RemoveByPrefix(CacheKey);
await _libraryCacheProvider.RemoveByPrefixAsync(CacheKey);
return Ok();

View File

@ -1,15 +1,12 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using API.Constants;
using API.DTOs;
using API.DTOs.SeriesDetail;
using API.Services.Plus;
using EasyCaching.Core;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
namespace API.Controllers;
@ -20,16 +17,18 @@ public class RatingController : BaseApiController
{
private readonly ILicenseService _licenseService;
private readonly IRatingService _ratingService;
private readonly IMemoryCache _cache;
private readonly ILogger<RatingController> _logger;
public const string CacheKey = "rating-";
private readonly IEasyCachingProvider _cacheProvider;
public const string CacheKey = "rating_";
public RatingController(ILicenseService licenseService, IRatingService ratingService, IMemoryCache memoryCache, ILogger<RatingController> logger)
public RatingController(ILicenseService licenseService, IRatingService ratingService,
ILogger<RatingController> logger, IEasyCachingProviderFactory cachingProviderFactory)
{
_licenseService = licenseService;
_ratingService = ratingService;
_cache = memoryCache;
_logger = logger;
_cacheProvider = cachingProviderFactory.GetCachingProvider(EasyCacheProfiles.KavitaPlusRatings);
}
/// <summary>
@ -47,27 +46,16 @@ public class RatingController : BaseApiController
}
var cacheKey = CacheKey + seriesId;
var setCache = false;
IEnumerable<RatingDto> ratings;
if (_cache.TryGetValue(cacheKey, out string cachedData))
var results = await _cacheProvider.GetAsync<IEnumerable<RatingDto>>(cacheKey);
if (results.HasValue)
{
ratings = JsonConvert.DeserializeObject<IEnumerable<RatingDto>>(cachedData);
}
else
{
ratings = await _ratingService.GetRatings(seriesId);
setCache = true;
}
if (setCache)
{
var cacheEntryOptions = new MemoryCacheEntryOptions()
.SetSize(1)
.SetAbsoluteExpiration(TimeSpan.FromHours(24));
_cache.Set(cacheKey, JsonConvert.SerializeObject(ratings), cacheEntryOptions);
_logger.LogDebug("Caching external rating for {Key}", cacheKey);
return Ok(results.Value);
}
var ratings = await _ratingService.GetRatings(seriesId);
await _cacheProvider.SetAsync(cacheKey, ratings, TimeSpan.FromHours(24));
_logger.LogDebug("Caching external rating for {Key}", cacheKey);
return Ok(ratings);
}
}

View File

@ -9,6 +9,7 @@ using API.DTOs.Recommendation;
using API.Extensions;
using API.Helpers;
using API.Services.Plus;
using EasyCaching.Core;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Newtonsoft.Json;
@ -20,16 +21,16 @@ public class RecommendedController : BaseApiController
private readonly IUnitOfWork _unitOfWork;
private readonly IRecommendationService _recommendationService;
private readonly ILicenseService _licenseService;
private readonly IMemoryCache _cache;
public const string CacheKey = "recommendation-";
private readonly IEasyCachingProvider _cacheProvider;
public const string CacheKey = "recommendation_";
public RecommendedController(IUnitOfWork unitOfWork, IRecommendationService recommendationService,
ILicenseService licenseService, IMemoryCache cache)
ILicenseService licenseService, IEasyCachingProviderFactory cachingProviderFactory)
{
_unitOfWork = unitOfWork;
_recommendationService = recommendationService;
_licenseService = licenseService;
_cache = cache;
_cacheProvider = cachingProviderFactory.GetCachingProvider(EasyCacheProfiles.KavitaPlusRecommendations);
}
/// <summary>
@ -53,16 +54,14 @@ public class RecommendedController : BaseApiController
}
var cacheKey = $"{CacheKey}-{seriesId}-{userId}";
if (_cache.TryGetValue(cacheKey, out string cachedData))
var results = await _cacheProvider.GetAsync<RecommendationDto>(cacheKey);
if (results.HasValue)
{
return Ok(JsonConvert.DeserializeObject<RecommendationDto>(cachedData));
return Ok(results.Value);
}
var ret = await _recommendationService.GetRecommendationsForSeries(userId, seriesId);
var cacheEntryOptions = new MemoryCacheEntryOptions()
.SetSize(ret.OwnedSeries.Count() + ret.ExternalSeries.Count())
.SetAbsoluteExpiration(TimeSpan.FromHours(10));
_cache.Set(cacheKey, JsonConvert.SerializeObject(ret), cacheEntryOptions);
await _cacheProvider.SetAsync(cacheKey, ret, TimeSpan.FromHours(10));
return Ok(ret);
}

View File

@ -11,6 +11,7 @@ using API.Helpers.Builders;
using API.Services;
using API.Services.Plus;
using AutoMapper;
using EasyCaching.Core;
using Hangfire;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
@ -26,20 +27,22 @@ public class ReviewController : BaseApiController
private readonly ILicenseService _licenseService;
private readonly IMapper _mapper;
private readonly IReviewService _reviewService;
private readonly IMemoryCache _cache;
private readonly IScrobblingService _scrobblingService;
public const string CacheKey = "review-";
private readonly IEasyCachingProvider _cacheProvider;
public const string CacheKey = "review_";
public ReviewController(ILogger<ReviewController> logger, IUnitOfWork unitOfWork, ILicenseService licenseService,
IMapper mapper, IReviewService reviewService, IMemoryCache cache, IScrobblingService scrobblingService)
IMapper mapper, IReviewService reviewService, IScrobblingService scrobblingService,
IEasyCachingProviderFactory cachingProviderFactory)
{
_logger = logger;
_unitOfWork = unitOfWork;
_licenseService = licenseService;
_mapper = mapper;
_reviewService = reviewService;
_cache = cache;
_scrobblingService = scrobblingService;
_cacheProvider = cachingProviderFactory.GetCachingProvider(EasyCacheProfiles.KavitaPlusReviews);
}
@ -63,15 +66,26 @@ public class ReviewController : BaseApiController
var cacheKey = CacheKey + seriesId;
IEnumerable<UserReviewDto> externalReviews;
var setCache = false;
if (_cache.TryGetValue(cacheKey, out string cachedData))
var result = await _cacheProvider.GetAsync<IEnumerable<UserReviewDto>>(cacheKey);
if (result.HasValue)
{
externalReviews = JsonConvert.DeserializeObject<IEnumerable<UserReviewDto>>(cachedData);
externalReviews = result.Value;
}
else
{
externalReviews = await _reviewService.GetReviewsForSeries(userId, seriesId);
setCache = true;
}
// if (_cache.TryGetValue(cacheKey, out string cachedData))
// {
// externalReviews = JsonConvert.DeserializeObject<IEnumerable<UserReviewDto>>(cachedData);
// }
// else
// {
// externalReviews = await _reviewService.GetReviewsForSeries(userId, seriesId);
// setCache = true;
// }
// Fetch external reviews and splice them in
foreach (var r in externalReviews)
@ -81,10 +95,11 @@ public class ReviewController : BaseApiController
if (setCache)
{
var cacheEntryOptions = new MemoryCacheEntryOptions()
.SetSize(userRatings.Count)
.SetAbsoluteExpiration(TimeSpan.FromHours(10));
_cache.Set(cacheKey, JsonConvert.SerializeObject(externalReviews), cacheEntryOptions);
// var cacheEntryOptions = new MemoryCacheEntryOptions()
// .SetSize(userRatings.Count)
// .SetAbsoluteExpiration(TimeSpan.FromHours(10));
//_cache.Set(cacheKey, JsonConvert.SerializeObject(externalReviews), cacheEntryOptions);
await _cacheProvider.SetAsync(cacheKey, externalReviews, TimeSpan.FromHours(10));
_logger.LogDebug("Caching external reviews for {Key}", cacheKey);
}

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using API.Constants;
@ -15,12 +14,11 @@ using API.Extensions;
using API.Helpers;
using API.Services;
using API.Services.Plus;
using Kavita.Common;
using EasyCaching.Core;
using Kavita.Common.Extensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
namespace API.Controllers;
@ -31,19 +29,25 @@ public class SeriesController : BaseApiController
private readonly ITaskScheduler _taskScheduler;
private readonly IUnitOfWork _unitOfWork;
private readonly ISeriesService _seriesService;
private readonly IMemoryCache _cache;
private readonly ILicenseService _licenseService;
private readonly IEasyCachingProvider _ratingCacheProvider;
private readonly IEasyCachingProvider _reviewCacheProvider;
private readonly IEasyCachingProvider _recommendationCacheProvider;
public SeriesController(ILogger<SeriesController> logger, ITaskScheduler taskScheduler, IUnitOfWork unitOfWork,
ISeriesService seriesService, IMemoryCache cache, ILicenseService licenseService)
ISeriesService seriesService, ILicenseService licenseService,
IEasyCachingProviderFactory cachingProviderFactory)
{
_logger = logger;
_taskScheduler = taskScheduler;
_unitOfWork = unitOfWork;
_seriesService = seriesService;
_cache = cache;
_licenseService = licenseService;
_ratingCacheProvider = cachingProviderFactory.GetCachingProvider(EasyCacheProfiles.KavitaPlusRatings);
_reviewCacheProvider = cachingProviderFactory.GetCachingProvider(EasyCacheProfiles.KavitaPlusReviews);
_recommendationCacheProvider = cachingProviderFactory.GetCachingProvider(EasyCacheProfiles.KavitaPlusRecommendations);
}
[HttpPost]
@ -344,12 +348,13 @@ public class SeriesController : BaseApiController
if (await _licenseService.HasActiveLicense())
{
_logger.LogDebug("Clearing cache as series weblinks may have changed");
_cache.Remove(ReviewController.CacheKey + updateSeriesMetadataDto.SeriesMetadata.SeriesId);
_cache.Remove(RatingController.CacheKey + updateSeriesMetadataDto.SeriesMetadata.SeriesId);
await _reviewCacheProvider.RemoveAsync(ReviewController.CacheKey + updateSeriesMetadataDto.SeriesMetadata.SeriesId);
await _ratingCacheProvider.RemoveAsync(RatingController.CacheKey + updateSeriesMetadataDto.SeriesMetadata.SeriesId);
var allUsers = (await _unitOfWork.UserRepository.GetAllUsersAsync()).Select(s => s.Id);
foreach (var userId in allUsers)
{
_cache.Remove(RecommendedController.CacheKey + $"{updateSeriesMetadataDto.SeriesMetadata.SeriesId}-{userId}");
await _recommendationCacheProvider.RemoveAsync(RecommendedController.CacheKey + $"{updateSeriesMetadataDto.SeriesMetadata.SeriesId}-{userId}");
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using API.Constants;
using API.Data;
using API.DTOs.Jobs;
using API.DTOs.MediaErrors;
@ -13,6 +14,7 @@ using API.Extensions;
using API.Helpers;
using API.Services;
using API.Services.Tasks;
using EasyCaching.Core;
using Hangfire;
using Hangfire.Storage;
using Kavita.Common;
@ -38,12 +40,12 @@ public class ServerController : BaseApiController
private readonly IAccountService _accountService;
private readonly ITaskScheduler _taskScheduler;
private readonly IUnitOfWork _unitOfWork;
private readonly IMemoryCache _memoryCache;
private readonly IEasyCachingProviderFactory _cachingProviderFactory;
public ServerController(ILogger<ServerController> logger,
IBackupService backupService, IArchiveService archiveService, IVersionUpdaterService versionUpdaterService, IStatsService statsService,
ICleanupService cleanupService, IScannerService scannerService, IAccountService accountService,
ITaskScheduler taskScheduler, IUnitOfWork unitOfWork, IMemoryCache memoryCache)
ITaskScheduler taskScheduler, IUnitOfWork unitOfWork, IEasyCachingProviderFactory cachingProviderFactory)
{
_logger = logger;
_backupService = backupService;
@ -55,7 +57,7 @@ public class ServerController : BaseApiController
_accountService = accountService;
_taskScheduler = taskScheduler;
_unitOfWork = unitOfWork;
_memoryCache = memoryCache;
_cachingProviderFactory = cachingProviderFactory;
}
/// <summary>
@ -244,10 +246,16 @@ public class ServerController : BaseApiController
/// <returns></returns>
[Authorize("RequireAdminRole")]
[HttpPost("bust-review-and-rec-cache")]
public ActionResult BustReviewAndRecCache()
public async Task<ActionResult> BustReviewAndRecCache()
{
_memoryCache.Clear();
return Ok();
_logger.LogInformation("Busting Kavita+ Cache");
var provider = _cachingProviderFactory.GetCachingProvider(EasyCacheProfiles.KavitaPlusReviews);
await provider.FlushAsync();
provider = _cachingProviderFactory.GetCachingProvider(EasyCacheProfiles.KavitaPlusRecommendations);
await provider.FlushAsync();
provider = _cachingProviderFactory.GetCachingProvider(EasyCacheProfiles.KavitaPlusRatings);
await provider.FlushAsync();
return Ok();
}

View File

@ -191,6 +191,14 @@ public class SettingsController : BaseApiController
_unitOfWork.SettingsRepository.Update(setting);
}
if (setting.Key == ServerSettingKey.CacheSize && updateSettingsDto.CacheSize + string.Empty != setting.Value)
{
setting.Value = updateSettingsDto.CacheSize + string.Empty;
// CacheSize is managed in appSetting.json
Configuration.CacheSize = updateSettingsDto.CacheSize;
_unitOfWork.SettingsRepository.Update(setting);
}
if (setting.Key == ServerSettingKey.IpAddresses && updateSettingsDto.IpAddresses != setting.Value)
{
if (OsInfo.IsDocker) continue;

View File

@ -0,0 +1,7 @@
namespace API.DTOs.Device;
public class SendSeriesToDeviceDto
{
public int DeviceId { get; set; }
public int SeriesId { get; set; }
}

View File

@ -72,4 +72,8 @@ public class ServerSettingDto
/// The Host name (ie Reverse proxy domain name) for the server
/// </summary>
public string HostName { get; set; }
/// <summary>
/// The size in MB for Caching API data
/// </summary>
public long CacheSize { get; set; }
}

View File

@ -136,7 +136,8 @@ public class AppUserProgressRepository : IAppUserProgressRepository
{
return await _context.AppUserProgresses
.Select(d => d.LastModifiedUtc)
.MaxAsync();
.OrderByDescending(d => d)
.FirstOrDefaultAsync();
}
public async Task<ProgressDto> GetUserProgressDtoAsync(int chapterId, int userId)

View File

@ -89,10 +89,10 @@ public static class Seed
},
new()
{
Key = ServerSettingKey.Port, Value = "5000"
Key = ServerSettingKey.Port, Value = Configuration.DefaultHttpPort + string.Empty
}, // Not used from DB, but DB is sync with appSettings.json
new() {
Key = ServerSettingKey.IpAddresses, Value = "0.0.0.0,::"
Key = ServerSettingKey.IpAddresses, Value = Configuration.DefaultIpAddresses
}, // Not used from DB, but DB is sync with appSettings.json
new() {Key = ServerSettingKey.AllowStatCollection, Value = "true"},
new() {Key = ServerSettingKey.EnableOpds, Value = "true"},
@ -108,6 +108,9 @@ public static class Seed
new() {Key = ServerSettingKey.HostName, Value = string.Empty},
new() {Key = ServerSettingKey.EncodeMediaAs, Value = EncodeFormat.PNG.ToString()},
new() {Key = ServerSettingKey.LicenseKey, Value = string.Empty},
new() {
Key = ServerSettingKey.CacheSize, Value = Configuration.DefaultCacheMemory + string.Empty
}, // Not used from DB, but DB is sync with appSettings.json
}.ToArray());
foreach (var defaultSetting in DefaultSettings)
@ -130,7 +133,6 @@ public static class Seed
directoryService.CacheDirectory + string.Empty;
context.ServerSetting.First(s => s.Key == ServerSettingKey.BackupDirectory).Value =
DirectoryService.BackupDirectory + string.Empty;
await context.SaveChangesAsync();
}

View File

@ -128,5 +128,10 @@ public enum ServerSettingKey
/// </summary>
[Description("LicenseKey")]
LicenseKey = 23,
/// <summary>
/// The size in MB for Caching API data
/// </summary>
[Description("Cache")]
CacheSize = 24,
}

View File

@ -79,6 +79,13 @@ public static class ApplicationServiceExtensions
{
options.UseInMemory(EasyCacheProfiles.Favicon);
options.UseInMemory(EasyCacheProfiles.License);
options.UseInMemory(EasyCacheProfiles.Library);
options.UseInMemory(EasyCacheProfiles.RevokedJwt);
// KavitaPlus stuff
options.UseInMemory(EasyCacheProfiles.KavitaPlusReviews);
options.UseInMemory(EasyCacheProfiles.KavitaPlusRecommendations);
options.UseInMemory(EasyCacheProfiles.KavitaPlusRatings);
});
services.AddMemoryCache(options =>

View File

@ -1,35 +0,0 @@
using System.Reflection;
using Microsoft.Extensions.Caching.Memory;
namespace API.Extensions;
public static class MemoryCacheExtensions
{
public static void RemoveByPrefix(this IMemoryCache memoryCache, string prefix)
{
if (memoryCache is not MemoryCache concreteMemoryCache) return;
var cacheEntriesCollectionInfo = typeof(MemoryCache)
.GetProperty("EntriesCollection", BindingFlags.NonPublic | BindingFlags.Instance);
var cacheEntriesCollection = cacheEntriesCollectionInfo?.GetValue(concreteMemoryCache) as dynamic;
if (cacheEntriesCollection == null) return;
foreach (var cacheItem in cacheEntriesCollection)
{
// Check if the cache key starts with the given prefix
if (cacheItem.GetType().GetProperty("Key").GetValue(cacheItem) is string cacheItemKey && cacheItemKey.StartsWith(prefix))
{
concreteMemoryCache.Remove(cacheItemKey);
}
}
}
public static void Clear(this IMemoryCache memoryCache)
{
if (memoryCache is MemoryCache concreteMemoryCache)
{
concreteMemoryCache.Clear();
}
}
}

View File

@ -70,6 +70,9 @@ public class ServerSettingConverter : ITypeConverter<IEnumerable<ServerSetting>,
case ServerSettingKey.HostName:
destination.HostName = row.Value;
break;
case ServerSettingKey.CacheSize:
destination.CacheSize = long.Parse(row.Value);
break;
}
}

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
using API.Data;
@ -40,6 +41,9 @@ public class RatingService : IRatingService
var license = await _unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.LicenseKey);
var series = await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(seriesId,
SeriesIncludes.Metadata | SeriesIncludes.Library | SeriesIncludes.Chapters | SeriesIncludes.Volumes);
// Don't send any ratings back for Comic libraries as Kavita+ doesn't have any providers for that
if (series == null || series.Library.Type == LibraryType.Comic) return ImmutableList<RatingDto>.Empty;
return await GetRatings(license.Value, series);
}

View File

@ -74,7 +74,7 @@ public class RecommendationService : IRecommendationService
var series =
await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(seriesId,
SeriesIncludes.Metadata | SeriesIncludes.Library | SeriesIncludes.Volumes | SeriesIncludes.Chapters);
if (series == null) return new RecommendationDto();
if (series == null || series.Library.Type == LibraryType.Comic) return new RecommendationDto();
var license = await _unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.LicenseKey);
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(userId);

View File

@ -466,10 +466,11 @@ public class ScrobblingService : IScrobblingService
var userIds = (await _unitOfWork.UserRepository.GetAllUsersAsync())
.Where(l => userId == 0 || userId == l.Id)
.Select(u => u.Id);
if (!await _licenseService.HasActiveLicense()) return;
foreach (var uId in userIds)
{
if (!await _licenseService.HasActiveLicense()) continue;
var wantToRead = await _unitOfWork.SeriesRepository.GetWantToReadForUserAsync(uId);
foreach (var wtr in wantToRead)
{
@ -505,6 +506,7 @@ public class ScrobblingService : IScrobblingService
foreach (var series in seriesWithProgress)
{
if (!libAllowsScrobbling[series.LibraryId]) continue;
await ScrobbleReadingUpdate(uId, series.Id);
}
@ -687,7 +689,10 @@ public class ScrobblingService : IScrobblingService
_logger.LogDebug("Processing Reading Events: {Count} / {Total}", progressCounter, totalProgress);
progressCounter++;
// Check if this media item can even be processed for this user
if (!DoesUserHaveProviderAndValid(evt)) continue;
if (!DoesUserHaveProviderAndValid(evt))
{
continue;
}
var count = await SetAndCheckRateLimit(userRateLimits, evt.AppUser, license.Value);
if (count == 0)
{

View File

@ -3,5 +3,5 @@
"Port": 5000,
"IpAddresses": "",
"BaseUrl": "/",
"Cache": 50
"Cache": 90
}

View File

@ -13,7 +13,7 @@ public static class Configuration
public const int DefaultHttpPort = 5000;
public const int DefaultTimeOutSecs = 90;
public const string DefaultXFrameOptions = "SAMEORIGIN";
public const int DefaultCacheMemory = 50;
public const long DefaultCacheMemory = 75;
private static readonly string AppSettingsFilename = Path.Join("config", GetAppSettingFilename());
public static string KavitaPlusApiUrl = "https://plus.kavitareader.com";
@ -42,7 +42,7 @@ public static class Configuration
set => SetBaseUrl(GetAppSettingFilename(), value);
}
public static int CacheSize
public static long CacheSize
{
get => GetCacheSize(GetAppSettingFilename());
set => SetCacheSize(GetAppSettingFilename(), value);
@ -69,15 +69,8 @@ public static class Configuration
try
{
var json = File.ReadAllText(filePath);
var jsonObj = JsonSerializer.Deserialize<dynamic>(json);
const string key = "TokenKey";
if (jsonObj.TryGetProperty(key, out JsonElement tokenElement))
{
return tokenElement.GetString();
}
return string.Empty;
var jsonObj = JsonSerializer.Deserialize<AppSettings>(json);
return jsonObj.TokenKey;
}
catch (Exception ex)
{
@ -144,29 +137,23 @@ public static class Configuration
private static int GetPort(string filePath)
{
const int defaultPort = 5000;
if (OsInfo.IsDocker)
{
return defaultPort;
return DefaultHttpPort;
}
try
{
var json = File.ReadAllText(filePath);
var jsonObj = JsonSerializer.Deserialize<dynamic>(json);
const string key = "Port";
if (jsonObj.TryGetProperty(key, out JsonElement tokenElement))
{
return tokenElement.GetInt32();
}
var jsonObj = JsonSerializer.Deserialize<AppSettings>(json);
return jsonObj.Port;
}
catch (Exception ex)
{
Console.WriteLine("Error writing app settings: " + ex.Message);
}
return defaultPort;
return DefaultHttpPort;
}
#endregion
@ -204,13 +191,8 @@ public static class Configuration
try
{
var json = File.ReadAllText(filePath);
var jsonObj = JsonSerializer.Deserialize<dynamic>(json);
const string key = "IpAddresses";
if (jsonObj.TryGetProperty(key, out JsonElement tokenElement))
{
return tokenElement.GetString();
}
var jsonObj = JsonSerializer.Deserialize<AppSettings>(json);
return jsonObj.IpAddresses;
}
catch (Exception ex)
{
@ -224,29 +206,23 @@ public static class Configuration
#region BaseUrl
private static string GetBaseUrl(string filePath)
{
try
{
var json = File.ReadAllText(filePath);
var jsonObj = JsonSerializer.Deserialize<dynamic>(json);
const string key = "BaseUrl";
var jsonObj = JsonSerializer.Deserialize<AppSettings>(json);
if (jsonObj.TryGetProperty(key, out JsonElement tokenElement))
var baseUrl = jsonObj.BaseUrl;
if (!string.IsNullOrEmpty(baseUrl))
{
var baseUrl = tokenElement.GetString();
if (!string.IsNullOrEmpty(baseUrl))
{
baseUrl = !baseUrl.StartsWith('/')
? $"/{baseUrl}"
: baseUrl;
baseUrl = !baseUrl.StartsWith('/')
? $"/{baseUrl}"
: baseUrl;
baseUrl = !baseUrl.EndsWith('/')
? $"{baseUrl}/"
: baseUrl;
baseUrl = !baseUrl.EndsWith('/')
? $"{baseUrl}/"
: baseUrl;
return baseUrl;
}
return DefaultBaseUrl;
return baseUrl;
}
}
catch (Exception ex)
@ -284,7 +260,7 @@ public static class Configuration
#endregion
#region CacheSize
private static void SetCacheSize(string filePath, int cache)
private static void SetCacheSize(string filePath, long cache)
{
if (cache <= 0) return;
try
@ -301,18 +277,14 @@ public static class Configuration
}
}
private static int GetCacheSize(string filePath)
private static long GetCacheSize(string filePath)
{
try
{
var json = File.ReadAllText(filePath);
var jsonObj = JsonSerializer.Deserialize<dynamic>(json);
const string key = "Port";
var jsonObj = JsonSerializer.Deserialize<AppSettings>(json);
if (jsonObj.TryGetProperty(key, out JsonElement tokenElement))
{
return tokenElement.GetInt32();
}
return jsonObj.Cache;
}
catch (Exception ex)
{
@ -336,14 +308,8 @@ public static class Configuration
try
{
var json = File.ReadAllText(filePath);
var jsonObj = JsonSerializer.Deserialize<dynamic>(json);
const string key = "XFrameOrigins";
if (jsonObj.TryGetProperty(key, out JsonElement tokenElement))
{
var origins = tokenElement.GetString();
return !string.IsNullOrEmpty(origins) ? origins : DefaultBaseUrl;
}
var jsonObj = JsonSerializer.Deserialize<AppSettings>(json);
return !string.IsNullOrEmpty(jsonObj.XFrameOrigins) ? jsonObj.XFrameOrigins : DefaultXFrameOptions;
}
catch (Exception ex)
{
@ -364,6 +330,8 @@ public static class Configuration
// ReSharper disable once MemberHidesStaticFromOuterClass
public string BaseUrl { get; set; }
// ReSharper disable once MemberHidesStaticFromOuterClass
public int Cache { get; set; }
public long Cache { get; set; }
// ReSharper disable once MemberHidesStaticFromOuterClass
public string XFrameOrigins { get; set; } = DefaultXFrameOptions;
}
}

View File

@ -40,7 +40,7 @@ export class ActionService implements OnDestroy {
private readingListModalRef: NgbModalRef | null = null;
private collectionModalRef: NgbModalRef | null = null;
constructor(private libraryService: LibraryService, private seriesService: SeriesService,
constructor(private libraryService: LibraryService, private seriesService: SeriesService,
private readerService: ReaderService, private toastr: ToastrService, private modalService: NgbModal,
private confirmService: ConfirmService, private memberService: MemberService, private deviceSerivce: DeviceService) { }
@ -53,7 +53,7 @@ export class ActionService implements OnDestroy {
* Request a file scan for a given Library
* @param library Partial Library, must have id and name populated
* @param callback Optional callback to perform actions after API completes
* @returns
* @returns
*/
async scanLibrary(library: Partial<Library>, callback?: LibraryActionCallback) {
if (!library.hasOwnProperty('id') || library.id === undefined) {
@ -76,7 +76,7 @@ export class ActionService implements OnDestroy {
* Request a refresh of Metadata for a given Library
* @param library Partial Library, must have id and name populated
* @param callback Optional callback to perform actions after API completes
* @returns
* @returns
*/
async refreshMetadata(library: Partial<Library>, callback?: LibraryActionCallback) {
if (!library.hasOwnProperty('id') || library.id === undefined) {
@ -112,7 +112,7 @@ export class ActionService implements OnDestroy {
* Request an analysis of files for a given Library (currently just word count)
* @param library Partial Library, must have id and name populated
* @param callback Optional callback to perform actions after API completes
* @returns
* @returns
*/
async analyzeFiles(library: Partial<Library>, callback?: LibraryActionCallback) {
if (!library.hasOwnProperty('id') || library.id === undefined) {
@ -285,7 +285,7 @@ export class ActionService implements OnDestroy {
* @param seriesId Series Id
* @param volumes Volumes, should have id, chapters and pagesRead populated
* @param chapters? Chapters, should have id
* @param callback Optional callback to perform actions after API completes
* @param callback Optional callback to perform actions after API completes
*/
markMultipleAsRead(seriesId: number, volumes: Array<Volume>, chapters?: Array<Chapter>, callback?: VoidActionCallback) {
this.readerService.markMultipleRead(seriesId, volumes.map(v => v.id), chapters?.map(c => c.id)).pipe(take(1)).subscribe(() => {
@ -306,7 +306,7 @@ export class ActionService implements OnDestroy {
* Mark all chapters and the volumes as Unread. All volumes must belong to a series
* @param seriesId Series Id
* @param volumes Volumes, should have id, chapters and pagesRead populated
* @param callback Optional callback to perform actions after API completes
* @param callback Optional callback to perform actions after API completes
*/
markMultipleAsUnread(seriesId: number, volumes: Array<Volume>, chapters?: Array<Chapter>, callback?: VoidActionCallback) {
this.readerService.markMultipleUnread(seriesId, volumes.map(v => v.id), chapters?.map(c => c.id)).pipe(take(1)).subscribe(() => {
@ -326,7 +326,7 @@ export class ActionService implements OnDestroy {
/**
* Mark all series as Read.
* @param series Series, should have id, pagesRead populated
* @param callback Optional callback to perform actions after API completes
* @param callback Optional callback to perform actions after API completes
*/
markMultipleSeriesAsRead(series: Array<Series>, callback?: VoidActionCallback) {
this.readerService.markMultipleSeriesRead(series.map(v => v.id)).pipe(take(1)).subscribe(() => {
@ -342,9 +342,9 @@ export class ActionService implements OnDestroy {
}
/**
* Mark all series as Unread.
* Mark all series as Unread.
* @param series Series, should have id, pagesRead populated
* @param callback Optional callback to perform actions after API completes
* @param callback Optional callback to perform actions after API completes
*/
markMultipleSeriesAsUnread(series: Array<Series>, callback?: VoidActionCallback) {
this.readerService.markMultipleSeriesUnread(series.map(v => v.id)).pipe(take(1)).subscribe(() => {
@ -425,9 +425,9 @@ export class ActionService implements OnDestroy {
/**
* Adds a set of series to a collection tag
* @param series
* @param callback
* @returns
* @param series
* @param callback
* @returns
*/
addMultipleSeriesToCollectionTag(series: Array<Series>, callback?: BooleanActionCallback) {
if (this.collectionModalRef != null) { return; }
@ -452,7 +452,7 @@ export class ActionService implements OnDestroy {
addSeriesToReadingList(series: Series, callback?: SeriesActionCallback) {
if (this.readingListModalRef != null) { return; }
this.readingListModalRef = this.modalService.open(AddToListModalComponent, { scrollable: true, size: 'md' });
this.readingListModalRef.componentInstance.seriesId = series.id;
this.readingListModalRef.componentInstance.seriesId = series.id;
this.readingListModalRef.componentInstance.title = series.name;
this.readingListModalRef.componentInstance.type = ADD_FLOW.Series;
@ -474,7 +474,7 @@ export class ActionService implements OnDestroy {
addVolumeToReadingList(volume: Volume, seriesId: number, callback?: VolumeActionCallback) {
if (this.readingListModalRef != null) { return; }
this.readingListModalRef = this.modalService.open(AddToListModalComponent, { scrollable: true, size: 'md' });
this.readingListModalRef.componentInstance.seriesId = seriesId;
this.readingListModalRef.componentInstance.seriesId = seriesId;
this.readingListModalRef.componentInstance.volumeId = volume.id;
this.readingListModalRef.componentInstance.type = ADD_FLOW.Volume;
@ -496,7 +496,7 @@ export class ActionService implements OnDestroy {
addChapterToReadingList(chapter: Chapter, seriesId: number, callback?: ChapterActionCallback) {
if (this.readingListModalRef != null) { return; }
this.readingListModalRef = this.modalService.open(AddToListModalComponent, { scrollable: true, size: 'md' });
this.readingListModalRef.componentInstance.seriesId = seriesId;
this.readingListModalRef.componentInstance.seriesId = seriesId;
this.readingListModalRef.componentInstance.chapterId = chapter.id;
this.readingListModalRef.componentInstance.type = ADD_FLOW.Chapter;
@ -517,7 +517,7 @@ export class ActionService implements OnDestroy {
editReadingList(readingList: ReadingList, callback?: ReadingListActionCallback) {
const readingListModalRef = this.modalService.open(EditReadingListModalComponent, { scrollable: true, size: 'lg' });
readingListModalRef.componentInstance.readingList = readingList;
readingListModalRef.componentInstance.readingList = readingList;
readingListModalRef.closed.pipe(take(1)).subscribe((list) => {
if (callback && list !== undefined) {
callback(readingList);
@ -535,7 +535,7 @@ export class ActionService implements OnDestroy {
* @param seriesId Series Id
* @param volumes Volumes, should have id, chapters and pagesRead populated
* @param chapters? Chapters, should have id
* @param callback Optional callback to perform actions after API completes
* @param callback Optional callback to perform actions after API completes
*/
async deleteMultipleSeries(seriesIds: Array<Series>, callback?: BooleanActionCallback) {
if (!await this.confirmService.confirm('Are you sure you want to delete ' + seriesIds.length + ' series? It will not modify files on disk.')) {
@ -578,15 +578,13 @@ export class ActionService implements OnDestroy {
});
}
private async promptIfForce(extraContent: string = '') {
// Prompt user if we should do a force or not
const config = this.confirmService.defaultConfirm;
config.header = 'Force Scan';
config.buttons = [
{text: 'Yes', type: 'secondary'},
{text: 'No', type: 'primary'},
];
const msg = 'Do you want to force this scan? This is will ignore optimizations that reduce processing and I/O. ' + extraContent;
return !await this.confirmService.confirm(msg, config); // Not because primary is the false state
sendSeriesToDevice(seriesId: number, device: Device, callback?: VoidActionCallback) {
this.deviceSerivce.sendSeriesTo(seriesId, device.id).subscribe(() => {
this.toastr.success('File(s) emailed to ' + device.name);
if (callback) {
callback();
}
});
}
}

View File

@ -19,7 +19,7 @@ export class DeviceService {
constructor(private httpClient: HttpClient, private accountService: AccountService) {
// Ensure we are authenticated before we make an authenticated api call.
// Ensure we are authenticated before we make an authenticated api call.
this.accountService.currentUser$.subscribe(user => {
if (!user) {
this.devicesSource.next([]);
@ -54,5 +54,9 @@ export class DeviceService {
return this.httpClient.post(this.baseUrl + 'device/send-to', {deviceId, chapterIds}, TextResonse);
}
sendSeriesTo(seriesId: number, deviceId: number) {
return this.httpClient.post(this.baseUrl + 'device/send-series-to', {deviceId, seriesId}, TextResonse);
}
}

View File

@ -17,4 +17,5 @@ export interface ServerSettings {
totalLogs: number;
enableFolderWatching: boolean;
hostName: string;
cacheSize: number;
}

View File

@ -36,7 +36,7 @@
<app-manage-tasks-settings></app-manage-tasks-settings>
</ng-container>
<ng-container *ngIf="tab.fragment === TabID.KavitaPlus">
<p>Kavita+ is a premium subscription service which unlocks features for all users on this Kavita instance. Buy a subscription to unlock <a href="https://wiki.kavitareader.com/en/kavita-plus" target="_blank" rel="noreferrer nofollow">premium benefits</a> today!</p>
<p>Kavita+ is a premium subscription service which unlocks features for all users on this Kavita instance. Buy a subscription to unlock <a href="https://wiki.kavitareader.com/en/kavita-plus" target="_blank" rel="noreferrer nofollow">premium benefits</a> today! <a href="https://wiki.kavitareader.com/en/kavita-plus" target="_blank" rel="noreferrer nofollow">FAQ</a></p>
<app-license></app-license>
</ng-container>
<ng-container *ngIf="tab.fragment === TabID.Plugins">

View File

@ -1,7 +1,7 @@
<div class="container-fluid">
<form [formGroup]="settingsForm" *ngIf="serverSettings !== undefined">
<div class="alert alert-warning" role="alert">
<strong>Notice:</strong> Changing Port, Base Url or IPs requires a manual restart of Kavita to take effect.
<strong>Notice:</strong> Changing Port, Base Url, Cache Size or IPs requires a manual restart of Kavita to take effect.
</div>
<div class="mb-3">
@ -97,13 +97,32 @@
</div>
</div>
<div class="mb-3">
<label for="stat-collection" class="form-label" aria-describedby="collection-info">Allow Anonymous Usage Collection</label>
<p class="accent" id="collection-info">Send anonymous usage data to Kavita's servers. This includes information on certain features used, number of files, OS version, Kavita install version, CPU, and memory. We will use this information to prioritize features, bug fixes, and performance tuning. Requires restart to take effect. See the <a href="https://wiki.kavitareader.com/en/faq" rel="noopener noreferrer" target="_blank" referrerpolicy="no-refer">wiki</a> for what is collected.</p>
<div class="form-check form-switch">
<input id="stat-collection" type="checkbox" aria-label="Stat Collection" class="form-check-input" formControlName="allowStatCollection" role="switch">
<label for="stat-collection" class="form-check-label">Send Data</label>
</div>
<div class="row g-0 mb-2 mt-3">
<div class="col-md-4 col-sm-12 pe-2">
<label for="cache-size" class="form-label">Cache Size</label>&nbsp;<i class="fa fa-info-circle" placement="right" [ngbTooltip]="cacheSizeTooltip" role="button" tabindex="0"></i>
<ng-template #cacheSizeTooltip>The amount of memory allowed for caching heavy APIs. Default is 50MB.</ng-template>
<span class="visually-hidden" id="cache-size-help">The amount of memory allowed for caching heavy APIs. Default is 50MB.</span>
<input id="cache-size" aria-describedby="cache-size-help" class="form-control" formControlName="cacheSize"
type="number" inputmode="numeric" step="5" min="50" onkeypress="return event.charCode >= 48 && event.charCode <= 57"
[class.is-invalid]="settingsForm.get('cacheSize')?.invalid && settingsForm.get('cacheSize')?.touched">
<ng-container *ngIf="settingsForm.get('cacheSize')?.errors as errors">
<p class="invalid-feedback" *ngIf="errors.min">
You must have at least 50 MB.
</p>
<p class="invalid-feedback" *ngIf="errors.required">
This field is required
</p>
</ng-container>
</div>
</div>
<div class="mb-3 mt-3">
<label for="stat-collection" class="form-label" aria-describedby="collection-info">Allow Anonymous Usage Collection</label>
<p class="accent" id="collection-info">Send anonymous usage data to Kavita's servers. This includes information on certain features used, number of files, OS version, Kavita install version, CPU, and memory. We will use this information to prioritize features, bug fixes, and performance tuning. Requires restart to take effect. See the <a href="https://wiki.kavitareader.com/en/faq" rel="noopener noreferrer" target="_blank" referrerpolicy="no-refer">wiki</a> for what is collected.</p>
<div class="form-check form-switch">
<input id="stat-collection" type="checkbox" aria-label="Stat Collection" class="form-check-input" formControlName="allowStatCollection" role="switch">
<label for="stat-collection" class="form-check-label">Send Data</label>
</div>
</div>
<!-- TODO: Move this to Plugins tab once we build out some basic tables -->

View File

@ -52,6 +52,7 @@ export class ManageSettingsComponent implements OnInit {
this.settingsForm.addControl('baseUrl', new FormControl(this.serverSettings.baseUrl, [Validators.pattern(/^(\/[\w-]+)*\/$/)]));
this.settingsForm.addControl('emailServiceUrl', new FormControl(this.serverSettings.emailServiceUrl, [Validators.required]));
this.settingsForm.addControl('totalBackups', new FormControl(this.serverSettings.totalBackups, [Validators.required, Validators.min(1), Validators.max(30)]));
this.settingsForm.addControl('cacheSize', new FormControl(this.serverSettings.cacheSize, [Validators.required, Validators.min(50)]));
this.settingsForm.addControl('totalLogs', new FormControl(this.serverSettings.totalLogs, [Validators.required, Validators.min(1), Validators.max(30)]));
this.settingsForm.addControl('enableFolderWatching', new FormControl(this.serverSettings.enableFolderWatching, [Validators.required]));
this.settingsForm.addControl('encodeMediaAs', new FormControl(this.serverSettings.encodeMediaAs, []));
@ -82,6 +83,7 @@ export class ManageSettingsComponent implements OnInit {
this.settingsForm.get('enableFolderWatching')?.setValue(this.serverSettings.enableFolderWatching);
this.settingsForm.get('encodeMediaAs')?.setValue(this.serverSettings.encodeMediaAs);
this.settingsForm.get('hostName')?.setValue(this.serverSettings.hostName);
this.settingsForm.get('cacheSize')?.setValue(this.serverSettings.cacheSize);
this.settingsForm.markAsPristine();
}
@ -127,5 +129,5 @@ export class ManageSettingsComponent implements OnInit {
});
}
}

View File

@ -56,44 +56,44 @@
}
.btn {
text-decoration: none;
color: hsla(0,0%,100%,.7);
height: 25px;
text-align: center;
-webkit-tap-highlight-color: transparent;
background: none;
border: 0;
border-radius: 0;
cursor: pointer;
line-height: inherit;
margin: 0;
outline: none;
padding: 0;
text-align: inherit;
text-decoration: none;
touch-action: manipulation;
transition: color .2s;
-webkit-user-select: none;
user-select: none;
text-decoration: none;
color: hsla(0,0%,100%,.7);
height: 25px;
text-align: center;
padding: 0px 5px;
-webkit-tap-highlight-color: transparent;
background: none;
border: 0;
border-radius: 0;
cursor: pointer;
line-height: inherit;
margin: 0;
outline: none;
text-align: inherit;
text-decoration: none;
touch-action: manipulation;
transition: color .2s;
-webkit-user-select: none;
user-select: none;
&:hover {
color: var(--primary-color);
}
&:hover {
color: var(--primary-color);
}
.active {
font-weight: bold;
}
.active {
font-weight: bold;
}
&.disabled {
color: lightgrey;
cursor: not-allowed;
}
}
&.disabled {
color: lightgrey;
cursor: not-allowed;
}
}
}
.virtual-scroller, virtual-scroller {
width: 100%;
//height: calc(100vh - 160px); // 64 is a random number, 523 for me.
//height: calc(100vh - 160px); // 64 is a random number, 523 for me.
height: calc(var(--vh) * 100 - 173px);
//height: calc(100vh - 160px);
//background-color: red;
@ -107,4 +107,4 @@ virtual-scroller.empty {
h2 {
display: inline-block;
word-break: break-all;
}
}

View File

@ -21,6 +21,7 @@ import { RelationKind } from 'src/app/_models/series-detail/relation-kind';
import {CommonModule} from "@angular/common";
import {CardItemComponent} from "../card-item/card-item.component";
import {RelationshipPipe} from "../../pipe/relationship.pipe";
import {Device} from "../../_models/device/device";
@Component({
selector: 'app-series-card',
@ -120,6 +121,10 @@ export class SeriesCardComponent implements OnInit, OnChanges {
case (Action.AnalyzeFiles):
this.actionService.analyzeFilesForSeries(series);
break;
case Action.SendTo:
const device = (action._extra!.data as Device);
this.actionService.sendSeriesToDevice(series.id, device);
break;
default:
break;
}

View File

@ -5,13 +5,11 @@ import {
EventEmitter,
HostListener,
inject,
OnDestroy,
OnInit
} from '@angular/core';
import { Title } from '@angular/platform-browser';
import { ActivatedRoute, Router } from '@angular/router';
import { Subject } from 'rxjs';
import { debounceTime, take, takeUntil } from 'rxjs/operators';
import { take } from 'rxjs/operators';
import { BulkSelectionService } from '../cards/bulk-selection.service';
import { KEY_CODES, UtilityService } from '../shared/_services/utility.service';
import { SeriesAddedEvent } from '../_models/events/series-added-event';
@ -39,6 +37,7 @@ import { NgFor, NgIf, DecimalPipe } from '@angular/common';
import { NgbNav, NgbNavItem, NgbNavItemRole, NgbNavLink, NgbNavContent, NgbNavOutlet } from '@ng-bootstrap/ng-bootstrap';
import { CardActionablesComponent } from '../cards/card-item/card-actionables/card-actionables.component';
import { SideNavCompanionBarComponent } from '../sidenav/_components/side-nav-companion-bar/side-nav-companion-bar.component';
import {Device} from "../_models/device/device";
@Component({
selector: 'app-library-detail',
@ -234,6 +233,8 @@ export class LibraryDetailComponent implements OnInit {
}
}
performAction(action: ActionItem<any>) {
if (typeof action.callback === 'function') {
action.callback(action, undefined);

View File

@ -329,14 +329,14 @@
<form [formGroup]="releaseYearRange" class="d-flex justify-content-between">
<div class="mb-3">
<label for="release-year-min" class="form-label">Release</label>
<input type="text" id="release-year-min" formControlName="min" class="form-control" style="width: 62px" placeholder="Min" (keyup.enter)="apply()">
<input type="number" id="release-year-min" formControlName="min" class="form-control custom-number" style="width: 62px" placeholder="Min" (keyup.enter)="apply()">
</div>
<div style="margin-top: 37px !important;">
<i class="fa-solid fa-minus" aria-hidden="true"></i>
</div>
<div class="mb-3" style="margin-top: 0.5rem">
<label for="release-year-max" class="form-label"><span class="visually-hidden">Max</span></label>
<input type="text" id="release-year-max" formControlName="max" class="form-control" style="width: 62px" placeholder="Max" (keyup.enter)="apply()">
<input type="number" id="release-year-max" formControlName="max" class="form-control custom-number" style="width: 62px" placeholder="Max" (keyup.enter)="apply()">
</div>
</form>
</div>

View File

@ -0,0 +1,12 @@
/* Works for Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Works for Firefox */
input[type="number"] {
-moz-appearance: textfield;
}

View File

@ -137,8 +137,8 @@ export class MetadataFilterComponent implements OnInit {
});
this.releaseYearRange = new FormGroup({
min: new FormControl({value: undefined, disabled: this.filterSettings.releaseYearDisabled}, [Validators.min(1000), Validators.max(9999)]),
max: new FormControl({value: undefined, disabled: this.filterSettings.releaseYearDisabled}, [Validators.min(1000), Validators.max(9999)])
min: new FormControl({value: undefined, disabled: this.filterSettings.releaseYearDisabled}, [Validators.min(1000), Validators.max(9999), Validators.maxLength(4), Validators.minLength(4)]),
max: new FormControl({value: undefined, disabled: this.filterSettings.releaseYearDisabled}, [Validators.min(1000), Validators.max(9999), Validators.maxLength(4), Validators.minLength(4)])
});
this.readProgressGroup.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(changes => {

View File

@ -22,8 +22,6 @@ export class ChangeEmailComponent implements OnInit {
form: FormGroup = new FormGroup({});
user: User | undefined = undefined;
hasChangePasswordAbility: Observable<boolean> = of(false);
passwordsMatch = false;
errors: string[] = [];
isViewMode: boolean = true;
emailLink: string = '';

View File

@ -1,3 +1,7 @@
.nav {
--bs-nav-link-disabled-color: rgb(154 187 219 / 75%);
}
.nav-link {
color: var(--nav-link-text-color);
@ -19,11 +23,11 @@
.nav-tabs {
border-color: var(--nav-tab-border-color);
.nav-link {
color: var(--nav-link-text-color);
position: relative;
&.active, &:focus {
color: var(--nav-tab-active-text-color);
background-color: var(--nav-tab-bg-color);
@ -37,7 +41,7 @@
&.active::before {
transform: scaleY(1);
}
&:hover {
color: var(--nav-tab-hover-text-color);
background-color: var(--nav-tab-hover-bg-color);

View File

@ -7,7 +7,7 @@
"name": "GPL-3.0",
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
},
"version": "0.7.4.0"
"version": "0.7.4.1"
},
"servers": [
{
@ -1643,6 +1643,37 @@
}
}
},
"/api/Device/send-series-to": {
"post": {
"tags": [
"Device"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SendSeriesToDeviceDto"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/SendSeriesToDeviceDto"
}
},
"application/*+json": {
"schema": {
"$ref": "#/components/schemas/SendSeriesToDeviceDto"
}
}
}
},
"responses": {
"200": {
"description": "Success"
}
}
}
},
"/api/Download/volume-size": {
"get": {
"tags": [
@ -14650,6 +14681,20 @@
"additionalProperties": false,
"description": "Represents all Search results for a query"
},
"SendSeriesToDeviceDto": {
"type": "object",
"properties": {
"deviceId": {
"type": "integer",
"format": "int32"
},
"seriesId": {
"type": "integer",
"format": "int32"
}
},
"additionalProperties": false
},
"SendToDeviceDto": {
"type": "object",
"properties": {
@ -15782,6 +15827,11 @@
"type": "string",
"description": "The Host name (ie Reverse proxy domain name) for the server",
"nullable": true
},
"cacheSize": {
"type": "integer",
"description": "The size in MB for Caching API data",
"format": "int64"
}
},
"additionalProperties": false