From 62afacae55415a013819eec6a18fe1f3313c62fb Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Wed, 16 Mar 2022 18:44:24 -0500 Subject: [PATCH] Side nav (#1155) * adding back side-nav * Event Widget Update (#1098) * Took care of some notes in the code * Fixed an issue where Extra might get flagged as special too early, if in a word like Extraordinary * Moved Tag cleanup code into Scanner service. Added a SplitQuery to another heavy API. Refactored Scan loop to remove parallelism and use async instead. * Lots of rework on the codebase to support detailed messages and easier management of message sending. Need to take a break on this work. * Progress is being made, but slowly. Code is broken in this commit. * Progress is being made, but slowly. Code is broken in this commit. * Fixed merge issue * Fixed unit tests * CoverUpdate is now hooked into new ProgressEvent structure * Refactored code to remove custom observables and have everything use standard messages$ * Refactored a ton of instances to NotificationProgressEvent style and tons of the UI to respect that too. UI is still a bit buggy, but wholistically the work is done. * Working much better. Sometimes events come in too fast. Currently cover update progress doesn't display on UI * Fixed unit tests * Removed SignalREvent to minimize internal event types. Updated the UI to use progress bars. Finished SiteThemeService. * Merged metadata refresh progress events and changed library scan events to merge cleaner in the UI * Changed RefreshMetadataProgress to CoverUpdateProgress to reflect the event better. * Theme Cleanup (#1089) * Fixed e-ink theme not properly applying correctly * Fixed some seed changes. Changed card checkboxes to use our themed ones * Fixed recently added carousel not going to recently-added page * Fixed an issue where no results found would show when searching for a library name * Cleaned up list a bit, typeahead dropdown still needs work * Added a TODO to streamline series-card component * Removed ng-lazyload-image module since we don't use it. We use lazysizes * Darken card on hover * Fixing accordion focus style * ux pass updates - Fixed typeahead width - Fixed changelog download buttons - Fixed a select - Fixed various input box-shadows - Fixed all anchors to only have underline on hover - Added navtab hover and active effects * more ux pass - Fixed spacing on theme cards - Fixed some light theme issues - Exposed text-muted-color for theme card subtitle color * UX pass fixes - Changed back to bright green for primary on dark theme - Changed fa icon to black on e-ink * Merged changelog component * Fixed anchor buttons text decoration * Changed nav tabs to have a background color instead of open active state * When user is not authenticated, make sure we set default theme (dark) * Cleanup on carousel * Updated Users tab to use small buttons with icons to align with Library tab * Cleaned up brand to not underline, removed default link underline on hover in dropdown and pill tabs * Fixed collection detail posters not rendering Co-authored-by: Robbie Davis * Bump versions by dotnet-bump-version. * Tweaked some of the emitting code * Some css, but pretty bad. Robbie please save me * Removed a todo * styling update * Only send filename on FileScanProgress * Some console.log spam cleanup * Various updates * Show events widget activity based on activeEvents * progress bar color updates * Code cleanup Co-authored-by: Robbie Davis * Bump versions by dotnet-bump-version. * Scanner event hub fix (#1099) * Scanner event hub fix - Fixed an issue where the scanner would error when adding a new series because the series didn't have a library name yet. (develop) * Removing library.type * Bump versions by dotnet-bump-version. * Workflow update to add nightly versions (#1100) # Changed - Changed: Changed automated workflow to release individual nightly versions on dockerhub * Bump versions by dotnet-bump-version. * Updating GA to parse version (#1101) * Bump versions by dotnet-bump-version. * GA Fixes (#1103) **Strictly Repo Changes** # Fixed - Fixed: Fixed an issue where patch version was not being added to docker tag. * Bump versions by dotnet-bump-version. * Fixed specials being misaligned (#1106) # Fixed - Fixed: Fixed issue with specials not being properly aligned (develop) * Bump versions by dotnet-bump-version. * Bugfix/ux pass 2 (#1107) * Adding margin bottom to series detail tabs * Styling tag badges with green on dark - Added 3 new css vars * Removing underline from readmore * Fixing see more to be on one line * adding gutter to see more * Changing queue toasts to info * adding api key tooltip * Updating active accordion on user preference. * Fixing search bar and close btn position * Fixed a bug where entering book reader in dark mode then closing out, would leave you in a broken white state. * Fixed broken wiki links Co-authored-by: Joseph Milazzo * Bump versions by dotnet-bump-version. * Series Detail Refactor (#1118) * Fixed a bug where reading list and collection's summary wouldn't render newlines * Moved all the logic in the UI for Series Detail into the backend (messy code). We are averaging 400ms max with much optimizations available. Next step is to refactor out of controller and provide unit tests. * Unit tests for CleanSpecialTitle * Laid out foundation for testing major code in SeriesController. * Refactored code so that read doesn't need to be disabled on page load. SeriesId doesn't need the series to actually load. * Removed old property from Volume * Changed tagbadge font size to rem. * Refactored some methods from SeriesController.cs into SeriesService.cs * UpdateRating unit tested * Wrote unit tests for SeriesDetail * Worked up some code where books are rendered only as volumes. However, looks like I will need to use Chapters to better support series_index as floats. * Refactored Series Detail to change Volume Name on Book libraries to have book name and series_index. * Some cleanup on the code * DeleteMultipleSeries test is hard. Going to skip. * Removed some debug code and make all tabs Books for Book library Type * Bump versions by dotnet-bump-version. * Tachiyomi Bugfix (#1119) * Updated the dependencies for .NET 6.0.2 * Fixed a bad prev chapter logic where we would bleed into chapters from last volume instead of specials. * Fixed the get prev chapter code to properly walk the order according to documentation and updated some bad test cases * Updated side nav to float a bit and added user settings to it. * Refactored the code to hide/show sidenav to be more angular and decoupled * Moved Changelog out of admin dashboard and into a dedicated page in user menu. Added a wiki link from user menu * Introduced a side nav item for rendering each item and refactored code to use it. * Added a filter of side nav when there are more than 10 libraries. Added some themeing overrides for side nav. * Cleaned up the template code for side nav item so if there is no link, we don't generate that html directive * Refactored side nav into a module and migrated a few pipes into a pipe module for easy re-use * Added companion bar on reading list and collection. Updated modules to load pages and make side nav items clickable as anchors, so new tab works. * Moved metadata filter into separate component/module and the button in the companion bar. Needs cleanup. * Finished cleanup and refactoring of metadata filter into separate component. Removed filtering from Collections as it doesn't work and wasn't hooked up. * Tweaked the css on carousel component * Added to library detail and series-detail * Fixes and css vars * Stop destroying sidenav, animaton timing * Integrated side nav on the rest of the pages * Navbar now collapses to icons * mobile sidenav start * more mobile fixes * mobile tweaks * light and e-ink theme updates * white and eink dropdown color fixes * plex inspired side-nav * theme fixes * Making spacing more uniform across app * More fixes * fixing spacing on cards * actionable fix for sidenav * no scroll on mobile when sidenav is open * hide sidenav on pages * Adding card spacing * Adding ability to remove sidenav when in a reader * tidying up sidenav toggles * side-nav mobile updates * fixing up other themes * overlay fixes * Cleaned up the code to make the observables have better names. Removed a bunch of pointless subscriptions. Cleaned up methods that werent needed. Added jsdocs to help ensure the understandability of the 2 states for the side nav. * Integrated a highlight effect on side nav. Fixed a ton of places where the nav was being hidden when it shouldn't. * Fixed where active state wasn't working on all urls * misc fixes - smaller hamburger - z-index fixes - active fixes * Revert "Merge branch 'develop' into feature/side-nav-upgrade" This reverts commit 76b0d15a984692874e0cb57e821686ea703144cf, reversing changes made to b3ed55395473aa35577500596a211ad22a42631b. * Fixing edit-series modal spacing * Give the ability to jump to a library from admin manage libraries page * Fixed a bug with highlighting active item on side nav * Moved localized series title to companion bar via subtitle * Removed old title * Fixed a bug where clicking a link would reload the whole app, styling fixes on filter, fixed issue with initial load not setting active state, adjusted styles on active style. * code cleanup Co-authored-by: Robbie Davis --- .github/workflows/sonar-scan.yml | 2 +- API.Tests/Services/ReaderServiceTests.cs | 176 ------ API/Controllers/AccountController.cs | 16 +- API/Controllers/ReaderController.cs | 18 +- API/DTOs/Account/InviteUserDto.cs | 2 + API/DTOs/Account/InviteUserResponse.cs | 13 - API/DTOs/Filtering/FilterDto.cs | 24 +- API/DTOs/Reader/ChapterInfoDto.cs | 1 - API/Data/Repositories/ChapterRepository.cs | 8 +- API/Data/Repositories/SeriesRepository.cs | 16 +- API/Services/EmailService.cs | 8 +- API/Services/ReaderService.cs | 38 +- Kavita.Common/Kavita.Common.csproj | 2 +- .../src/app/_models/invite-user-response.ts | 10 - UI/Web/src/app/_services/account.service.ts | 9 +- UI/Web/src/app/_services/nav.service.ts | 52 +- UI/Web/src/app/admin/admin.module.ts | 7 +- .../admin/dashboard/dashboard.component.html | 12 +- .../admin/dashboard/dashboard.component.ts | 4 +- .../invite-user/invite-user.component.html | 24 +- .../invite-user/invite-user.component.ts | 23 +- .../manage-library.component.html | 2 +- .../app/all-series/all-series.component.html | 10 +- .../app/all-series/all-series.component.ts | 6 +- .../announcements-routing.module.ts | 23 + .../announcements.component.html | 3 + .../announcements.component.scss | 0 .../announcements/announcements.component.ts | 15 + .../app/announcements/announcements.module.ts | 23 + .../changelog/changelog.component.html | 2 +- .../changelog/changelog.component.scss | 0 .../changelog/changelog.component.ts | 0 UI/Web/src/app/app-routing.module.ts | 8 + UI/Web/src/app/app.component.html | 9 +- UI/Web/src/app/app.component.scss | 39 ++ UI/Web/src/app/app.component.ts | 1 - UI/Web/src/app/app.module.ts | 20 +- .../src/app/book-reader/book-reader.module.ts | 4 +- .../book-reader/book-reader.component.ts | 2 + .../card-details-modal.component.html | 14 +- .../edit-series-modal.component.html | 6 +- .../card-detail-layout.component.html | 362 +----------- .../card-detail-layout.component.ts | 531 +---------------- .../cards/card-item/card-item.component.scss | 1 - UI/Web/src/app/cards/cards.module.ts | 8 +- .../carousel-reel.component.scss | 11 +- .../all-collections.component.html | 9 +- .../all-collections.component.ts | 5 +- .../collection-detail.component.ts | 2 +- .../src/app/collections/collections.module.ts | 2 + .../app/dashboard/dashboard.component.html | 24 +- .../library-detail.component.html | 13 +- .../library-detail.component.ts | 9 +- UI/Web/src/app/library/library.component.html | 10 +- UI/Web/src/app/library/library.component.ts | 6 +- .../app/manga-reader/_models/chapter-info.ts | 2 - .../manga-reader/manga-reader.component.html | 44 +- .../manga-reader/manga-reader.component.scss | 6 +- .../manga-reader/manga-reader.component.ts | 36 +- .../app/metadata-filter/filter-settings.ts | 21 + .../metadata-filter.component.html | 338 +++++++++++ .../metadata-filter.component.scss | 0 .../metadata-filter.component.ts | 555 ++++++++++++++++++ .../metadata-filter/metadata-filter.module.ts | 27 + .../app/nav-header/nav-header.component.html | 7 +- .../app/nav-header/nav-header.component.scss | 9 + .../app/nav-header/nav-header.component.ts | 5 +- UI/Web/src/app/on-deck/on-deck.component.html | 19 + UI/Web/src/app/on-deck/on-deck.component.scss | 0 UI/Web/src/app/on-deck/on-deck.component.ts | 133 +++++ UI/Web/src/app/pipe/pipe.module.ts | 7 +- .../app/{shared => pipe}/safe-html.pipe.ts | 0 .../reading-list-detail.component.html | 20 +- .../app/reading-list/reading-list.module.ts | 4 +- .../reading-list.router.module.ts | 6 +- .../reading-lists.component.html | 9 +- .../recently-added.component.html | 8 +- .../recently-added.component.ts | 7 +- .../series-detail.component.html | 25 +- .../series-detail/series-detail.component.ts | 19 +- .../app/shared/_services/utility.service.ts | 22 +- UI/Web/src/app/shared/shared.module.ts | 7 +- .../side-nav-companion-bar.component.html | 21 + .../side-nav-companion-bar.component.scss | 0 .../side-nav-companion-bar.component.ts | 47 ++ .../side-nav-item.component.html | 29 + .../side-nav-item.component.scss | 206 +++++++ .../side-nav-item/side-nav-item.component.ts | 72 +++ .../sidenav/side-nav/side-nav.component.html | 31 + .../sidenav/side-nav/side-nav.component.scss | 63 ++ .../sidenav/side-nav/side-nav.component.ts | 70 +++ UI/Web/src/app/sidenav/sidenav.module.ts | 34 ++ UI/Web/src/app/typeahead/typeahead.module.ts | 4 +- .../app/user-login/user-login.component.ts | 2 + .../api-key/api-key.component.html | 2 +- .../user-preferences.component.html | 73 +-- .../app/user-settings/user-settings.module.ts | 12 +- UI/Web/src/styles.scss | 5 +- UI/Web/src/theme/components/_anchors.scss | 5 +- UI/Web/src/theme/components/_carousel.scss | 3 + UI/Web/src/theme/components/_dropdown.scss | 2 +- UI/Web/src/theme/components/_modal.scss | 6 +- UI/Web/src/theme/components/_navbar.scss | 1 + UI/Web/src/theme/components/_pagination.scss | 14 + UI/Web/src/theme/components/_sidenav.scss | 52 ++ UI/Web/src/theme/components/_tagbadge.scss | 4 +- UI/Web/src/theme/themes/dark.scss | 28 +- UI/Web/src/theme/themes/e-ink.scss | 24 +- UI/Web/src/theme/themes/light.scss | 23 + 109 files changed, 2371 insertions(+), 1443 deletions(-) delete mode 100644 API/DTOs/Account/InviteUserResponse.cs delete mode 100644 UI/Web/src/app/_models/invite-user-response.ts create mode 100644 UI/Web/src/app/announcements/announcements-routing.module.ts create mode 100644 UI/Web/src/app/announcements/announcements.component.html create mode 100644 UI/Web/src/app/announcements/announcements.component.scss create mode 100644 UI/Web/src/app/announcements/announcements.component.ts create mode 100644 UI/Web/src/app/announcements/announcements.module.ts rename UI/Web/src/app/{admin => announcements}/changelog/changelog.component.html (92%) rename UI/Web/src/app/{admin => announcements}/changelog/changelog.component.scss (100%) rename UI/Web/src/app/{admin => announcements}/changelog/changelog.component.ts (100%) create mode 100644 UI/Web/src/app/metadata-filter/filter-settings.ts create mode 100644 UI/Web/src/app/metadata-filter/metadata-filter.component.html create mode 100644 UI/Web/src/app/metadata-filter/metadata-filter.component.scss create mode 100644 UI/Web/src/app/metadata-filter/metadata-filter.component.ts create mode 100644 UI/Web/src/app/metadata-filter/metadata-filter.module.ts create mode 100644 UI/Web/src/app/on-deck/on-deck.component.html create mode 100644 UI/Web/src/app/on-deck/on-deck.component.scss create mode 100644 UI/Web/src/app/on-deck/on-deck.component.ts rename UI/Web/src/app/{shared => pipe}/safe-html.pipe.ts (100%) create mode 100644 UI/Web/src/app/sidenav/side-nav-companion-bar/side-nav-companion-bar.component.html create mode 100644 UI/Web/src/app/sidenav/side-nav-companion-bar/side-nav-companion-bar.component.scss create mode 100644 UI/Web/src/app/sidenav/side-nav-companion-bar/side-nav-companion-bar.component.ts create mode 100644 UI/Web/src/app/sidenav/side-nav-item/side-nav-item.component.html create mode 100644 UI/Web/src/app/sidenav/side-nav-item/side-nav-item.component.scss create mode 100644 UI/Web/src/app/sidenav/side-nav-item/side-nav-item.component.ts create mode 100644 UI/Web/src/app/sidenav/side-nav/side-nav.component.html create mode 100644 UI/Web/src/app/sidenav/side-nav/side-nav.component.scss create mode 100644 UI/Web/src/app/sidenav/side-nav/side-nav.component.ts create mode 100644 UI/Web/src/app/sidenav/sidenav.module.ts create mode 100644 UI/Web/src/theme/components/_carousel.scss create mode 100644 UI/Web/src/theme/components/_sidenav.scss diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index e997a9e8d..ec7837fdc 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -230,7 +230,7 @@ jobs: severity: info description: v${{steps.get-version.outputs.assembly-version}} - ${{ steps.findPr.outputs.title }} details: '${{ steps.parse-body.outputs.BODY }}' - text: <@&950058626658234398> A new nightly build has been released for docker. + text: <@&939225459156217917> <@&939225350775406643> A new nightly build has been released for docker. webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }} stable: diff --git a/API.Tests/Services/ReaderServiceTests.cs b/API.Tests/Services/ReaderServiceTests.cs index 61fad6e0a..a66863487 100644 --- a/API.Tests/Services/ReaderServiceTests.cs +++ b/API.Tests/Services/ReaderServiceTests.cs @@ -1650,61 +1650,6 @@ public class ReaderServiceTests Assert.Equal("Some Special Title", nextChapter.Range); } - [Fact] - public async Task GetContinuePoint_ShouldReturnFirstVolumeChapter_WhenPreExistingProgress() - { - var series = new Series() - { - Name = "Test", - Library = new Library() - { - Name = "Test LIb", - Type = LibraryType.Manga, - }, - Volumes = new List() - { - EntityFactory.CreateVolume("0", new List() - { - EntityFactory.CreateChapter("230", false, new List(), 1), - //EntityFactory.CreateChapter("231", false, new List(), 1), (added later) - }), - EntityFactory.CreateVolume("1", new List() - { - EntityFactory.CreateChapter("1", false, new List(), 1), - EntityFactory.CreateChapter("2", false, new List(), 1), - }), - EntityFactory.CreateVolume("2", new List() - { - EntityFactory.CreateChapter("0", false, new List(), 1), - //EntityFactory.CreateChapter("14.9", false, new List(), 1), (added later) - }), - } - }; - _context.Series.Add(series); - - _context.AppUser.Add(new AppUser() - { - UserName = "majora2007" - }); - - await _context.SaveChangesAsync(); - - - var readerService = new ReaderService(_unitOfWork, Substitute.For>()); - var user = await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress); - await readerService.MarkSeriesAsRead(user, 1); - await _context.SaveChangesAsync(); - - // Add 2 new unread series to the Series - series.Volumes[0].Chapters.Add(EntityFactory.CreateChapter("231", false, new List(), 1)); - series.Volumes[2].Chapters.Add(EntityFactory.CreateChapter("14.9", false, new List(), 1)); - _context.Series.Attach(series); - await _context.SaveChangesAsync(); - - var nextChapter = await readerService.GetContinuePoint(1, 1); - Assert.Equal("14.9", nextChapter.Range); - } - #endregion #region MarkChaptersUntilAsRead @@ -1838,126 +1783,5 @@ public class ReaderServiceTests #endregion - #region MarkSeriesAsRead - [Fact] - public async Task MarkSeriesAsReadTest() - { - await ResetDB(); - - _context.Series.Add(new Series() - { - Name = "Test", - Library = new Library() { - Name = "Test LIb", - Type = LibraryType.Manga, - }, - Volumes = new List() - { - new Volume() - { - Chapters = new List() - { - new Chapter() - { - Pages = 1 - }, - new Chapter() - { - Pages = 2 - } - } - }, - new Volume() - { - Chapters = new List() - { - new Chapter() - { - Pages = 1 - }, - new Chapter() - { - Pages = 2 - } - } - } - } - }); - - _context.AppUser.Add(new AppUser() - { - UserName = "majora2007" - }); - - await _context.SaveChangesAsync(); - - var readerService = new ReaderService(_unitOfWork, Substitute.For>()); - - await readerService.MarkSeriesAsRead(await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress), 1); - await _context.SaveChangesAsync(); - - Assert.Equal(4, (await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress)).Progresses.Count); - } - - - #endregion - - #region MarkSeriesAsUnread - - [Fact] - public async Task MarkSeriesAsUnreadTest() - { - await ResetDB(); - - _context.Series.Add(new Series() - { - Name = "Test", - Library = new Library() { - Name = "Test LIb", - Type = LibraryType.Manga, - }, - Volumes = new List() - { - new Volume() - { - Chapters = new List() - { - new Chapter() - { - Pages = 1 - }, - new Chapter() - { - Pages = 2 - } - } - } - } - }); - - _context.AppUser.Add(new AppUser() - { - UserName = "majora2007" - }); - - await _context.SaveChangesAsync(); - - var readerService = new ReaderService(_unitOfWork, Substitute.For>()); - - var volumes = (await _unitOfWork.VolumeRepository.GetVolumes(1)).ToList(); - readerService.MarkChaptersAsRead(await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress), 1, volumes.First().Chapters); - - await _context.SaveChangesAsync(); - Assert.Equal(2, (await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress)).Progresses.Count); - - await readerService.MarkSeriesAsUnread(await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress), 1); - await _context.SaveChangesAsync(); - - var progresses = (await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress)).Progresses; - Assert.Equal(0, progresses.Max(p => p.PagesRead)); - Assert.Equal(2, progresses.Count); - } - - #endregion } diff --git a/API/Controllers/AccountController.cs b/API/Controllers/AccountController.cs index 7fc8769e7..913f53133 100644 --- a/API/Controllers/AccountController.cs +++ b/API/Controllers/AccountController.cs @@ -338,12 +338,6 @@ namespace API.Controllers - /// - /// Invites a user to the server. Will generate a setup link for continuing setup. If the server is not accessible, no - /// email will be sent. - /// - /// - /// [Authorize(Policy = "RequireAdminRole")] [HttpPost("invite")] public async Task> InviteUser(InviteUserDto dto) @@ -423,9 +417,7 @@ namespace API.Controllers var emailLink = GenerateEmailLink(token, "confirm-email", dto.Email); _logger.LogCritical("[Invite User]: Email Link for {UserName}: {Link}", user.UserName, emailLink); - var host = _environment.IsDevelopment() ? "localhost:4200" : Request.Host.ToString(); - var accessible = await _emailService.CheckIfAccessible(host); - if (accessible) + if (dto.SendEmail) { await _emailService.SendConfirmationEmail(new ConfirmationEmailDto() { @@ -434,11 +426,7 @@ namespace API.Controllers ServerConfirmationLink = emailLink }); } - return Ok(new InviteUserResponse - { - EmailLink = emailLink, - EmailSent = accessible - }); + return Ok(emailLink); } catch (Exception) { diff --git a/API/Controllers/ReaderController.cs b/API/Controllers/ReaderController.cs index fa3be9c05..a8a34bdfd 100644 --- a/API/Controllers/ReaderController.cs +++ b/API/Controllers/ReaderController.cs @@ -109,7 +109,14 @@ namespace API.Controllers public async Task MarkRead(MarkReadDto markReadDto) { var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername(), AppUserIncludes.Progress); - await _readerService.MarkSeriesAsRead(user, markReadDto.SeriesId); + var volumes = await _unitOfWork.VolumeRepository.GetVolumes(markReadDto.SeriesId); + user.Progresses ??= new List(); + foreach (var volume in volumes) + { + _readerService.MarkChaptersAsRead(user, markReadDto.SeriesId, volume.Chapters); + } + + _unitOfWork.UserRepository.Update(user); if (await _unitOfWork.CommitAsync()) { @@ -130,7 +137,14 @@ namespace API.Controllers public async Task MarkUnread(MarkReadDto markReadDto) { var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername(), AppUserIncludes.Progress); - await _readerService.MarkSeriesAsUnread(user, markReadDto.SeriesId); + var volumes = await _unitOfWork.VolumeRepository.GetVolumes(markReadDto.SeriesId); + user.Progresses ??= new List(); + foreach (var volume in volumes) + { + _readerService.MarkChaptersAsUnread(user, markReadDto.SeriesId, volume.Chapters); + } + + _unitOfWork.UserRepository.Update(user); if (await _unitOfWork.CommitAsync()) { diff --git a/API/DTOs/Account/InviteUserDto.cs b/API/DTOs/Account/InviteUserDto.cs index 42d4bdf8e..04c9c1103 100644 --- a/API/DTOs/Account/InviteUserDto.cs +++ b/API/DTOs/Account/InviteUserDto.cs @@ -16,4 +16,6 @@ public class InviteUserDto /// A list of libraries to grant access to /// public IList Libraries { get; init; } + + public bool SendEmail { get; init; } = true; } diff --git a/API/DTOs/Account/InviteUserResponse.cs b/API/DTOs/Account/InviteUserResponse.cs deleted file mode 100644 index 9387b5492..000000000 --- a/API/DTOs/Account/InviteUserResponse.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace API.DTOs.Account; - -public class InviteUserResponse -{ - /// - /// Email link used to setup the user account - /// - public string EmailLink { get; set; } - /// - /// Was an email sent (ie is this server accessible) - /// - public bool EmailSent { get; set; } -} diff --git a/API/DTOs/Filtering/FilterDto.cs b/API/DTOs/Filtering/FilterDto.cs index 90ad52759..fba9a7493 100644 --- a/API/DTOs/Filtering/FilterDto.cs +++ b/API/DTOs/Filtering/FilterDto.cs @@ -25,51 +25,51 @@ namespace API.DTOs.Filtering /// public IList Genres { get; init; } = new List(); /// - /// A list of Writers to restrict search to. Defaults to all Writers by passing an empty list + /// A list of Writers to restrict search to. Defaults to all genres by passing an empty list /// public IList Writers { get; init; } = new List(); /// - /// A list of Penciller ids to restrict search to. Defaults to all Pencillers by passing an empty list + /// A list of Penciller ids to restrict search to. Defaults to all genres by passing an empty list /// public IList Penciller { get; init; } = new List(); /// - /// A list of Inker ids to restrict search to. Defaults to all Inkers by passing an empty list + /// A list of Inker ids to restrict search to. Defaults to all genres by passing an empty list /// public IList Inker { get; init; } = new List(); /// - /// A list of Colorist ids to restrict search to. Defaults to all Colorists by passing an empty list + /// A list of Colorist ids to restrict search to. Defaults to all genres by passing an empty list /// public IList Colorist { get; init; } = new List(); /// - /// A list of Letterer ids to restrict search to. Defaults to all Letterers by passing an empty list + /// A list of Letterer ids to restrict search to. Defaults to all genres by passing an empty list /// public IList Letterer { get; init; } = new List(); /// - /// A list of CoverArtist ids to restrict search to. Defaults to all CoverArtists by passing an empty list + /// A list of CoverArtist ids to restrict search to. Defaults to all genres by passing an empty list /// public IList CoverArtist { get; init; } = new List(); /// - /// A list of Editor ids to restrict search to. Defaults to all Editors by passing an empty list + /// A list of Editor ids to restrict search to. Defaults to all genres by passing an empty list /// public IList Editor { get; init; } = new List(); /// - /// A list of Publisher ids to restrict search to. Defaults to all Publishers by passing an empty list + /// A list of Publisher ids to restrict search to. Defaults to all genres by passing an empty list /// public IList Publisher { get; init; } = new List(); /// - /// A list of Character ids to restrict search to. Defaults to all Characters by passing an empty list + /// A list of Character ids to restrict search to. Defaults to all genres by passing an empty list /// public IList Character { get; init; } = new List(); /// - /// A list of Translator ids to restrict search to. Defaults to all Translatorss by passing an empty list + /// A list of Translator ids to restrict search to. Defaults to all genres by passing an empty list /// public IList Translators { get; init; } = new List(); /// - /// A list of Collection Tag ids to restrict search to. Defaults to all Collection Tags by passing an empty list + /// A list of Collection Tag ids to restrict search to. Defaults to all genres by passing an empty list /// public IList CollectionTags { get; init; } = new List(); /// - /// A list of Tag ids to restrict search to. Defaults to all Tags by passing an empty list + /// A list of Tag ids to restrict search to. Defaults to all genres by passing an empty list /// public IList Tags { get; init; } = new List(); /// diff --git a/API/DTOs/Reader/ChapterInfoDto.cs b/API/DTOs/Reader/ChapterInfoDto.cs index 9f33bada7..7c847d926 100644 --- a/API/DTOs/Reader/ChapterInfoDto.cs +++ b/API/DTOs/Reader/ChapterInfoDto.cs @@ -12,7 +12,6 @@ namespace API.DTOs.Reader public MangaFormat SeriesFormat { get; set; } public int SeriesId { get; set; } public int LibraryId { get; set; } - public LibraryType LibraryType { get; set; } public string ChapterTitle { get; set; } = string.Empty; public int Pages { get; set; } public string FileName { get; set; } diff --git a/API/Data/Repositories/ChapterRepository.cs b/API/Data/Repositories/ChapterRepository.cs index ab3684fa0..330aa4b5e 100644 --- a/API/Data/Repositories/ChapterRepository.cs +++ b/API/Data/Repositories/ChapterRepository.cs @@ -81,8 +81,7 @@ public class ChapterRepository : IChapterRepository data.TitleName, SeriesFormat = series.Format, SeriesName = series.Name, - series.LibraryId, - LibraryType = series.Library.Type + series.LibraryId }) .Select(data => new ChapterInfoDto() { @@ -90,13 +89,12 @@ public class ChapterRepository : IChapterRepository VolumeNumber = data.VolumeNumber + string.Empty, VolumeId = data.VolumeId, IsSpecial = data.IsSpecial, - SeriesId = data.SeriesId, + SeriesId =data.SeriesId, SeriesFormat = data.SeriesFormat, SeriesName = data.SeriesName, LibraryId = data.LibraryId, Pages = data.Pages, - ChapterTitle = data.TitleName, - LibraryType = data.LibraryType + ChapterTitle = data.TitleName }) .AsNoTracking() .AsSplitQuery() diff --git a/API/Data/Repositories/SeriesRepository.cs b/API/Data/Repositories/SeriesRepository.cs index d70681b46..efe2f1a27 100644 --- a/API/Data/Repositories/SeriesRepository.cs +++ b/API/Data/Repositories/SeriesRepository.cs @@ -79,8 +79,8 @@ public interface ISeriesRepository /// Task AddSeriesModifiers(int userId, List series); Task GetSeriesCoverImageAsync(int seriesId); - Task> GetOnDeck(int userId, int libraryId, UserParams userParams, FilterDto filter, bool cutoffOnDate = true); - Task> GetRecentlyAdded(int libraryId, int userId, UserParams userParams, FilterDto filter); + Task> GetOnDeck(int userId, int libraryId, UserParams userParams, FilterDto filter); + Task> GetRecentlyAdded(int libraryId, int userId, UserParams userParams, FilterDto filter); // NOTE: Probably put this in LibraryRepo Task GetSeriesMetadata(int seriesId); Task> GetSeriesDtoForCollectionAsync(int collectionId, int userId, UserParams userParams); Task> GetFilesForSeries(int seriesId); @@ -593,11 +593,11 @@ public class SeriesRepository : ISeriesRepository /// Pagination information /// Optional (default null) filter on query /// - public async Task> GetOnDeck(int userId, int libraryId, UserParams userParams, FilterDto filter, bool cutoffOnDate = true) + public async Task> GetOnDeck(int userId, int libraryId, UserParams userParams, FilterDto filter) { //var allSeriesWithProgress = await _context.AppUserProgresses.Select(p => p.SeriesId).ToListAsync(); //var allChapters = await GetChapterIdsForSeriesAsync(allSeriesWithProgress); - var cutoffProgressPoint = DateTime.Now - TimeSpan.FromDays(30); + var cuttoffProgressPoint = DateTime.Now - TimeSpan.FromDays(30); var query = (await CreateFilteredSearchQueryable(userId, libraryId, filter)) .Join(_context.AppUserProgresses, s => s.Id, progress => progress.SeriesId, (s, progress) => new @@ -612,12 +612,8 @@ public class SeriesRepository : ISeriesRepository // This is only taking into account chapters that have progress on them, not all chapters in said series LastChapterCreated = _context.Chapter.Where(c => progress.ChapterId == c.Id).Max(c => c.Created) //LastChapterCreated = _context.Chapter.Where(c => allChapters.Contains(c.Id)).Max(c => c.Created) - }); - if (cutoffOnDate) - { - query = query.Where(d => d.LastReadingProgress >= cutoffProgressPoint); - } - + }) + .Where(d => d.LastReadingProgress >= cuttoffProgressPoint); // I think I need another Join statement. The problem is the chapters are still limited to progress diff --git a/API/Services/EmailService.cs b/API/Services/EmailService.cs index c5ba90464..ab2c52a2c 100644 --- a/API/Services/EmailService.cs +++ b/API/Services/EmailService.cs @@ -98,7 +98,7 @@ public class EmailService : IEmailService return await SendEmailWithPost(emailLink + "/api/email/email-password-reset", data); } - private static async Task SendEmailWithGet(string url, int timeoutSecs = 30) + private static async Task SendEmailWithGet(string url) { try { @@ -108,7 +108,7 @@ public class EmailService : IEmailService .WithHeader("x-api-key", "MsnvA2DfQqxSK5jh") .WithHeader("x-kavita-version", BuildInfo.Version) .WithHeader("Content-Type", "application/json") - .WithTimeout(TimeSpan.FromSeconds(timeoutSecs)) + .WithTimeout(TimeSpan.FromSeconds(30)) .GetStringAsync(); if (!string.IsNullOrEmpty(response) && bool.Parse(response)) @@ -124,7 +124,7 @@ public class EmailService : IEmailService } - private static async Task SendEmailWithPost(string url, object data, int timeoutSecs = 30) + private static async Task SendEmailWithPost(string url, object data) { try { @@ -134,7 +134,7 @@ public class EmailService : IEmailService .WithHeader("x-api-key", "MsnvA2DfQqxSK5jh") .WithHeader("x-kavita-version", BuildInfo.Version) .WithHeader("Content-Type", "application/json") - .WithTimeout(TimeSpan.FromSeconds(timeoutSecs)) + .WithTimeout(TimeSpan.FromSeconds(30)) .PostJsonAsync(data); if (response.StatusCode != StatusCodes.Status200OK) diff --git a/API/Services/ReaderService.cs b/API/Services/ReaderService.cs index ab78437c2..ee8647187 100644 --- a/API/Services/ReaderService.cs +++ b/API/Services/ReaderService.cs @@ -16,8 +16,6 @@ namespace API.Services; public interface IReaderService { - Task MarkSeriesAsRead(AppUser user, int seriesId); - Task MarkSeriesAsUnread(AppUser user, int seriesId); void MarkChaptersAsRead(AppUser user, int seriesId, IEnumerable chapters); void MarkChaptersAsUnread(AppUser user, int seriesId, IEnumerable chapters); Task SaveReadingProgress(ProgressDto progressDto, int userId); @@ -47,40 +45,6 @@ public class ReaderService : IReaderService return Parser.Parser.NormalizePath(Path.Join(baseDirectory, $"{userId}", $"{seriesId}", $"{chapterId}")); } - /// - /// Does not commit. Marks all entities under the series as read. - /// - /// - /// - public async Task MarkSeriesAsRead(AppUser user, int seriesId) - { - var volumes = await _unitOfWork.VolumeRepository.GetVolumes(seriesId); - user.Progresses ??= new List(); - foreach (var volume in volumes) - { - MarkChaptersAsRead(user, seriesId, volume.Chapters); - } - - _unitOfWork.UserRepository.Update(user); - } - - /// - /// Does not commit. Marks all entities under the series as unread. - /// - /// - /// - public async Task MarkSeriesAsUnread(AppUser user, int seriesId) - { - var volumes = await _unitOfWork.VolumeRepository.GetVolumes(seriesId); - user.Progresses ??= new List(); - foreach (var volume in volumes) - { - MarkChaptersAsUnread(user, seriesId, volume.Chapters); - } - - _unitOfWork.UserRepository.Update(user); - } - /// /// Marks all Chapters as Read by creating or updating UserProgress rows. Does not commit. /// @@ -403,7 +367,7 @@ public class ReaderService : IReaderService .ToList(); // If there are any volumes that have progress, return those. If not, move on. - var currentlyReadingChapter = volumeChapters.FirstOrDefault(chapter => chapter.PagesRead < chapter.Pages); // (removed for GetContinuePoint_ShouldReturnFirstVolumeChapter_WhenPreExistingProgress), not sure if needed && chapter.PagesRead > 0 + var currentlyReadingChapter = volumeChapters.FirstOrDefault(chapter => chapter.PagesRead < chapter.Pages && chapter.PagesRead > 0); if (currentlyReadingChapter != null) return currentlyReadingChapter; // Check loose leaf chapters (and specials). First check if there are any diff --git a/Kavita.Common/Kavita.Common.csproj b/Kavita.Common/Kavita.Common.csproj index 381e53452..7ee020cd9 100644 --- a/Kavita.Common/Kavita.Common.csproj +++ b/Kavita.Common/Kavita.Common.csproj @@ -19,4 +19,4 @@ - \ No newline at end of file + diff --git a/UI/Web/src/app/_models/invite-user-response.ts b/UI/Web/src/app/_models/invite-user-response.ts deleted file mode 100644 index a9042c555..000000000 --- a/UI/Web/src/app/_models/invite-user-response.ts +++ /dev/null @@ -1,10 +0,0 @@ -export interface InviteUserResponse { - /** - * Link to register new user - */ - emailLink: string; - /** - * If an email was sent to the invited user - */ - emailSent: boolean; -} \ No newline at end of file diff --git a/UI/Web/src/app/_services/account.service.ts b/UI/Web/src/app/_services/account.service.ts index df5555f41..419dec77d 100644 --- a/UI/Web/src/app/_services/account.service.ts +++ b/UI/Web/src/app/_services/account.service.ts @@ -8,7 +8,6 @@ import { User } from '../_models/user'; import { Router } from '@angular/router'; import { MessageHubService } from './message-hub.service'; import { ThemeService } from '../theme.service'; -import { InviteUserResponse } from '../_models/invite-user-response'; @Injectable({ providedIn: 'root' @@ -22,9 +21,6 @@ export class AccountService implements OnDestroy { // Stores values, when someone subscribes gives (1) of last values seen. private currentUserSource = new ReplaySubject(1); - /** - * - */ currentUser$ = this.currentUserSource.asObservable(); /** @@ -63,7 +59,6 @@ export class AccountService implements OnDestroy { map((response: User) => { const user = response; if (user) { - console.log('Login: ', user); this.setCurrentUser(user); this.messageHub.createHubConnection(user, this.hasAdminRole(user)); } @@ -135,8 +130,8 @@ export class AccountService implements OnDestroy { return this.httpClient.post(this.baseUrl + 'account/resend-confirmation-email?userId=' + userId, {}, {responseType: 'text' as 'json'}); } - inviteUser(model: {email: string, roles: Array, libraries: Array}) { - return this.httpClient.post(this.baseUrl + 'account/invite', model); + inviteUser(model: {email: string, roles: Array, libraries: Array, sendEmail: boolean}) { + return this.httpClient.post(this.baseUrl + 'account/invite', model, {responseType: 'text' as 'json'}); } confirmEmail(model: {email: string, username: string, password: string, token: string}) { diff --git a/UI/Web/src/app/_services/nav.service.ts b/UI/Web/src/app/_services/nav.service.ts index c1ca3f0ad..9dba9d9b0 100644 --- a/UI/Web/src/app/_services/nav.service.ts +++ b/UI/Web/src/app/_services/nav.service.ts @@ -1,23 +1,71 @@ import { Injectable } from '@angular/core'; -import { ReplaySubject } from 'rxjs'; +import { ReplaySubject, take } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class NavService { + public localStorageSideNavKey = 'kavita--sidenav--collapsed'; private navbarVisibleSource = new ReplaySubject(1); + /** + * If the top Nav bar is rendered or not + */ navbarVisible$ = this.navbarVisibleSource.asObservable(); + private sideNavCollapseSource = new ReplaySubject(1); + /** + * If the Side Nav is in a collapsed state or not. + */ + sideNavCollapsed$ = this.sideNavCollapseSource.asObservable(); + + private sideNavVisibilitySource = new ReplaySubject(1); + /** + * If the side nav is rendered or not into the DOM. + */ + sideNavVisibility$ = this.sideNavVisibilitySource.asObservable(); + constructor() { this.showNavBar(); + const sideNavState = (localStorage.getItem(this.localStorageSideNavKey) === 'true') || false; + this.sideNavCollapseSource.next(sideNavState); + this.showSideNav(); } - + + /** + * Shows the top nav bar. This should be visible on all pages except the reader. + */ showNavBar() { this.navbarVisibleSource.next(true); } + /** + * Hides the top nav bar. + */ hideNavBar() { this.navbarVisibleSource.next(false); } + + /** + * Shows the side nav. When being visible, the side nav will automatically return to previous collapsed state. + */ + showSideNav() { + this.sideNavVisibilitySource.next(true); + } + + /** + * Hides the side nav. This is useful for the readers and login page. + */ + hideSideNav() { + this.sideNavVisibilitySource.next(false); + } + + toggleSideNav() { + this.sideNavCollapseSource.pipe(take(1)).subscribe(val => { + if (val === undefined) val = false; + const newVal = !(val || false); + this.sideNavCollapseSource.next(newVal); + localStorage.setItem(this.localStorageSideNavKey, newVal + ''); + }); + } } diff --git a/UI/Web/src/app/admin/admin.module.ts b/UI/Web/src/app/admin/admin.module.ts index d594cbff3..0f042a097 100644 --- a/UI/Web/src/app/admin/admin.module.ts +++ b/UI/Web/src/app/admin/admin.module.ts @@ -13,13 +13,13 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { ResetPasswordModalComponent } from './_modals/reset-password-modal/reset-password-modal.component'; import { ManageSettingsComponent } from './manage-settings/manage-settings.component'; import { ManageSystemComponent } from './manage-system/manage-system.component'; -import { ChangelogComponent } from './changelog/changelog.component'; +import { ChangelogComponent } from '../announcements/changelog/changelog.component'; import { PipeModule } from '../pipe/pipe.module'; import { InviteUserComponent } from './invite-user/invite-user.component'; import { RoleSelectorComponent } from './role-selector/role-selector.component'; import { LibrarySelectorComponent } from './library-selector/library-selector.component'; import { EditUserComponent } from './edit-user/edit-user.component'; -import { UserSettingsModule } from '../user-settings/user-settings.module'; +import { SidenavModule } from '../sidenav/sidenav.module'; @@ -35,7 +35,6 @@ import { UserSettingsModule } from '../user-settings/user-settings.module'; ResetPasswordModalComponent, ManageSettingsComponent, ManageSystemComponent, - ChangelogComponent, InviteUserComponent, RoleSelectorComponent, LibrarySelectorComponent, @@ -51,7 +50,7 @@ import { UserSettingsModule } from '../user-settings/user-settings.module'; NgbDropdownModule, SharedModule, PipeModule, - UserSettingsModule // API-key componet + SidenavModule ], providers: [] }) diff --git a/UI/Web/src/app/admin/dashboard/dashboard.component.html b/UI/Web/src/app/admin/dashboard/dashboard.component.html index 84a81d506..7db5206ea 100644 --- a/UI/Web/src/app/admin/dashboard/dashboard.component.html +++ b/UI/Web/src/app/admin/dashboard/dashboard.component.html @@ -1,6 +1,9 @@ -
-

Admin Dashboard

- + +

+ Admin Dashboard +

+
+
diff --git a/UI/Web/src/app/admin/dashboard/dashboard.component.ts b/UI/Web/src/app/admin/dashboard/dashboard.component.ts index 33549db13..d84b3ba26 100644 --- a/UI/Web/src/app/admin/dashboard/dashboard.component.ts +++ b/UI/Web/src/app/admin/dashboard/dashboard.component.ts @@ -3,6 +3,7 @@ import { ActivatedRoute } from '@angular/router'; import { ToastrService } from 'ngx-toastr'; import { ServerService } from 'src/app/_services/server.service'; import { Title } from '@angular/platform-browser'; +import { NavService } from '../../_services/nav.service'; @@ -18,13 +19,12 @@ export class DashboardComponent implements OnInit { {title: 'Users', fragment: 'users'}, {title: 'Libraries', fragment: 'libraries'}, {title: 'System', fragment: 'system'}, - {title: 'Changelog', fragment: 'changelog'}, ]; counter = this.tabs.length + 1; active = this.tabs[0]; constructor(public route: ActivatedRoute, private serverService: ServerService, - private toastr: ToastrService, private titleService: Title) { + private toastr: ToastrService, private titleService: Title, public navService: NavService) { this.route.fragment.subscribe(frag => { const tab = this.tabs.filter(item => item.fragment === frag); if (tab.length > 0) { diff --git a/UI/Web/src/app/admin/invite-user/invite-user.component.html b/UI/Web/src/app/admin/invite-user/invite-user.component.html index 495b3f6e9..83fbb86eb 100644 --- a/UI/Web/src/app/admin/invite-user/invite-user.component.html +++ b/UI/Web/src/app/admin/invite-user/invite-user.component.html @@ -9,7 +9,13 @@ Invite a user to your server. Enter their email in and we will send them an email to create an account.

-
+

+ +  Checking accessibility of server... +

+ + +
@@ -22,6 +28,11 @@
+ +

Use this link to finish setting up the user account due to your server not being accessible outside your local network.

+ +
+
@@ -33,21 +44,12 @@
- -

User invited

-

You can use the following link below to setup the account for your user or use the copy button. You may need to log out before using the link to register a new user. - If your server is externallyaccessible, an email will have been sent to the user and the links can be used by them to finish setting up their account. -

- - -
-