Merge pull request #254 from adityachandelgit/develop

Merge Develop into Master for the Release
This commit is contained in:
Aditya Chandel
2025-05-11 23:47:22 -06:00
committed by GitHub
8 changed files with 123 additions and 100 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ dependencies {
// --- Database & Migration --- // --- Database & Migration ---
implementation 'org.mariadb.jdbc:mariadb-java-client:3.5.3' implementation 'org.mariadb.jdbc:mariadb-java-client:3.5.3'
implementation 'org.flywaydb:flyway-mysql:11.7.1' implementation 'org.flywaydb:flyway-mysql:11.8.0'
// --- Security & Authentication --- // --- Security & Authentication ---
implementation 'io.jsonwebtoken:jjwt-api:0.12.6' implementation 'io.jsonwebtoken:jjwt-api:0.12.6'
@@ -27,10 +27,11 @@ spring:
username: ${DATABASE_USERNAME:root} username: ${DATABASE_USERNAME:root}
password: ${DATABASE_PASSWORD:${MYSQL_ROOT_PASSWORD}} password: ${DATABASE_PASSWORD:${MYSQL_ROOT_PASSWORD}}
hikari: hikari:
max-lifetime: 580000 # 580 seconds max-lifetime: 580000 # 9.6 minutes (avoid DB-side connection cuts)
connection-test-query: SELECT 1 connection-test-query: SELECT 1
maximum-pool-size: 10 maximum-pool-size: 10 # Allows bursts
idle-timeout: 300000 # 5 minutes minimum-idle: 1 # Shrinks when idle
idle-timeout: 300000 # 5 minutes before idle connections are closed
jpa: jpa:
hibernate: hibernate:
naming: naming:
@@ -52,3 +53,8 @@ logging:
com.adityachandel.booklore: ${LOG_LEVEL:INFO} com.adityachandel.booklore: ${LOG_LEVEL:INFO}
org.apache.fontbox: ERROR org.apache.fontbox: ERROR
org.apache.pdfbox: ERROR org.apache.pdfbox: ERROR
org.quartz.core.QuartzScheduler: WARN
org.quartz.simpl.SimpleThreadPool: WARN
org.quartz.simpl.RAMJobStore: WARN
org.hibernate.orm.connections.pooling: WARN
org.springframework.security.config.annotation.authentication.configuration.InitializeUserDetailsBeanManagerConfigurer: ERROR
@@ -97,7 +97,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
@ViewChild(BookTableComponent) bookTableComponent!: BookTableComponent; @ViewChild(BookTableComponent) bookTableComponent!: BookTableComponent;
@ViewChild(BookFilterComponent) bookFilterComponent!: BookFilterComponent; @ViewChild(BookFilterComponent) bookFilterComponent!: BookFilterComponent;
selectedFilter = new BehaviorSubject<{ type: string; value: any } | null>(null); selectedFilter = new BehaviorSubject<Record<string, any> | null>(null);
protected resetFilterSubject = new Subject<void>(); protected resetFilterSubject = new Subject<void>();
protected userService = inject(UserService); protected userService = inject(UserService);
@@ -257,43 +257,37 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
private sideBarFilter(bookState: BookState): Observable<BookState> { private sideBarFilter(bookState: BookState): Observable<BookState> {
return this.selectedFilter.pipe( return this.selectedFilter.pipe(
map(selectedFilter => { map((activeFilters: Record<string, any[]> | null) => {
if (!selectedFilter) { if (!activeFilters) {
return bookState; return bookState;
} }
let filteredBooks = bookState.books || [];
switch (selectedFilter.type) { const filteredBooks = (bookState.books || []).filter(book => {
case 'author': return Object.entries(activeFilters).every(([filterType, filterValues]) => {
filteredBooks = filteredBooks.filter(book => if (!Array.isArray(filterValues) || filterValues.length === 0) return true;
book.metadata?.authors?.some(author => author === selectedFilter.value)
); switch (filterType) {
break; case 'author':
case 'category': return filterValues.every(val => book.metadata?.authors?.includes(val));
filteredBooks = filteredBooks.filter(book => case 'category':
book.metadata?.categories?.some(category => category === selectedFilter.value) return filterValues.every(val => book.metadata?.categories?.includes(val));
); case 'publisher':
break; return filterValues.every(val => book.metadata?.publisher === val);
case 'publisher': case 'award':
filteredBooks = filteredBooks.filter(book => return filterValues.every(val =>
book.metadata?.publisher === selectedFilter.value book.metadata?.awards?.some(
); award => award.name === val.name && award.designation === 'WINNER'
break; )
case 'award': );
filteredBooks = filteredBooks.filter(book => case 'series':
book.metadata?.awards?.some( return filterValues.every(val => book.metadata?.seriesName === val);
award => award.name === selectedFilter.value.name && award.designation === 'WINNER' default:
) return true;
); }
break; });
case 'series': });
filteredBooks = filteredBooks.filter(book =>
book.metadata?.seriesName === selectedFilter.value return { ...bookState, books: filteredBooks };
);
break;
default:
break;
}
return {...bookState, books: filteredBooks};
}) })
); );
} }
@@ -523,8 +517,8 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
} }
ngAfterViewInit() { ngAfterViewInit() {
this.bookFilterComponent.filterSelected.subscribe((item) => { this.bookFilterComponent.filterSelected.subscribe((filters: Record<string, any> | null) => {
this.selectedFilter.next(item); this.selectedFilter.next(filters);
}); });
this.activatedRoute.queryParamMap.subscribe(paramMap => { this.activatedRoute.queryParamMap.subscribe(paramMap => {
@@ -1,13 +1,23 @@
<div *ngIf="showFilters" class="w-[225px] ml-4 h-[calc(100vh-6.5rem)] rounded-xl bg-[var(--card-background)] overflow-hidden"> <div *ngIf="showFilters" class="w-[225px] ml-4 h-[calc(100vh-6.5rem)] rounded-xl bg-[var(--card-background)] overflow-hidden">
<p-accordion [value]="0"> <p-accordion [value]="0">
<p-accordion-panel *ngFor="let filterType of filterTypes; let i = index" [value]="i"> <p-accordion-panel *ngFor="let filterType of filterTypes; let i = index" [value]="i">
<p-accordion-header>{{ filterType | titlecase }}</p-accordion-header> <p-accordion-header>
<span class="inline-flex items-center gap-1">
{{ filterType | titlecase }}
<span *ngIf="activeFilters[filterType]?.length" class="text-sm text-[var(--primary-color)]">
({{ activeFilters[filterType].length }})
</span>
</span>
</p-accordion-header>
<p-accordion-content class="h-[40rem] !overflow-y-auto"> <p-accordion-content class="h-[40rem] !overflow-y-auto">
<div *ngIf="filterStreams[filterType] | async as filters"> <div *ngIf="filterStreams[filterType] | async as filters">
<div *ngFor="let filter of filters"> <div *ngFor="let filter of filters">
<p <p
class="cursor-pointer transition-colors duration-200 ease-in-out pb-1" class="cursor-pointer transition-colors duration-200 ease-in-out pb-1"
[ngClass]="{'text-[var(--primary-color)]': activeFilter.type === filterType && activeFilter.value === (filter.value?.id || filter.value)}" [ngClass]="{
'text-[var(--primary-color)]':
activeFilters[filterType]?.includes(filter.value?.id || filter.value)
}"
(click)="handleFilterClick(filterType, filter.value?.id || filter.value)"> (click)="handleFilterClick(filterType, filter.value?.id || filter.value)">
<p-badge [value]="filter.bookCount"></p-badge> <p-badge [value]="filter.bookCount"></p-badge>
{{ filter.value.name || filter.value }} {{ filter.value.name || filter.value }}
@@ -32,14 +32,14 @@ type Filter<T> = { value: T; bookCount: number };
] ]
}) })
export class BookFilterComponent implements OnInit { export class BookFilterComponent implements OnInit {
@Output() filterSelected = new EventEmitter<{ type: string; value: any } | null>(); @Output() filterSelected = new EventEmitter<Record<string, any> | null>();
@Input() showFilters: boolean = true; @Input() showFilters: boolean = true;
@Input() entity$!: Observable<Library | Shelf | null> | undefined; @Input() entity$!: Observable<Library | Shelf | null> | undefined;
@Input() entityType$!: Observable<EntityType> | undefined; @Input() entityType$!: Observable<EntityType> | undefined;
@Input() resetFilter$!: Subject<void>; @Input() resetFilter$!: Subject<void>;
activeFilter: { type: string; value: any | null } = {type: '', value: null}; activeFilters: Record<string, any> = {};
filterStreams: Record<string, Observable<Filter<any>[]>> = {}; filterStreams: Record<string, Observable<Filter<any>[]>> = {};
filterTypes: string[] = []; filterTypes: string[] = [];
@@ -91,18 +91,29 @@ export class BookFilterComponent implements OnInit {
return books; return books;
} }
handleFilterClick(filterType: string, value: any) { handleFilterClick(filterType: string, value: any): void {
if (this.activeFilter.type === filterType && this.activeFilter.value === value) { if (!this.activeFilters[filterType]) {
this.activeFilter = {type: '', value: null}; this.activeFilters[filterType] = [];
this.filterSelected.emit(null);
} else {
this.activeFilter = {type: filterType, value};
this.filterSelected.emit({type: filterType, value});
} }
const index = this.activeFilters[filterType].indexOf(value);
if (index > -1) {
// Deselect
this.activeFilters[filterType].splice(index, 1);
if (this.activeFilters[filterType].length === 0) {
delete this.activeFilters[filterType];
}
} else {
// Select
this.activeFilters[filterType].push(value);
}
// Emit updated filter state
this.filterSelected.emit({ ...this.activeFilters });
} }
clearActiveFilter() { clearActiveFilter() {
this.activeFilter = { type: '', value: null }; this.activeFilters = {};
this.filterSelected.emit(null); this.filterSelected.emit(null);
} }
} }
@@ -1,47 +1,46 @@
<p-progressSpinner *ngIf="(bookState$ | async)?.loaded === false" styleClass="spinner center-spinner"></p-progressSpinner> <div class="dashboard-container">
<p-progressSpinner *ngIf="(bookState$ | async)?.loaded === false" styleClass="spinner center-spinner"></p-progressSpinner>
<div class="dashboard" *ngIf="(bookState$ | async)?.loaded === true"> <div class="dashboard" *ngIf="(bookState$ | async)?.loaded === true">
<div> <div>
<div class="dashboard-no-library" *ngIf="isLibrariesEmpty$ | async; else dashboardScroller"> <div class="dashboard-no-library" *ngIf="isLibrariesEmpty$ | async; else dashboardScroller">
<div *ngIf="(userService.userData$ | async)?.permissions as permissions"> <div *ngIf="(userService.userData$ | async)?.permissions as permissions">
<div *ngIf="permissions.admin || permissions.canManipulateLibrary"> <div *ngIf="permissions.admin || permissions.canManipulateLibrary">
<h1 class="no-library-header">Looks like you haven't added a library yet. Let's add one!</h1> <h1 class="no-library-header">Looks like you haven't added a library yet. Let's add one!</h1>
<p-button <p-button
label="Add a Library" label="Add a Library"
icon="pi pi-plus" icon="pi pi-plus"
styleClass="p-button-rounded p-button-outlined" styleClass="p-button-rounded p-button-outlined"
(click)="createNewLibrary()"> (click)="createNewLibrary()">
</p-button> </p-button>
</div>
</div> </div>
</div> </div>
<ng-template #dashboardScroller>
<app-dashboard-scroller
[books]="lastReadBooks$ | async"
[bookListType]="'lastRead'"
[title]="'Last Read Books'">
</app-dashboard-scroller>
<div class="mb-6">
<p-divider></p-divider>
</div>
<app-dashboard-scroller
[books]="latestAddedBooks$ | async"
[title]="'Latest Added Books'">
</app-dashboard-scroller>
<div class="mb-6">
<p-divider></p-divider>
</div>
<app-dashboard-scroller
[books]="randomBooks$ | async"
[title]="'Discover Random Reads'">
</app-dashboard-scroller>
</ng-template>
</div> </div>
<ng-template #dashboardScroller>
<app-dashboard-scroller
[books]="lastReadBooks$ | async"
[bookListType]="'lastRead'"
[title]="'Last Read Books'">
</app-dashboard-scroller>
<div class="mb-6">
<p-divider></p-divider>
</div>
<app-dashboard-scroller
[books]="latestAddedBooks$ | async"
[title]="'Latest Added Books'">
</app-dashboard-scroller>
<div class="mb-6">
<p-divider></p-divider>
</div>
<app-dashboard-scroller
[books]="randomBooks$ | async"
[title]="'Discover Random Reads'">
</app-dashboard-scroller>
<p-divider></p-divider>
</ng-template>
</div> </div>
</div> </div>
@@ -1,3 +1,8 @@
.dashboard-container {
height: calc(100vh - 6.7rem);
overflow-y: auto;
}
.dashboard { .dashboard {
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
@@ -13,7 +13,6 @@ import {Library} from '../../book/model/library.model';
import {LibraryService} from '../../book/service/library.service'; import {LibraryService} from '../../book/service/library.service';
import {Dialog} from 'primeng/dialog'; import {Dialog} from 'primeng/dialog';
import {Password} from 'primeng/password'; import {Password} from 'primeng/password';
import {Tooltip} from 'primeng/tooltip';
@Component({ @Component({
selector: 'app-user-management', selector: 'app-user-management',
@@ -26,8 +25,7 @@ import {Tooltip} from 'primeng/tooltip';
NgStyle, NgStyle,
MultiSelect, MultiSelect,
Dialog, Dialog,
Password, Password
Tooltip,
], ],
templateUrl: './user-management.component.html', templateUrl: './user-management.component.html',
styleUrls: ['./user-management.component.scss'], styleUrls: ['./user-management.component.scss'],