Merge pull request #554 from adityachandelgit/develop
Merge Develop into Master for Release
This commit is contained in:
+5
@@ -54,6 +54,11 @@ public class SecurityUtil {
|
||||
var user = getCurrentUser();
|
||||
return user != null && user.getPermissions().isCanEmailBook();
|
||||
}
|
||||
public boolean canDeleteBook() {
|
||||
var user = getCurrentUser();
|
||||
return user != null && user.getPermissions().isCanDeleteBook();
|
||||
}
|
||||
|
||||
|
||||
public boolean canViewUserProfile(Long userId) {
|
||||
var user = getCurrentUser();
|
||||
|
||||
@@ -5,7 +5,9 @@ import com.adityachandel.booklore.model.dto.Book;
|
||||
import com.adityachandel.booklore.model.dto.BookRecommendation;
|
||||
import com.adityachandel.booklore.model.dto.BookViewerSettings;
|
||||
import com.adityachandel.booklore.model.dto.request.ReadProgressRequest;
|
||||
import com.adityachandel.booklore.model.dto.request.ReadStatusUpdateRequest;
|
||||
import com.adityachandel.booklore.model.dto.request.ShelvesAssignmentRequest;
|
||||
import com.adityachandel.booklore.model.dto.response.BookDeletionResponse;
|
||||
import com.adityachandel.booklore.service.metadata.MetadataBackupRestoreService;
|
||||
import com.adityachandel.booklore.service.recommender.BookRecommendationService;
|
||||
import com.adityachandel.booklore.service.BookService;
|
||||
@@ -21,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@RequestMapping("/api/v1/books")
|
||||
@@ -43,6 +46,12 @@ public class BookController {
|
||||
return ResponseEntity.ok(bookService.getBook(bookId, withDescription));
|
||||
}
|
||||
|
||||
@PreAuthorize("@securityUtil.canDeleteBook() or @securityUtil.isAdmin()")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<BookDeletionResponse> deleteBooks(@RequestParam Set<Long> ids) {
|
||||
return bookService.deleteBooks(ids);
|
||||
}
|
||||
|
||||
@GetMapping("/batch")
|
||||
public ResponseEntity<List<Book>> getBooksByIds(@RequestParam Set<Long> ids, @RequestParam(required = false, defaultValue = "false") boolean withDescription) {
|
||||
return ResponseEntity.ok(bookService.getBooksByIds(ids, withDescription));
|
||||
@@ -104,4 +113,11 @@ public class BookController {
|
||||
public ResponseEntity<List<BookRecommendation>> getRecommendations(@PathVariable Long id, @RequestParam(defaultValue = "25") @Max(25) @Min(1) int limit) {
|
||||
return ResponseEntity.ok(bookRecommendationService.getRecommendations(id, limit));
|
||||
}
|
||||
|
||||
@PutMapping("/{bookId}/read-status")
|
||||
@CheckBookAccess(bookIdParam = "bookId")
|
||||
public ResponseEntity<Void> updateReadStatus(@PathVariable long bookId, @RequestBody @Valid ReadStatusUpdateRequest request) {
|
||||
bookService.updateReadStatus(bookId, request.status());
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,8 @@ public enum ApiError {
|
||||
INVALID_CREDENTIALS(HttpStatus.BAD_REQUEST, "Invalid credentials"),
|
||||
REMOTE_AUTH_DISABLED(HttpStatus.NON_AUTHORITATIVE_INFORMATION, "Remote login is disabled"),
|
||||
SELF_DELETION_NOT_ALLOWED(HttpStatus.FORBIDDEN, "You cannot delete your own account"),
|
||||
INVALID_INPUT(HttpStatus.BAD_REQUEST, "%s");
|
||||
INVALID_INPUT(HttpStatus.BAD_REQUEST, "%s"),
|
||||
FILE_DELETION_DISABLED(HttpStatus.BAD_REQUEST, "File deletion is disabled"),;
|
||||
|
||||
private final HttpStatus status;
|
||||
private final String message;
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler(AccessDeniedException.class)
|
||||
public ResponseEntity<ErrorResponse> handleAccessDeniedException(AccessDeniedException ex) {
|
||||
ErrorResponse errorResponse = new ErrorResponse(HttpStatus.FORBIDDEN.value(), "Access Denied: " + ex.getMessage());
|
||||
ErrorResponse errorResponse = new ErrorResponse(HttpStatus.FORBIDDEN.value(), ex.getMessage());
|
||||
return new ResponseEntity<>(errorResponse, HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -28,6 +28,7 @@ public class BookLoreUserTransformer {
|
||||
permissions.setCanDownload(userEntity.getPermissions().isPermissionDownload());
|
||||
permissions.setCanEditMetadata(userEntity.getPermissions().isPermissionEditMetadata());
|
||||
permissions.setCanEmailBook(userEntity.getPermissions().isPermissionEmailBook());
|
||||
permissions.setCanDeleteBook(userEntity.getPermissions().isPermissionDeleteBook());
|
||||
permissions.setCanManipulateLibrary(userEntity.getPermissions().isPermissionManipulateLibrary());
|
||||
|
||||
BookLoreUser bookLoreUser = new BookLoreUser();
|
||||
|
||||
@@ -27,4 +27,5 @@ public class Book {
|
||||
private EpubProgress epubProgress;
|
||||
private CbxProgress cbxProgress;
|
||||
private Set<Shelf> shelves;
|
||||
private String readStatus;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public class BookLoreUser {
|
||||
private boolean canEditMetadata;
|
||||
private boolean canManipulateLibrary;
|
||||
private boolean canEmailBook;
|
||||
private boolean canDeleteBook;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -43,6 +43,7 @@ public class BookMetadata {
|
||||
private String hardcoverId;
|
||||
private Double hardcoverRating;
|
||||
private Integer hardcoverReviewCount;
|
||||
private Double personalRating;
|
||||
private String googleId;
|
||||
|
||||
private Instant coverUpdatedOn;
|
||||
|
||||
@@ -15,6 +15,7 @@ public class UserCreateRequest {
|
||||
private boolean permissionDownload;
|
||||
private boolean permissionEditMetadata;
|
||||
private boolean permissionEmailBook;
|
||||
private boolean permissionDeleteBook;
|
||||
private boolean permissionAdmin;
|
||||
|
||||
private Set<Long> selectedLibraries;
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package com.adityachandel.booklore.model.dto.request;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record ReadStatusUpdateRequest(@NotBlank String status) {}
|
||||
+1
@@ -19,5 +19,6 @@ public class UserUpdateRequest {
|
||||
private boolean canEditMetadata;
|
||||
private boolean canManipulateLibrary;
|
||||
private boolean canEmailBook;
|
||||
private boolean canDeleteBook;
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.adityachandel.booklore.model.dto.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BookDeletionResponse {
|
||||
private Set<Long> deleted;
|
||||
private List<Long> failedFileDeletions;
|
||||
}
|
||||
+1
@@ -21,6 +21,7 @@ public enum AppSettingKey {
|
||||
OIDC_ENABLED("oidc_enabled", false),
|
||||
CBX_CACHE_SIZE_IN_MB("cbx_cache_size_in_mb", false),
|
||||
PDF_CACHE_SIZE_IN_MB("pdf_cache_size_in_mb", false),
|
||||
BOOK_DELETION_ENABLED("book_deletion_enabled", false),
|
||||
MAX_FILE_UPLOAD_SIZE_IN_MB("max_file_upload_size_in_mb", false);
|
||||
|
||||
private final String dbKey;
|
||||
|
||||
+1
@@ -22,6 +22,7 @@ public class AppSettings {
|
||||
private Integer maxFileUploadSizeInMb;
|
||||
private boolean remoteAuthEnabled;
|
||||
private boolean oidcEnabled;
|
||||
private boolean bookDeletionEnabled;
|
||||
private OidcProviderDetails oidcProviderDetails;
|
||||
private OidcAutoProvisionDetails oidcAutoProvisionDetails;
|
||||
private MetadataProviderSettings metadataProviderSettings;
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.adityachandel.booklore.model.entity;
|
||||
import com.adityachandel.booklore.convertor.BookRecommendationIdsListConverter;
|
||||
import com.adityachandel.booklore.model.dto.BookRecommendationLite;
|
||||
import com.adityachandel.booklore.model.enums.BookFileType;
|
||||
import com.adityachandel.booklore.model.enums.ReadStatus;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
@@ -40,6 +41,10 @@ public class BookEntity {
|
||||
@Column(name = "metadata_match_score")
|
||||
private Float metadataMatchScore;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "read_status")
|
||||
private ReadStatus readStatus;
|
||||
|
||||
@OneToOne(mappedBy = "book", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
|
||||
private BookMetadataEntity metadata;
|
||||
|
||||
|
||||
+8
@@ -90,6 +90,9 @@ public class BookMetadataEntity {
|
||||
@Column(name = "hardcover_review_count")
|
||||
private Integer hardcoverReviewCount;
|
||||
|
||||
@Column(name = "personal_rating")
|
||||
private Double personalRating;
|
||||
|
||||
@Column(name = "asin", length = 10)
|
||||
private String asin;
|
||||
|
||||
@@ -152,6 +155,9 @@ public class BookMetadataEntity {
|
||||
@Column(name = "hardcover_review_count_locked")
|
||||
private Boolean hardcoverReviewCountLocked = Boolean.FALSE;
|
||||
|
||||
@Column(name = "personal_rating_locked")
|
||||
private Boolean personalRatingLocked = Boolean.FALSE;
|
||||
|
||||
@Column(name = "cover_locked")
|
||||
private Boolean coverLocked = Boolean.FALSE;
|
||||
|
||||
@@ -225,6 +231,7 @@ public class BookMetadataEntity {
|
||||
this.goodreadsReviewCountLocked = lock;
|
||||
this.hardcoverRatingLocked = lock;
|
||||
this.hardcoverReviewCountLocked = lock;
|
||||
this.personalRatingLocked = lock;
|
||||
this.goodreadsIdLocked = lock;
|
||||
this.hardcoverIdLocked = lock;
|
||||
this.googleIdLocked = lock;
|
||||
@@ -253,6 +260,7 @@ public class BookMetadataEntity {
|
||||
&& Boolean.TRUE.equals(this.goodreadsReviewCountLocked)
|
||||
&& Boolean.TRUE.equals(this.hardcoverRatingLocked)
|
||||
&& Boolean.TRUE.equals(this.hardcoverReviewCountLocked)
|
||||
&& Boolean.TRUE.equals(this.personalRatingLocked)
|
||||
&& Boolean.TRUE.equals(this.goodreadsIdLocked)
|
||||
&& Boolean.TRUE.equals(this.hardcoverIdLocked)
|
||||
&& Boolean.TRUE.equals(this.googleIdLocked)
|
||||
|
||||
+3
@@ -35,6 +35,9 @@ public class UserPermissionsEntity {
|
||||
@Column(name = "permission_email_book", nullable = false)
|
||||
private boolean permissionEmailBook = false;
|
||||
|
||||
@Column(name = "permission_delete_book", nullable = false)
|
||||
private boolean permissionDeleteBook = false;
|
||||
|
||||
@Column(name = "permission_admin", nullable = false)
|
||||
private boolean permissionAdmin;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.adityachandel.booklore.model.enums;
|
||||
|
||||
public enum ReadStatus {
|
||||
UNREAD,
|
||||
READING,
|
||||
RE_READING,
|
||||
READ,
|
||||
PARTIALLY_READ,
|
||||
PAUSED,
|
||||
WONT_READ,
|
||||
ABANDONED
|
||||
}
|
||||
@@ -5,17 +5,23 @@ import com.adityachandel.booklore.exception.ApiError;
|
||||
import com.adityachandel.booklore.mapper.BookMapper;
|
||||
import com.adityachandel.booklore.model.dto.*;
|
||||
import com.adityachandel.booklore.model.dto.request.ReadProgressRequest;
|
||||
import com.adityachandel.booklore.model.dto.response.BookDeletionResponse;
|
||||
import com.adityachandel.booklore.model.entity.*;
|
||||
import com.adityachandel.booklore.model.enums.BookFileType;
|
||||
import com.adityachandel.booklore.model.enums.ReadStatus;
|
||||
import com.adityachandel.booklore.repository.*;
|
||||
import com.adityachandel.booklore.service.appsettings.AppSettingService;
|
||||
import com.adityachandel.booklore.util.FileService;
|
||||
import com.adityachandel.booklore.util.FileUtils;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.UrlResource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
@@ -24,12 +30,11 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@@ -50,6 +55,7 @@ public class BookService {
|
||||
private final AuthenticationService authenticationService;
|
||||
private final BookQueryService bookQueryService;
|
||||
private final UserProgressService userProgressService;
|
||||
private final AppSettingService appSettingService;
|
||||
|
||||
public List<Book> getBookDTOs(boolean includeDescription) {
|
||||
BookLoreUser user = authenticationService.getAuthenticatedUser();
|
||||
@@ -349,4 +355,33 @@ public class BookService {
|
||||
.body(new ByteArrayResource(inputStream.readAllBytes()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public ResponseEntity<BookDeletionResponse> deleteBooks(Set<Long> ids) {
|
||||
List<BookEntity> books = bookQueryService.findAllWithMetadataByIds(ids);
|
||||
List<Long> failedFileDeletions = new ArrayList<>();
|
||||
for (BookEntity book : books) {
|
||||
Path fullFilePath = book.getFullFilePath();
|
||||
try {
|
||||
if (Files.exists(fullFilePath)) {
|
||||
Files.delete(fullFilePath);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
failedFileDeletions.add(book.getId());
|
||||
}
|
||||
}
|
||||
bookRepository.deleteAll(books);
|
||||
BookDeletionResponse response = new BookDeletionResponse(ids, failedFileDeletions);
|
||||
return failedFileDeletions.isEmpty()
|
||||
? ResponseEntity.ok(response)
|
||||
: ResponseEntity.status(HttpStatus.MULTI_STATUS).body(response);
|
||||
}
|
||||
|
||||
public void updateReadStatus(long bookId, @NotBlank String status) {
|
||||
BookEntity bookEntity = bookRepository.findById(bookId).orElseThrow(() -> ApiError.BOOK_NOT_FOUND.createException(bookId));
|
||||
ReadStatus readStatus = EnumUtils.getEnumIgnoreCase(ReadStatus.class, status);
|
||||
bookEntity.setReadStatus(readStatus);
|
||||
bookRepository.save(bookEntity);
|
||||
}
|
||||
}
|
||||
+1
@@ -80,6 +80,7 @@ public class AppSettingService {
|
||||
builder.cbxCacheSizeInMb(Integer.parseInt(settingPersistenceHelper.getOrCreateSetting(AppSettingKey.CBX_CACHE_SIZE_IN_MB, "5120")));
|
||||
builder.pdfCacheSizeInMb(Integer.parseInt(settingPersistenceHelper.getOrCreateSetting(AppSettingKey.PDF_CACHE_SIZE_IN_MB, "5120")));
|
||||
builder.maxFileUploadSizeInMb(Integer.parseInt(settingPersistenceHelper.getOrCreateSetting(AppSettingKey.MAX_FILE_UPLOAD_SIZE_IN_MB, "100")));
|
||||
builder.bookDeletionEnabled(Boolean.parseBoolean(settingPersistenceHelper.getOrCreateSetting(AppSettingKey.BOOK_DELETION_ENABLED, "false")));
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
+1
@@ -225,6 +225,7 @@ public class BookMetadataService {
|
||||
metadataCombined.setAmazonReviewCount(metadata.getAmazonReviewCount() != null ? metadata.getAmazonReviewCount() : metadataCombined.getAmazonReviewCount());
|
||||
metadataCombined.setHardcoverRating(metadata.getHardcoverRating() != null ? metadata.getHardcoverRating() : metadataCombined.getHardcoverRating());
|
||||
metadataCombined.setHardcoverReviewCount(metadata.getHardcoverReviewCount() != null ? metadata.getHardcoverReviewCount() : metadataCombined.getHardcoverReviewCount());
|
||||
metadataCombined.setPersonalRating(metadata.getPersonalRating() != null ? metadata.getPersonalRating() : metadataCombined.getPersonalRating());
|
||||
metadataCombined.setSeriesName(metadata.getSeriesName() != null ? metadata.getSeriesName() : metadataCombined.getSeriesName());
|
||||
metadataCombined.setSeriesNumber(metadata.getSeriesNumber() != null ? metadata.getSeriesNumber() : metadataCombined.getSeriesNumber());
|
||||
metadataCombined.setSeriesTotal(metadata.getSeriesTotal() != null ? metadata.getSeriesTotal() : metadataCombined.getSeriesTotal());
|
||||
|
||||
+1
@@ -113,6 +113,7 @@ public class BookMetadataUpdater {
|
||||
updateFieldIfUnlocked(metadata::getGoodreadsReviewCountLocked, newMetadata.getGoodreadsReviewCount(), metadata::setGoodreadsReviewCount);
|
||||
updateFieldIfUnlocked(metadata::getHardcoverRatingLocked, newMetadata.getHardcoverRating(), metadata::setHardcoverRating);
|
||||
updateFieldIfUnlocked(metadata::getHardcoverReviewCountLocked, newMetadata.getHardcoverReviewCount(), metadata::setHardcoverReviewCount);
|
||||
updateFieldIfUnlocked(metadata::getPersonalRatingLocked, newMetadata.getPersonalRating(), metadata::setPersonalRating);
|
||||
updateFieldIfUnlocked(metadata::getSeriesNameLocked, newMetadata.getSeriesName(), metadata::setSeriesName);
|
||||
updateFieldIfUnlocked(metadata::getSeriesNumberLocked, newMetadata.getSeriesNumber(), metadata::setSeriesNumber);
|
||||
updateFieldIfUnlocked(metadata::getSeriesTotalLocked, newMetadata.getSeriesTotal(), metadata::setSeriesTotal);
|
||||
|
||||
+4
@@ -50,6 +50,7 @@ public class UserProvisioningService {
|
||||
perms.setPermissionEditMetadata(true);
|
||||
perms.setPermissionManipulateLibrary(true);
|
||||
perms.setPermissionEmailBook(true);
|
||||
perms.setPermissionDeleteBook(true);
|
||||
|
||||
user.setPermissions(perms);
|
||||
createUser(user);
|
||||
@@ -76,6 +77,7 @@ public class UserProvisioningService {
|
||||
permissions.setPermissionDownload(request.isPermissionDownload());
|
||||
permissions.setPermissionEditMetadata(request.isPermissionEditMetadata());
|
||||
permissions.setPermissionEmailBook(request.isPermissionEmailBook());
|
||||
permissions.setPermissionDeleteBook(request.isPermissionDeleteBook());
|
||||
permissions.setPermissionAdmin(request.isPermissionAdmin());
|
||||
user.setPermissions(permissions);
|
||||
|
||||
@@ -105,6 +107,7 @@ public class UserProvisioningService {
|
||||
perms.setPermissionEditMetadata(defaultPermissions.contains("permissionEditMetadata"));
|
||||
perms.setPermissionManipulateLibrary(defaultPermissions.contains("permissionManipulateLibrary"));
|
||||
perms.setPermissionEmailBook(defaultPermissions.contains("permissionEmailBook"));
|
||||
perms.setPermissionDeleteBook(defaultPermissions.contains("permissionDeleteBooks"));
|
||||
}
|
||||
user.setPermissions(perms);
|
||||
|
||||
@@ -145,6 +148,7 @@ public class UserProvisioningService {
|
||||
permissions.setPermissionDownload(true);
|
||||
permissions.setPermissionEditMetadata(true);
|
||||
permissions.setPermissionEmailBook(true);
|
||||
permissions.setPermissionDeleteBook(true);
|
||||
permissions.setPermissionAdmin(isAdmin);
|
||||
user.setPermissions(permissions);
|
||||
|
||||
|
||||
@@ -14,12 +14,8 @@ import com.adityachandel.booklore.model.entity.LibraryEntity;
|
||||
import com.adityachandel.booklore.model.entity.UserSettingEntity;
|
||||
import com.adityachandel.booklore.repository.LibraryRepository;
|
||||
import com.adityachandel.booklore.repository.UserRepository;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -56,6 +52,7 @@ public class UserService {
|
||||
user.getPermissions().setPermissionEditMetadata(updateRequest.getPermissions().isCanEditMetadata());
|
||||
user.getPermissions().setPermissionManipulateLibrary(updateRequest.getPermissions().isCanManipulateLibrary());
|
||||
user.getPermissions().setPermissionEmailBook(updateRequest.getPermissions().isCanEmailBook());
|
||||
user.getPermissions().setPermissionDeleteBook(updateRequest.getPermissions().isCanDeleteBook());
|
||||
}
|
||||
|
||||
if (updateRequest.getAssignedLibraries() != null && getMyself().getPermissions().isAdmin()) {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
ALTER TABLE user_permissions
|
||||
ADD COLUMN permission_delete_book BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
UPDATE user_permissions up
|
||||
SET up.permission_delete_book = TRUE
|
||||
WHERE up.permission_admin = TRUE;
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE book_metadata
|
||||
ADD COLUMN personal_rating FLOAT,
|
||||
ADD COLUMN personal_rating_locked BOOLEAN DEFAULT FALSE
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE book
|
||||
ADD COLUMN read_status VARCHAR(20) DEFAULT 'UNREAD';
|
||||
@@ -193,15 +193,17 @@
|
||||
class="grid"
|
||||
#container
|
||||
[ngStyle]="{'grid-template-columns': 'repeat(auto-fill, minmax(' + gridColumnMinWidth + ', 1fr))'}">
|
||||
@for (book of scroll.viewPortItems; track book) {
|
||||
@for (book of scroll.viewPortItems; let i = $index; track book) {
|
||||
<div
|
||||
class="virtual-scroller-item relative"
|
||||
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
|
||||
<app-book-card
|
||||
[index]="i"
|
||||
[book]="book"
|
||||
[isCheckboxEnabled]="true"
|
||||
[onBookSelect]="handleBookSelect.bind(this)"
|
||||
[isSeriesCollapsed]="seriesCollapseFilter.isSeriesCollapsed"
|
||||
(checkboxClick)="onCheckboxClicked($event)"
|
||||
[isSelected]="selectedBooks.has(book.id)">
|
||||
</app-book-card>
|
||||
</div>
|
||||
@@ -212,62 +214,91 @@
|
||||
</div>
|
||||
}
|
||||
@if (selectedBooks.size > 0) {
|
||||
<div class="book-browser-footer bg-[var(--card-background)] bg-opacity-10" [@slideInOut]>
|
||||
<div class="flex justify-between gap-8">
|
||||
@if (entityType$ | async; as entityType) {
|
||||
@if (userService.userState$ | async; as userData) {
|
||||
@if (userData.permissions.canEditMetadata) {
|
||||
<p-tieredmenu #menu [model]="metadataMenuItems" [popup]="true" appendTo="body"/>
|
||||
<p-button
|
||||
(click)="menu.toggle($event)"
|
||||
tooltip="Metadata actions"
|
||||
tooltipPosition="top"
|
||||
outlined="true"
|
||||
severity="info"
|
||||
icon="pi pi-database">
|
||||
</p-button>
|
||||
@if (userService.userState$ | async; as userData) {
|
||||
<div class="book-browser-footer bg-[var(--card-background)] bg-opacity-10" [@slideInOut]>
|
||||
<div class="flex justify-between items-center">
|
||||
<div class="flex">
|
||||
@if (entityType$ | async; as entityType) {
|
||||
<div class="flex gap-6 pr-2">
|
||||
@if (userData.permissions.canEditMetadata) {
|
||||
<p-menu #menu [model]="metadataMenuItems" [popup]="true" appendTo="body"/>
|
||||
<p-button
|
||||
(click)="menu.toggle($event)"
|
||||
pTooltip="Metadata actions"
|
||||
tooltipPosition="top"
|
||||
outlined="true"
|
||||
severity="info"
|
||||
icon="pi pi-database">
|
||||
</p-button>
|
||||
}
|
||||
@if (entityType === EntityType.LIBRARY || entityType === EntityType.ALL_BOOKS || entityType === EntityType.UNSHELVED) {
|
||||
<p-button
|
||||
icon="pi pi-bookmark-fill"
|
||||
outlined="true"
|
||||
severity="info"
|
||||
(onClick)="openShelfAssigner()"
|
||||
pTooltip="Assign to shelf"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
@if (entityType === EntityType.SHELF) {
|
||||
<p-button
|
||||
icon="pi pi-bookmark"
|
||||
outlined="true"
|
||||
severity="info"
|
||||
(click)="unshelfBooks()"
|
||||
pTooltip="Remove from shelf"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
@if (userData.permissions.canEditMetadata) {
|
||||
<p-button
|
||||
outlined="true"
|
||||
icon="pi pi-lock"
|
||||
severity="info"
|
||||
(click)="lockUnlockMetadata()"
|
||||
pTooltip="Lock/Unlock metadata"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@if (entityType === EntityType.LIBRARY || entityType === EntityType.ALL_BOOKS || entityType === EntityType.UNSHELVED) {
|
||||
<p-divider layout="vertical"></p-divider>
|
||||
<div class="flex gap-6 px-2">
|
||||
<p-button
|
||||
icon="pi pi-bookmark-fill"
|
||||
outlined="true"
|
||||
severity="info"
|
||||
(onClick)="openShelfAssigner()"
|
||||
pTooltip="Assign to shelf"
|
||||
icon="pi pi-check-square"
|
||||
severity="success"
|
||||
(click)="selectAllBooks()"
|
||||
pTooltip="Select all books"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
@if (entityType === EntityType.SHELF) {
|
||||
<p-button
|
||||
icon="pi pi-bookmark"
|
||||
outlined="true"
|
||||
severity="info"
|
||||
(click)="unshelfBooks()"
|
||||
pTooltip="Remove from shelf"
|
||||
icon="pi pi-times"
|
||||
severity="warn"
|
||||
(click)="deselectAllBooks()"
|
||||
pTooltip="Deselect all books"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p-button
|
||||
outlined="true"
|
||||
icon="pi pi-lock"
|
||||
severity="info"
|
||||
(click)="lockUnlockMetadata()"
|
||||
pTooltip="Lock/Unlock metadata"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
<p-button
|
||||
outlined="true"
|
||||
icon="pi pi-times"
|
||||
severity="warn"
|
||||
(click)="deselectAllBooks()"
|
||||
pTooltip="Deselect all books"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
@if (userData?.permissions?.admin || userData?.permissions?.canDeleteBook) {
|
||||
<p-divider layout="vertical"></p-divider>
|
||||
<p-button
|
||||
outlined="true"
|
||||
icon="pi pi-trash"
|
||||
severity="danger"
|
||||
(click)="confirmDeleteBooks()"
|
||||
pTooltip="Delete selected books"
|
||||
class="pl-2"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
.book-browser-footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 30%;
|
||||
right: 30%;
|
||||
left: 25%;
|
||||
right: 25%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 1rem 0.5rem 0.5rem;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {AfterViewInit, ChangeDetectorRef, Component, inject, OnInit, ViewChild} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {MenuItem, MessageService, PrimeTemplate} from 'primeng/api';
|
||||
import {ConfirmationService, MenuItem, MessageService, PrimeTemplate} from 'primeng/api';
|
||||
import {LibraryService} from '../../service/library.service';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {debounceTime, filter, map, switchMap, take} from 'rxjs/operators';
|
||||
@@ -41,7 +41,7 @@ import {Popover} from 'primeng/popover';
|
||||
import {Slider} from 'primeng/slider';
|
||||
import {Select} from 'primeng/select';
|
||||
import {FilterSortPreferenceService} from './filters/filter-sorting-preferences.service';
|
||||
import {TieredMenu} from 'primeng/tieredmenu';
|
||||
import {Divider} from 'primeng/divider';
|
||||
|
||||
export enum EntityType {
|
||||
LIBRARY = 'Library',
|
||||
@@ -74,7 +74,7 @@ const SORT_DIRECTION = {
|
||||
standalone: true,
|
||||
templateUrl: './book-browser.component.html',
|
||||
styleUrls: ['./book-browser.component.scss'],
|
||||
imports: [Button, VirtualScrollerModule, BookCardComponent, AsyncPipe, ProgressSpinner, Menu, InputText, FormsModule, BookTableComponent, BookFilterComponent, Tooltip, NgClass, Fluid, PrimeTemplate, NgStyle, OverlayPanelModule, DropdownModule, Checkbox, Popover, Slider, Select, TieredMenu],
|
||||
imports: [Button, VirtualScrollerModule, BookCardComponent, AsyncPipe, ProgressSpinner, Menu, InputText, FormsModule, BookTableComponent, BookFilterComponent, Tooltip, NgClass, Fluid, PrimeTemplate, NgStyle, OverlayPanelModule, DropdownModule, Checkbox, Popover, Slider, Select, Divider],
|
||||
providers: [SeriesCollapseFilter],
|
||||
animations: [
|
||||
trigger('slideInOut', [
|
||||
@@ -135,6 +135,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
private changeDetectorRef = inject(ChangeDetectorRef);
|
||||
private libraryShelfMenuService = inject(LibraryShelfMenuService);
|
||||
protected seriesCollapseFilter = inject(SeriesCollapseFilter);
|
||||
protected confirmationService = inject(ConfirmationService);
|
||||
|
||||
private sideBarFilter = new SideBarFilter(this.selectedFilter, this.selectedFilterMode);
|
||||
private headerFilter = new HeaderFilter(this.searchTerm$);
|
||||
@@ -145,6 +146,8 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
filterVisibility = true;
|
||||
private settingFiltersFromUrl = false;
|
||||
protected metadataMenuItems: MenuItem[] | undefined;
|
||||
currentBooks: Book[] = [];
|
||||
lastSelectedIndex: number | null = null;
|
||||
|
||||
get currentCardSize() {
|
||||
return this.coverScalePreferenceService.currentCardSize;
|
||||
@@ -478,6 +481,32 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
);
|
||||
}
|
||||
|
||||
onCheckboxClicked(event: { index: number; bookId: number; selected: boolean; shiftKey: boolean }) {
|
||||
const {index, bookId, selected, shiftKey} = event;
|
||||
if (!shiftKey || this.lastSelectedIndex === null) {
|
||||
if (selected) {
|
||||
this.selectedBooks.add(bookId);
|
||||
} else {
|
||||
this.selectedBooks.delete(bookId);
|
||||
}
|
||||
this.lastSelectedIndex = index;
|
||||
} else {
|
||||
const start = Math.min(this.lastSelectedIndex, index);
|
||||
const end = Math.max(this.lastSelectedIndex, index);
|
||||
const isUnselectingRange = !selected;
|
||||
for (let i = start; i <= end; i++) {
|
||||
const book = this.currentBooks[i];
|
||||
if (!book) continue;
|
||||
|
||||
if (isUnselectingRange) {
|
||||
this.selectedBooks.delete(book.id);
|
||||
} else {
|
||||
this.selectedBooks.add(book.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handleBookSelect(bookId: number, selected: boolean): void {
|
||||
if (selected) {
|
||||
this.selectedBooks.add(bookId);
|
||||
@@ -492,6 +521,16 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
this.isDrawerVisible = this.selectedBooks.size > 0;
|
||||
}
|
||||
|
||||
selectAllBooks(): void {
|
||||
if (!this.currentBooks) return;
|
||||
for (const book of this.currentBooks) {
|
||||
this.selectedBooks.add(book.id);
|
||||
}
|
||||
if (this.bookTableComponent) {
|
||||
this.bookTableComponent.selectAllBooks();
|
||||
}
|
||||
}
|
||||
|
||||
deselectAllBooks(): void {
|
||||
this.selectedBooks.clear();
|
||||
this.isDrawerVisible = false;
|
||||
@@ -500,6 +539,21 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
}
|
||||
|
||||
confirmDeleteBooks(): void {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to delete ${this.selectedBooks.size} book(s)?`,
|
||||
header: 'Confirm Deletion',
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
accept: () => {
|
||||
this.bookService.deleteBooks(this.selectedBooks).subscribe(() => {
|
||||
this.selectedBooks.clear();
|
||||
});
|
||||
},
|
||||
reject: () => {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onSeriesCollapseCheckboxChange(value: boolean): void {
|
||||
this.seriesCollapseFilter.setCollapsed(value);
|
||||
}
|
||||
@@ -515,6 +569,14 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
switchMap(({entityId, entityType}) => this.fetchBooksByEntity(entityId, entityType))
|
||||
);
|
||||
}
|
||||
this.bookState$
|
||||
.pipe(
|
||||
filter(state => state.loaded && !state.error),
|
||||
map(state => state.books || [])
|
||||
)
|
||||
.subscribe(books => {
|
||||
this.currentBooks = books;
|
||||
});
|
||||
}
|
||||
|
||||
onSearchTermChange(term: string): void {
|
||||
|
||||
@@ -28,14 +28,11 @@
|
||||
<p-button [hidden]="readButtonHidden" [rounded]="true" icon="pi pi-book" class="read-btn" (click)="readBook(book)"></p-button>
|
||||
|
||||
@if (isCheckboxEnabled) {
|
||||
<p-checkbox
|
||||
[(ngModel)]="isSelected"
|
||||
binary="true"
|
||||
id="select-checkbox-{{book.id}}"
|
||||
name="select-checkbox-{{book.id}}"
|
||||
<input
|
||||
type="checkbox"
|
||||
class="select-checkbox"
|
||||
(ngModelChange)="toggleSelection(isSelected || false)">
|
||||
</p-checkbox>
|
||||
[checked]="isSelected"
|
||||
(click)="toggleSelection(!isSelected, $event)">
|
||||
}
|
||||
|
||||
@if (progressPercentage !== null) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {Component, inject, Input, OnInit, ViewChild} from '@angular/core';
|
||||
import {Component, ElementRef, EventEmitter, inject, Input, OnInit, Output, ViewChild} from '@angular/core';
|
||||
import {Book, BookMetadata} from '../../../model/book.model';
|
||||
import {Button} from 'primeng/button';
|
||||
import {MenuModule} from 'primeng/menu';
|
||||
import {MenuItem, MessageService} from 'primeng/api';
|
||||
import {ConfirmationService, MenuItem, MessageService} from 'primeng/api';
|
||||
import {DialogService} from 'primeng/dynamicdialog';
|
||||
import {ShelfAssignerComponent} from '../../shelf-assigner/shelf-assigner.component';
|
||||
import {BookService} from '../../../service/book.service';
|
||||
@@ -12,7 +12,7 @@ import {MetadataFetchOptionsComponent} from '../../../metadata/metadata-options-
|
||||
import {MetadataRefreshType} from '../../../metadata/model/request/metadata-refresh-type.enum';
|
||||
import {MetadataRefreshRequest} from '../../../metadata/model/request/metadata-refresh-request.model';
|
||||
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
|
||||
import { NgClass } from '@angular/common';
|
||||
import {NgClass} from '@angular/common';
|
||||
import {UserService} from '../../../../settings/user-management/user.service';
|
||||
import {filter} from 'rxjs';
|
||||
import {EmailService} from '../../../../settings/email/email.service';
|
||||
@@ -29,6 +29,9 @@ import {ProgressBar} from 'primeng/progressbar';
|
||||
standalone: true
|
||||
})
|
||||
export class BookCardComponent implements OnInit {
|
||||
@Input() index!: number;
|
||||
@Output() checkboxClick = new EventEmitter<{ index: number; bookId: number; selected: boolean; shiftKey: boolean }>();
|
||||
|
||||
@Input() book!: Book;
|
||||
@Input() isCheckboxEnabled: boolean = false;
|
||||
@Input() onBookSelect?: (bookId: number, selected: boolean) => void;
|
||||
@@ -37,6 +40,8 @@ export class BookCardComponent implements OnInit {
|
||||
@Input() readButtonHidden: boolean = false;
|
||||
@Input() isSeriesCollapsed: boolean = false;
|
||||
|
||||
@ViewChild('checkboxElem') checkboxElem!: ElementRef<HTMLInputElement>;
|
||||
|
||||
items: MenuItem[] | undefined;
|
||||
isHovered: boolean = false;
|
||||
isImageLoaded: boolean = false;
|
||||
@@ -48,6 +53,7 @@ export class BookCardComponent implements OnInit {
|
||||
private messageService = inject(MessageService);
|
||||
private router = inject(Router);
|
||||
protected urlHelper = inject(UrlHelperService);
|
||||
private confirmationService = inject(ConfirmationService);
|
||||
|
||||
private userPermissions: any;
|
||||
|
||||
@@ -79,9 +85,16 @@ export class BookCardComponent implements OnInit {
|
||||
this.bookService.readBook(book.id);
|
||||
}
|
||||
|
||||
toggleSelection(selected: boolean): void {
|
||||
toggleSelection(selected: boolean, event?: MouseEvent): void {
|
||||
if (this.isCheckboxEnabled) {
|
||||
this.isSelected = selected;
|
||||
this.checkboxClick.emit({
|
||||
index: this.index,
|
||||
bookId: this.book.id,
|
||||
selected,
|
||||
shiftKey: !!event?.shiftKey,
|
||||
});
|
||||
|
||||
if (this.onBookSelect) {
|
||||
this.onBookSelect(this.book.id, selected);
|
||||
}
|
||||
@@ -113,49 +126,6 @@ export class BookCardComponent implements OnInit {
|
||||
private getPermissionBasedMenuItems(): MenuItem[] {
|
||||
const items: MenuItem[] = [];
|
||||
|
||||
if (this.hasEditMetadataPermission()) {
|
||||
items.push(
|
||||
{
|
||||
label: 'Match Book',
|
||||
icon: 'pi pi-sparkles',
|
||||
command: () => {
|
||||
setTimeout(() => {
|
||||
this.router.navigate(['/book', this.book.id], {
|
||||
queryParams: {tab: 'match'}
|
||||
})
|
||||
}, 150);
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Quick Refresh',
|
||||
icon: 'pi pi-bolt',
|
||||
command: () => {
|
||||
const metadataRefreshRequest: MetadataRefreshRequest = {
|
||||
quick: true,
|
||||
refreshType: MetadataRefreshType.BOOKS,
|
||||
bookIds: [this.book.id],
|
||||
};
|
||||
this.bookService.autoRefreshMetadata(metadataRefreshRequest).subscribe();
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Granular Refresh',
|
||||
icon: 'pi pi-database',
|
||||
command: () => {
|
||||
this.dialogService.open(MetadataFetchOptionsComponent, {
|
||||
header: 'Metadata Refresh Options',
|
||||
modal: true,
|
||||
closable: true,
|
||||
data: {
|
||||
bookIds: [this.book!.id],
|
||||
metadataRefreshType: MetadataRefreshType.BOOKS,
|
||||
},
|
||||
});
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (this.hasDownloadPermission()) {
|
||||
items.push({
|
||||
label: 'Download',
|
||||
@@ -166,6 +136,26 @@ export class BookCardComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
if (this.hasDeleteBookPermission()) {
|
||||
items.push({
|
||||
label: 'Delete Book',
|
||||
icon: 'pi pi-trash',
|
||||
command: () => {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to delete "${this.book.metadata?.title}"?`,
|
||||
header: 'Confirm Deletion',
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptIcon: 'pi pi-trash',
|
||||
rejectIcon: 'pi pi-times',
|
||||
acceptButtonStyleClass: 'p-button-danger',
|
||||
accept: () => {
|
||||
this.bookService.deleteBooks(new Set([this.book.id])).subscribe();
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (this.hasEmailBookPermission()) {
|
||||
items.push(
|
||||
{
|
||||
@@ -216,6 +206,53 @@ export class BookCardComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
if (this.hasEditMetadataPermission()) {
|
||||
items.push({
|
||||
label: 'Metadata',
|
||||
icon: 'pi pi-database',
|
||||
items: [
|
||||
{
|
||||
label: 'Search Metadata',
|
||||
icon: 'pi pi-sparkles',
|
||||
command: () => {
|
||||
setTimeout(() => {
|
||||
this.router.navigate(['/book', this.book.id], {
|
||||
queryParams: {tab: 'match'}
|
||||
})
|
||||
}, 150);
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Auto Fetch',
|
||||
icon: 'pi pi-bolt',
|
||||
command: () => {
|
||||
const metadataRefreshRequest: MetadataRefreshRequest = {
|
||||
quick: true,
|
||||
refreshType: MetadataRefreshType.BOOKS,
|
||||
bookIds: [this.book.id],
|
||||
};
|
||||
this.bookService.autoRefreshMetadata(metadataRefreshRequest).subscribe();
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Advanced Fetch',
|
||||
icon: 'pi pi-database',
|
||||
command: () => {
|
||||
this.dialogService.open(MetadataFetchOptionsComponent, {
|
||||
header: 'Metadata Refresh Options',
|
||||
modal: true,
|
||||
closable: true,
|
||||
data: {
|
||||
bookIds: [this.book!.id],
|
||||
metadataRefreshType: MetadataRefreshType.BOOKS,
|
||||
},
|
||||
});
|
||||
},
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -242,16 +279,24 @@ export class BookCardComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
private isAdmin(): boolean {
|
||||
return this.userPermissions?.admin ?? false;
|
||||
}
|
||||
|
||||
private hasEditMetadataPermission(): boolean {
|
||||
return this.userPermissions?.canEditMetadata ?? false;
|
||||
return this.isAdmin() || (this.userPermissions?.canEditMetadata ?? false);
|
||||
}
|
||||
|
||||
private hasDownloadPermission(): boolean {
|
||||
return this.userPermissions?.canDownload ?? false;
|
||||
return this.isAdmin() || (this.userPermissions?.canDownload ?? false);
|
||||
}
|
||||
|
||||
private hasEmailBookPermission(): boolean {
|
||||
return this.userPermissions?.canEmailBook ?? false;
|
||||
return this.isAdmin() || (this.userPermissions?.canEmailBook ?? false);
|
||||
}
|
||||
|
||||
private hasDeleteBookPermission(): boolean {
|
||||
return this.isAdmin() || (this.userPermissions?.canDeleteBook ?? false);
|
||||
}
|
||||
|
||||
isMetadataFullyLocked(metadata: BookMetadata): boolean {
|
||||
|
||||
+83
-51
@@ -5,7 +5,7 @@ import {BookService} from '../../../service/book.service';
|
||||
import {Library} from '../../../model/library.model';
|
||||
import {Shelf} from '../../../model/shelf.model';
|
||||
import {EntityType} from '../book-browser.component';
|
||||
import {Book} from '../../../model/book.model';
|
||||
import {Book, ReadStatus} from '../../../model/book.model';
|
||||
import {Accordion, AccordionContent, AccordionHeader, AccordionPanel} from 'primeng/accordion';
|
||||
import {AsyncPipe, NgClass, TitleCasePipe} from '@angular/common';
|
||||
import {Badge} from 'primeng/badge';
|
||||
@@ -17,60 +17,73 @@ import {FilterSortPreferenceService} from '../filters/filter-sorting-preferences
|
||||
type Filter<T> = { value: T; bookCount: number };
|
||||
|
||||
export const ratingRanges = [
|
||||
{id: '0to1', label: '0 to 1', min: 0, max: 1},
|
||||
{id: '1to2', label: '1 to 2', min: 1, max: 2},
|
||||
{id: '2to3', label: '2 to 3', min: 2, max: 3},
|
||||
{id: '3to4', label: '3 to 4', min: 3, max: 4},
|
||||
{id: '4to4.5', label: '4 to 4.5', min: 4, max: 4.5},
|
||||
{id: '4.5plus', label: '4.5+', min: 4.5, max: Infinity}
|
||||
{id: '0to1', label: '0 to 1', min: 0, max: 1, sortIndex: 0},
|
||||
{id: '1to2', label: '1 to 2', min: 1, max: 2, sortIndex: 1},
|
||||
{id: '2to3', label: '2 to 3', min: 2, max: 3, sortIndex: 2},
|
||||
{id: '3to4', label: '3 to 4', min: 3, max: 4, sortIndex: 3},
|
||||
{id: '4to4.5', label: '4 to 4.5', min: 4, max: 4.5, sortIndex: 4},
|
||||
{id: '4.5plus', label: '4.5+', min: 4.5, max: Infinity, sortIndex: 5}
|
||||
];
|
||||
|
||||
export const ratingOptions10 = Array.from({ length: 10 }, (_, i) => ({
|
||||
id: `${i + 1}`,
|
||||
label: `${i + 1}`,
|
||||
value: i + 1,
|
||||
sortIndex: i
|
||||
}));
|
||||
|
||||
export const fileSizeRanges = [
|
||||
{id: '<1mb', label: '< 1 MB', min: 0, max: 1024},
|
||||
{id: '1to10mb', label: '1–10 MB', min: 1024, max: 10240},
|
||||
{id: '10to50mb', label: '10–50 MB', min: 10240, max: 51200},
|
||||
{id: '50to100mb', label: '50–100 MB', min: 51200, max: 102400},
|
||||
{id: '250to500mb', label: '250–500 MB', min: 256000, max: 512000},
|
||||
{id: '500mbto1gb', label: '500 MB – 1 GB', min: 512000, max: 1048576},
|
||||
{id: '1to2gb', label: '1–2 GB', min: 1048576, max: 2097152},
|
||||
{id: '5plusgb', label: '5+ GB', min: 5242880, max: Infinity}
|
||||
{id: '<1mb', label: '< 1 MB', min: 0, max: 1024, sortIndex: 0},
|
||||
{id: '1to10mb', label: '1–10 MB', min: 1024, max: 10240, sortIndex: 1},
|
||||
{id: '10to50mb', label: '10–50 MB', min: 10240, max: 51200, sortIndex: 2},
|
||||
{id: '50to100mb', label: '50–100 MB', min: 51200, max: 102400, sortIndex: 3},
|
||||
{id: '250to500mb', label: '250–500 MB', min: 256000, max: 512000, sortIndex: 4},
|
||||
{id: '500mbto1gb', label: '0.5–1 GB', min: 512000, max: 1048576, sortIndex: 5},
|
||||
{id: '1to2gb', label: '1–2 GB', min: 1048576, max: 2097152, sortIndex: 6},
|
||||
{id: '5plusgb', label: '5+ GB', min: 5242880, max: Infinity, sortIndex: 7}
|
||||
];
|
||||
|
||||
export const pageCountRanges = [
|
||||
{id: '<50', label: '< 50 pages', min: 0, max: 50},
|
||||
{id: '50to100', label: '50–100 pages', min: 50, max: 100},
|
||||
{id: '100to200', label: '100–200 pages', min: 100, max: 200},
|
||||
{id: '200to400', label: '200–400 pages', min: 200, max: 400},
|
||||
{id: '400to600', label: '400–600 pages', min: 400, max: 600},
|
||||
{id: '600to1000', label: '600–1000 pages', min: 600, max: 1000},
|
||||
{id: '1000plus', label: '1000+ pages', min: 1000, max: Infinity}
|
||||
{id: '<50', label: '< 50 pages', min: 0, max: 50, sortIndex: 0},
|
||||
{id: '50to100', label: '50–100 pages', min: 50, max: 100, sortIndex: 1},
|
||||
{id: '100to200', label: '100–200 pages', min: 100, max: 200, sortIndex: 2},
|
||||
{id: '200to400', label: '200–400 pages', min: 200, max: 400, sortIndex: 3},
|
||||
{id: '400to600', label: '400–600 pages', min: 400, max: 600, sortIndex: 4},
|
||||
{id: '600to1000', label: '600–1000 pages', min: 600, max: 1000, sortIndex: 5},
|
||||
{id: '1000plus', label: '1000+ pages', min: 1000, max: Infinity, sortIndex: 6}
|
||||
];
|
||||
|
||||
export const matchScoreRanges = [
|
||||
{id: '0.95-1.0', min: 0.95, max: 1.01, name: 'Outstanding (95–100%)', sortIndex: 0},
|
||||
{id: '0.90-0.94', min: 0.90, max: 0.95, name: 'Excellent (90–94%)', sortIndex: 1},
|
||||
{id: '0.80-0.89', min: 0.80, max: 0.90, name: 'Great (80–89%)', sortIndex: 2},
|
||||
{id: '0.70-0.79', min: 0.70, max: 0.80, name: 'Good (70–79%)', sortIndex: 3},
|
||||
{id: '0.50-0.69', min: 0.50, max: 0.70, name: 'Fair (50–69%)', sortIndex: 4},
|
||||
{id: '0.30-0.49', min: 0.30, max: 0.50, name: 'Weak (30–49%)', sortIndex: 5},
|
||||
{id: '0.00-0.29', min: 0.00, max: 0.30, name: 'Poor (0–29%)', sortIndex: 6}
|
||||
{id: '0.95-1.0', min: 0.95, max: 1.01, label: 'Outstanding (95–100%)', sortIndex: 0},
|
||||
{id: '0.90-0.94', min: 0.90, max: 0.95, label: 'Excellent (90–94%)', sortIndex: 1},
|
||||
{id: '0.80-0.89', min: 0.80, max: 0.90, label: 'Great (80–89%)', sortIndex: 2},
|
||||
{id: '0.70-0.79', min: 0.70, max: 0.80, label: 'Good (70–79%)', sortIndex: 3},
|
||||
{id: '0.50-0.69', min: 0.50, max: 0.70, label: 'Fair (50–69%)', sortIndex: 4},
|
||||
{id: '0.30-0.49', min: 0.30, max: 0.50, label: 'Weak (30–49%)', sortIndex: 5},
|
||||
{id: '0.00-0.29', min: 0.00, max: 0.30, label: 'Poor (0–29%)', sortIndex: 6}
|
||||
];
|
||||
|
||||
const getLanguageFilter = (book: Book) => {
|
||||
function getLanguageFilter(book: Book): { id: string; name: string }[] {
|
||||
const lang = book.metadata?.language;
|
||||
return lang ? [{id: lang, name: lang}] : [];
|
||||
};
|
||||
|
||||
function getFileSizeRangeFilters(sizeKb?: number) {
|
||||
if (sizeKb == null) return [];
|
||||
const match = fileSizeRanges.find(r => sizeKb >= r.min && sizeKb < r.max);
|
||||
return match ? [{id: match.id, name: match.label}] : [];
|
||||
}
|
||||
|
||||
function getRatingRangeFilters(rating?: number) {
|
||||
function getFileSizeRangeFilters(sizeKb?: number): { id: string; name: string; sortIndex?: number }[] {
|
||||
if (sizeKb == null) return [];
|
||||
const match = fileSizeRanges.find(r => sizeKb >= r.min && sizeKb < r.max);
|
||||
return match ? [{id: match.id, name: match.label, sortIndex: match.sortIndex}] : [];
|
||||
}
|
||||
|
||||
function getRatingRangeFilters(rating?: number): { id: string; name: string; sortIndex?: number }[] {
|
||||
if (rating == null) return [];
|
||||
const match = ratingRanges.find(r => rating >= r.min && rating < r.max);
|
||||
return match ? [{id: match.id, name: match.label}] : [];
|
||||
return match ? [{id: match.id, name: match.label, sortIndex: match.sortIndex}] : [];
|
||||
}
|
||||
|
||||
function getRatingRangeFilters10(rating?: number): { id: string; name: string; sortIndex?: number }[] {
|
||||
if (!rating || rating < 1 || rating > 10) return [];
|
||||
const idx = ratingOptions10.find(r => r.value === rating || +r.id === rating);
|
||||
return idx ? [{ id: idx.id, name: idx.label, sortIndex: idx.sortIndex }] : [];
|
||||
}
|
||||
|
||||
function extractPublishedYearFilter(book: Book): { id: number; name: string }[] {
|
||||
@@ -81,20 +94,35 @@ function extractPublishedYearFilter(book: Book): { id: number; name: string }[]
|
||||
}
|
||||
|
||||
function getShelfStatusFilter(book: Book): { id: string; name: string }[] {
|
||||
const isShelved = book.shelves && book.shelves.length > 0;
|
||||
const isShelved = book.shelves?.length! > 0;
|
||||
return [{id: isShelved ? 'shelved' : 'unshelved', name: isShelved ? 'Shelved' : 'Unshelved'}];
|
||||
}
|
||||
|
||||
function getPageCountRangeFilters(pageCount?: number) {
|
||||
function getPageCountRangeFilters(pageCount?: number): { id: string; name: string; sortIndex?: number }[] {
|
||||
if (pageCount == null) return [];
|
||||
const match = pageCountRanges.find(r => pageCount >= r.min && pageCount < r.max);
|
||||
return match ? [{id: match.id, name: match.label}] : [];
|
||||
return match ? [{id: match.id, name: match.label, sortIndex: match.sortIndex}] : [];
|
||||
}
|
||||
|
||||
export function getMatchScoreRangeFilters(score?: number | null): { id: string; name: string; sortIndex?: number }[] {
|
||||
function getMatchScoreRangeFilters(score?: number | null): { id: string; name: string; sortIndex?: number }[] {
|
||||
if (score == null) return [];
|
||||
const match = matchScoreRanges.find(r => score >= r.min && score < r.max);
|
||||
return match ? [{id: match.id, name: match.name, sortIndex: match.sortIndex}] : [];
|
||||
return match ? [{id: match.id, name: match.label, sortIndex: match.sortIndex}] : [];
|
||||
}
|
||||
|
||||
const readStatusLabels: Record<ReadStatus, string> = {
|
||||
[ReadStatus.UNREAD]: 'Unread',
|
||||
[ReadStatus.READING]: 'Reading',
|
||||
[ReadStatus.RE_READING]: 'Re-reading',
|
||||
[ReadStatus.PARTIALLY_READ]: 'Partially Read',
|
||||
[ReadStatus.PAUSED]: 'Paused',
|
||||
[ReadStatus.READ]: 'Read',
|
||||
[ReadStatus.WONT_READ]: 'Won’t Read',
|
||||
[ReadStatus.ABANDONED]: 'Abandoned',
|
||||
};
|
||||
|
||||
function getReadStatusName(status?: ReadStatus | null): string {
|
||||
return status != null ? readStatusLabels[status] ?? 'Unknown' : 'Unknown';
|
||||
}
|
||||
|
||||
@Component({
|
||||
@@ -138,6 +166,9 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
category: 'Category',
|
||||
series: 'Series',
|
||||
publisher: 'Publisher',
|
||||
readStatus: 'Read Status',
|
||||
personalRating: 'Personal Rating',
|
||||
matchScore: 'Metadata Match Score',
|
||||
amazonRating: 'Amazon Rating',
|
||||
goodreadsRating: 'Goodreads Rating',
|
||||
hardcoverRating: 'Hardcover Rating',
|
||||
@@ -145,8 +176,7 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
fileSize: 'File Size',
|
||||
shelfStatus: 'Shelf Status',
|
||||
pageCount: 'Page Count',
|
||||
language: 'Language',
|
||||
matchScore: 'Metadata Match Score'
|
||||
language: 'Language'
|
||||
};
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
@@ -167,16 +197,18 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
author: this.getFilterStream((book: Book) => book.metadata?.authors.map(name => ({id: name, name})) || [], 'id', 'name', sortMode),
|
||||
category: this.getFilterStream((book: Book) => book.metadata?.categories.map(name => ({id: name, name})) || [], 'id', 'name', sortMode),
|
||||
series: this.getFilterStream((book) => (book.metadata?.seriesName ? [{id: book.metadata.seriesName, name: book.metadata.seriesName}] : []), 'id', 'name', sortMode),
|
||||
matchScore: this.getFilterStream((book: Book) => getMatchScoreRangeFilters(book.metadataMatchScore), 'id', 'name', 'sortIndex'),
|
||||
publisher: this.getFilterStream((book) => (book.metadata?.publisher ? [{id: book.metadata.publisher, name: book.metadata.publisher}] : []), 'id', 'name', sortMode),
|
||||
readStatus: this.getFilterStream((book: Book) => [{id: book.readStatus ?? ReadStatus.UNREAD, name: getReadStatusName(book.readStatus)}], 'id', 'name', sortMode),
|
||||
matchScore: this.getFilterStream((book: Book) => getMatchScoreRangeFilters(book.metadataMatchScore), 'id', 'name', 'sortIndex'),
|
||||
personalRating: this.getFilterStream((book: Book) => getRatingRangeFilters10(book.metadata?.personalRating!), 'id', 'name', 'sortIndex'),
|
||||
amazonRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.amazonRating!), 'id', 'name', 'sortIndex'),
|
||||
goodreadsRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.goodreadsRating!), 'id', 'name', 'sortIndex'),
|
||||
hardcoverRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.hardcoverRating!), 'id', 'name', 'sortIndex'),
|
||||
shelfStatus: this.getFilterStream(getShelfStatusFilter, 'id', 'name', sortMode),
|
||||
publishedDate: this.getFilterStream(extractPublishedYearFilter, 'id', 'name', sortMode),
|
||||
language: this.getFilterStream(getLanguageFilter, 'id', 'name', sortMode),
|
||||
fileSize: this.getFilterStream((book: Book) => getFileSizeRangeFilters(book.fileSizeKb), 'id', 'name', sortMode),
|
||||
amazonRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.amazonRating!), 'id', 'name', sortMode),
|
||||
goodreadsRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.goodreadsRating!), 'id', 'name', sortMode),
|
||||
hardcoverRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.hardcoverRating!), 'id', 'name', sortMode),
|
||||
pageCount: this.getFilterStream((book: Book) => getPageCountRangeFilters(book.metadata?.pageCount!), 'id', 'name', sortMode),
|
||||
fileSize: this.getFilterStream((book: Book) => getFileSizeRangeFilters(book.fileSizeKb), 'id', 'name', 'sortIndex'),
|
||||
pageCount: this.getFilterStream((book: Book) => getPageCountRangeFilters(book.metadata?.pageCount!), 'id', 'name', 'sortIndex'),
|
||||
};
|
||||
|
||||
this.filterTypes = Object.keys(this.filterStreams);
|
||||
|
||||
@@ -45,6 +45,12 @@ export class BookTableComponent implements OnChanges {
|
||||
});
|
||||
}
|
||||
|
||||
selectAllBooks(): void {
|
||||
this.selectedBookIds = new Set(this.books.map(book => book.id));
|
||||
this.selectedBooks = [...this.books];
|
||||
this.selectedBooksChange.emit(this.selectedBookIds);
|
||||
}
|
||||
|
||||
clearSelectedBooks(): void {
|
||||
this.selectedBookIds.clear();
|
||||
this.selectedBooks = [];
|
||||
|
||||
@@ -11,6 +11,11 @@ export function isRatingInRange(rating: number | undefined | null, rangeId: stri
|
||||
return rating >= range.min && rating < range.max;
|
||||
}
|
||||
|
||||
export function isRatingInRange10(rating: number | undefined | null, rangeId: string): boolean {
|
||||
if (rating == null) return false;
|
||||
return `${Math.round(rating)}` === rangeId;
|
||||
}
|
||||
|
||||
export function isFileSizeInRange(fileSizeKb: number | undefined, rangeId: string): boolean {
|
||||
if (fileSizeKb == null) return false;
|
||||
const range = fileSizeRanges.find(r => r.id === rangeId);
|
||||
@@ -63,12 +68,16 @@ export class SideBarFilter implements BookFilter {
|
||||
return mode === 'and'
|
||||
? filterValues.every(val => book.metadata?.seriesName === val)
|
||||
: filterValues.some(val => book.metadata?.seriesName === val);
|
||||
case 'readStatus':
|
||||
return filterValues.some(val => book.readStatus === val);
|
||||
case 'amazonRating':
|
||||
return filterValues.some(range => isRatingInRange(book.metadata?.amazonRating, range));
|
||||
case 'goodreadsRating':
|
||||
return filterValues.some(range => isRatingInRange(book.metadata?.goodreadsRating, range));
|
||||
case 'hardcoverRating':
|
||||
return filterValues.some(range => isRatingInRange(book.metadata?.hardcoverRating, range));
|
||||
case 'personalRating':
|
||||
return filterValues.some(range => isRatingInRange10(book.metadata?.personalRating, range));
|
||||
case 'publishedDate':
|
||||
return filterValues.includes(new Date(book.metadata?.publishedDate || '').getFullYear());
|
||||
case 'fileSize':
|
||||
|
||||
+31
-13
@@ -3,10 +3,24 @@ import {ActivatedRoute} from '@angular/router';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {Book, BookRecommendation} from '../../model/book.model';
|
||||
import {Observable, Subscription} from 'rxjs';
|
||||
import {distinctUntilChanged, filter, map, shareReplay, switchMap, take, tap} from 'rxjs/operators';
|
||||
import {
|
||||
distinctUntilChanged,
|
||||
filter,
|
||||
map,
|
||||
shareReplay,
|
||||
switchMap,
|
||||
take,
|
||||
tap
|
||||
} from 'rxjs/operators';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {AppSettingsService} from '../../../core/service/app-settings.service';
|
||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||
import {
|
||||
Tab,
|
||||
TabList,
|
||||
TabPanel,
|
||||
TabPanels,
|
||||
Tabs
|
||||
} from 'primeng/tabs';
|
||||
import {MetadataViewerComponent} from './metadata-viewer/metadata-viewer.component';
|
||||
import {MetadataEditorComponent} from './metadata-editor/metadata-editor.component';
|
||||
import {MetadataSearcherComponent} from './metadata-searcher/metadata-searcher.component';
|
||||
@@ -40,34 +54,36 @@ export class BookMetadataCenterComponent implements OnInit, OnDestroy {
|
||||
admin: boolean = false;
|
||||
|
||||
private userSubscription: Subscription = Subscription.EMPTY;
|
||||
private routeSubscription: Subscription = Subscription.EMPTY;
|
||||
private tabSubscription: Subscription = Subscription.EMPTY;
|
||||
private recommendationSubscription: Subscription = Subscription.EMPTY;
|
||||
private appSettings$ = this.appSettingsService.appSettings$;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.bookService.loadBooks();
|
||||
|
||||
this.book$ = this.route.paramMap.pipe(
|
||||
const bookId$ = this.route.paramMap.pipe(
|
||||
map(params => Number(params.get('bookId'))),
|
||||
filter(bookId => !isNaN(bookId)),
|
||||
distinctUntilChanged(),
|
||||
shareReplay(1)
|
||||
);
|
||||
|
||||
this.book$ = bookId$.pipe(
|
||||
switchMap(bookId =>
|
||||
this.bookService.bookState$.pipe(
|
||||
map(state => state.books?.find(b => b.id === bookId)),
|
||||
filter((book): book is Book => !!book && !!book.metadata),
|
||||
distinctUntilChanged((a, b) => a.id === b.id && a.metadata === b.metadata),
|
||||
switchMap(book =>
|
||||
this.bookService.getBookByIdFromAPI(book.id, true).pipe(
|
||||
tap(bookWithDescription => {
|
||||
this.fetchBookRecommendationsIfNeeded(bookWithDescription.metadata!.bookId);
|
||||
})
|
||||
)
|
||||
)
|
||||
switchMap(book => this.bookService.getBookByIdFromAPI(book.id, true))
|
||||
)
|
||||
),
|
||||
shareReplay(1)
|
||||
);
|
||||
|
||||
this.recommendationSubscription = bookId$.pipe(
|
||||
tap(bookId => this.fetchBookRecommendationsIfNeeded(bookId))
|
||||
).subscribe();
|
||||
|
||||
this.tabSubscription = this.route.queryParamMap.pipe(
|
||||
map(queryParams => queryParams.get('tab') ?? 'view'),
|
||||
distinctUntilChanged()
|
||||
@@ -85,8 +101,8 @@ export class BookMetadataCenterComponent implements OnInit, OnDestroy {
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.userSubscription.unsubscribe();
|
||||
this.routeSubscription.unsubscribe();
|
||||
this.tabSubscription.unsubscribe();
|
||||
this.recommendationSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
private fetchBookRecommendationsIfNeeded(bookId: number): void {
|
||||
@@ -98,7 +114,9 @@ export class BookMetadataCenterComponent implements OnInit, OnDestroy {
|
||||
.subscribe(settings => {
|
||||
if (settings!.similarBookRecommendation ?? false) {
|
||||
this.bookService.getBookRecommendations(bookId).subscribe(recommendations => {
|
||||
this.recommendedBooks = recommendations;
|
||||
this.recommendedBooks = recommendations.sort(
|
||||
(a, b) => (b.similarityScore ?? 0) - (a.similarityScore ?? 0)
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+47
-25
@@ -63,10 +63,24 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2 pt-2">
|
||||
<div class="flex items-center gap-2">
|
||||
<i class="pi pi-thumbs-up-fill"
|
||||
pTooltip="Personal Rating"
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
<p-rating
|
||||
[ngModel]="book?.metadata!.personalRating"
|
||||
(onRate)="onPersonalRatingChange(book, $event)"
|
||||
stars="10"
|
||||
[style.--p-rating-icon-active-color]="getStarColorScaled(book?.metadata!.personalRating, 10)">
|
||||
</p-rating>
|
||||
</div>
|
||||
@if (book?.metadata!.amazonRating || book?.metadata!.goodreadsRating || book?.metadata!.hardcoverRating) {
|
||||
@if (book?.metadata!.amazonRating) {
|
||||
@if (book?.metadata!.asin) {
|
||||
<span>|</span>
|
||||
<a class="flex items-center gap-1" [href]="'https://www.amazon.com/dp/' + book?.metadata!.asin" target="_blank" rel="noopener noreferrer">
|
||||
<img src="https://www.amazon.com/favicon.ico" alt="Amazon"
|
||||
class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg"/>
|
||||
@@ -79,7 +93,7 @@
|
||||
</span>
|
||||
}
|
||||
<p-rating [ngModel]="book?.metadata!.amazonRating" readonly stars="5"
|
||||
[style.--p-rating-icon-active-color]="getStarColor(book?.metadata!.amazonRating)">
|
||||
[style.--p-rating-icon-active-color]="getStarColorScaled(book?.metadata!.amazonRating)">
|
||||
</p-rating>
|
||||
<p class="font-semibold">({{ book?.metadata!.amazonReviewCount | number:'1.0-0' }})</p>
|
||||
@if (book?.metadata!.goodreadsRating || book?.metadata!.hardcoverRating) {
|
||||
@@ -100,7 +114,7 @@
|
||||
</span>
|
||||
}
|
||||
<p-rating [ngModel]="book?.metadata!.goodreadsRating" readonly stars="5"
|
||||
[style.--p-rating-icon-active-color]="getStarColor(book?.metadata!.goodreadsRating)">
|
||||
[style.--p-rating-icon-active-color]="getStarColorScaled(book?.metadata!.goodreadsRating)">
|
||||
</p-rating>
|
||||
<p class="font-semibold">({{ book?.metadata!.goodreadsReviewCount | number:'1.0-0' }})</p>
|
||||
@if (book?.metadata!.hardcoverRating) {
|
||||
@@ -121,7 +135,7 @@
|
||||
</span>
|
||||
}
|
||||
<p-rating [ngModel]="book?.metadata!.hardcoverRating" readonly stars="5"
|
||||
[style.--p-rating-icon-active-color]="getStarColor(book?.metadata!.hardcoverRating)">
|
||||
[style.--p-rating-icon-active-color]="getStarColorScaled(book?.metadata!.hardcoverRating)">
|
||||
</p-rating>
|
||||
<p class="font-semibold">({{ book?.metadata!.hardcoverReviewCount | number:'1.0-0' }})</p>
|
||||
@if ((book?.metadata!.amazonRating || book?.metadata!.goodreadsRating || book?.metadata!.hardcoverRating) && book?.metadata!.googleId) {
|
||||
@@ -134,17 +148,6 @@
|
||||
class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg"/>
|
||||
</a>
|
||||
}
|
||||
|
||||
} @else {
|
||||
<p-rating
|
||||
[(ngModel)]="book?.metadata!.rating"
|
||||
readonly
|
||||
stars="5"
|
||||
[style.--p-rating-icon-active-color]="getStarColor(book?.metadata!.rating)">
|
||||
</p-rating>
|
||||
<p class="font-semibold">
|
||||
{{ book.metadata?.reviewCount ? '(' + (book.metadata?.reviewCount | number:'1.0-0') + ' Ratings)' : 'No Ratings' }}
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
<div class="flex gap-2 pt-4 overflow-x-auto scrollbar-hide">
|
||||
@@ -165,23 +168,37 @@
|
||||
}
|
||||
</div>
|
||||
<div class="grid gap-x-20 gap-y-2 pt-6" style="grid-template-columns: repeat(5, max-content);">
|
||||
<p class="whitespace-nowrap flex items-center gap-2">
|
||||
<span class="font-bold">File Type:</span>
|
||||
<span
|
||||
class="inline-block px-2 py-0.5 rounded-full text-xs font-bold text-white"
|
||||
[ngClass]="getFileTypeColorClass(getFileExtension(book?.filePath))">
|
||||
{{ getFileExtension(book?.filePath) || '-' }}
|
||||
</span>
|
||||
</p>
|
||||
<div>
|
||||
<p class="whitespace-nowrap flex items-center gap-2">
|
||||
<span class="font-bold">Read Status:</span>
|
||||
<p-tag
|
||||
class="cursor-pointer text-white"
|
||||
[severity]="getStatusSeverity(selectedReadStatus)"
|
||||
(click)="menu.toggle($event)">
|
||||
{{ getStatusLabel(selectedReadStatus) }}
|
||||
</p-tag>
|
||||
<p-menu #menu [popup]="true" [model]="readStatusMenuItems"></p-menu>
|
||||
</p>
|
||||
</div>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">Publisher:</span> {{ book?.metadata!.publisher || '-' }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">Published:</span> {{ book?.metadata!.publishedDate || '-' }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">Language:</span> {{ book?.metadata!.language || '-' }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">ISBN 10:</span> {{ book?.metadata!.isbn10 || '-' }}</p>
|
||||
|
||||
<p class="whitespace-nowrap flex items-center gap-2">
|
||||
<span class="font-bold">File Type:</span>
|
||||
<span
|
||||
class="inline-block px-2 py-0.5 rounded-lg text-xs font-bold text-gray-200"
|
||||
[ngClass]="getFileTypeColorClass(getFileExtension(book?.filePath))">
|
||||
{{ getFileExtension(book?.filePath) || '-' }}
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<p class="whitespace-nowrap flex items-center gap-2">
|
||||
<span class="font-bold">Metadata Score:</span>
|
||||
@if (book?.metadataMatchScore != null) {
|
||||
<span
|
||||
class="inline-block px-2 py-0.5 rounded-full text-xs font-bold text-white border"
|
||||
class="inline-block px-2 py-0.5 rounded-lg text-xs font-bold text-gray-200 border"
|
||||
[ngClass]="getMatchScoreColorClass(book?.metadataMatchScore!)">
|
||||
{{ (book?.metadataMatchScore! * 100) | number:'1.0-0' }}%
|
||||
</span>
|
||||
@@ -189,8 +206,6 @@
|
||||
<span>-</span>
|
||||
}
|
||||
</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">Page Count:</span> {{ book?.metadata!.pageCount || '-' }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">File Size:</span> {{ getFileSizeInMB(book) }}</p>
|
||||
<p class="whitespace-nowrap flex items-center gap-2">
|
||||
<span class="font-bold">Progress:</span>
|
||||
<span
|
||||
@@ -199,6 +214,7 @@
|
||||
{{ getProgressPercent(book) !== null ? getProgressPercent(book) + '%' : 'N/A' }}
|
||||
</span>
|
||||
</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">File Size:</span> {{ getFileSizeInMB(book) }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">ISBN 13:</span> {{ book?.metadata!.isbn13 || '-' }}</p>
|
||||
</div>
|
||||
<div class="pt-2 flex items-center gap-2 w-full">
|
||||
@@ -286,6 +302,12 @@
|
||||
</p-splitbutton>
|
||||
}
|
||||
}
|
||||
@if (userData.permissions.canDeleteBook || userData.permissions.admin) {
|
||||
@if (otherItems$ | async; as otherItems) {
|
||||
<p-button icon="pi pi-ellipsis-v" outlined severity="info" (click)="entitymenu.toggle($event)"></p-button>
|
||||
<p-menu #entitymenu [model]="otherItems" [popup]="true" appendTo="body"></p-menu>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
+131
-15
@@ -3,15 +3,15 @@ import {Button, ButtonDirective} from 'primeng/button';
|
||||
import {AsyncPipe, DecimalPipe, NgClass} from '@angular/common';
|
||||
import {Observable} from 'rxjs';
|
||||
import {BookService} from '../../../service/book.service';
|
||||
import {Rating} from 'primeng/rating';
|
||||
import {Rating, RatingRateEvent} from 'primeng/rating';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Tag} from 'primeng/tag';
|
||||
import {Book, BookMetadata, BookRecommendation} from '../../../model/book.model';
|
||||
import {Book, BookMetadata, BookRecommendation, ReadStatus} from '../../../model/book.model';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
|
||||
import {UserService} from '../../../../settings/user-management/user.service';
|
||||
import {SplitButton} from 'primeng/splitbutton';
|
||||
import {MenuItem, MessageService} from 'primeng/api';
|
||||
import {ConfirmationService, MenuItem, MessageService} from 'primeng/api';
|
||||
import {BookSenderComponent} from '../../../components/book-sender/book-sender.component';
|
||||
import {DialogService} from 'primeng/dynamicdialog';
|
||||
import {EmailService} from '../../../../settings/email/email.service';
|
||||
@@ -26,15 +26,16 @@ import {ToggleButton} from 'primeng/togglebutton';
|
||||
import {MetadataFetchOptionsComponent} from '../../metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
|
||||
import {MetadataRefreshType} from '../../model/request/metadata-refresh-type.enum';
|
||||
import {MetadataRefreshRequest} from '../../model/request/metadata-refresh-request.model';
|
||||
import {RouterLink} from '@angular/router';
|
||||
import {Router, RouterLink} from '@angular/router';
|
||||
import {filter, map, take} from 'rxjs/operators';
|
||||
import {Menu} from 'primeng/menu';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-viewer',
|
||||
standalone: true,
|
||||
templateUrl: './metadata-viewer.component.html',
|
||||
styleUrl: './metadata-viewer.component.scss',
|
||||
imports: [Button, AsyncPipe, Rating, FormsModule, Tag, Divider, SplitButton, NgClass, Tooltip, DecimalPipe, InfiniteScrollDirective, BookCardComponent, ButtonDirective, Editor, ProgressBar, ToggleButton, RouterLink]
|
||||
imports: [Button, AsyncPipe, Rating, FormsModule, Tag, Divider, SplitButton, NgClass, Tooltip, DecimalPipe, InfiniteScrollDirective, BookCardComponent, ButtonDirective, Editor, ProgressBar, ToggleButton, RouterLink, Menu]
|
||||
})
|
||||
export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
|
||||
@@ -50,16 +51,32 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
protected urlHelper = inject(UrlHelperService);
|
||||
protected userService = inject(UserService);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
private confirmationService = inject(ConfirmationService);
|
||||
private router = inject(Router);
|
||||
|
||||
emailMenuItems$!: Observable<MenuItem[]>;
|
||||
readMenuItems$!: Observable<MenuItem[]>;
|
||||
refreshMenuItems$!: Observable<MenuItem[]>;
|
||||
otherItems$!: Observable<MenuItem[]>;
|
||||
bookInSeries: Book[] = [];
|
||||
|
||||
isExpanded = false;
|
||||
showFilePath = false;
|
||||
isAutoFetching = false;
|
||||
|
||||
readStatusOptions = [
|
||||
{label: 'Unread', value: ReadStatus.UNREAD},
|
||||
{label: 'Reading', value: ReadStatus.READING},
|
||||
{label: 'Re-reading', value: ReadStatus.RE_READING},
|
||||
{label: 'Partially Read', value: ReadStatus.PARTIALLY_READ},
|
||||
{label: 'Paused', value: ReadStatus.PAUSED},
|
||||
{label: 'Read', value: ReadStatus.READ},
|
||||
{label: 'Won’t Read', value: ReadStatus.WONT_READ},
|
||||
{label: 'Abandoned', value: ReadStatus.ABANDONED}
|
||||
];
|
||||
|
||||
selectedReadStatus: ReadStatus = ReadStatus.UNREAD;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.emailMenuItems$ = this.book$.pipe(
|
||||
map(book => book?.metadata ?? null),
|
||||
@@ -111,18 +128,48 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
])
|
||||
);
|
||||
|
||||
this.otherItems$ = this.book$.pipe(
|
||||
filter((book): book is Book => book !== null),
|
||||
map((book): MenuItem[] => [
|
||||
{
|
||||
label: 'Delete Book',
|
||||
icon: 'pi pi-trash',
|
||||
command: () => {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to delete "${book.metadata?.title}"?`,
|
||||
header: 'Confirm Deletion',
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptIcon: 'pi pi-trash',
|
||||
rejectIcon: 'pi pi-times',
|
||||
acceptButtonStyleClass: 'p-button-danger',
|
||||
accept: () => {
|
||||
this.bookService.deleteBooks(new Set([book.id])).subscribe({
|
||||
next: () => {
|
||||
this.router.navigate(['/dashboard']);
|
||||
},
|
||||
error: () => {
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
])
|
||||
);
|
||||
|
||||
this.book$
|
||||
.pipe(
|
||||
takeUntilDestroyed(this.destroyRef),
|
||||
map(book => book?.metadata),
|
||||
filter((metadata): metadata is BookMetadata => metadata != null)
|
||||
filter((book): book is Book => book != null && book.metadata != null)
|
||||
)
|
||||
.subscribe(metadata => {
|
||||
.subscribe(book => {
|
||||
const metadata = book.metadata;
|
||||
this.isAutoFetching = false;
|
||||
this.loadBooksInSeriesAndFilterRecommended(metadata.bookId);
|
||||
this.loadBooksInSeriesAndFilterRecommended(metadata!.bookId);
|
||||
if (this.quillEditor?.quill) {
|
||||
this.quillEditor.quill.root.innerHTML = metadata.description;
|
||||
this.quillEditor.quill.root.innerHTML = metadata!.description;
|
||||
}
|
||||
this.selectedReadStatus = book.readStatus ?? ReadStatus.UNREAD;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -244,16 +291,18 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
getStarColor(rating?: number | null): string {
|
||||
getStarColorScaled(rating?: number | null, maxScale: number = 5): string {
|
||||
if (rating == null) {
|
||||
return 'rgb(203, 213, 225)';
|
||||
} else if (rating >= 4.5) {
|
||||
}
|
||||
const normalized = rating / maxScale;
|
||||
if (normalized >= 0.9) {
|
||||
return 'rgb(34, 197, 94)';
|
||||
} else if (rating >= 4) {
|
||||
} else if (normalized >= 0.75) {
|
||||
return 'rgb(52, 211, 153)';
|
||||
} else if (rating >= 3.5) {
|
||||
} else if (normalized >= 0.6) {
|
||||
return 'rgb(234, 179, 8)';
|
||||
} else if (rating >= 2.5) {
|
||||
} else if (normalized >= 0.4) {
|
||||
return 'rgb(249, 115, 22)';
|
||||
} else {
|
||||
return 'rgb(239, 68, 68)';
|
||||
@@ -276,4 +325,71 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
if (progress == null) return 'bg-gray-600';
|
||||
return 'bg-blue-500';
|
||||
}
|
||||
|
||||
onPersonalRatingChange(book: Book, event: RatingRateEvent): void {
|
||||
const rating = event.value;
|
||||
if (!book || !book.metadata) return;
|
||||
const updatedMetadata = {
|
||||
...book.metadata,
|
||||
personalRating: rating
|
||||
};
|
||||
this.bookService.updateBookMetadata(book.id, updatedMetadata, false).subscribe({
|
||||
next: () => {
|
||||
},
|
||||
error: (err) => {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getStatusSeverity(status: string): 'success' | 'secondary' | 'info' | 'warn' | 'danger' | undefined {
|
||||
const normalized = status?.toUpperCase();
|
||||
if (['UNREAD', 'PAUSED'].includes(normalized)) return 'secondary';
|
||||
if (['READING', 'RE_READING'].includes(normalized)) return 'info';
|
||||
if (['READ'].includes(normalized)) return 'success';
|
||||
if (['PARTIALLY_READ'].includes(normalized)) return 'warn';
|
||||
if (['WONT_READ', 'ABANDONED'].includes(normalized)) return 'danger';
|
||||
return undefined;
|
||||
}
|
||||
|
||||
readStatusMenuItems = this.readStatusOptions.map(option => ({
|
||||
label: option.label,
|
||||
command: () => this.updateReadStatus(option.value)
|
||||
}));
|
||||
|
||||
getStatusLabel(value: string): string {
|
||||
return this.readStatusOptions.find(o => o.value === value)?.label ?? 'Unknown';
|
||||
}
|
||||
|
||||
updateReadStatus(status: ReadStatus): void {
|
||||
if (!status) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.book$.pipe(take(1)).subscribe(book => {
|
||||
if (!book || !book.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.bookService.updateBookReadStatus(book.id, status).subscribe({
|
||||
next: () => {
|
||||
this.selectedReadStatus = status;
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Read Status Updated',
|
||||
detail: `Marked as "${this.getStatusLabel(status)}"`,
|
||||
life: 2000
|
||||
});
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('Failed to update read status:', err);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Update Failed',
|
||||
detail: 'Could not update read status.',
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ export interface Book {
|
||||
fileSizeKb?: number;
|
||||
seriesCount?: number | null;
|
||||
metadataMatchScore?: number | null;
|
||||
readStatus?: ReadStatus;
|
||||
}
|
||||
|
||||
export interface EpubProgress {
|
||||
@@ -61,6 +62,7 @@ export interface BookMetadata {
|
||||
goodreadsReviewCount?: number | null;
|
||||
hardcoverRating?: number | null;
|
||||
hardcoverReviewCount?: number | null;
|
||||
personalRating?: number | null;
|
||||
coverUpdatedOn?: string;
|
||||
authors: string[];
|
||||
categories: string[];
|
||||
@@ -159,3 +161,19 @@ export interface BulkMetadataUpdateRequest {
|
||||
publishedDate?: string;
|
||||
genres?: string[];
|
||||
}
|
||||
|
||||
export interface BookDeletionResponse {
|
||||
deleted: number[];
|
||||
failedFileDeletions: number[];
|
||||
}
|
||||
|
||||
export enum ReadStatus {
|
||||
UNREAD = 'UNREAD',
|
||||
READING = 'READING',
|
||||
RE_READING = 'RE_READING',
|
||||
READ = 'READ',
|
||||
PARTIALLY_READ = 'PARTIALLY_READ',
|
||||
PAUSED = 'PAUSED',
|
||||
WONT_READ = 'WONT_READ',
|
||||
ABANDONED = 'ABANDONED'
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {BehaviorSubject, first, Observable, of} from 'rxjs';
|
||||
import {BehaviorSubject, first, Observable, of, throwError} from 'rxjs';
|
||||
import {HttpClient, HttpParams} from '@angular/common/http';
|
||||
import {catchError, filter, map, tap} from 'rxjs/operators';
|
||||
import {Book, BookMetadata, BookRecommendation, BookSetting, BulkMetadataUpdateRequest} from '../model/book.model';
|
||||
import {Book, BookDeletionResponse, BookMetadata, BookRecommendation, BookSetting, BulkMetadataUpdateRequest, ReadStatus} from '../model/book.model';
|
||||
import {BookState} from '../model/state/book-state.model';
|
||||
import {API_CONFIG} from '../../config/api-config';
|
||||
import {FetchMetadataRequest} from '../metadata/model/request/fetch-metadata-request.model';
|
||||
@@ -176,13 +176,46 @@ export class BookService {
|
||||
});
|
||||
}
|
||||
|
||||
getBooksByIdsFromAPI(bookIds: number[], withDescription: boolean) {
|
||||
return this.http.get<Book[]>(`${this.url}/batch`, {
|
||||
params: {
|
||||
ids: bookIds.map(id => id.toString()),
|
||||
withDescription: withDescription.toString()
|
||||
}
|
||||
});
|
||||
deleteBooks(ids: Set<number>): Observable<BookDeletionResponse> {
|
||||
const idList = Array.from(ids);
|
||||
const params = new HttpParams().set('ids', idList.join(','));
|
||||
|
||||
return this.http.delete<BookDeletionResponse>(this.url, {params}).pipe(
|
||||
tap(response => {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const remainingBooks = (currentState.books || []).filter(
|
||||
book => !ids.has(book.id)
|
||||
);
|
||||
|
||||
this.bookStateSubject.next({
|
||||
books: remainingBooks,
|
||||
loaded: true,
|
||||
error: null,
|
||||
});
|
||||
|
||||
if (response.failedFileDeletions?.length > 0) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Some files could not be deleted',
|
||||
detail: `Books: ${response.failedFileDeletions.join(', ')}`,
|
||||
});
|
||||
} else {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Books Deleted',
|
||||
detail: `${idList.length} book(s) deleted successfully.`,
|
||||
});
|
||||
}
|
||||
}),
|
||||
catchError(error => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Delete Failed',
|
||||
detail: error?.error?.message || error?.message || 'An error occurred while deleting books.',
|
||||
});
|
||||
return throwError(() => error);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
downloadFile(bookId: number): void {
|
||||
@@ -454,4 +487,8 @@ export class BookService {
|
||||
getBackupMetadata(bookId: number) {
|
||||
return this.http.get<any>(`${this.url}/${bookId}/metadata/restore`);
|
||||
}
|
||||
|
||||
updateBookReadStatus(id: number, status: ReadStatus): Observable<void> {
|
||||
return this.http.put<void>(`${this.url}/${id}/read-status`, {status});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,5 +106,6 @@ export enum AppSettingKey {
|
||||
MAX_FILE_UPLOAD_SIZE_IN_MB = 'MAX_FILE_UPLOAD_SIZE_IN_MB',
|
||||
METADATA_PROVIDER_SETTINGS = 'METADATA_PROVIDER_SETTINGS',
|
||||
METADATA_MATCH_WEIGHTS = 'METADATA_MATCH_WEIGHTS',
|
||||
METADATA_PERSISTENCE_SETTINGS = 'METADATA_PERSISTENCE_SETTINGS'
|
||||
METADATA_PERSISTENCE_SETTINGS = 'METADATA_PERSISTENCE_SETTINGS',
|
||||
BOOK_DELETION_ENABLED = 'BOOK_DELETION_ENABLED'
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<th style="width: 80px;">Edit Metadata</th>
|
||||
<th style="width: 80px;">Manage Library</th>
|
||||
<th style="width: 80px;">Email Books</th>
|
||||
<th style="width: 80px;">Delete Books</th>
|
||||
<th style="width: 120px;">Edit</th>
|
||||
<th style="width: 80px;">Change Password</th>
|
||||
<th style="width: 80px;">Delete</th>
|
||||
@@ -114,6 +115,14 @@
|
||||
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canEmailBook" disabled></p-checkbox>
|
||||
}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
@if (user.isEditing) {
|
||||
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canDeleteBook"></p-checkbox>
|
||||
}
|
||||
@if (!user.isEditing) {
|
||||
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canDeleteBook" disabled></p-checkbox>
|
||||
}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<ng-container>
|
||||
@if (!user.isEditing) {
|
||||
|
||||
@@ -90,6 +90,7 @@ export interface User {
|
||||
canUpload: boolean;
|
||||
canDownload: boolean;
|
||||
canEmailBook: boolean;
|
||||
canDeleteBook: boolean;
|
||||
canEditMetadata: boolean;
|
||||
canManipulateLibrary: boolean;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user