Make left menu work
This commit is contained in:
@@ -50,6 +50,9 @@ public class LibraryService {
|
|||||||
Set<String> deletedPaths = currentPaths.stream().filter(path -> !updatedPaths.contains(path)).collect(Collectors.toSet());
|
Set<String> deletedPaths = currentPaths.stream().filter(path -> !updatedPaths.contains(path)).collect(Collectors.toSet());
|
||||||
Set<String> newPaths = updatedPaths.stream().filter(path -> !currentPaths.contains(path)).collect(Collectors.toSet());
|
Set<String> newPaths = updatedPaths.stream().filter(path -> !currentPaths.contains(path)).collect(Collectors.toSet());
|
||||||
|
|
||||||
|
if(newPaths.isEmpty() && deletedPaths.isEmpty()) {
|
||||||
|
return libraryMapper.toLibrary(libraryRepository.save(library));
|
||||||
|
} else {
|
||||||
if (!deletedPaths.isEmpty()) {
|
if (!deletedPaths.isEmpty()) {
|
||||||
Set<LibraryPathEntity> pathsToRemove = library.getLibraryPaths().stream()
|
Set<LibraryPathEntity> pathsToRemove = library.getLibraryPaths().stream()
|
||||||
.filter(pathEntity -> deletedPaths.contains(pathEntity.getPath()))
|
.filter(pathEntity -> deletedPaths.contains(pathEntity.getPath()))
|
||||||
@@ -85,8 +88,8 @@ public class LibraryService {
|
|||||||
log.info("Parsing task completed!");
|
log.info("Parsing task completed!");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
return libraryMapper.toLibrary(libraryRepository.save(library));
|
||||||
return libraryMapper.toLibrary(library);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Library createLibrary(CreateLibraryRequest request) {
|
public Library createLibrary(CreateLibraryRequest request) {
|
||||||
|
|||||||
@@ -26,6 +26,14 @@
|
|||||||
</i>
|
</i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<a class="topbar-items topbar-item">
|
||||||
|
<i
|
||||||
|
class="pi pi-sort"
|
||||||
|
pTooltip="Select sorting"
|
||||||
|
tooltipPosition="top">
|
||||||
|
</i>
|
||||||
|
</a>
|
||||||
|
|
||||||
<a class="topbar-items topbar-item" (click)="toggleTableGrid()">
|
<a class="topbar-items topbar-item" (click)="toggleTableGrid()">
|
||||||
<i
|
<i
|
||||||
[ngClass]="viewIcon"
|
[ngClass]="viewIcon"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, inject, OnInit} from '@angular/core';
|
||||||
import {AppMenuitemComponent} from './app.menuitem.component';
|
import {AppMenuitemComponent} from './app.menuitem.component';
|
||||||
import {AsyncPipe, NgForOf, NgIf} from '@angular/common';
|
import {AsyncPipe, NgForOf, NgIf} from '@angular/common';
|
||||||
import {MenuModule} from 'primeng/menu';
|
import {MenuModule} from 'primeng/menu';
|
||||||
@@ -7,6 +7,7 @@ import {Observable, of} from 'rxjs';
|
|||||||
import {map} from 'rxjs/operators';
|
import {map} from 'rxjs/operators';
|
||||||
import {ShelfService} from '../../../book/service/shelf.service';
|
import {ShelfService} from '../../../book/service/shelf.service';
|
||||||
import {BookService} from '../../../book/service/book.service';
|
import {BookService} from '../../../book/service/book.service';
|
||||||
|
import {LibraryShelfMenuService} from '../../../book/service/library-shelf-menu.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-menu',
|
selector: 'app-menu',
|
||||||
@@ -18,8 +19,11 @@ export class AppMenuComponent implements OnInit {
|
|||||||
shelfMenu$: Observable<any> | undefined;
|
shelfMenu$: Observable<any> | undefined;
|
||||||
homeMenu$: Observable<any> | undefined;
|
homeMenu$: Observable<any> | undefined;
|
||||||
|
|
||||||
constructor(private libraryService: LibraryService, private shelfService: ShelfService, private bookService: BookService) {
|
private libraryService = inject(LibraryService);
|
||||||
}
|
private shelfService = inject(ShelfService);
|
||||||
|
private bookService = inject(BookService);
|
||||||
|
private libraryShelfMenuService = inject(LibraryShelfMenuService);
|
||||||
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.libraryMenu$ = this.libraryService.libraryState$.pipe(
|
this.libraryMenu$ = this.libraryService.libraryState$.pipe(
|
||||||
@@ -28,7 +32,9 @@ export class AppMenuComponent implements OnInit {
|
|||||||
label: 'Library',
|
label: 'Library',
|
||||||
separator: false,
|
separator: false,
|
||||||
items: state.libraries?.map((library) => ({
|
items: state.libraries?.map((library) => ({
|
||||||
|
menu: this.libraryShelfMenuService.initializeLibraryMenuItems(library),
|
||||||
label: library.name,
|
label: library.name,
|
||||||
|
type: 'Library',
|
||||||
icon: 'pi pi-' + library.icon,
|
icon: 'pi pi-' + library.icon,
|
||||||
routerLink: [`/library/${library.id}/books`],
|
routerLink: [`/library/${library.id}/books`],
|
||||||
bookCount$: this.libraryService.getBookCount(library.id ?? 0),
|
bookCount$: this.libraryService.getBookCount(library.id ?? 0),
|
||||||
@@ -43,7 +49,9 @@ export class AppMenuComponent implements OnInit {
|
|||||||
label: 'Shelves',
|
label: 'Shelves',
|
||||||
separator: false,
|
separator: false,
|
||||||
items: state.shelves?.map((shelf) => ({
|
items: state.shelves?.map((shelf) => ({
|
||||||
|
menu: this.libraryShelfMenuService.initializeLibraryMenuItems(shelf),
|
||||||
label: shelf.name,
|
label: shelf.name,
|
||||||
|
type: 'Shelf',
|
||||||
icon: 'pi pi-' + shelf.icon,
|
icon: 'pi pi-' + shelf.icon,
|
||||||
routerLink: [`/shelf/${shelf.id}/books`],
|
routerLink: [`/shelf/${shelf.id}/books`],
|
||||||
bookCount$: this.shelfService.getBookCount(shelf.id ?? 0),
|
bookCount$: this.shelfService.getBookCount(shelf.id ?? 0),
|
||||||
@@ -66,6 +74,7 @@ export class AppMenuComponent implements OnInit {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'All Books',
|
label: 'All Books',
|
||||||
|
type: 'All Books',
|
||||||
icon: 'pi pi-fw pi-book',
|
icon: 'pi pi-fw pi-book',
|
||||||
routerLink: ['/all-books'],
|
routerLink: ['/all-books'],
|
||||||
bookCount$: of(bookState.books ? bookState.books.length : 0),
|
bookCount$: of(bookState.books ? bookState.books.length : 0),
|
||||||
|
|||||||
@@ -28,8 +28,10 @@
|
|||||||
</span>
|
</span>
|
||||||
<i class="pi pi-fw pi-angle-down layout-submenu-toggler" *ngIf="item.items"></i>
|
<i class="pi pi-fw pi-angle-down layout-submenu-toggler" *ngIf="item.items"></i>
|
||||||
</a>
|
</a>
|
||||||
<span *ngIf="(item.routerLink && !item.items) && item.visible !== false" class="book-count">
|
<span *ngIf="(item.routerLink && !item.items) && item.visible !== false">
|
||||||
|
<ng-container *ngIf="item.type === 'Library' || item.type === 'Shelf'">
|
||||||
<p-button
|
<p-button
|
||||||
|
(click)="entitymenu.toggle($event)"
|
||||||
(mouseover)="hovered = true"
|
(mouseover)="hovered = true"
|
||||||
(mouseleave)="hovered = false"
|
(mouseleave)="hovered = false"
|
||||||
[text]="true"
|
[text]="true"
|
||||||
@@ -41,6 +43,15 @@
|
|||||||
[style.height]="'30px'"
|
[style.height]="'30px'"
|
||||||
[style.display]="'flex'">
|
[style.display]="'flex'">
|
||||||
</p-button>
|
</p-button>
|
||||||
|
<p-menu #entitymenu [model]="item.menu" [popup]="true" appendTo="body"></p-menu>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container *ngIf="item.type === 'All Books'">
|
||||||
|
<p
|
||||||
|
class="text-[var(--primary-color)] pr-1">
|
||||||
|
{{ (item.bookCount$ | async)?.toString() || '0' }}
|
||||||
|
</p>
|
||||||
|
</ng-container>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import {MenuService} from './service/app.menu.service';
|
|||||||
import {AsyncPipe, NgClass, NgForOf, NgIf} from '@angular/common';
|
import {AsyncPipe, NgClass, NgForOf, NgIf} from '@angular/common';
|
||||||
import {Ripple} from 'primeng/ripple';
|
import {Ripple} from 'primeng/ripple';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
|
import {Menu} from 'primeng/menu';
|
||||||
|
import {MenuItem} from 'primeng/api';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: '[app-menuitem]',
|
selector: '[app-menuitem]',
|
||||||
@@ -20,7 +22,8 @@ import {Button} from 'primeng/button';
|
|||||||
Ripple,
|
Ripple,
|
||||||
NgIf,
|
NgIf,
|
||||||
AsyncPipe,
|
AsyncPipe,
|
||||||
Button
|
Button,
|
||||||
|
Menu
|
||||||
],
|
],
|
||||||
animations: [
|
animations: [
|
||||||
trigger('children', [
|
trigger('children', [
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<div class="topbar-right-items">
|
<div class="topbar-right-items">
|
||||||
<app-book-searcher></app-book-searcher>
|
<app-book-searcher></app-book-searcher>
|
||||||
<ul class="topbar-items">
|
<ul class="topbar-items pl-6">
|
||||||
<div class="flex gap-6">
|
<div class="flex gap-6">
|
||||||
<li>
|
<li>
|
||||||
<a class="topbar-item">
|
<a class="topbar-item">
|
||||||
|
|||||||
Reference in New Issue
Block a user