Skip to content

Commit

Permalink
New UX Part 1.5 (Kareadita#3105)
Browse files Browse the repository at this point in the history
  • Loading branch information
majora2007 authored Aug 11, 2024
1 parent c188e0f commit ac21b04
Show file tree
Hide file tree
Showing 239 changed files with 1,623 additions and 773 deletions.
29 changes: 29 additions & 0 deletions API/Controllers/ChapterController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Threading.Tasks;
using API.Data;
using API.Data.Repositories;
using API.DTOs;
using Microsoft.AspNetCore.Mvc;

namespace API.Controllers;

public class ChapterController : BaseApiController
{
private readonly IUnitOfWork _unitOfWork;

public ChapterController(IUnitOfWork unitOfWork)
{
_unitOfWork = unitOfWork;
}

[HttpGet]
public async Task<ActionResult<ChapterDto>> GetChapter(int chapterId)
{
var chapter =
await _unitOfWork.ChapterRepository.GetChapterDtoAsync(chapterId,
ChapterIncludes.People | ChapterIncludes.Files);

return Ok(chapter);
}


}
19 changes: 11 additions & 8 deletions API/Controllers/SeriesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,22 +229,25 @@ public async Task<ActionResult> UpdateSeries(UpdateSeriesDto updateSeries)
{
// Trigger a refresh when we are moving from a locked image to a non-locked
needsRefreshMetadata = true;
series.CoverImage = string.Empty;
series.CoverImage = null;
series.CoverImageLocked = updateSeries.CoverImageLocked;
series.ResetColorScape();

}

_unitOfWork.SeriesRepository.Update(series);

if (await _unitOfWork.CommitAsync())
if (!await _unitOfWork.CommitAsync())
{
if (needsRefreshMetadata)
{
_taskScheduler.RefreshSeriesMetadata(series.LibraryId, series.Id);
}
return Ok();
return BadRequest(await _localizationService.Translate(User.GetUserId(), "generic-series-update"));
}

if (needsRefreshMetadata)
{
_taskScheduler.RefreshSeriesMetadata(series.LibraryId, series.Id);
}

return BadRequest(await _localizationService.Translate(User.GetUserId(), "generic-series-update"));
return Ok();
}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions API/Controllers/UploadController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ public async Task<ActionResult> UploadLibraryCoverImageFromUrl(UploadFileDto upl
if (string.IsNullOrEmpty(uploadFileDto.Url))
{
library.CoverImage = null;
library.ResetColorScape();
_unitOfWork.LibraryRepository.Update(library);
if (_unitOfWork.HasChanges())
{
Expand Down
6 changes: 6 additions & 0 deletions API/DTOs/ChapterDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,10 @@ public class ChapterDto : IHasReadTimeEstimate, IHasCoverImage
public string CoverImage { get; set; }
public string PrimaryColor { get; set; }
public string SecondaryColor { get; set; }

public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}
}
10 changes: 8 additions & 2 deletions API/DTOs/Collection/AppUserCollectionDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public class AppUserCollectionDto : IHasCoverImage
/// </summary>
public string? CoverImage { get; set; } = string.Empty;

public string PrimaryColor { get; set; }
public string SecondaryColor { get; set; }
public string PrimaryColor { get; set; } = string.Empty;
public string SecondaryColor { get; set; } = string.Empty;
public bool CoverImageLocked { get; set; }

/// <summary>
Expand Down Expand Up @@ -48,4 +48,10 @@ public class AppUserCollectionDto : IHasCoverImage
/// A <br/> separated string of all missing series
/// </summary>
public string? MissingSeriesFromSource { get; set; }

public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}
}
10 changes: 8 additions & 2 deletions API/DTOs/ReadingLists/ReadingListDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public class ReadingListDto : IHasCoverImage
/// </summary>
public string? CoverImage { get; set; } = string.Empty;

public string PrimaryColor { get; set; }
public string SecondaryColor { get; set; }
public string PrimaryColor { get; set; } = string.Empty;
public string SecondaryColor { get; set; } = string.Empty;

/// <summary>
/// Minimum Year the Reading List starts
Expand All @@ -39,4 +39,10 @@ public class ReadingListDto : IHasCoverImage
/// </summary>
public int EndingMonth { get; set; }

public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}

}
6 changes: 6 additions & 0 deletions API/DTOs/SeriesDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,10 @@ public class SeriesDto : IHasReadTimeEstimate, IHasCoverImage
public string? CoverImage { get; set; }
public string PrimaryColor { get; set; }
public string SecondaryColor { get; set; }

public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}
}
6 changes: 6 additions & 0 deletions API/DTOs/VolumeDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,10 @@ public bool IsSpecial()
public string CoverImage { get; set; }
public string PrimaryColor { get; set; }
public string SecondaryColor { get; set; }

public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}
}
6 changes: 6 additions & 0 deletions API/Entities/AppUserCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public class AppUserCollection : IEntityDate, IHasCoverImage
/// </summary>
public string? MissingSeriesFromSource { get; set; }

public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}

// Relationship
public AppUser AppUser { get; set; } = null!;
public int AppUserId { get; set; }
Expand Down
6 changes: 6 additions & 0 deletions API/Entities/Chapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,10 @@ public bool IsSingleVolumeChapter()
{
return MinNumber.Is(Parser.DefaultChapterNumber) && !IsSpecial;
}

public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}
}
7 changes: 7 additions & 0 deletions API/Entities/Interfaces/IHasCoverImage.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace API.Entities.Interfaces;

#nullable enable

public interface IHasCoverImage
{
/// <summary>
Expand All @@ -16,4 +18,9 @@ public interface IHasCoverImage
/// Secondary color derived from the Cover Image
/// </summary>
public string? SecondaryColor { get; set; }

/// <summary>
/// Nulls out the ColorScape properties
/// </summary>
void ResetColorScape();
}
6 changes: 6 additions & 0 deletions API/Entities/Library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,10 @@ public void UpdateLastScanned(DateTime? time)
LastScanned = (DateTime) time;
}
}

public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}
}
6 changes: 6 additions & 0 deletions API/Entities/ReadingList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,10 @@ public class ReadingList : IEntityDate, IHasCoverImage
// Relationships
public int AppUserId { get; set; }
public AppUser AppUser { get; set; } = null!;

public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}
}
6 changes: 6 additions & 0 deletions API/Entities/Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,10 @@ public bool MatchesSeriesByName(string nameNormalized, string localizedNameNorma
NormalizedName == localizedNameNormalized ||
NormalizedLocalizedName == localizedNameNormalized;
}

public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}
}
6 changes: 6 additions & 0 deletions API/Entities/Volume.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,10 @@ public string GetNumberTitle()
return $"{MinNumber}-{MaxNumber}";
}

public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}

}
Loading

0 comments on commit ac21b04

Please sign in to comment.