Merge pull request #245 from adityachandelgit/develop
Merge Develop into Master for Release
This commit is contained in:
+38
-9
@@ -5,6 +5,8 @@ import com.adityachandel.booklore.exception.ApiError;
|
||||
import com.adityachandel.booklore.model.dto.BookLoreUser;
|
||||
import com.adityachandel.booklore.model.dto.request.UserLoginRequest;
|
||||
import com.adityachandel.booklore.model.entity.BookLoreUserEntity;
|
||||
import com.adityachandel.booklore.model.entity.RefreshTokenEntity;
|
||||
import com.adityachandel.booklore.repository.RefreshTokenRepository;
|
||||
import com.adityachandel.booklore.repository.UserRepository;
|
||||
import com.adityachandel.booklore.service.user.UserCreatorService;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -14,6 +16,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -23,6 +26,7 @@ public class AuthenticationService {
|
||||
|
||||
private final AppProperties appProperties;
|
||||
private final UserRepository userRepository;
|
||||
private final RefreshTokenRepository refreshTokenRepository;
|
||||
private final UserCreatorService userCreatorService;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
private final JwtUtils jwtUtils;
|
||||
@@ -33,7 +37,8 @@ public class AuthenticationService {
|
||||
}
|
||||
|
||||
public ResponseEntity<Map<String, String>> loginUser(UserLoginRequest loginRequest) {
|
||||
BookLoreUserEntity user = userRepository.findByUsername(loginRequest.getUsername()).orElseThrow(() -> ApiError.USER_NOT_FOUND.createException(loginRequest.getUsername()));
|
||||
BookLoreUserEntity user = userRepository.findByUsername(loginRequest.getUsername())
|
||||
.orElseThrow(() -> ApiError.USER_NOT_FOUND.createException(loginRequest.getUsername()));
|
||||
|
||||
if (!passwordEncoder.matches(loginRequest.getPassword(), user.getPasswordHash())) {
|
||||
throw ApiError.INVALID_CREDENTIALS.createException();
|
||||
@@ -63,24 +68,48 @@ public class AuthenticationService {
|
||||
String accessToken = jwtUtils.generateAccessToken(user);
|
||||
String refreshToken = jwtUtils.generateRefreshToken(user);
|
||||
|
||||
RefreshTokenEntity refreshTokenEntity = RefreshTokenEntity.builder()
|
||||
.user(user)
|
||||
.token(refreshToken)
|
||||
.expiryDate(new Date(System.currentTimeMillis() + jwtUtils.getRefreshTokenExpirationMs()))
|
||||
.revoked(false)
|
||||
.build();
|
||||
|
||||
refreshTokenRepository.save(refreshTokenEntity);
|
||||
|
||||
return ResponseEntity.ok(Map.of(
|
||||
"accessToken", accessToken,
|
||||
"refreshToken", refreshToken,
|
||||
"refreshToken", refreshTokenEntity.getToken(),
|
||||
"isDefaultPassword", String.valueOf(user.isDefaultPassword())
|
||||
));
|
||||
}
|
||||
|
||||
public ResponseEntity<Map<String, String>> refreshToken(String refreshToken) {
|
||||
if (!jwtUtils.validateToken(refreshToken)) {
|
||||
throw ApiError.INVALID_CREDENTIALS.createException();
|
||||
public ResponseEntity<Map<String, String>> refreshToken(String token) {
|
||||
RefreshTokenEntity storedToken = refreshTokenRepository.findByToken(token).orElseThrow(() -> ApiError.INVALID_CREDENTIALS.createException("Refresh token not found"));
|
||||
|
||||
if (storedToken.isRevoked() || storedToken.getExpiryDate().before(new Date()) || !jwtUtils.validateToken(token)) {
|
||||
throw ApiError.INVALID_CREDENTIALS.createException("Invalid or expired refresh token");
|
||||
}
|
||||
|
||||
String username = jwtUtils.extractUsername(refreshToken);
|
||||
BookLoreUserEntity user = userRepository.findByUsername(username).orElseThrow(() -> ApiError.USER_NOT_FOUND.createException(username));
|
||||
BookLoreUserEntity user = storedToken.getUser();
|
||||
|
||||
storedToken.setRevoked(true);
|
||||
storedToken.setRevocationDate(new Date());
|
||||
refreshTokenRepository.save(storedToken);
|
||||
|
||||
String newAccessToken = jwtUtils.generateAccessToken(user);
|
||||
String newRefreshToken = jwtUtils.generateRefreshToken(user);
|
||||
RefreshTokenEntity newRefreshTokenEntity = RefreshTokenEntity.builder()
|
||||
.user(user)
|
||||
.token(newRefreshToken)
|
||||
.expiryDate(new Date(System.currentTimeMillis() + jwtUtils.getRefreshTokenExpirationMs()))
|
||||
.revoked(false)
|
||||
.build();
|
||||
|
||||
return ResponseEntity.ok(Map.of("accessToken", newAccessToken, "refreshToken", newRefreshToken));
|
||||
refreshTokenRepository.save(newRefreshTokenEntity);
|
||||
|
||||
return ResponseEntity.ok(Map.of(
|
||||
"accessToken", jwtUtils.generateAccessToken(user),
|
||||
"refreshToken", newRefreshToken
|
||||
));
|
||||
}
|
||||
}
|
||||
+13
-15
@@ -1,31 +1,33 @@
|
||||
package com.adityachandel.booklore.config.security;
|
||||
|
||||
import io.jsonwebtoken.*;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import com.adityachandel.booklore.model.entity.BookLoreUserEntity;
|
||||
import com.adityachandel.booklore.service.JwtSecretService;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.ExpiredJwtException;
|
||||
import io.jsonwebtoken.JwtException;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
import java.util.Date;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class JwtUtils {
|
||||
|
||||
private final JwtSecretService jwtSecretService;
|
||||
private final long accessTokenExpirationMs;
|
||||
private final long refreshTokenExpirationMs;
|
||||
|
||||
public JwtUtils(JwtSecretService jwtSecretService) {
|
||||
this.jwtSecretService = jwtSecretService;
|
||||
this.accessTokenExpirationMs = 36000000; // 10 hours
|
||||
this.refreshTokenExpirationMs = 604800000; // 7 days
|
||||
}
|
||||
@Getter
|
||||
public final long accessTokenExpirationMs = 1000L * 60 * 60 * 10; // 10 hours
|
||||
@Getter
|
||||
public final long refreshTokenExpirationMs = 1000L * 60 * 60 * 24 * 30; // 30 days
|
||||
|
||||
private SecretKey getSigningKey() {
|
||||
String secretKey = jwtSecretService.getSecret();
|
||||
@@ -83,8 +85,4 @@ public class JwtUtils {
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid userId claim type");
|
||||
}
|
||||
|
||||
public boolean isTokenExpired(String token) {
|
||||
return extractClaims(token).getExpiration().before(new Date());
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.adityachandel.booklore.model.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table(name = "refresh_token")
|
||||
public class RefreshTokenEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false, unique = true, length = 512)
|
||||
private String token;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "user_id", referencedColumnName = "id")
|
||||
private BookLoreUserEntity user;
|
||||
|
||||
@Column(name = "expiry_date", nullable = false)
|
||||
private Date expiryDate;
|
||||
|
||||
@Column(nullable = false)
|
||||
private boolean revoked = false;
|
||||
|
||||
@Column(name = "revocation_date")
|
||||
private Date revocationDate;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.adityachandel.booklore.repository;
|
||||
|
||||
import com.adityachandel.booklore.model.entity.BookLoreUserEntity;
|
||||
import com.adityachandel.booklore.model.entity.RefreshTokenEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface RefreshTokenRepository extends JpaRepository<RefreshTokenEntity, Long> {
|
||||
Optional<RefreshTokenEntity> findByToken(String token);
|
||||
void deleteByUser(BookLoreUserEntity user);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE refresh_token
|
||||
(
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
user_id BIGINT NOT NULL,
|
||||
token VARCHAR(512) NOT NULL,
|
||||
expiry_date TIMESTAMP NOT NULL,
|
||||
revoked BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
revocation_date TIMESTAMP NULL,
|
||||
|
||||
CONSTRAINT uq_refresh_token UNIQUE (token),
|
||||
CONSTRAINT fk_refresh_token_user FOREIGN KEY (user_id)
|
||||
REFERENCES users (id)
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
@@ -30,7 +30,7 @@ import {FormsModule} from '@angular/forms';
|
||||
import {BookFilterComponent} from './book-filter/book-filter.component';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {Fluid} from 'primeng/fluid';
|
||||
import {UserService} from '../../../user.service';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {LockUnlockMetadataDialogComponent} from './lock-unlock-metadata-dialog/lock-unlock-metadata-dialog.component';
|
||||
|
||||
export enum EntityType {
|
||||
|
||||
@@ -13,7 +13,7 @@ import {MetadataRefreshType} from '../../../../metadata/model/request/metadata-r
|
||||
import {MetadataRefreshRequest} from '../../../../metadata/model/request/metadata-refresh-request.model';
|
||||
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
|
||||
import {NgClass, NgIf} from '@angular/common';
|
||||
import {UserService} from '../../../../user.service';
|
||||
import {UserService} from '../../../../settings/user-management/user.service';
|
||||
import {filter} from 'rxjs';
|
||||
import {EmailService} from '../../../../settings/email/email.service';
|
||||
import {TieredMenu} from 'primeng/tieredmenu';
|
||||
|
||||
@@ -10,7 +10,7 @@ import {Book, BookSetting} from '../../../model/book.model';
|
||||
import {BookService} from '../../../service/book.service';
|
||||
import {forkJoin} from 'rxjs';
|
||||
import {Select} from 'primeng/select';
|
||||
import {UserService} from '../../../../user.service';
|
||||
import {UserService} from '../../../../settings/user-management/user.service';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {MessageService} from 'primeng/api';
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import {NgxExtendedPdfViewerModule} from 'ngx-extended-pdf-viewer';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {forkJoin, Subscription} from 'rxjs';
|
||||
import {BookSetting} from '../../model/book.model';
|
||||
import {UserService} from '../../../user.service';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {NgIf} from '@angular/common';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {MessageService} from 'primeng/api';
|
||||
|
||||
@@ -6,7 +6,7 @@ import {Message} from 'primeng/message';
|
||||
import {NgIf} from '@angular/common';
|
||||
import {Password} from 'primeng/password';
|
||||
import {MessageService, PrimeTemplate} from 'primeng/api';
|
||||
import {UserService} from '../../../user.service';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {AuthService} from '../../service/auth.service';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -11,7 +11,7 @@ import {BookService} from '../../../book/service/book.service';
|
||||
import {BookState} from '../../../book/model/state/book-state.model';
|
||||
import {Book} from '../../../book/model/book.model';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {UserService} from '../../../user.service';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -9,7 +9,7 @@ import {Ripple} from 'primeng/ripple';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Menu} from 'primeng/menu';
|
||||
import {MenuItem} from 'primeng/api';
|
||||
import {UserService} from '../../../user.service';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
|
||||
@Component({
|
||||
selector: '[app-menuitem]',
|
||||
|
||||
@@ -17,8 +17,8 @@ import {ThemeConfiguratorComponent} from '../theme-configurator/theme-configurat
|
||||
import {LiveNotificationBoxComponent} from '../../../core/component/live-notification-box/live-notification-box.component';
|
||||
import {BookUploaderComponent} from '../../../utilities/component/book-uploader/book-uploader.component';
|
||||
import {AuthService} from '../../../core/service/auth.service';
|
||||
import {UserService} from '../../../user.service';
|
||||
import {UserProfileDialogComponent} from '../../../user-profile-dialog/user-profile-dialog.component';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {UserProfileDialogComponent} from '../../../settings/global-preferences/user-profile-dialog/user-profile-dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-topbar',
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
<div class="rounded-xl overflow-hidden bg-card">
|
||||
<div class="rounded-xl overflow-hidden">
|
||||
<p-tabs [value]="tab" lazy="true">
|
||||
<p-tablist>
|
||||
<p-tab value="view">Book Details</p-tab>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {BookMetadataCenterService} from './book-metadata-center.service';
|
||||
import {UserService} from '../../user.service';
|
||||
import {UserService} from '../../settings/user-management/user.service';
|
||||
import {Book, BookRecommendation} from '../../book/model/book.model';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {distinctUntilChanged, filter, map, switchMap, take} from 'rxjs/operators';
|
||||
|
||||
+9
-8
@@ -22,6 +22,15 @@
|
||||
</p-progressSpinner>
|
||||
|
||||
<div class="flex items-center gap-6">
|
||||
<p-button
|
||||
icon="pi pi-refresh"
|
||||
(onClick)="regenerateCover(metadata.bookId)"
|
||||
pTooltip="Regenerate cover"
|
||||
tooltipPosition="top"
|
||||
[outlined]="true"
|
||||
[disabled]="metadata['coverLocked']">
|
||||
</p-button>
|
||||
|
||||
<p-fileupload
|
||||
pTooltip="Upload cover"
|
||||
tooltipPosition="top"
|
||||
@@ -39,14 +48,6 @@
|
||||
(onBeforeUpload)="onBeforeSend()">
|
||||
</p-fileupload>
|
||||
|
||||
<p-button
|
||||
icon="pi pi-refresh"
|
||||
(onClick)="regenerateCover(metadata.bookId)"
|
||||
pTooltip="Regenerate cover"
|
||||
tooltipPosition="top"
|
||||
[disabled]="metadata['coverLocked']">
|
||||
</p-button>
|
||||
|
||||
<p-button *ngIf="!metadata['coverLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['coverLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="warn"></p-button>
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p-button label="Search" type="submit" [disabled]="!isSearchEnabled || loading"></p-button>
|
||||
<p-button label="Search" type="submit" outlined="true" [disabled]="!isSearchEnabled || loading"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import {Tag} from 'primeng/tag';
|
||||
import {Book, BookMetadata, BookRecommendation} from '../../../book/model/book.model';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
|
||||
import {UserService} from '../../../user.service';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {SplitButton} from 'primeng/splitbutton';
|
||||
import {MenuItem, MessageService} from 'primeng/api';
|
||||
import {BookSenderComponent} from '../../../book/components/book-sender/book-sender.component';
|
||||
|
||||
+2
-2
@@ -71,8 +71,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-row gap-6">
|
||||
<p-button severity="warn" label="Reset" (onClick)="reset()"></p-button>
|
||||
<p-button label="Submit" (onClick)="submit()"></p-button>
|
||||
<p-button severity="warn" outlined="true" label="Reset" (onClick)="reset()"></p-button>
|
||||
<p-button label="Save" outlined="true" (onClick)="submit()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import {RadioButton} from 'primeng/radiobutton';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {User, UserBookPreferences, UserService} from '../../user.service';
|
||||
import {User, UserBookPreferences, UserService} from '../user-management/user.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-preferences',
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;"></i>
|
||||
</h2>
|
||||
<p-button outlined="true" label="Create New Provider" (onClick)="openCreateProviderDialog()"></p-button>
|
||||
<p-button outlined="true" icon="pi pi-plus" label="Create New Provider" (onClick)="openCreateProviderDialog()"></p-button>
|
||||
</div>
|
||||
|
||||
<p-table [value]="emailProviders">
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;"></i>
|
||||
</h2>
|
||||
<p-button outlined="true" label="Add New Recipient" (onClick)="openAddRecipientDialog()"></p-button>
|
||||
<p-button outlined="true" icon="pi pi-plus" label="Add New Recipient" (onClick)="openAddRecipientDialog()"></p-button>
|
||||
</div>
|
||||
|
||||
<p-table [value]="recipientEmails">
|
||||
|
||||
+11
-4
@@ -1,4 +1,4 @@
|
||||
<p class="text-xl pb-2 pt-8">
|
||||
<p class="text-xl">
|
||||
Uploaded Files Pattern
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Define a naming pattern for future uploads using available metadata. Existing files will remain unchanged."
|
||||
@@ -17,7 +17,14 @@
|
||||
placeholder="e.g., {title} - {authors}"
|
||||
(input)="onPatternChange(uploadPattern)"
|
||||
/>
|
||||
<p-button label="Save" icon="pi pi-check" (onClick)="savePattern()" [disabled]="!!errorMessage"></p-button>
|
||||
<p-button
|
||||
label="Save"
|
||||
icon="pi pi-check"
|
||||
(onClick)="savePattern()"
|
||||
severity="primary"
|
||||
outlined="true"
|
||||
[disabled]="!!errorMessage">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -71,8 +78,8 @@
|
||||
<ul class="list-disc pl-6">
|
||||
<li>Only the placeholders {title} and {authors} are supported. These values will be extracted from the metadata of the uploaded PDF or EPUB file.</li>
|
||||
<li>Multiple authors will be joined using commas.</li>
|
||||
<li>If <code>{bookname}</code> is used but missing, the path defaults to <code>/filename.pdf</code>.</li>
|
||||
<li>If <code>{authors}</code> is used but missing, it falls back to <code>{bookname}/filename.pdf</code> if the title exists, otherwise <code>/filename.pdf</code>.
|
||||
<li>If <code>{title}</code> is used but is missing in uploaded book's metadata, the path will fall back to <code>/filename.pdf</code>.</li>
|
||||
<li>If <code>{authors}</code> is used but is missing in uploaded book's metadata, the path will fall back to <code>{title}/filename.pdf</code> if the title exists, otherwise <code>/filename.pdf</code>.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
+2
-2
@@ -2,9 +2,9 @@ import {Component, inject, OnInit} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Button} from 'primeng/button';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {AppSettingsService} from '../core/service/app-settings.service';
|
||||
import {AppSettingsService} from '../../../core/service/app-settings.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {AppSettings} from '../core/model/app-settings.model';
|
||||
import {AppSettings} from '../../../core/model/app-settings.model';
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
|
||||
@@ -1,38 +1,54 @@
|
||||
<div class="w-full h-[calc(100vh-12.1rem)] overflow-y-auto border rounded-lg p-4 enclosing-container">
|
||||
<div class="w-full h-[calc(100vh-12.1rem)] overflow-y-auto border rounded-lg enclosing-container">
|
||||
|
||||
<p class="text-xl pb-4 pt-6">Book Cover Image</p>
|
||||
<div class="grid grid-cols-[auto,1fr] pl-6 gap-y-4 gap-x-4 items-center">
|
||||
<p class="text-lg py-1">Resolution:
|
||||
<div class="p-4">
|
||||
<div class="flex items-center gap-2 pb-4 pt-6">
|
||||
<p class="text-xl">Book Cover Image</p>
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Specifies the resolution of the generated cover image. Higher resolutions result in sharper images but may increase file size. This setting will apply to future books, or else use 'Regenerate' button."
|
||||
pTooltip="Settings related to book cover images, such as resolution and regeneration options."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-select
|
||||
[options]="resolutionOptions"
|
||||
[(ngModel)]="selectedResolution"
|
||||
(ngModelChange)="onResolutionChange()"
|
||||
placeholder="Select Resolution">
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
<p class="text-lg py-1">Regenerate Covers?
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="This option will regenerate the covers for all EPUB and PDF books (except locked ones) using the selected resolution."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</p>
|
||||
<p-button label="Regenerate" icon="pi pi-refresh" (onClick)="regenerateCovers()"></p-button>
|
||||
<div class="grid grid-cols-[auto,1fr] pl-6 gap-y-4 gap-x-4 items-center">
|
||||
<p class="text-lg py-1">Resolution:
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Specifies the resolution of the generated cover image. Higher resolutions result in sharper images but may increase file size. This setting will apply to future books, or else use 'Regenerate' button."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-select
|
||||
[options]="resolutionOptions"
|
||||
[(ngModel)]="selectedResolution"
|
||||
(ngModelChange)="onResolutionChange()"
|
||||
placeholder="Select Resolution">
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
<p class="text-lg py-1">Regenerate Covers?
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="This option will regenerate the covers for all EPUB and PDF books (except locked ones) using the selected resolution."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</p>
|
||||
<p-button
|
||||
label="Regenerate"
|
||||
icon="pi pi-refresh"
|
||||
outlined="true"
|
||||
(onClick)="regenerateCovers()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p-divider></p-divider>
|
||||
<div class="pt-2 pb-6">
|
||||
<p-divider></p-divider>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-row gap-11">
|
||||
<div class="flex flex-row gap-11 p-4">
|
||||
<div>
|
||||
<p class="text-xl pb-4 pt-8">Auto Book Search
|
||||
<p class="text-xl pb-4">Auto Book Search
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="If enabled, Booklore will automatically perform a metadata match/search when the book information tab is opened."
|
||||
tooltipPosition="right"
|
||||
@@ -50,7 +66,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xl pb-4 pt-8">Similar Book Recommendation
|
||||
<p class="text-xl pb-4">Similar Book Recommendation
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Enable or disable similar book recommendations entirely."
|
||||
tooltipPosition="right"
|
||||
@@ -69,24 +85,36 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p-divider></p-divider>
|
||||
<div class="pt-2 pb-6">
|
||||
<p-divider></p-divider>
|
||||
</div>
|
||||
|
||||
<app-opds-settings></app-opds-settings>
|
||||
<div class="p-4">
|
||||
<app-opds-settings></app-opds-settings>
|
||||
</div>
|
||||
|
||||
<p-divider></p-divider>
|
||||
<div class="pt-2 pb-6">
|
||||
<p-divider></p-divider>
|
||||
</div>
|
||||
|
||||
<app-file-upload-pattern></app-file-upload-pattern>
|
||||
<div class="p-4">
|
||||
<app-file-upload-pattern></app-file-upload-pattern>
|
||||
</div>
|
||||
|
||||
<p-divider></p-divider>
|
||||
<div class="pt-2 pb-6">
|
||||
<p-divider></p-divider>
|
||||
</div>
|
||||
|
||||
<p class="text-xl pb-4 pt-8">
|
||||
Quick Book Match Preferences
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Choose how metadata fields (title, description, authors, categories, cover) are retrieved by setting priority providers. You can apply the same provider settings to all fields or customize them individually. Enable ‘Refresh Covers’ to update book covers, and ‘Merge Categories’ to consolidate categories/genres from all sources while preserving the existing categories/genres in the book."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</p>
|
||||
<app-metadata-advanced-fetch-options (metadataOptionsSubmitted)="onMetadataSubmit($event)" [currentMetadataOptions]="currentMetadataOptions"></app-metadata-advanced-fetch-options>
|
||||
<div class="p-4">
|
||||
<p class="text-xl">
|
||||
Quick Book Match Preferences
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Choose how metadata fields (title, description, authors, categories, cover) are retrieved by setting priority providers. You can apply the same provider settings to all fields or customize them individually. Enable ‘Refresh Covers’ to update book covers, and ‘Merge Categories’ to consolidate categories/genres from all sources while preserving the existing categories/genres in the book."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</p>
|
||||
<app-metadata-advanced-fetch-options (metadataOptionsSubmitted)="onMetadataSubmit($event)" [currentMetadataOptions]="currentMetadataOptions"></app-metadata-advanced-fetch-options>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -16,8 +16,8 @@ import {AppSettings} from '../../core/model/app-settings.model';
|
||||
import {MetadataRefreshOptions} from '../../metadata/model/request/metadata-refresh-options.model';
|
||||
import {MetadataAdvancedFetchOptionsComponent} from '../../metadata/metadata-options-dialog/metadata-advanced-fetch-options/metadata-advanced-fetch-options.component';
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
import {FileUploadPatternComponent} from '../../file-upload-pattern/file-upload-pattern.component';
|
||||
import {OpdsSettingsComponent} from '../../opds-settings/opds-settings.component';
|
||||
import {FileUploadPatternComponent} from './file-upload-pattern/file-upload-pattern.component';
|
||||
import {OpdsSettingsComponent} from './opds-settings/opds-settings.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-global-preferences',
|
||||
|
||||
+18
-15
@@ -1,4 +1,4 @@
|
||||
<p class="text-xl pb-2 pt-6 flex items-center gap-2">
|
||||
<p class="text-xl flex items-center gap-2">
|
||||
OPDS Server Settings
|
||||
<i
|
||||
class="pi pi-info-circle text-sky-600"
|
||||
@@ -11,16 +11,13 @@
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<p class="text-lg py-1">OPDS Server Enabled:</p>
|
||||
<p-toggleButton
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="opdsEnabled"
|
||||
onLabel="OPDS ON"
|
||||
offLabel="OPDS OFF"
|
||||
(onChange)="toggleOpdsServer()"
|
||||
style="width: 150px;">
|
||||
</p-toggleButton>
|
||||
(onChange)="toggleOpdsServer()">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
|
||||
<div *ngIf="opdsEnabled" class="flex flex-col gap-2 mt-4 rounded-lg">
|
||||
<div *ngIf="opdsEnabled" class="flex items-center gap-2 mt-4">
|
||||
<p class="text-lg py-1">OPDS Endpoint:</p>
|
||||
<div class="flex items-center gap-4">
|
||||
<input
|
||||
@@ -40,13 +37,19 @@
|
||||
</div>
|
||||
|
||||
<div *ngIf="opdsEnabled" class="mt-6">
|
||||
<p-button
|
||||
label="Create New User"
|
||||
icon="pi pi-plus"
|
||||
outlined="true"
|
||||
severity="primary"
|
||||
(onClick)="openCreateUserDialog()">
|
||||
</p-button>
|
||||
|
||||
|
||||
<div class="flex justify-between items-center">
|
||||
<h2 class="text-lg flex items-center gap-2">
|
||||
Current OPDS Users:
|
||||
</h2>
|
||||
<p-button
|
||||
label="Create OPDS User"
|
||||
icon="pi pi-plus"
|
||||
outlined="true"
|
||||
(onClick)="openCreateUserDialog()">
|
||||
</p-button>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<p-table [value]="users" [responsiveLayout]="'scroll'">
|
||||
+7
-7
@@ -6,15 +6,15 @@ import {Button} from 'primeng/button';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Dialog} from 'primeng/dialog';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {ToggleButton} from 'primeng/togglebutton';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
|
||||
import {OpdsUser, OpdsUserService} from '../opds-user.service';
|
||||
import {AppSettingsService} from '../core/service/app-settings.service';
|
||||
import {AppSettings} from '../core/model/app-settings.model';
|
||||
import {OpdsUser, OpdsUserService} from './opds-user.service';
|
||||
import {AppSettingsService} from '../../../core/service/app-settings.service';
|
||||
import {AppSettings} from '../../../core/model/app-settings.model';
|
||||
import {Password} from 'primeng/password';
|
||||
import {API_CONFIG} from '../config/api-config';
|
||||
import {API_CONFIG} from '../../../config/api-config';
|
||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||
|
||||
@Component({
|
||||
selector: 'app-opds-settings',
|
||||
@@ -27,8 +27,8 @@ import {API_CONFIG} from '../config/api-config';
|
||||
InputText,
|
||||
Dialog,
|
||||
Tooltip,
|
||||
ToggleButton,
|
||||
Password
|
||||
Password,
|
||||
ToggleSwitch
|
||||
],
|
||||
templateUrl: './opds-settings.component.html',
|
||||
styleUrl: './opds-settings.component.scss'
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {API_CONFIG} from './config/api-config';
|
||||
import {API_CONFIG} from '../../../config/api-config';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Observable} from 'rxjs';
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import {FormBuilder, FormGroup, Validators, FormsModule, ReactiveFormsModule} fr
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {NgIf} from '@angular/common';
|
||||
import {Password} from 'primeng/password';
|
||||
import {User, UserService} from '../user.service';
|
||||
import {User, UserService} from '../../user-management/user.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {Message} from 'primeng/message';
|
||||
@@ -1,29 +1,31 @@
|
||||
<div class="card" *ngIf="userService.userData$ | async as userData">
|
||||
<p-tabs [(value)]="activeTab">
|
||||
<p-tablist>
|
||||
<p-tab [value]="SettingsTab.BookReader">Book Reader</p-tab>
|
||||
<ng-container *ngIf="userData.permissions.admin">
|
||||
<p-tab [value]="SettingsTab.UserManagement">User Management</p-tab>
|
||||
<p-tab [value]="SettingsTab.Email">Email</p-tab>
|
||||
<p-tab [value]="SettingsTab.GlobalSettings">Global Settings</p-tab>
|
||||
</ng-container>
|
||||
</p-tablist>
|
||||
<div *ngIf="userService.userData$ | async as userData">
|
||||
<div class="rounded-xl overflow-hidden">
|
||||
<p-tabs [(value)]="activeTab">
|
||||
<p-tablist>
|
||||
<p-tab [value]="SettingsTab.BookReader">Book Reader</p-tab>
|
||||
<ng-container *ngIf="userData.permissions.admin">
|
||||
<p-tab [value]="SettingsTab.UserManagement">User Management</p-tab>
|
||||
<p-tab [value]="SettingsTab.Email">Email Setting</p-tab>
|
||||
<p-tab [value]="SettingsTab.GlobalSettings">Other Settings</p-tab>
|
||||
</ng-container>
|
||||
</p-tablist>
|
||||
|
||||
<p-tabpanels>
|
||||
<p-tabpanel [value]="SettingsTab.BookReader">
|
||||
<app-book-preferences></app-book-preferences>
|
||||
</p-tabpanel>
|
||||
<ng-container *ngIf="userData.permissions.admin">
|
||||
<p-tabpanel [value]="SettingsTab.UserManagement">
|
||||
<app-admin></app-admin>
|
||||
<p-tabpanels>
|
||||
<p-tabpanel [value]="SettingsTab.BookReader">
|
||||
<app-book-preferences></app-book-preferences>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel [value]="SettingsTab.Email">
|
||||
<app-email></app-email>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel [value]="SettingsTab.GlobalSettings">
|
||||
<app-global-preferences></app-global-preferences>
|
||||
</p-tabpanel>
|
||||
</ng-container>
|
||||
</p-tabpanels>
|
||||
</p-tabs>
|
||||
<ng-container *ngIf="userData.permissions.admin">
|
||||
<p-tabpanel [value]="SettingsTab.UserManagement">
|
||||
<app-user-management></app-user-management>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel [value]="SettingsTab.Email">
|
||||
<app-email></app-email>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel [value]="SettingsTab.GlobalSettings">
|
||||
<app-global-preferences></app-global-preferences>
|
||||
</p-tabpanel>
|
||||
</ng-container>
|
||||
</p-tabpanels>
|
||||
</p-tabs>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||
import {BookPreferences} from './book-preferences/book-preferences.component';
|
||||
import {AdminComponent} from './admin/admin.component';
|
||||
import {UserService} from '../user.service';
|
||||
import {UserService} from './user-management/user.service';
|
||||
import {AsyncPipe, NgIf} from '@angular/common';
|
||||
import {EmailComponent} from './email/email.component';
|
||||
import {GlobalPreferencesComponent} from './global-preferences/global-preferences.component';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {UserManagementComponent} from './user-management/user-management.component';
|
||||
|
||||
export enum SettingsTab {
|
||||
BookReader = 'book-reader',
|
||||
@@ -25,11 +25,11 @@ export enum SettingsTab {
|
||||
TabPanels,
|
||||
TabPanel,
|
||||
BookPreferences,
|
||||
AdminComponent,
|
||||
NgIf,
|
||||
AsyncPipe,
|
||||
EmailComponent,
|
||||
GlobalPreferencesComponent
|
||||
GlobalPreferencesComponent,
|
||||
UserManagementComponent
|
||||
],
|
||||
templateUrl: './settings.component.html',
|
||||
styleUrl: './settings.component.scss'
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import {MultiSelectModule} from 'primeng/multiselect';
|
||||
import {Library} from '../../../book/model/library.model';
|
||||
import {Button} from 'primeng/button';
|
||||
import {LibraryService} from '../../../book/service/library.service';
|
||||
import {UserService} from '../../../user.service';
|
||||
import {UserService} from '../user.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {NgIf} from '@angular/common';
|
||||
+10
-4
@@ -1,5 +1,11 @@
|
||||
<div class="p-4">
|
||||
<p-button outlined="true" label="Create User" (onClick)="openCreateUserDialog()"></p-button>
|
||||
<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">
|
||||
Current Booklore Users
|
||||
</h2>
|
||||
<p-button outlined="true" label="Create BookLore User" icon="pi pi-plus" (onClick)="openCreateUserDialog()"></p-button>
|
||||
</div>
|
||||
|
||||
<p-table [value]="users" class="mt-4">
|
||||
<ng-template pTemplate="header">
|
||||
@@ -88,8 +94,8 @@
|
||||
|
||||
<p-dialog header="Change Password" [(visible)]="isPasswordDialogVisible" [modal]="true" [closable]="false" [style]="{width: '20vw'}">
|
||||
<div class="flex flex-col gap-8 items-center">
|
||||
<p-password [(ngModel)]="newPassword" placeholder="New Password" [feedback]="false" class="w-full" fluid></p-password>
|
||||
<p-password [(ngModel)]="confirmNewPassword" placeholder="Confirm Password" [feedback]="false" class="w-full" fluid></p-password>
|
||||
<p-password [(ngModel)]="newPassword" placeholder="New Password" [feedback]="false" class="w-full" fluid></p-password>
|
||||
<p-password [(ngModel)]="confirmNewPassword" placeholder="Confirm Password" [feedback]="false" class="w-full" fluid></p-password>
|
||||
<p *ngIf="passwordError" class="p-error text-red-500 w-full text-left">{{ passwordError }}</p>
|
||||
<div class="flex gap-4 w-full justify-end">
|
||||
<p-button label="Cancel" icon="pi pi-times" severity="secondary" (onClick)="isPasswordDialogVisible = false"></p-button>
|
||||
@@ -0,0 +1,3 @@
|
||||
.enclosing-container {
|
||||
border-color: var(--p-content-border-color);
|
||||
}
|
||||
+7
-5
@@ -5,7 +5,7 @@ import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {CreateUserDialogComponent} from './create-user-dialog/create-user-dialog.component';
|
||||
import {TableModule} from 'primeng/table';
|
||||
import {NgIf, NgStyle} from '@angular/common';
|
||||
import {User, UserService} from '../../user.service';
|
||||
import {User, UserService} from './user.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {MultiSelect} from 'primeng/multiselect';
|
||||
@@ -13,9 +13,10 @@ 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-admin',
|
||||
selector: 'app-user-management',
|
||||
imports: [
|
||||
FormsModule,
|
||||
Button,
|
||||
@@ -26,11 +27,12 @@ import {Password} from 'primeng/password';
|
||||
MultiSelect,
|
||||
Dialog,
|
||||
Password,
|
||||
Tooltip,
|
||||
],
|
||||
templateUrl: './admin.component.html',
|
||||
styleUrls: ['./admin.component.scss'],
|
||||
templateUrl: './user-management.component.html',
|
||||
styleUrls: ['./user-management.component.scss'],
|
||||
})
|
||||
export class AdminComponent implements OnInit {
|
||||
export class UserManagementComponent implements OnInit {
|
||||
ref: DynamicDialogRef | undefined;
|
||||
private dialogService = inject(DialogService);
|
||||
private userService = inject(UserService);
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
import {inject, Injectable, Injector} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {BehaviorSubject, Observable, tap, throwError} from 'rxjs';
|
||||
import {API_CONFIG} from './config/api-config';
|
||||
import {RxStompService} from './shared/websocket/rx-stomp.service';
|
||||
import {Library} from './book/model/library.model';
|
||||
import {API_CONFIG} from '../../config/api-config';
|
||||
import {RxStompService} from '../../shared/websocket/rx-stomp.service';
|
||||
import {Library} from '../../book/model/library.model';
|
||||
import {catchError} from 'rxjs/operators';
|
||||
|
||||
export interface User {
|
||||
Reference in New Issue
Block a user