Add Metadata Manager for organizing and standardizing metadata (#1312)
This commit is contained in:
@@ -19,6 +19,7 @@ import {BookdropFileReviewComponent} from './bookdrop/bookdrop-file-review-compo
|
||||
import {MainDashboardComponent} from './dashboard/components/main-dashboard/main-dashboard.component';
|
||||
import {SeriesPageComponent} from './book/components/series-page/series-page.component';
|
||||
import {StatsComponent} from './stats-component/stats-component';
|
||||
import {MetadataManagerComponent} from './book/components/metadata-manager/metadata-manager.component';
|
||||
|
||||
export const routes: Routes = [
|
||||
{
|
||||
@@ -44,9 +45,10 @@ export const routes: Routes = [
|
||||
{path: 'shelf/:shelfId/books', component: BookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'unshelved-books', component: BookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'series/:seriesName', component: SeriesPageComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'magic-shelf/:magicShelfId/books', component: BookBrowserComponent, canActivate: [AuthGuard] },
|
||||
{path: 'magic-shelf/:magicShelfId/books', component: BookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'book/:bookId', component: BookMetadataCenterComponent, canActivate: [AuthGuard]},
|
||||
{path: 'bookdrop', component: BookdropFileReviewComponent, canActivate: [AuthGuard]},
|
||||
{path: 'metadata-manager', component: MetadataManagerComponent, canActivate: [AuthGuard]},
|
||||
{path: 'stats', component: StatsComponent, canActivate: [AuthGuard]},
|
||||
]
|
||||
},
|
||||
|
||||
@@ -0,0 +1,364 @@
|
||||
<div class="main-container enclosing-container">
|
||||
<div class="settings-header">
|
||||
<h2 class="settings-title">
|
||||
<i class="pi pi-sitemap"></i>
|
||||
Metadata Manager
|
||||
<app-external-doc-link docType="metadataManager"></app-external-doc-link>
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
Organize, merge, split, rename, and standardize authors, genres, moods, and tags across your library.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="settings-content">
|
||||
<p-tabs [(value)]="activeTab">
|
||||
<p-tablist>
|
||||
@for (tab of tabConfigs; track tab.type) {
|
||||
<p-tab [value]="tab.type">
|
||||
<i class="pi {{ tab.icon }}"></i> {{ tab.label }}s ({{ getMetadataItems(tab.type).length }})
|
||||
</p-tab>
|
||||
}
|
||||
</p-tablist>
|
||||
<p-tabpanels>
|
||||
@for (tab of tabConfigs; track tab.type) {
|
||||
<p-tabpanel [value]="tab.type">
|
||||
<div class="section-header">
|
||||
<p-iconfield class="search-input">
|
||||
<p-inputicon class="pi pi-search"/>
|
||||
<input
|
||||
pInputText
|
||||
type="text"
|
||||
#tableFilter
|
||||
(input)="filterGlobal($event, dataTable)"
|
||||
[placeholder]="tab.placeholder"/>
|
||||
</p-iconfield>
|
||||
<div class="actions">
|
||||
<p-button
|
||||
label="Clear Selection"
|
||||
icon="pi pi-times"
|
||||
[disabled]="getSelectedItems(tab.type).length === 0"
|
||||
(onClick)="clearSelection(tab.type)"
|
||||
severity="secondary"
|
||||
size="small"
|
||||
outlined></p-button>
|
||||
<p-button
|
||||
label="Delete Selected"
|
||||
icon="pi pi-trash"
|
||||
[disabled]="getSelectedItems(tab.type).length === 0"
|
||||
(onClick)="openDeleteDialog(tab.type)"
|
||||
severity="danger"
|
||||
size="small"
|
||||
outlined></p-button>
|
||||
<p-button
|
||||
label="Merge/Split Selected"
|
||||
icon="pi pi-sitemap"
|
||||
[disabled]="getSelectedItems(tab.type).length < 2"
|
||||
(onClick)="openMergeDialog(tab.type)"
|
||||
severity="success"
|
||||
size="small"
|
||||
outlined></p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-card">
|
||||
<p-table
|
||||
#dataTable
|
||||
[value]="getMetadataItems(tab.type)"
|
||||
[loading]="loading"
|
||||
[globalFilterFields]="['value']"
|
||||
[paginator]="true"
|
||||
[rows]="50"
|
||||
[rowsPerPageOptions]="[25, 50, 100]"
|
||||
[scrollable]="true"
|
||||
scrollHeight="flex">
|
||||
<ng-template pTemplate="header">
|
||||
<tr>
|
||||
<th style="width: 3rem">
|
||||
<div class="header-content">
|
||||
<p-checkbox
|
||||
[binary]="true"
|
||||
[ngModel]="getSelectAll(tab.selectAllKey)"
|
||||
(ngModelChange)="setSelectAll(tab.selectAllKey, $event); toggleAll(tab.type, $event, dataTable.filteredValue || dataTable.value)"></p-checkbox>
|
||||
</div>
|
||||
</th>
|
||||
<th pSortableColumn="value">
|
||||
<div class="header-content">
|
||||
<i class="pi {{ tab.icon }}"></i>
|
||||
<span>{{ tab.label }}</span>
|
||||
<p-sortIcon field="value"></p-sortIcon>
|
||||
</div>
|
||||
</th>
|
||||
<th pSortableColumn="count">
|
||||
<div class="header-content">
|
||||
<i class="pi pi-book"></i>
|
||||
<span>Books</span>
|
||||
<p-sortIcon field="count"></p-sortIcon>
|
||||
</div>
|
||||
</th>
|
||||
<th class="actions-header">
|
||||
<div class="header-content">
|
||||
<i class="pi pi-cog"></i>
|
||||
<span>Actions</span>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
</ng-template>
|
||||
<ng-template pTemplate="body" let-item>
|
||||
<tr>
|
||||
<td>
|
||||
<p-checkbox
|
||||
[(ngModel)]="item.selected"
|
||||
[binary]="true"
|
||||
(ngModelChange)="onRowSelect(tab.type)"></p-checkbox>
|
||||
</td>
|
||||
<td>
|
||||
<span class="clickable-cell" (click)="onMetadataClick(tab.type, item.value)">
|
||||
{{ item.value }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ item.count }}</td>
|
||||
<td class="actions-cell">
|
||||
<p-button
|
||||
icon="pi pi-filter"
|
||||
severity="info"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
pTooltip="Select similar"
|
||||
(onClick)="selectSimilar(tab.type, item.value)"></p-button>
|
||||
<p-button
|
||||
icon="pi pi-pencil"
|
||||
severity="secondary"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
pTooltip="Rename/Split"
|
||||
(onClick)="openRenameDialog(tab.type, item)"></p-button>
|
||||
<p-button
|
||||
icon="pi pi-trash"
|
||||
severity="danger"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
pTooltip="Delete"
|
||||
(onClick)="openDeleteDialog(tab.type, item)"></p-button>
|
||||
</td>
|
||||
</tr>
|
||||
</ng-template>
|
||||
</p-table>
|
||||
</div>
|
||||
</p-tabpanel>
|
||||
}
|
||||
</p-tabpanels>
|
||||
</p-tabs>
|
||||
</div>
|
||||
|
||||
<p-dialog
|
||||
header="Merge/Split {{ currentMergeType | titlecase }}"
|
||||
[(visible)]="showMergeDialog"
|
||||
[modal]="true"
|
||||
styleClass="user-dialog"
|
||||
[style]="{width: '50rem'}">
|
||||
<div class="dialog-form">
|
||||
<p>You are merging/splitting {{ getSelectedItems(currentMergeType).length }} {{ currentMergeType }}:</p>
|
||||
<ul class="selected-items">
|
||||
@for (item of getSelectedItems(currentMergeType); track item.value) {
|
||||
<li>
|
||||
• {{ item.value }} <span class="count">({{ item.count }} books)</span>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
<div class="form-field">
|
||||
<label for="mergeTarget">Target Value{{ isSingleValueField(currentMergeType) ? '' : '(s)' }}:</label>
|
||||
<input
|
||||
id="mergeTarget"
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="mergeTarget"
|
||||
class="w-full"
|
||||
[placeholder]="isSingleValueField(currentMergeType) ? 'e.g., English' : 'e.g., Fiction, Mystery, Thriller'"/>
|
||||
@if (isSingleValueField(currentMergeType)) {
|
||||
<small class="help-text">
|
||||
<strong>How it works:</strong><br/>
|
||||
• Enter the standardized value you want all selected items to merge into<br/>
|
||||
• All books with any of the selected {{ currentMergeType }} will be updated to use this single value<br/>
|
||||
<br/>
|
||||
<strong>Example:</strong> When merging "En", "English", "en-US"<br/>
|
||||
• Enter "English" → All books will have their {{ currentMergeType.slice(0, -1) }} merged to "English"<br/>
|
||||
<br/>
|
||||
<strong>Note:</strong> Each book can only have one {{ currentMergeType.slice(0, -1) }}, so only enter one target value.
|
||||
</small>
|
||||
} @else {
|
||||
<small class="help-text">
|
||||
<strong>How it works:</strong><br/>
|
||||
• Enter a single value to merge all selected {{ currentMergeType }} into one<br/>
|
||||
• Enter multiple values separated by commas to split into multiple {{ currentMergeType }}<br/>
|
||||
<br/>
|
||||
<strong>Example:</strong> When merging/splitting "Sci-Fi", "SciFi", "Science Fiction"<br/>
|
||||
• Merge: Enter "Science Fiction" → All books get one standardized tag<br/>
|
||||
• Split: Enter "Science Fiction, Sci-Fi" → All books get both the formal name and common abbreviation
|
||||
</small>
|
||||
}
|
||||
</div>
|
||||
@if (mergingInProgress) {
|
||||
<div class="processing-note">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
<span>This process may take longer if "Write to file" is enabled in the settings.</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<ng-template pTemplate="footer">
|
||||
<div class="dialog-actions">
|
||||
<p-button
|
||||
label="Cancel"
|
||||
icon="pi pi-times"
|
||||
(onClick)="showMergeDialog = false"
|
||||
[disabled]="mergingInProgress"
|
||||
severity="secondary"
|
||||
outlined></p-button>
|
||||
<p-button
|
||||
[label]="mergingInProgress ? 'Processing...' : 'Confirm'"
|
||||
[icon]="mergingInProgress ? 'pi pi-spin pi-spinner' : 'pi pi-check'"
|
||||
[loading]="mergingInProgress"
|
||||
[disabled]="mergingInProgress"
|
||||
(onClick)="confirmMerge()"
|
||||
severity="success"></p-button>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-dialog>
|
||||
|
||||
<p-dialog
|
||||
header="Rename/Split {{ currentMergeType | titlecase }}"
|
||||
[(visible)]="showRenameDialog"
|
||||
[modal]="true"
|
||||
styleClass="user-dialog"
|
||||
[style]="{width: '40rem'}">
|
||||
<div class="dialog-form">
|
||||
<p>You are renaming/splitting:</p>
|
||||
<div class="current-value">
|
||||
<strong>{{ currentRenameItem?.value }}</strong>
|
||||
<span class="count">({{ currentRenameItem?.count }} books)</span>
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label for="renameTarget">New Name(s):</label>
|
||||
<input
|
||||
id="renameTarget"
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="renameTarget"
|
||||
class="w-full"
|
||||
[placeholder]="isSingleValueField(currentMergeType) ? 'e.g., Mystery' : 'e.g., Mystery, Detective'"
|
||||
(keyup.enter)="confirmRename()"/>
|
||||
@if (isSingleValueField(currentMergeType)) {
|
||||
<small class="help-text">
|
||||
<strong>How it works:</strong><br/>
|
||||
• Enter a new value to rename this {{ currentMergeType.slice(0, -1) }}<br/>
|
||||
<br/>
|
||||
<strong>Note:</strong> Each book can only have one {{ currentMergeType.slice(0, -1) }}, so splitting into multiple values is not allowed.
|
||||
</small>
|
||||
} @else {
|
||||
<small class="help-text">
|
||||
<strong>How it works:</strong><br/>
|
||||
• Enter a single value to rename the {{ currentMergeType.slice(0, -1) }}<br/>
|
||||
• Enter multiple values separated by commas to split into multiple {{ currentMergeType }}<br/>
|
||||
<br/>
|
||||
<strong>Example:</strong> When renaming/splitting "Mystery & Detective"<br/>
|
||||
• Rename: Enter "Mystery" → Renames to just "Mystery"<br/>
|
||||
• Split: Enter "Mystery, Detective" → Splits into two separate {{ currentMergeType }}
|
||||
</small>
|
||||
}
|
||||
</div>
|
||||
@if (mergingInProgress) {
|
||||
<div class="processing-note">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
<span>This process may take some time if "Write to file" is enabled in settings.</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<ng-template pTemplate="footer">
|
||||
<div class="dialog-actions">
|
||||
<p-button
|
||||
label="Cancel"
|
||||
icon="pi pi-times"
|
||||
(onClick)="showRenameDialog = false"
|
||||
[disabled]="mergingInProgress"
|
||||
severity="secondary"
|
||||
outlined></p-button>
|
||||
<p-button
|
||||
[label]="mergingInProgress ? 'Processing...' : 'Confirm'"
|
||||
[icon]="mergingInProgress ? 'pi pi-spin pi-spinner' : 'pi pi-check'"
|
||||
[loading]="mergingInProgress"
|
||||
[disabled]="mergingInProgress"
|
||||
(onClick)="confirmRename()"
|
||||
severity="success"></p-button>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-dialog>
|
||||
|
||||
<p-dialog
|
||||
header="Delete {{ currentMergeType | titlecase }}"
|
||||
[(visible)]="showDeleteDialog"
|
||||
[modal]="true"
|
||||
styleClass="user-dialog"
|
||||
[style]="{width: '40rem'}">
|
||||
<div class="dialog-form">
|
||||
<div class="warning-message">
|
||||
<i class="pi pi-exclamation-triangle"></i>
|
||||
<p>You are about to delete {{ currentDeleteItem ? '1' : getSelectedItems(currentMergeType).length }} {{ currentMergeType }}:</p>
|
||||
</div>
|
||||
|
||||
@if (currentDeleteItem) {
|
||||
<div class="current-value">
|
||||
<strong>{{ currentDeleteItem.value }}</strong>
|
||||
<span class="count">({{ currentDeleteItem.count }} books)</span>
|
||||
</div>
|
||||
} @else {
|
||||
<ul class="selected-items">
|
||||
@for (item of getSelectedItems(currentMergeType); track item.value) {
|
||||
<li>
|
||||
• {{ item.value }} <span class="count">({{ item.count }} books)</span>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
||||
<div class="delete-info">
|
||||
<p><strong>What will happen:</strong></p>
|
||||
<ul>
|
||||
<li>The {{ currentMergeType.slice(0, -1) }} will be removed from all affected books</li>
|
||||
<li>This action cannot be undone</li>
|
||||
<li>Total books affected: <strong>{{ currentDeleteItem ? currentDeleteItem.count : getTotalAffectedBooks(getSelectedItems(currentMergeType)) }}</strong></li>
|
||||
</ul>
|
||||
</div>
|
||||
@if (deletingInProgress) {
|
||||
<div class="processing-note">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
<span>This process may take some time if "Write to file" is enabled in settings.</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<ng-template pTemplate="footer">
|
||||
<div class="dialog-actions">
|
||||
<p-button
|
||||
label="Cancel"
|
||||
icon="pi pi-times"
|
||||
(onClick)="showDeleteDialog = false"
|
||||
[disabled]="deletingInProgress"
|
||||
severity="secondary"
|
||||
outlined></p-button>
|
||||
<p-button
|
||||
[label]="deletingInProgress ? 'Deleting...' : 'Delete'"
|
||||
[icon]="deletingInProgress ? 'pi pi-spin pi-spinner' : 'pi pi-trash'"
|
||||
[loading]="deletingInProgress"
|
||||
[disabled]="deletingInProgress"
|
||||
(onClick)="confirmDelete()"
|
||||
severity="danger"></p-button>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-dialog>
|
||||
</div>
|
||||
@@ -0,0 +1,449 @@
|
||||
.metadata-manager {
|
||||
padding: 1.5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
|
||||
h2 {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.description {
|
||||
color: var(--text-color-secondary);
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.table-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1rem;
|
||||
gap: 1rem;
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.table-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
::ng-deep {
|
||||
.p-tabs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.p-tabpanels {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.p-tabpanel {
|
||||
display: none;
|
||||
|
||||
&.p-tabpanel-active {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.p-datatable-tbody > tr > td {
|
||||
padding-top: 0.5rem;
|
||||
padding-bottom: 0.5rem;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.p-datatable-table {
|
||||
align-self: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.p-datatable-thead > tr > th .header-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.merge-dialog-content {
|
||||
.selected-items {
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
margin: 1rem 0;
|
||||
padding-left: 1.5rem;
|
||||
|
||||
li {
|
||||
margin-bottom: 0.5rem;
|
||||
|
||||
.count {
|
||||
color: var(--text-color-secondary);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.field {
|
||||
margin-top: 1.5rem;
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 0.5rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
small {
|
||||
display: block;
|
||||
margin-top: 0.5rem;
|
||||
color: var(--text-color-secondary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.main-container {
|
||||
width: 100%;
|
||||
padding: 1rem;
|
||||
height: calc(100dvh - 10.5rem);
|
||||
border-width: 1px;
|
||||
border-radius: 0.5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
height: calc(100dvh - 6.125rem);
|
||||
}
|
||||
}
|
||||
|
||||
.enclosing-container {
|
||||
border-color: var(--p-content-border-color);
|
||||
background: var(--p-content-background);
|
||||
}
|
||||
|
||||
.settings-header {
|
||||
margin-top: 1rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.settings-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: var(--p-text-color);
|
||||
margin: 0 0 0.75rem 0;
|
||||
|
||||
.pi {
|
||||
color: var(--p-primary-color);
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-description {
|
||||
opacity: 0.7;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.5;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.settings-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
padding: 0.5rem 1rem 0 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
flex-shrink: 0;
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.section-title-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: 1rem;
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.table-card {
|
||||
border: 1px solid rgba(128, 128, 128, 0.2);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: var(--surface-ground);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
|
||||
.p-datatable {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
|
||||
.p-datatable-wrapper {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.p-paginator {
|
||||
border-top: 1px solid var(--p-datatable-body-cell-border-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.actions-header {
|
||||
min-width: 120px;
|
||||
|
||||
.header-content {
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
.actions-cell {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
p-button {
|
||||
display: inline-flex;
|
||||
}
|
||||
}
|
||||
|
||||
.clickable-cell {
|
||||
cursor: pointer;
|
||||
transition: color 0.2s;
|
||||
|
||||
&:hover {
|
||||
color: var(--p-primary-color);
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
::ng-deep {
|
||||
.p-tabs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.p-tabpanels {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.p-tabpanel {
|
||||
display: none;
|
||||
|
||||
&.p-tabpanel-active {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.p-datatable-tbody > tr > td {
|
||||
padding-top: 0.5rem;
|
||||
padding-bottom: 0.5rem;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.p-datatable-table {
|
||||
align-self: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.p-datatable-thead > tr > th .header-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.user-dialog {
|
||||
.p-dialog-content {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.p-dialog-footer {
|
||||
padding: 1rem 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
|
||||
.warning-message {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 1rem;
|
||||
background: rgba(251, 146, 60, 0.15);
|
||||
border: 1px solid var(--p-orange-500);
|
||||
border-radius: 8px;
|
||||
color: var(--p-text-color);
|
||||
|
||||
.pi-exclamation-triangle {
|
||||
font-size: 1.5rem;
|
||||
color: var(--p-orange-500);
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.delete-info {
|
||||
padding: 1rem;
|
||||
background: var(--surface-ground);
|
||||
border-radius: 8px;
|
||||
border: 1px solid rgba(128, 128, 128, 0.2);
|
||||
|
||||
p {
|
||||
margin: 0 0 0.5rem 0;
|
||||
font-weight: 600;
|
||||
color: var(--p-text-color);
|
||||
}
|
||||
|
||||
ul {
|
||||
margin: 0;
|
||||
padding-left: 1.5rem;
|
||||
list-style-type: disc;
|
||||
|
||||
li {
|
||||
margin-bottom: 0.25rem;
|
||||
color: var(--p-text-color);
|
||||
|
||||
strong {
|
||||
color: var(--p-primary-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.selected-items {
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
margin: 0;
|
||||
padding-left: 1.5rem;
|
||||
|
||||
li {
|
||||
margin-bottom: 0.5rem;
|
||||
color: var(--p-text-color);
|
||||
|
||||
.count {
|
||||
opacity: 0.7;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.current-value {
|
||||
padding: 1rem;
|
||||
background: var(--surface-ground);
|
||||
border: 1px solid rgba(128, 128, 128, 0.2);
|
||||
border-radius: 8px;
|
||||
margin-bottom: 1.5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
|
||||
strong {
|
||||
font-size: 1.1rem;
|
||||
color: var(--p-primary-color);
|
||||
}
|
||||
|
||||
.count {
|
||||
opacity: 0.7;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
}
|
||||
|
||||
.form-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
label {
|
||||
font-weight: 600;
|
||||
color: var(--p-text-color);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
small {
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.processing-note {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem;
|
||||
margin-top: 1rem;
|
||||
border-left: 3px solid #f59e0b;
|
||||
border-top: 1px solid #f59e0b;
|
||||
border-bottom: 1px solid #f59e0b;
|
||||
border-right: 1px solid #f59e0b;
|
||||
border-radius: 4px;
|
||||
font-size: 0.875rem;
|
||||
|
||||
i {
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,590 @@
|
||||
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||
import {TableModule} from 'primeng/table';
|
||||
import {ButtonModule} from 'primeng/button';
|
||||
import {CheckboxModule} from 'primeng/checkbox';
|
||||
import {InputTextModule} from 'primeng/inputtext';
|
||||
import {DialogModule} from 'primeng/dialog';
|
||||
import {ConfirmDialogModule} from 'primeng/confirmdialog';
|
||||
import {ConfirmationService, MessageService} from 'primeng/api';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {Book} from '../../model/book.model';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {IconField} from 'primeng/iconfield';
|
||||
import {InputIcon} from 'primeng/inputicon';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
||||
|
||||
interface MetadataItem {
|
||||
value: string;
|
||||
count: number;
|
||||
bookIds: number[];
|
||||
selected: boolean;
|
||||
}
|
||||
|
||||
type MetadataType = 'authors' | 'categories' | 'moods' | 'tags' | 'series' | 'publishers' | 'languages';
|
||||
|
||||
interface TabConfig {
|
||||
type: MetadataType;
|
||||
label: string;
|
||||
placeholder: string;
|
||||
selectAllKey: 'selectAllAuthors' | 'selectAllCategories' | 'selectAllMoods' | 'selectAllTags' | 'selectAllSeries' | 'selectAllPublishers' | 'selectAllLanguages';
|
||||
icon: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-manager',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
Tabs,
|
||||
TableModule,
|
||||
ButtonModule,
|
||||
CheckboxModule,
|
||||
InputTextModule,
|
||||
DialogModule,
|
||||
ConfirmDialogModule,
|
||||
TabList,
|
||||
Tab,
|
||||
TabPanels,
|
||||
TabPanel,
|
||||
Tooltip,
|
||||
IconField,
|
||||
InputIcon,
|
||||
ExternalDocLinkComponent
|
||||
],
|
||||
providers: [ConfirmationService],
|
||||
templateUrl: './metadata-manager.component.html',
|
||||
styleUrls: ['./metadata-manager.component.scss']
|
||||
})
|
||||
export class MetadataManagerComponent implements OnInit, OnDestroy {
|
||||
private bookService = inject(BookService);
|
||||
private messageService = inject(MessageService);
|
||||
private confirmationService = inject(ConfirmationService);
|
||||
private router = inject(Router);
|
||||
private route = inject(ActivatedRoute);
|
||||
|
||||
private routeSub!: Subscription;
|
||||
|
||||
authors: MetadataItem[] = [];
|
||||
categories: MetadataItem[] = [];
|
||||
moods: MetadataItem[] = [];
|
||||
tags: MetadataItem[] = [];
|
||||
series: MetadataItem[] = [];
|
||||
publishers: MetadataItem[] = [];
|
||||
languages: MetadataItem[] = [];
|
||||
|
||||
selectAllAuthors = false;
|
||||
selectAllCategories = false;
|
||||
selectAllMoods = false;
|
||||
selectAllTags = false;
|
||||
selectAllSeries = false;
|
||||
selectAllPublishers = false;
|
||||
selectAllLanguages = false;
|
||||
|
||||
loading = false;
|
||||
mergingInProgress = false;
|
||||
deletingInProgress = false;
|
||||
showMergeDialog = false;
|
||||
showRenameDialog = false;
|
||||
showDeleteDialog = false;
|
||||
mergeTarget = '';
|
||||
renameTarget = '';
|
||||
currentMergeType: MetadataType = 'authors';
|
||||
currentRenameItem: MetadataItem | null = null;
|
||||
currentDeleteItem: MetadataItem | null = null;
|
||||
|
||||
private validTabs: MetadataType[] = ['authors', 'categories', 'moods', 'tags', 'series', 'publishers', 'languages'];
|
||||
private _activeTab: MetadataType = 'authors';
|
||||
|
||||
get activeTab(): MetadataType {
|
||||
return this._activeTab;
|
||||
}
|
||||
|
||||
set activeTab(value: MetadataType) {
|
||||
this._activeTab = value;
|
||||
this.router.navigate([], {
|
||||
relativeTo: this.route,
|
||||
queryParams: {tab: value},
|
||||
queryParamsHandling: 'merge'
|
||||
});
|
||||
}
|
||||
|
||||
tabConfigs: TabConfig[] = [
|
||||
{type: 'authors', label: 'Author', placeholder: 'Search authors...', selectAllKey: 'selectAllAuthors', icon: 'pi-user'},
|
||||
{type: 'categories', label: 'Genre', placeholder: 'Search genres...', selectAllKey: 'selectAllCategories', icon: 'pi-tag'},
|
||||
{type: 'moods', label: 'Mood', placeholder: 'Search moods...', selectAllKey: 'selectAllMoods', icon: 'pi-heart'},
|
||||
{type: 'tags', label: 'Tag', placeholder: 'Search tags...', selectAllKey: 'selectAllTags', icon: 'pi-tags'},
|
||||
{type: 'series', label: 'Series', placeholder: 'Search series...', selectAllKey: 'selectAllSeries', icon: 'pi-book'},
|
||||
{type: 'publishers', label: 'Publisher', placeholder: 'Search publishers...', selectAllKey: 'selectAllPublishers', icon: 'pi-building'},
|
||||
{type: 'languages', label: 'Language', placeholder: 'Search languages...', selectAllKey: 'selectAllLanguages', icon: 'pi-globe'}
|
||||
];
|
||||
|
||||
ngOnInit() {
|
||||
this.loadMetadata();
|
||||
this.routeSub = this.route.queryParams.subscribe(params => {
|
||||
const tabParam = params['tab'] as MetadataType;
|
||||
if (this.validTabs.includes(tabParam)) {
|
||||
this._activeTab = tabParam;
|
||||
} else {
|
||||
this._activeTab = 'authors';
|
||||
this.router.navigate([], {
|
||||
relativeTo: this.route,
|
||||
queryParams: {tab: this._activeTab},
|
||||
queryParamsHandling: 'merge',
|
||||
replaceUrl: true
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.routeSub.unsubscribe();
|
||||
}
|
||||
|
||||
loadMetadata() {
|
||||
this.loading = true;
|
||||
this.bookService.bookState$.subscribe(state => {
|
||||
if (state.loaded && state.books) {
|
||||
this.extractMetadata(state.books);
|
||||
this.loading = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private extractMetadata(books: Book[]) {
|
||||
const authorsMap = new Map<string, Set<number>>();
|
||||
const categoriesMap = new Map<string, Set<number>>();
|
||||
const moodsMap = new Map<string, Set<number>>();
|
||||
const tagsMap = new Map<string, Set<number>>();
|
||||
const seriesMap = new Map<string, Set<number>>();
|
||||
const publishersMap = new Map<string, Set<number>>();
|
||||
const languagesMap = new Map<string, Set<number>>();
|
||||
|
||||
books.forEach(book => {
|
||||
if (book.metadata) {
|
||||
this.addToMap(authorsMap, book.metadata.authors, book.id);
|
||||
this.addToMap(categoriesMap, book.metadata.categories, book.id);
|
||||
this.addToMap(moodsMap, book.metadata.moods, book.id);
|
||||
this.addToMap(tagsMap, book.metadata.tags, book.id);
|
||||
if (book.metadata.seriesName) {
|
||||
this.addToMap(seriesMap, [book.metadata.seriesName], book.id);
|
||||
}
|
||||
if (book.metadata.publisher) {
|
||||
this.addToMap(publishersMap, [book.metadata.publisher], book.id);
|
||||
}
|
||||
if (book.metadata.language) {
|
||||
this.addToMap(languagesMap, [book.metadata.language], book.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.authors = this.mapToItems(authorsMap);
|
||||
this.categories = this.mapToItems(categoriesMap);
|
||||
this.moods = this.mapToItems(moodsMap);
|
||||
this.tags = this.mapToItems(tagsMap);
|
||||
this.series = this.mapToItems(seriesMap);
|
||||
this.publishers = this.mapToItems(publishersMap);
|
||||
this.languages = this.mapToItems(languagesMap);
|
||||
}
|
||||
|
||||
private addToMap(map: Map<string, Set<number>>, values: string[] | undefined, bookId: number) {
|
||||
if (!values) return;
|
||||
values.forEach(value => {
|
||||
if (!map.has(value)) {
|
||||
map.set(value, new Set());
|
||||
}
|
||||
map.get(value)!.add(bookId);
|
||||
});
|
||||
}
|
||||
|
||||
private mapToItems(map: Map<string, Set<number>>): MetadataItem[] {
|
||||
return Array.from(map.entries())
|
||||
.map(([value, bookIds]) => ({
|
||||
value,
|
||||
count: bookIds.size,
|
||||
bookIds: Array.from(bookIds),
|
||||
selected: false
|
||||
}))
|
||||
.sort((a, b) => b.count - a.count);
|
||||
}
|
||||
|
||||
getSelectedItems(type: MetadataType): MetadataItem[] {
|
||||
return this[type].filter(item => item.selected);
|
||||
}
|
||||
|
||||
openMergeDialog(type: MetadataType) {
|
||||
const selected = this.getSelectedItems(type);
|
||||
if (selected.length < 2) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Invalid Selection',
|
||||
detail: 'Please select at least 2 items to merge.'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.currentMergeType = type;
|
||||
this.mergeTarget = selected[0].value;
|
||||
this.showMergeDialog = true;
|
||||
}
|
||||
|
||||
openRenameDialog(type: MetadataType, item: MetadataItem) {
|
||||
this.currentMergeType = type;
|
||||
this.currentRenameItem = item;
|
||||
this.renameTarget = item.value;
|
||||
this.showRenameDialog = true;
|
||||
}
|
||||
|
||||
openDeleteDialog(type: MetadataType, item?: MetadataItem) {
|
||||
if (item) {
|
||||
this.currentMergeType = type;
|
||||
this.currentDeleteItem = item;
|
||||
this.showDeleteDialog = true;
|
||||
} else {
|
||||
const selected = this.getSelectedItems(type);
|
||||
if (selected.length === 0) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Invalid Selection',
|
||||
detail: 'Please select at least 1 item to delete.'
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.currentMergeType = type;
|
||||
this.currentDeleteItem = null;
|
||||
this.showDeleteDialog = true;
|
||||
}
|
||||
}
|
||||
|
||||
confirmRename() {
|
||||
if (!this.currentRenameItem || !this.renameTarget.trim()) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Invalid Target',
|
||||
detail: 'Please enter a valid name.'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const targetValues = this.renameTarget.split(',').map(v => v.trim()).filter(v => v.length > 0);
|
||||
|
||||
if (targetValues.length === 0) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Invalid Target',
|
||||
detail: 'Please enter at least one valid target value.'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isSingleValueField(this.currentMergeType) && targetValues.length > 1) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Invalid Target',
|
||||
detail: `Each book can only have one ${this.currentMergeType.slice(0, -1)}. Please enter only one value.`
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetValues.length === 1 && targetValues[0] === this.currentRenameItem.value) {
|
||||
this.showRenameDialog = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.performRename(targetValues);
|
||||
}
|
||||
|
||||
private performRename(targetValues: string[]) {
|
||||
if (!this.currentRenameItem) return;
|
||||
|
||||
const oldValue = this.currentRenameItem.value;
|
||||
const affectedBooks = this.currentRenameItem.count;
|
||||
const action = targetValues.length === 1 ? 'renamed' : 'split';
|
||||
const resultText = targetValues.length === 1
|
||||
? `"${targetValues[0]}"`
|
||||
: `${targetValues.length} values`;
|
||||
|
||||
this.loading = true;
|
||||
this.mergingInProgress = true;
|
||||
this.bookService.consolidateMetadata(this.currentMergeType, targetValues, [oldValue]).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: `${action === 'renamed' ? 'Rename' : 'Split'} Successful`,
|
||||
detail: `Successfully ${action} "${oldValue}" ${action === 'renamed' ? 'to' : 'into'} ${resultText}. ${affectedBooks} book${affectedBooks > 1 ? 's' : ''} updated.`,
|
||||
life: 5000
|
||||
});
|
||||
this.showRenameDialog = false;
|
||||
this.currentRenameItem = null;
|
||||
this.renameTarget = '';
|
||||
this.mergingInProgress = false;
|
||||
this.loading = false;
|
||||
this.loadMetadata();
|
||||
},
|
||||
error: (error) => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: `${action === 'renamed' ? 'Rename' : 'Split'} Failed`,
|
||||
detail: error?.error?.message || `An error occurred during ${action === 'renamed' ? 'rename' : 'split'}.`
|
||||
});
|
||||
this.loading = false;
|
||||
this.mergingInProgress = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
confirmMerge() {
|
||||
const selected = this.getSelectedItems(this.currentMergeType);
|
||||
if (!this.mergeTarget.trim()) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Invalid Target',
|
||||
detail: 'Please enter a target value for merging.'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const targetValues = this.mergeTarget.split(',').map(v => v.trim()).filter(v => v.length > 0);
|
||||
|
||||
if (targetValues.length === 0) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Invalid Target',
|
||||
detail: 'Please enter at least one valid target value.'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isSingleValueField(this.currentMergeType) && targetValues.length > 1) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Invalid Target',
|
||||
detail: `Each book can only have one ${this.currentMergeType.slice(0, -1)}. Please enter only one target value to standardize to.`
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.performMerge(targetValues);
|
||||
}
|
||||
|
||||
private performMerge(targetValues: string[]) {
|
||||
const selected = this.getSelectedItems(this.currentMergeType);
|
||||
const valuesToMerge = selected.map(s => s.value);
|
||||
const affectedBooks = this.getTotalAffectedBooks(selected);
|
||||
const operation = targetValues.length === 1 ? 'merge' : 'merge/split';
|
||||
const operationPast = targetValues.length === 1 ? 'merged' : 'merged/split';
|
||||
|
||||
this.loading = true;
|
||||
this.mergingInProgress = true;
|
||||
this.bookService.consolidateMetadata(this.currentMergeType, targetValues, valuesToMerge).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: `${operation === 'merge' ? 'Merge' : 'Merge/Split'} Successful`,
|
||||
detail: `Successfully ${operationPast} ${selected.length} ${this.currentMergeType} into ${targetValues.length} value(s). ${affectedBooks} book${affectedBooks > 1 ? 's' : ''} updated.`,
|
||||
life: 5000
|
||||
});
|
||||
this.showMergeDialog = false;
|
||||
this.mergeTarget = '';
|
||||
this.clearSelection(this.currentMergeType);
|
||||
this.mergingInProgress = false;
|
||||
this.loading = false;
|
||||
this.loadMetadata();
|
||||
},
|
||||
error: (error) => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: `${operation === 'merge' ? 'Merge' : 'Merge/Split'} Failed`,
|
||||
detail: error?.error?.message || `An error occurred during ${operation}.`
|
||||
});
|
||||
this.loading = false;
|
||||
this.mergingInProgress = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
confirmDelete() {
|
||||
const itemsToDelete = this.currentDeleteItem
|
||||
? [this.currentDeleteItem.value]
|
||||
: this.getSelectedItems(this.currentMergeType).map(item => item.value);
|
||||
|
||||
if (itemsToDelete.length === 0) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Invalid Selection',
|
||||
detail: 'Please select at least one item to delete.'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.performDelete(itemsToDelete);
|
||||
}
|
||||
|
||||
private performDelete(valuesToDelete: string[]) {
|
||||
const itemCount = valuesToDelete.length;
|
||||
const affectedBooks = this.currentDeleteItem
|
||||
? this.currentDeleteItem.count
|
||||
: this.getTotalAffectedBooks(this.getSelectedItems(this.currentMergeType));
|
||||
|
||||
this.loading = true;
|
||||
this.deletingInProgress = true;
|
||||
this.bookService.deleteMetadata(this.currentMergeType, valuesToDelete).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Delete Successful',
|
||||
detail: `Successfully deleted ${itemCount} ${this.currentMergeType.slice(0, -1)}${itemCount > 1 ? 's' : ''}. ${affectedBooks} book${affectedBooks > 1 ? 's' : ''} updated.`,
|
||||
life: 5000
|
||||
});
|
||||
this.showDeleteDialog = false;
|
||||
this.currentDeleteItem = null;
|
||||
this.clearSelection(this.currentMergeType);
|
||||
this.deletingInProgress = false;
|
||||
this.loading = false;
|
||||
this.loadMetadata();
|
||||
},
|
||||
error: (error) => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Delete Failed',
|
||||
detail: error?.error?.message || 'An error occurred during deletion.'
|
||||
});
|
||||
this.loading = false;
|
||||
this.deletingInProgress = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getMetadataItems(type: MetadataType): MetadataItem[] {
|
||||
return this[type];
|
||||
}
|
||||
|
||||
getSelectAll(key: TabConfig['selectAllKey']): boolean {
|
||||
return this[key];
|
||||
}
|
||||
|
||||
setSelectAll(key: TabConfig['selectAllKey'], value: boolean) {
|
||||
this[key] = value;
|
||||
}
|
||||
|
||||
toggleAll(type: MetadataType, checked: boolean, filteredItems?: MetadataItem[]) {
|
||||
const itemsToToggle = filteredItems || this[type];
|
||||
itemsToToggle.forEach(item => item.selected = checked);
|
||||
this.updateSelectAllState(type);
|
||||
}
|
||||
|
||||
private updateSelectAllState(type: MetadataType) {
|
||||
const allItems = this[type];
|
||||
const allSelected = allItems.length > 0 && allItems.every(item => item.selected);
|
||||
|
||||
switch (type) {
|
||||
case 'authors':
|
||||
this.selectAllAuthors = allSelected;
|
||||
break;
|
||||
case 'categories':
|
||||
this.selectAllCategories = allSelected;
|
||||
break;
|
||||
case 'moods':
|
||||
this.selectAllMoods = allSelected;
|
||||
break;
|
||||
case 'tags':
|
||||
this.selectAllTags = allSelected;
|
||||
break;
|
||||
case 'series':
|
||||
this.selectAllSeries = allSelected;
|
||||
break;
|
||||
case 'publishers':
|
||||
this.selectAllPublishers = allSelected;
|
||||
break;
|
||||
case 'languages':
|
||||
this.selectAllLanguages = allSelected;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
onRowSelect(type: MetadataType) {
|
||||
this.updateSelectAllState(type);
|
||||
}
|
||||
|
||||
clearSelection(type: MetadataType) {
|
||||
this[type].forEach(item => item.selected = false);
|
||||
switch (type) {
|
||||
case 'authors':
|
||||
this.selectAllAuthors = false;
|
||||
break;
|
||||
case 'categories':
|
||||
this.selectAllCategories = false;
|
||||
break;
|
||||
case 'moods':
|
||||
this.selectAllMoods = false;
|
||||
break;
|
||||
case 'tags':
|
||||
this.selectAllTags = false;
|
||||
break;
|
||||
case 'series':
|
||||
this.selectAllSeries = false;
|
||||
break;
|
||||
case 'publishers':
|
||||
this.selectAllPublishers = false;
|
||||
break;
|
||||
case 'languages':
|
||||
this.selectAllLanguages = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
selectSimilar(type: MetadataType, value: string) {
|
||||
const normalized = value.toLowerCase().trim();
|
||||
this[type].forEach(item => {
|
||||
const itemNormalized = item.value.toLowerCase().trim();
|
||||
item.selected = itemNormalized.includes(normalized) || normalized.includes(itemNormalized);
|
||||
});
|
||||
}
|
||||
|
||||
filterGlobal(event: any, dt: any) {
|
||||
dt.filterGlobal(event.target.value, 'contains');
|
||||
}
|
||||
|
||||
onMetadataClick(type: MetadataType, value: string): void {
|
||||
const filterKeyMap: Record<MetadataType, string> = {
|
||||
authors: 'author',
|
||||
categories: 'category',
|
||||
moods: 'mood',
|
||||
tags: 'tag',
|
||||
series: 'series',
|
||||
publishers: 'publisher',
|
||||
languages: 'language'
|
||||
};
|
||||
|
||||
this.navigateToFilteredBooks(filterKeyMap[type], value);
|
||||
}
|
||||
|
||||
navigateToFilteredBooks(filterKey: string, filterValue: string): void {
|
||||
this.router.navigate(['/all-books'], {
|
||||
queryParams: {
|
||||
view: 'grid',
|
||||
sort: 'title',
|
||||
direction: 'asc',
|
||||
sidebar: true,
|
||||
filter: `${filterKey}:${filterValue}`
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected isSingleValueField(type: MetadataType): boolean {
|
||||
return type === 'series' || type === 'publishers' || type === 'languages';
|
||||
}
|
||||
|
||||
protected getTotalAffectedBooks(items: MetadataItem[]): number {
|
||||
const uniqueBookIds = new Set<number>();
|
||||
items.forEach(item => {
|
||||
item.bookIds.forEach(bookId => uniqueBookIds.add(bookId));
|
||||
});
|
||||
return uniqueBookIds.size;
|
||||
}
|
||||
}
|
||||
@@ -571,6 +571,24 @@ export class BookService {
|
||||
);
|
||||
}
|
||||
|
||||
consolidateMetadata(metadataType: 'authors' | 'categories' | 'moods' | 'tags' | 'series' | 'publishers' | 'languages', targetValues: string[], valuesToMerge: string[]): Observable<any> {
|
||||
const payload = {metadataType, targetValues, valuesToMerge};
|
||||
return this.http.post(`${this.url}/metadata/manage/consolidate`, payload).pipe(
|
||||
tap(() => {
|
||||
this.refreshBooks();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
deleteMetadata(metadataType: 'authors' | 'categories' | 'moods' | 'tags' | 'series' | 'publishers' | 'languages', valuesToDelete: string[]): Observable<any> {
|
||||
const payload = {metadataType, valuesToDelete};
|
||||
return this.http.post(`${this.url}/metadata/manage/delete`, payload).pipe(
|
||||
tap(() => {
|
||||
this.refreshBooks();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/*------------------ All the websocket handlers go below ------------------*/
|
||||
|
||||
@@ -662,17 +680,4 @@ export class BookService {
|
||||
);
|
||||
}
|
||||
|
||||
restoreMetadata(bookId: number) {
|
||||
return this.http.post<BookMetadata>(`${this.url}/${bookId}/metadata/restore`, null).pipe(
|
||||
map(updatedMetadata => {
|
||||
this.handleBookMetadataUpdate(bookId, updatedMetadata);
|
||||
return updatedMetadata;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
getBackupMetadata(bookId: number) {
|
||||
return this.http.get<any>(`${this.url}/${bookId}/metadata/restore`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ export class AppMenuComponent implements OnInit {
|
||||
icon: 'pi pi-fw pi-book',
|
||||
routerLink: ['/all-books'],
|
||||
bookCount$: of(bookState.books ? bookState.books.length : 0),
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
])
|
||||
|
||||
@@ -57,6 +57,15 @@
|
||||
<i class="pi pi-chart-bar text-surface-100"></i>
|
||||
</a>
|
||||
</li>
|
||||
@if (userService.userState$ | async; as userState) {
|
||||
<li>
|
||||
@if (userState.user?.permissions?.canManipulateLibrary || userState.user?.permissions?.admin) {
|
||||
<a class="topbar-item" (click)="navigateToMetadataManager()" pTooltip="Metadata Manager" tooltipPosition="bottom">
|
||||
<i class="pi pi-sparkles text-surface-100"></i>
|
||||
</a>
|
||||
}
|
||||
</li>
|
||||
}
|
||||
<li>
|
||||
<a class="topbar-item" (click)="navigateToSettings()" pTooltip="Settings" tooltipPosition="bottom">
|
||||
<i class="pi pi-cog text-surface-100"></i>
|
||||
|
||||
@@ -151,6 +151,10 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
this.router.navigate(['/bookdrop']);
|
||||
}
|
||||
|
||||
navigateToMetadataManager() {
|
||||
this.router.navigate(['/metadata-manager']);
|
||||
}
|
||||
|
||||
navigateToStats() {
|
||||
this.router.navigate(['/stats']);
|
||||
}
|
||||
|
||||
+1
-6
@@ -5,12 +5,7 @@
|
||||
<h2 class="settings-title">
|
||||
<i class="pi pi-tablet"></i>
|
||||
Kobo Integration Settings
|
||||
<i class="pi pi-external-link external-link-icon"
|
||||
pTooltip="View documentation"
|
||||
tooltipPosition="right"
|
||||
(click)="openKoboDocumentation()"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
<app-external-doc-link docType="kobo"></app-external-doc-link>
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
Configure Kobo device integration to sync your library books and reading progress with your Kobo e-reader.
|
||||
|
||||
-5
@@ -27,11 +27,6 @@
|
||||
color: var(--p-primary-color);
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.external-link-icon {
|
||||
color: #0ea5e9 !important; // Sky-600 equivalent
|
||||
font-size: 1rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-description {
|
||||
|
||||
+2
-6
@@ -9,20 +9,20 @@ import {ConfirmDialog} from 'primeng/confirmdialog';
|
||||
import {UserService} from '../../user-management/user.service';
|
||||
import {Subject} from 'rxjs';
|
||||
import {debounceTime, filter, take, takeUntil} from 'rxjs/operators';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||
import {Slider} from 'primeng/slider';
|
||||
import {AppSettingsService} from '../../../core/service/app-settings.service';
|
||||
import {SettingsHelperService} from '../../../core/service/settings-helper.service';
|
||||
import {AppSettingKey, KoboSettings} from '../../../core/model/app-settings.model';
|
||||
import {ShelfService} from '../../../book/service/shelf.service';
|
||||
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-kobo-sync-setting-component',
|
||||
standalone: true,
|
||||
templateUrl: './kobo-sync-settings-component.html',
|
||||
styleUrl: './kobo-sync-settings-component.scss',
|
||||
imports: [FormsModule, Button, InputText, ConfirmDialog, Tooltip, ToggleSwitch, Slider],
|
||||
imports: [FormsModule, Button, InputText, ConfirmDialog, ToggleSwitch, Slider, ExternalDocLinkComponent],
|
||||
providers: [MessageService, ConfirmationService]
|
||||
})
|
||||
export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
||||
@@ -205,10 +205,6 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
openKoboDocumentation(): void {
|
||||
window.open('https://booklore-app.github.io/booklore-docs/docs/integration/kobo', '_blank');
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
|
||||
+1
-6
@@ -5,12 +5,7 @@
|
||||
<h2 class="settings-title">
|
||||
<i class="pi pi-mobile"></i>
|
||||
KOReader Sync Settings
|
||||
<i class="pi pi-external-link external-link-icon"
|
||||
pTooltip="View documentation"
|
||||
tooltipPosition="right"
|
||||
(click)="openKoReaderDocumentation()"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
<app-external-doc-link docType="koReader"></app-external-doc-link>
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
Configure KOReader integration to sync your reading progress between your device and Booklore library.
|
||||
|
||||
-5
@@ -27,11 +27,6 @@
|
||||
color: var(--p-primary-color);
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.external-link-icon {
|
||||
color: #0ea5e9 !important;
|
||||
font-size: 1rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-description {
|
||||
|
||||
+2
-6
@@ -10,7 +10,7 @@ import {KoreaderService} from '../koreader.service';
|
||||
import {UserService} from '../../user-management/user.service';
|
||||
import {filter, takeUntil} from 'rxjs/operators';
|
||||
import {Subject} from 'rxjs';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
@@ -22,7 +22,7 @@ import {Tooltip} from 'primeng/tooltip';
|
||||
ToggleSwitch,
|
||||
Button,
|
||||
ToastModule,
|
||||
Tooltip
|
||||
ExternalDocLinkComponent
|
||||
],
|
||||
providers: [MessageService],
|
||||
templateUrl: './koreader-settings-component.html',
|
||||
@@ -130,8 +130,4 @@ export class KoreaderSettingsComponent implements OnInit, OnDestroy {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
openKoReaderDocumentation() {
|
||||
window.open('https://booklore-app.github.io/booklore-docs/docs/integration/koreader', '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,7 @@
|
||||
<h2 class="settings-title">
|
||||
<i class="pi pi-envelope"></i>
|
||||
Email Providers
|
||||
<i class="pi pi-external-link external-link-icon"
|
||||
pTooltip="View documentation"
|
||||
tooltipPosition="right"
|
||||
(click)="navigateToEmailDocumentation()"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
<app-external-doc-link docType="email"></app-external-doc-link>
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
Configure email-sending services like Gmail, Outlook, or custom SMTP servers for sending books via email. The default email provider will be used for 'Quick Book Send' located in the Book Card menu.
|
||||
|
||||
@@ -20,11 +20,6 @@
|
||||
color: var(--p-primary-color);
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.external-link-icon {
|
||||
color: #0ea5e9 !important;
|
||||
font-size: 0.875rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-description {
|
||||
|
||||
@@ -11,6 +11,7 @@ import {EmailProvider} from './email-provider.model';
|
||||
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {EmailProviderService} from './email-provider.service';
|
||||
import {CreateEmailProviderDialogComponent} from '../create-email-provider-dialog/create-email-provider-dialog.component';
|
||||
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-email-provider',
|
||||
@@ -22,7 +23,8 @@ import {CreateEmailProviderDialogComponent} from '../create-email-provider-dialo
|
||||
ReactiveFormsModule,
|
||||
TableModule,
|
||||
Tooltip,
|
||||
FormsModule
|
||||
FormsModule,
|
||||
ExternalDocLinkComponent
|
||||
],
|
||||
templateUrl: './email-provider.component.html',
|
||||
styleUrl: './email-provider.component.scss'
|
||||
@@ -136,8 +138,4 @@ export class EmailProviderComponent implements OnInit {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
navigateToEmailDocumentation() {
|
||||
window.open('https://booklore-app.github.io/booklore-docs/docs/email-setup', '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
+2
-12
@@ -32,12 +32,7 @@
|
||||
<div class="config-field">
|
||||
<div class="config-label-row">
|
||||
<label class="config-label">Cookie (Optional, but highly recommended)</label>
|
||||
<i class="pi pi-external-link external-link-icon"
|
||||
pTooltip="View documentation"
|
||||
tooltipPosition="right"
|
||||
(click)="navigateToAmazonCookieDocumentation()"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
<app-external-doc-link docType="amazonCookie"></app-external-doc-link>
|
||||
</div>
|
||||
<p class="config-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
@@ -88,12 +83,7 @@
|
||||
<div class="config-field">
|
||||
<div class="config-label-row">
|
||||
<label class="config-label">API Token</label>
|
||||
<i class="pi pi-external-link external-link-icon"
|
||||
pTooltip="View documentation"
|
||||
tooltipPosition="right"
|
||||
(click)="navigateToHardcoverTokenDocumentation()"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
<app-external-doc-link docType="hardcover"></app-external-doc-link>
|
||||
</div>
|
||||
<input
|
||||
type="text"
|
||||
|
||||
-5
@@ -110,11 +110,6 @@
|
||||
.config-label {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.external-link-icon {
|
||||
color: #0ea5e9 !important;
|
||||
font-size: 0.875rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
.config-description {
|
||||
|
||||
+2
-10
@@ -9,7 +9,7 @@ import {filter, take} from 'rxjs/operators';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {AppSettingKey} from '../../../core/model/app-settings.model';
|
||||
import {Select} from 'primeng/select';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-provider-settings',
|
||||
@@ -21,7 +21,7 @@ import {Tooltip} from 'primeng/tooltip';
|
||||
Button,
|
||||
FormsModule,
|
||||
Select,
|
||||
Tooltip
|
||||
ExternalDocLinkComponent
|
||||
],
|
||||
templateUrl: './metadata-provider-settings.component.html',
|
||||
styleUrl: './metadata-provider-settings.component.scss'
|
||||
@@ -144,12 +144,4 @@ export class MetadataProviderSettingsComponent implements OnInit {
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
navigateToAmazonCookieDocumentation() {
|
||||
window.open('https://booklore-app.github.io/booklore-docs/docs/metadata/amazon-cookie', '_blank');
|
||||
}
|
||||
|
||||
navigateToHardcoverTokenDocumentation() {
|
||||
window.open('https://booklore-app.github.io/booklore-docs/docs/metadata/hardcover-token', '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
+1
-6
@@ -3,12 +3,7 @@
|
||||
<h2 class="settings-title">
|
||||
<i class="pi pi-database"></i>
|
||||
Library Metadata Configuration
|
||||
<i class="pi pi-external-link external-link-icon"
|
||||
pTooltip="View documentation"
|
||||
tooltipPosition="right"
|
||||
(click)="navigateMetadataDoc()"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
<app-external-doc-link docType="fetchConfig"></app-external-doc-link>
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
Configure metadata fetch behavior for your libraries. Set global defaults and create library-specific overrides to control how book metadata is retrieved from different providers.
|
||||
|
||||
-5
@@ -16,11 +16,6 @@
|
||||
background: var(--p-content-background);
|
||||
}
|
||||
|
||||
.external-link-icon {
|
||||
color: #0ea5e9 !important;
|
||||
font-size: 0.875rem !important;
|
||||
}
|
||||
|
||||
.settings-header {
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 2rem;
|
||||
|
||||
+3
-7
@@ -10,14 +10,14 @@ import {Library} from '../../book/model/library.model';
|
||||
import {LibraryService} from '../../book/service/library.service';
|
||||
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 {AppSettings, AppSettingKey} from '../../core/model/app-settings.model';
|
||||
import {AppSettingKey, AppSettings} from '../../core/model/app-settings.model';
|
||||
import {AppSettingsService} from '../../core/service/app-settings.service';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {ExternalDocLinkComponent} from '../../shared/components/external-doc-link/external-doc-link.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-library-metadata-settings-component',
|
||||
standalone: true,
|
||||
imports: [CommonModule, FormsModule, MetadataAdvancedFetchOptionsComponent, AccordionModule, Tooltip],
|
||||
imports: [CommonModule, FormsModule, MetadataAdvancedFetchOptionsComponent, AccordionModule, ExternalDocLinkComponent],
|
||||
templateUrl: './library-metadata-settings.component.html',
|
||||
styleUrls: ['./library-metadata-settings.component.scss']
|
||||
})
|
||||
@@ -220,8 +220,4 @@ export class LibraryMetadataSettingsComponent implements OnInit {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
navigateMetadataDoc(): void {
|
||||
window.open('https://booklore-app.github.io/booklore-docs/docs/metadata/metadata-fetch-configuration', '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,7 @@
|
||||
<h2 class="settings-title">
|
||||
<i class="pi pi-server"></i>
|
||||
OPDS Settings (New)
|
||||
<i class="pi pi-external-link external-link-icon"
|
||||
pTooltip="View documentation"
|
||||
tooltipPosition="right"
|
||||
(click)="navigateToOpdsDoc()"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
<app-external-doc-link docType="opds"></app-external-doc-link>
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
Manage your OPDS credentials and control how your book collection is shared with reading apps.
|
||||
|
||||
@@ -34,11 +34,6 @@
|
||||
color: var(--p-primary-color);
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.external-link-icon {
|
||||
color: #0ea5e9 !important;
|
||||
font-size: 0.875rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-description {
|
||||
|
||||
@@ -12,11 +12,12 @@ import {ConfirmationService, MessageService} from 'primeng/api';
|
||||
import {OpdsUserV2, OpdsUserV2CreateRequest, OpdsV2Service} from './opds-v2.service';
|
||||
import {catchError, filter, take, takeUntil, tap} from 'rxjs/operators';
|
||||
import {UserService} from '../user-management/user.service';
|
||||
import {of, pipe, Subject} from 'rxjs';
|
||||
import {of, Subject} from 'rxjs';
|
||||
import {Password} from 'primeng/password';
|
||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||
import {AppSettingsService} from '../../core/service/app-settings.service';
|
||||
import {AppSettingKey} from '../../core/model/app-settings.model';
|
||||
import {ExternalDocLinkComponent} from '../../shared/components/external-doc-link/external-doc-link.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-opds-settings-v2',
|
||||
@@ -30,7 +31,8 @@ import {AppSettingKey} from '../../core/model/app-settings.model';
|
||||
ConfirmDialog,
|
||||
TableModule,
|
||||
Password,
|
||||
ToggleSwitch
|
||||
ToggleSwitch,
|
||||
ExternalDocLinkComponent
|
||||
],
|
||||
providers: [ConfirmationService],
|
||||
templateUrl: './opds-settings-v2.html',
|
||||
@@ -203,10 +205,6 @@ export class OpdsSettingsV2 implements OnInit, OnDestroy {
|
||||
this.messageService.add({severity, summary, detail});
|
||||
}
|
||||
|
||||
navigateToOpdsDoc(): void {
|
||||
window.open('https://booklore-app.github.io/booklore-docs/docs/integration/opds', '_blank');
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
import {Component, Input} from '@angular/core';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
|
||||
export type DocType = 'kobo' | 'opds' | 'metadataManager' | 'koReader' | 'email' | 'amazonCookie' | 'fetchConfig' | 'hardcover';
|
||||
|
||||
@Component({
|
||||
selector: 'app-external-doc-link',
|
||||
standalone: true,
|
||||
imports: [Tooltip],
|
||||
template: `
|
||||
<i class="pi pi-external-link external-link-icon"
|
||||
[pTooltip]="tooltip"
|
||||
[tooltipPosition]="tooltipPosition"
|
||||
[style.font-size]="size"
|
||||
(click)="openLink()"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
`,
|
||||
styles: [`
|
||||
.external-link-icon {
|
||||
color: #0ea5e9 !important;
|
||||
}
|
||||
`]
|
||||
})
|
||||
export class ExternalDocLinkComponent {
|
||||
private readonly BASE_URL = 'https://booklore-app.github.io/booklore-docs/docs';
|
||||
|
||||
private readonly DOC_URLS: Record<DocType, string> = {
|
||||
kobo: `${this.BASE_URL}/integration/kobo`,
|
||||
opds: `${this.BASE_URL}/integration/opds`,
|
||||
metadataManager: `${this.BASE_URL}/metadata/metadata-manager`,
|
||||
koReader: `${this.BASE_URL}/integration/koreader`,
|
||||
email: `${this.BASE_URL}/email-setup`,
|
||||
amazonCookie: `${this.BASE_URL}/metadata/amazon-cookie`,
|
||||
hardcover: `${this.BASE_URL}/metadata/hardcover-token`,
|
||||
fetchConfig: `${this.BASE_URL}/metadata/metadata-fetch-configuration`
|
||||
};
|
||||
|
||||
@Input() docType!: DocType;
|
||||
@Input() tooltip: string = 'View documentation';
|
||||
@Input() tooltipPosition: 'top' | 'bottom' | 'left' | 'right' = 'right';
|
||||
@Input() size: string = '1rem';
|
||||
|
||||
openLink(): void {
|
||||
const url = this.DOC_URLS[this.docType];
|
||||
if (url) {
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user