Support individual “write to file” settings per book type, with configurable file size limits (#2206)
Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
+127
-16
@@ -10,39 +10,150 @@
|
||||
<div class="warning-notice">
|
||||
<i class="pi pi-exclamation-triangle"></i>
|
||||
<div>
|
||||
<strong>Network Storage Notice:</strong> These features are designed for local file systems and have not been tested with network storage (NAS/cloud). Functionality cannot be guaranteed on network file systems.
|
||||
<strong>Network Storage Warning:</strong> These features directly modify and move book files on disk (including rewriting metadata and renaming files). They are designed for local file systems only. Using them on NAS or cloud-backed storage is untested and may lead to file corruption,
|
||||
incomplete writes, or permanent data loss. Github issues related to network storage will not be supported.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- EPUB Settings -->
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Write Metadata to File</label>
|
||||
<p-toggleswitch
|
||||
[ngModel]="metadataPersistence.saveToOriginalFile"
|
||||
(onChange)="onPersistenceToggle('saveToOriginalFile')">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
<label class="setting-label">Write Metadata to EPUB</label>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
Write metadata directly into the original file. (Only Epub and PDF formats are currently supported.)
|
||||
Write metadata directly into EPUB files when editing book information.
|
||||
</p>
|
||||
<div class="setting-item setting-item-indented">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Enabled:</label>
|
||||
<p-toggleswitch
|
||||
[ngModel]="metadataPersistence.saveToOriginalFile.epub.enabled"
|
||||
(onChange)="onSaveToOriginalFileToggle('epub')">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
@if (metadataPersistence.saveToOriginalFile.epub.enabled) {
|
||||
<div class="filesize-input" style="margin-top: 0.5rem;">
|
||||
<label>Max File Size (MB):</label>
|
||||
<input
|
||||
type="number"
|
||||
[(ngModel)]="metadataPersistence.saveToOriginalFile.epub.maxFileSizeInMb"
|
||||
(change)="onFilesizeChange('epub')"
|
||||
min="1"
|
||||
max="1000"
|
||||
class="filesize-field">
|
||||
<i
|
||||
class="pi pi-info-circle text-blue-500"
|
||||
pTooltip="Only files up to this size (MB) will be updated. Larger files are ignored."
|
||||
tooltipPosition="right"
|
||||
style="cursor: help; margin-left: 4px;"
|
||||
></i>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CBX Settings -->
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<label class="setting-label">Write Metadata to CBX</label>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
Write metadata directly into CBX files when editing book information.
|
||||
</p>
|
||||
<div class="setting-item setting-item-indented">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Enabled:</label>
|
||||
<p-toggleswitch
|
||||
[ngModel]="metadataPersistence.saveToOriginalFile.cbx.enabled"
|
||||
(onChange)="onSaveToOriginalFileToggle('cbx')">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
@if (metadataPersistence.saveToOriginalFile.cbx.enabled) {
|
||||
<div class="filesize-input" style="margin-top: 0.5rem;">
|
||||
<label>Max File Size (MB):</label>
|
||||
<input
|
||||
type="number"
|
||||
[(ngModel)]="metadataPersistence.saveToOriginalFile.cbx.maxFileSizeInMb"
|
||||
(change)="onFilesizeChange('cbx')"
|
||||
min="1"
|
||||
max="1000"
|
||||
class="filesize-field">
|
||||
<i
|
||||
class="pi pi-info-circle text-blue-500"
|
||||
pTooltip="Only files up to this size (MB) will be updated. Larger files are ignored."
|
||||
tooltipPosition="right"
|
||||
style="cursor: help; margin-left: 4px;"
|
||||
></i>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- PDF Settings -->
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<label class="setting-label">Write Metadata to PDF</label>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
Write metadata directly into PDF files when editing book information. <br>
|
||||
Note: PDFs do not support embedded covers, and only a limited set of metadata can be updated (Title, Authors, Publisher, Categories, Description, Language, Published Date). This is a limitation of the PDF format.
|
||||
</p>
|
||||
<div class="setting-item setting-item-indented">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Enabled:</label>
|
||||
<p-toggleswitch
|
||||
[ngModel]="metadataPersistence.saveToOriginalFile.pdf.enabled"
|
||||
(onChange)="onSaveToOriginalFileToggle('pdf')">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
@if (metadataPersistence.saveToOriginalFile.pdf.enabled) {
|
||||
<div class="filesize-input" style="margin-top: 0.5rem;">
|
||||
<label>Max File Size (MB):</label>
|
||||
<input
|
||||
type="number"
|
||||
[(ngModel)]="metadataPersistence.saveToOriginalFile.pdf.maxFileSizeInMb"
|
||||
(change)="onFilesizeChange('pdf')"
|
||||
min="1"
|
||||
max="1000"
|
||||
class="filesize-field">
|
||||
<i
|
||||
class="pi pi-info-circle text-blue-500"
|
||||
pTooltip="Only files up to this size (MB) will be updated. Larger files are ignored."
|
||||
tooltipPosition="right"
|
||||
style="cursor: help; margin-left: 4px;"
|
||||
></i>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Auto-Move Files on Metadata Update</label>
|
||||
<p-toggleswitch
|
||||
[ngModel]="metadataPersistence.moveFilesToLibraryPattern"
|
||||
(onChange)="onPersistenceToggle('moveFilesToLibraryPattern')">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
<label class="setting-label">Auto-Move Files on Metadata Update</label>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
Automatically move and rename files according to their library's naming pattern when metadata is updated, either through manual editing or auto-fetch operations.
|
||||
</p>
|
||||
<div class="setting-item setting-item-indented">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Enabled:</label>
|
||||
<p-toggleswitch
|
||||
[ngModel]="metadataPersistence.moveFilesToLibraryPattern"
|
||||
(onChange)="onPersistenceToggle('moveFilesToLibraryPattern')">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+65
-8
@@ -40,6 +40,7 @@
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 2rem;
|
||||
flex-wrap: wrap;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
@@ -47,9 +48,10 @@
|
||||
}
|
||||
|
||||
&.setting-item-indented {
|
||||
margin-top: 1rem;
|
||||
margin-left: 1.5rem;
|
||||
padding-left: 1rem;
|
||||
border-left: 2px solid var(--p-content-border-color);
|
||||
border-left: 2px solid var(--p-border-color);
|
||||
position: relative;
|
||||
|
||||
&::before {
|
||||
@@ -140,19 +142,74 @@
|
||||
.warning-notice {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.5rem;
|
||||
color: var(--p-red-400);
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.5;
|
||||
gap: 0.75rem;
|
||||
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.55;
|
||||
|
||||
padding: 0.875rem 1rem;
|
||||
border-radius: 10px;
|
||||
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--p-surface-900) 85%,
|
||||
var(--p-red-600) 15%
|
||||
);
|
||||
|
||||
border-left: 4px solid var(--p-red-500);
|
||||
|
||||
color: var(--p-text-color);
|
||||
|
||||
.pi-exclamation-triangle {
|
||||
color: var(--p-red-500);
|
||||
margin-top: 0.125rem;
|
||||
color: var(--p-red-400);
|
||||
margin-top: 0.15rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: 700;
|
||||
color: var(--p-red-300);
|
||||
}
|
||||
}
|
||||
|
||||
.nested-settings {
|
||||
margin-top: 1rem;
|
||||
margin-left: 1.5rem;
|
||||
padding-left: 1rem;
|
||||
border-left: 2px solid var(--surface-border);
|
||||
}
|
||||
|
||||
.format-setting {
|
||||
margin-bottom: 1rem;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.filesize-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
|
||||
label {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: var(--p-red-500);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.filesize-field {
|
||||
width: 100px;
|
||||
padding: 0.5rem;
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-radius: 6px;
|
||||
background: var(--p-content-background);
|
||||
color: var(--p-text-color);
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--p-primary-color);
|
||||
box-shadow: 0 0 0 2px var(--p-primary-color-transparent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+49
-16
@@ -1,17 +1,19 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {AppSettingKey, AppSettings, MetadataPersistenceSettings} from '../../../../shared/model/app-settings.model';
|
||||
import {AppSettingKey, AppSettings, MetadataPersistenceSettings, SaveToOriginalFileSettings} from '../../../../shared/model/app-settings.model';
|
||||
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
|
||||
import {SettingsHelperService} from '../../../../shared/service/settings-helper.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-persistence-settings-component',
|
||||
imports: [
|
||||
ToggleSwitch,
|
||||
FormsModule
|
||||
FormsModule,
|
||||
Tooltip
|
||||
],
|
||||
templateUrl: './metadata-persistence-settings-component.html',
|
||||
styleUrl: './metadata-persistence-settings-component.scss'
|
||||
@@ -19,7 +21,20 @@ import {filter, take} from 'rxjs/operators';
|
||||
export class MetadataPersistenceSettingsComponent implements OnInit {
|
||||
|
||||
metadataPersistence: MetadataPersistenceSettings = {
|
||||
saveToOriginalFile: false,
|
||||
saveToOriginalFile: {
|
||||
epub: {
|
||||
enabled: false,
|
||||
maxFileSizeInMb: 250
|
||||
},
|
||||
pdf: {
|
||||
enabled: false,
|
||||
maxFileSizeInMb: 250
|
||||
},
|
||||
cbx: {
|
||||
enabled: false,
|
||||
maxFileSizeInMb: 250
|
||||
}
|
||||
},
|
||||
convertCbrCb7ToCbz: false,
|
||||
moveFilesToLibraryPattern: false
|
||||
};
|
||||
@@ -34,7 +49,19 @@ export class MetadataPersistenceSettingsComponent implements OnInit {
|
||||
}
|
||||
|
||||
onPersistenceToggle(key: keyof MetadataPersistenceSettings): void {
|
||||
this.updatePersistenceSettings(key);
|
||||
if (key !== 'saveToOriginalFile') {
|
||||
this.metadataPersistence[key] = !this.metadataPersistence[key];
|
||||
this.settingsHelper.saveSetting(AppSettingKey.METADATA_PERSISTENCE_SETTINGS, this.metadataPersistence);
|
||||
}
|
||||
}
|
||||
|
||||
onSaveToOriginalFileToggle(format: keyof SaveToOriginalFileSettings): void {
|
||||
this.metadataPersistence.saveToOriginalFile[format].enabled =
|
||||
!this.metadataPersistence.saveToOriginalFile[format].enabled;
|
||||
this.settingsHelper.saveSetting(AppSettingKey.METADATA_PERSISTENCE_SETTINGS, this.metadataPersistence);
|
||||
}
|
||||
|
||||
onFilesizeChange(format: keyof SaveToOriginalFileSettings): void {
|
||||
this.settingsHelper.saveSetting(AppSettingKey.METADATA_PERSISTENCE_SETTINGS, this.metadataPersistence);
|
||||
}
|
||||
|
||||
@@ -53,19 +80,25 @@ export class MetadataPersistenceSettingsComponent implements OnInit {
|
||||
|
||||
private initializeSettings(settings: AppSettings): void {
|
||||
if (settings.metadataPersistenceSettings) {
|
||||
this.metadataPersistence = {...settings.metadataPersistenceSettings};
|
||||
}
|
||||
}
|
||||
const persistenceSettings = settings.metadataPersistenceSettings;
|
||||
|
||||
private updatePersistenceSettings(key: keyof MetadataPersistenceSettings): void {
|
||||
if (key === 'saveToOriginalFile') {
|
||||
this.metadataPersistence.saveToOriginalFile = !this.metadataPersistence.saveToOriginalFile;
|
||||
|
||||
if (!this.metadataPersistence.saveToOriginalFile) {
|
||||
this.metadataPersistence.convertCbrCb7ToCbz = false;
|
||||
}
|
||||
} else {
|
||||
this.metadataPersistence[key] = !this.metadataPersistence[key];
|
||||
this.metadataPersistence = {
|
||||
...persistenceSettings,
|
||||
saveToOriginalFile: {
|
||||
epub: {
|
||||
enabled: persistenceSettings.saveToOriginalFile?.epub?.enabled ?? false,
|
||||
maxFileSizeInMb: persistenceSettings.saveToOriginalFile?.epub?.maxFileSizeInMb ?? 100
|
||||
},
|
||||
pdf: {
|
||||
enabled: persistenceSettings.saveToOriginalFile?.pdf?.enabled ?? false,
|
||||
maxFileSizeInMb: persistenceSettings.saveToOriginalFile?.pdf?.maxFileSizeInMb ?? 100
|
||||
},
|
||||
cbx: {
|
||||
enabled: persistenceSettings.saveToOriginalFile?.cbx?.enabled ?? false,
|
||||
maxFileSizeInMb: persistenceSettings.saveToOriginalFile?.cbx?.maxFileSizeInMb ?? 250
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user