mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-05-13 11:02:18 -04:00
Custom keybinds, Default language per Library, and bugfixes (#4162)
Co-authored-by: Joseph Milazzo <josephmajora@gmail.com>
This commit is contained in:
@@ -182,18 +182,15 @@ public class LibraryController : BaseApiController
|
||||
/// <returns></returns>
|
||||
[Authorize(Policy = "RequireAdminRole")]
|
||||
[HttpPost("has-files-at-root")]
|
||||
public ActionResult<IDictionary<string, bool>> AnyFilesAtRoot(CheckForFilesInFolderRootsDto dto)
|
||||
public ActionResult<IList<string>> AnyFilesAtRoot(CheckForFilesInFolderRootsDto dto)
|
||||
{
|
||||
var results = new Dictionary<string, bool>();
|
||||
foreach (var root in dto.Roots)
|
||||
{
|
||||
results.TryAdd(root,
|
||||
_directoryService
|
||||
.GetFilesWithCertainExtensions(root, Parser.SupportedExtensions, SearchOption.TopDirectoryOnly)
|
||||
.Any());
|
||||
}
|
||||
var foldersWithFilesAtRoot = dto.Roots
|
||||
.Where(root => _directoryService
|
||||
.GetFilesWithCertainExtensions(root, Parser.SupportedExtensions, SearchOption.TopDirectoryOnly)
|
||||
.Any())
|
||||
.ToList();
|
||||
|
||||
return Ok(results);
|
||||
return Ok(foldersWithFilesAtRoot);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -658,6 +655,7 @@ public class LibraryController : BaseApiController
|
||||
library.EnableMetadata = dto.EnableMetadata;
|
||||
library.RemovePrefixForSortName = dto.RemovePrefixForSortName;
|
||||
library.InheritWebLinksFromFirstChapter = dto.InheritWebLinksFromFirstChapter;
|
||||
library.DefaultLanguage = dto.DefaultLanguage;
|
||||
|
||||
library.LibraryFileTypes = dto.FileGroupTypes
|
||||
.Select(t => new LibraryFileTypeGroup() {FileTypeGroup = t, LibraryId = library.Id})
|
||||
|
||||
@@ -14,6 +14,7 @@ using API.SignalR;
|
||||
using Flurl.Http;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.StaticFiles;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace API.Controllers;
|
||||
@@ -62,9 +63,15 @@ public class UploadController : BaseApiController
|
||||
public async Task<ActionResult<string>> GetImageFromFile(UploadUrlDto dto)
|
||||
{
|
||||
var dateString = $"{DateTime.UtcNow.ToShortDateString()}_{DateTime.UtcNow.ToLongTimeString()}".Replace('/', '_').Replace(':', '_');
|
||||
var format = _directoryService.FileSystem.Path.GetExtension(dto.Url.Split('?')[0]).Replace(".", string.Empty);
|
||||
try
|
||||
{
|
||||
var format = await dto.Url.GetFileFormatAsync();
|
||||
if (string.IsNullOrEmpty(format))
|
||||
{
|
||||
// Fallback to unreliable parsing if needed
|
||||
format = _directoryService.FileSystem.Path.GetExtension(dto.Url.Split('?')[0]).Replace(".", string.Empty);
|
||||
}
|
||||
|
||||
var path = await dto.Url
|
||||
.DownloadFileAsync(_directoryService.TempDirectory, $"coverupload_{dateString}.{format}");
|
||||
|
||||
@@ -499,7 +506,7 @@ public class UploadController : BaseApiController
|
||||
var person = await _unitOfWork.PersonRepository.GetPersonById(uploadFileDto.Id);
|
||||
if (person == null) return BadRequest(await _localizationService.Translate(User.GetUserId(), "person-doesnt-exist"));
|
||||
|
||||
await _coverDbService.SetPersonCoverByUrl(person, uploadFileDto.Url, true);
|
||||
await _coverDbService.SetPersonCoverByUrl(person, uploadFileDto.Url, chooseBetterImage: false);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -121,6 +121,7 @@ public class UsersController : BaseApiController
|
||||
existingPreferences.ColorScapeEnabled = preferencesDto.ColorScapeEnabled;
|
||||
existingPreferences.BookReaderHighlightSlots = preferencesDto.BookReaderHighlightSlots;
|
||||
existingPreferences.DataSaver = preferencesDto.DataSaver;
|
||||
existingPreferences.CustomKeyBinds = preferencesDto.CustomKeyBinds;
|
||||
|
||||
var allLibs = (await _unitOfWork.LibraryRepository.GetLibrariesForUserIdAsync(user.Id))
|
||||
.Select(l => l.Id).ToList();
|
||||
|
||||
Reference in New Issue
Block a user