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 ---
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 ---
implementation 'io.jsonwebtoken:jjwt-api:0.12.6'
@@ -27,10 +27,11 @@ spring:
username: ${DATABASE_USERNAME:root}
password: ${DATABASE_PASSWORD:${MYSQL_ROOT_PASSWORD}}
hikari:
max-lifetime: 580000 # 580 seconds
max-lifetime: 580000 # 9.6 minutes (avoid DB-side connection cuts)
connection-test-query: SELECT 1
maximum-pool-size: 10
idle-timeout: 300000 # 5 minutes
maximum-pool-size: 10 # Allows bursts
minimum-idle: 1 # Shrinks when idle
idle-timeout: 300000 # 5 minutes before idle connections are closed
jpa:
hibernate:
naming:
@@ -51,4 +52,9 @@ logging:
root: ${ROOT_LOG_LEVEL:INFO}
com.adityachandel.booklore: ${LOG_LEVEL:INFO}
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(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 userService = inject(UserService);
@@ -257,43 +257,37 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
private sideBarFilter(bookState: BookState): Observable<BookState> {
return this.selectedFilter.pipe(
map(selectedFilter => {
if (!selectedFilter) {
map((activeFilters: Record<string, any[]> | null) => {
if (!activeFilters) {
return bookState;
}
let filteredBooks = bookState.books || [];
switch (selectedFilter.type) {
case 'author':
filteredBooks = filteredBooks.filter(book =>
book.metadata?.authors?.some(author => author === selectedFilter.value)
);
break;
case 'category':
filteredBooks = filteredBooks.filter(book =>
book.metadata?.categories?.some(category => category === selectedFilter.value)
);
break;
case 'publisher':
filteredBooks = filteredBooks.filter(book =>
book.metadata?.publisher === selectedFilter.value
);
break;
case 'award':
filteredBooks = filteredBooks.filter(book =>
book.metadata?.awards?.some(
award => award.name === selectedFilter.value.name && award.designation === 'WINNER'
)
);
break;
case 'series':
filteredBooks = filteredBooks.filter(book =>
book.metadata?.seriesName === selectedFilter.value
);
break;
default:
break;
}
return {...bookState, books: filteredBooks};
const filteredBooks = (bookState.books || []).filter(book => {
return Object.entries(activeFilters).every(([filterType, filterValues]) => {
if (!Array.isArray(filterValues) || filterValues.length === 0) return true;
switch (filterType) {
case 'author':
return filterValues.every(val => book.metadata?.authors?.includes(val));
case 'category':
return filterValues.every(val => book.metadata?.categories?.includes(val));
case 'publisher':
return filterValues.every(val => book.metadata?.publisher === val);
case 'award':
return filterValues.every(val =>
book.metadata?.awards?.some(
award => award.name === val.name && award.designation === 'WINNER'
)
);
case 'series':
return filterValues.every(val => book.metadata?.seriesName === val);
default:
return true;
}
});
});
return { ...bookState, books: filteredBooks };
})
);
}
@@ -523,8 +517,8 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
}
ngAfterViewInit() {
this.bookFilterComponent.filterSelected.subscribe((item) => {
this.selectedFilter.next(item);
this.bookFilterComponent.filterSelected.subscribe((filters: Record<string, any> | null) => {
this.selectedFilter.next(filters);
});
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">
<p-accordion [value]="0">
<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">
<div *ngIf="filterStreams[filterType] | async as filters">
<div *ngFor="let filter of filters">
<p
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)">
<p-badge [value]="filter.bookCount"></p-badge>
{{ filter.value.name || filter.value }}
@@ -32,14 +32,14 @@ type Filter<T> = { value: T; bookCount: number };
]
})
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() entity$!: Observable<Library | Shelf | null> | undefined;
@Input() entityType$!: Observable<EntityType> | undefined;
@Input() resetFilter$!: Subject<void>;
activeFilter: { type: string; value: any | null } = {type: '', value: null};
activeFilters: Record<string, any> = {};
filterStreams: Record<string, Observable<Filter<any>[]>> = {};
filterTypes: string[] = [];
@@ -91,18 +91,29 @@ export class BookFilterComponent implements OnInit {
return books;
}
handleFilterClick(filterType: string, value: any) {
if (this.activeFilter.type === filterType && this.activeFilter.value === value) {
this.activeFilter = {type: '', value: null};
this.filterSelected.emit(null);
} else {
this.activeFilter = {type: filterType, value};
this.filterSelected.emit({type: filterType, value});
handleFilterClick(filterType: string, value: any): void {
if (!this.activeFilters[filterType]) {
this.activeFilters[filterType] = [];
}
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() {
this.activeFilter = { type: '', value: null };
this.activeFilters = {};
this.filterSelected.emit(null);
}
}
@@ -1,47 +1,46 @@
<p-progressSpinner *ngIf="(bookState$ | async)?.loaded === false" styleClass="spinner center-spinner"></p-progressSpinner>
<div class="dashboard" *ngIf="(bookState$ | async)?.loaded === true">
<div>
<div class="dashboard-no-library" *ngIf="isLibrariesEmpty$ | async; else dashboardScroller">
<div *ngIf="(userService.userData$ | async)?.permissions as permissions">
<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>
<p-button
label="Add a Library"
icon="pi pi-plus"
styleClass="p-button-rounded p-button-outlined"
(click)="createNewLibrary()">
</p-button>
<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>
<div class="dashboard-no-library" *ngIf="isLibrariesEmpty$ | async; else dashboardScroller">
<div *ngIf="(userService.userData$ | async)?.permissions as permissions">
<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>
<p-button
label="Add a Library"
icon="pi pi-plus"
styleClass="p-button-rounded p-button-outlined"
(click)="createNewLibrary()">
</p-button>
</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>
<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>
@@ -1,3 +1,8 @@
.dashboard-container {
height: calc(100vh - 6.7rem);
overflow-y: auto;
}
.dashboard {
flex-direction: column;
align-items: center;
@@ -13,7 +13,6 @@ import {Library} from '../../book/model/library.model';
import {LibraryService} from '../../book/service/library.service';
import {Dialog} from 'primeng/dialog';
import {Password} from 'primeng/password';
import {Tooltip} from 'primeng/tooltip';
@Component({
selector: 'app-user-management',
@@ -26,8 +25,7 @@ import {Tooltip} from 'primeng/tooltip';
NgStyle,
MultiSelect,
Dialog,
Password,
Tooltip,
Password
],
templateUrl: './user-management.component.html',
styleUrls: ['./user-management.component.scss'],