- Add option to sort sidebar shelf and library
- Move user settings to a separate table - Make settings tabs' elements more consistent
This commit is contained in:
committed by
Aditya Chandel
parent
4cb82d2ba7
commit
5d1dd1576c
@@ -1,7 +1,7 @@
|
||||
<div class="w-full h-[calc(100vh-12.1rem)] overflow-y-auto border rounded-lg p-4 enclosing-container">
|
||||
|
||||
<div class="flex justify-between items-center pb-2 pt-4">
|
||||
<h2 class="text-xl flex items-center gap-2">
|
||||
<div class="flex justify-between items-center pb-2 pt-2">
|
||||
<h2 class="text-lg font-bold flex items-center gap-2">
|
||||
Current Booklore Users
|
||||
</h2>
|
||||
<p-button outlined="true" label="Create BookLore User" icon="pi pi-plus" (onClick)="openCreateUserDialog()"></p-button>
|
||||
@@ -70,12 +70,12 @@
|
||||
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canEmailBook" disabled *ngIf="!user.isEditing"></p-checkbox>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<ng-container *ngIf="user.username !== 'admin'">
|
||||
<ng-container *ngIf="!user.permissions.admin">
|
||||
<p-button *ngIf="!user.isEditing" icon="pi pi-pencil" outlined="true" severity="info" (onClick)="toggleEdit(user)"></p-button>
|
||||
<p-button *ngIf="user.isEditing" icon="pi pi-check" outlined="true" severity="success" (onClick)="saveUser(user)"></p-button>
|
||||
<p-button *ngIf="user.isEditing" icon="pi pi-times" outlined="true" severity="danger" (onClick)="toggleEdit(user)"></p-button>
|
||||
</ng-container>
|
||||
<p-button *ngIf="user.username === 'admin'"
|
||||
<p-button *ngIf="!user.permissions.admin"
|
||||
icon="pi pi-pencil"
|
||||
outlined="true"
|
||||
severity="primary"
|
||||
@@ -83,12 +83,12 @@
|
||||
</p-button>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<ng-container *ngIf="user.username !== 'admin'">
|
||||
<ng-container *ngIf="!user.permissions.admin">
|
||||
<p-button icon="pi pi-key" outlined="true" severity="warn" (onClick)="openChangePasswordDialog(user)"></p-button>
|
||||
</ng-container>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<ng-container *ngIf="user.username !== 'admin'">
|
||||
<ng-container *ngIf="!user.permissions.admin">
|
||||
<p-button icon="pi pi-trash" outlined="true" severity="danger" (onClick)="deleteUser(user)"></p-button>
|
||||
</ng-container>
|
||||
</td>
|
||||
|
||||
@@ -6,6 +6,43 @@ import {RxStompService} from '../../shared/websocket/rx-stomp.service';
|
||||
import {Library} from '../../book/model/library.model';
|
||||
import {catchError} from 'rxjs/operators';
|
||||
|
||||
export interface SidebarLibrarySorting {
|
||||
field: string;
|
||||
order: string;
|
||||
}
|
||||
|
||||
export interface SidebarShelfSorting {
|
||||
field: string;
|
||||
order: string;
|
||||
}
|
||||
|
||||
export interface PerBookSetting {
|
||||
pdf: string;
|
||||
epub: string;
|
||||
}
|
||||
|
||||
export type PageSpread = 'off' | 'even' | 'odd';
|
||||
|
||||
export interface PdfReaderSetting {
|
||||
pageSpread: PageSpread;
|
||||
pageZoom: string;
|
||||
showSidebar: boolean;
|
||||
}
|
||||
|
||||
export interface EpubReaderSetting {
|
||||
theme: string;
|
||||
font: string;
|
||||
fontSize: number;
|
||||
}
|
||||
|
||||
export interface UserSettings {
|
||||
perBookSetting: PerBookSetting;
|
||||
pdfReaderSetting: PdfReaderSetting;
|
||||
epubReaderSetting: EpubReaderSetting;
|
||||
sidebarLibrarySorting: SidebarLibrarySorting;
|
||||
sidebarShelfSorting: SidebarShelfSorting
|
||||
}
|
||||
|
||||
export interface User {
|
||||
id: number;
|
||||
username: string;
|
||||
@@ -20,27 +57,10 @@ export interface User {
|
||||
canEditMetadata: boolean;
|
||||
canManipulateLibrary: boolean;
|
||||
};
|
||||
bookPreferences: UserBookPreferences;
|
||||
userSettings: UserSettings;
|
||||
provisioningMethod?: 'LOCAL' | 'OIDC' | 'REMOTE';
|
||||
}
|
||||
|
||||
export interface UserBookPreferences {
|
||||
perBookSetting: {
|
||||
pdf: string;
|
||||
epub: string;
|
||||
};
|
||||
pdfReaderSetting: {
|
||||
pageSpread: 'off' | 'even' | 'odd';
|
||||
pageZoom: string;
|
||||
showSidebar: boolean;
|
||||
};
|
||||
epubReaderSetting: {
|
||||
theme: string;
|
||||
font: string;
|
||||
fontSize: number;
|
||||
};
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -67,10 +87,6 @@ export class UserService {
|
||||
return this.http.get<User>(`${this.userUrl}/me`);
|
||||
}
|
||||
|
||||
getLocalUser(): User | null {
|
||||
return this.userDataSubject.getValue();
|
||||
}
|
||||
|
||||
createUser(userData: Omit<User, 'id'>): Observable<void> {
|
||||
return this.http.post<void>(this.apiUrl, userData);
|
||||
}
|
||||
@@ -80,11 +96,7 @@ export class UserService {
|
||||
}
|
||||
|
||||
updateUser(userId: number, updateData: Partial<User>): Observable<User> {
|
||||
return this.http.put<User>(`${this.userUrl}/${userId}`, updateData).pipe(
|
||||
tap(user => {
|
||||
this.userDataSubject.next(user);
|
||||
})
|
||||
);
|
||||
return this.http.put<User>(`${this.userUrl}/${userId}`, updateData);
|
||||
}
|
||||
|
||||
deleteUser(userId: number): Observable<void> {
|
||||
@@ -117,15 +129,22 @@ export class UserService {
|
||||
);
|
||||
}
|
||||
|
||||
updateBookPreferences(userId: number, prefs: UserBookPreferences): void {
|
||||
this.http.put<void>(`${this.userUrl}/${userId}/book-preferences`, prefs)
|
||||
.subscribe(() => {
|
||||
const currentUser = this.userDataSubject.getValue();
|
||||
if (currentUser) {
|
||||
const updatedUser = {...currentUser, bookPreferences: {...prefs}};
|
||||
this.userDataSubject.next(updatedUser);
|
||||
}
|
||||
});
|
||||
updateUserSetting(userId: number, key: string, value: any): void {
|
||||
const payload = {
|
||||
key,
|
||||
value
|
||||
};
|
||||
this.http.put<void>(`${this.userUrl}/${userId}/settings`, payload, {
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
responseType: 'text' as 'json'
|
||||
}).subscribe(() => {
|
||||
const currentUser = this.userDataSubject.getValue();
|
||||
if (currentUser) {
|
||||
const updatedSettings = {...currentUser.userSettings, [key]: value};
|
||||
const updatedUser = {...currentUser, settings: updatedSettings};
|
||||
this.userDataSubject.next(updatedUser);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private startWebSocket(): void {
|
||||
|
||||
Reference in New Issue
Block a user