Gate all file write operations for network storage users (#3231)
This commit is contained in:
+2
-2
@@ -37,7 +37,7 @@
|
||||
{{ t('tabSearch') }}
|
||||
</p-tab>
|
||||
}
|
||||
@if ((admin || canEditMetadata) && !isPhysical) {
|
||||
@if ((admin || canEditMetadata) && !isPhysical && isLocalStorage) {
|
||||
<p-tab value="sidecar">
|
||||
<i [class]="'pi pi-file'"></i>
|
||||
{{ t('tabSidecar') }}
|
||||
@@ -63,7 +63,7 @@
|
||||
<app-metadata-searcher [book$]="book$" [isActiveTab]="tab === 'match'"></app-metadata-searcher>
|
||||
</p-tabpanel>
|
||||
}
|
||||
@if ((admin || canEditMetadata) && !isPhysical) {
|
||||
@if ((admin || canEditMetadata) && !isPhysical && isLocalStorage) {
|
||||
<p-tabpanel value="sidecar">
|
||||
<app-sidecar-viewer [book$]="book$"></app-sidecar-viewer>
|
||||
</p-tabpanel>
|
||||
|
||||
+11
@@ -50,6 +50,7 @@ export class BookMetadataCenterComponent implements OnInit, OnDestroy {
|
||||
canEditMetadata: boolean = false;
|
||||
admin: boolean = false;
|
||||
isPhysical: boolean = false;
|
||||
isLocalStorage: boolean = true;
|
||||
|
||||
private appSettings$ = this.appSettingsService.appSettings$;
|
||||
private currentBookId$ = new BehaviorSubject<number | null>(null);
|
||||
@@ -145,6 +146,16 @@ export class BookMetadataCenterComponent implements OnInit, OnDestroy {
|
||||
this.canEditMetadata = userState.user?.permissions?.canEditMetadata ?? false;
|
||||
this.admin = userState.user?.permissions?.admin ?? false;
|
||||
});
|
||||
|
||||
this.appSettings$
|
||||
.pipe(
|
||||
filter(settings => !!settings),
|
||||
take(1),
|
||||
takeUntil(this.destroy$)
|
||||
)
|
||||
.subscribe(settings => {
|
||||
this.isLocalStorage = settings!.diskType === 'LOCAL';
|
||||
});
|
||||
}
|
||||
|
||||
private fetchBookRecommendationsIfNeeded(bookId: number): void {
|
||||
|
||||
+26
-24
@@ -66,30 +66,32 @@
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
<div class="sidecar-actions">
|
||||
<p-button
|
||||
icon="pi pi-upload"
|
||||
[label]="t('libraryOverrides.exportSidecar')"
|
||||
size="small"
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
[loading]="isSidecarExporting(library.id!)"
|
||||
(onClick)="exportSidecarForLibrary(library.id!, $event)"
|
||||
[pTooltip]="t('libraryOverrides.exportTooltip')"
|
||||
tooltipPosition="top"
|
||||
/>
|
||||
<p-button
|
||||
icon="pi pi-download"
|
||||
[label]="t('libraryOverrides.importSidecar')"
|
||||
size="small"
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
[loading]="isSidecarImporting(library.id!)"
|
||||
(onClick)="importSidecarForLibrary(library.id!, $event)"
|
||||
[pTooltip]="t('libraryOverrides.importTooltip')"
|
||||
tooltipPosition="top"
|
||||
/>
|
||||
</div>
|
||||
@if (isLocalStorage) {
|
||||
<div class="sidecar-actions">
|
||||
<p-button
|
||||
icon="pi pi-upload"
|
||||
[label]="t('libraryOverrides.exportSidecar')"
|
||||
size="small"
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
[loading]="isSidecarExporting(library.id!)"
|
||||
(onClick)="exportSidecarForLibrary(library.id!, $event)"
|
||||
[pTooltip]="t('libraryOverrides.exportTooltip')"
|
||||
tooltipPosition="top"
|
||||
/>
|
||||
<p-button
|
||||
icon="pi pi-download"
|
||||
[label]="t('libraryOverrides.importSidecar')"
|
||||
size="small"
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
[loading]="isSidecarImporting(library.id!)"
|
||||
(onClick)="importSidecarForLibrary(library.id!, $event)"
|
||||
[pTooltip]="t('libraryOverrides.importTooltip')"
|
||||
tooltipPosition="top"
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</p-accordion-header>
|
||||
<p-accordion-content>
|
||||
|
||||
+2
@@ -41,11 +41,13 @@ export class LibraryMetadataSettingsComponent implements OnInit {
|
||||
activePanel: number | null = null;
|
||||
sidecarExporting: Record<number, boolean> = {};
|
||||
sidecarImporting: Record<number, boolean> = {};
|
||||
isLocalStorage = true;
|
||||
private cachedDefaultOptions: Record<number, MetadataRefreshOptions> = {};
|
||||
|
||||
ngOnInit() {
|
||||
this.appSettingsService.appSettings$.subscribe(appSettings => {
|
||||
if (appSettings) {
|
||||
this.isLocalStorage = appSettings.diskType === 'LOCAL';
|
||||
this.defaultMetadataOptions = appSettings.defaultMetadataRefreshOptions;
|
||||
this.cachedDefaultOptions = {};
|
||||
this.initializeLibraryOptions(appSettings);
|
||||
|
||||
+40
-21
@@ -10,27 +10,39 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="section-notice">
|
||||
<div class="warning-notice">
|
||||
<i class="pi pi-exclamation-triangle"></i>
|
||||
<div>
|
||||
<strong>{{ t('networkWarningTitle') }}</strong> {{ t('networkWarning') }}
|
||||
@if (isNetworkStorage) {
|
||||
<div class="section-notice">
|
||||
<div class="info-notice">
|
||||
<i class="pi pi-lock"></i>
|
||||
<div>
|
||||
<strong>{{ t('networkModeTitle') }}</strong> {{ t('networkModeDesc') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="info-notice unsupported-formats-note">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
<div>
|
||||
<strong>Note:</strong> <span [innerHTML]="t('unsupportedNote')"></span>
|
||||
} @else {
|
||||
<div class="section-notice">
|
||||
<div class="warning-notice">
|
||||
<i class="pi pi-exclamation-triangle"></i>
|
||||
<div>
|
||||
<strong>{{ t('networkWarningTitle') }}</strong> {{ t('networkWarning') }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="info-notice unsupported-formats-note">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
<div>
|
||||
<strong>Note:</strong> <span [innerHTML]="t('unsupportedNote')"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="section-body">
|
||||
<div class="section-body" [class.network-disabled]="isNetworkStorage">
|
||||
<div class="setting-item">
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch
|
||||
[ngModel]="metadataPersistence.saveToOriginalFile.epub.enabled"
|
||||
(onChange)="onSaveToOriginalFileToggle('epub')">
|
||||
(onChange)="onSaveToOriginalFileToggle('epub')"
|
||||
[disabled]="isNetworkStorage">
|
||||
</p-toggleswitch>
|
||||
<label class="setting-label">{{ t('writeEpub') }}</label>
|
||||
</div>
|
||||
@@ -61,7 +73,8 @@
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch
|
||||
[ngModel]="metadataPersistence.saveToOriginalFile.cbx.enabled"
|
||||
(onChange)="onSaveToOriginalFileToggle('cbx')">
|
||||
(onChange)="onSaveToOriginalFileToggle('cbx')"
|
||||
[disabled]="isNetworkStorage">
|
||||
</p-toggleswitch>
|
||||
<label class="setting-label">{{ t('writeCbx') }}</label>
|
||||
</div>
|
||||
@@ -92,7 +105,8 @@
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch
|
||||
[ngModel]="metadataPersistence.saveToOriginalFile.pdf.enabled"
|
||||
(onChange)="onSaveToOriginalFileToggle('pdf')">
|
||||
(onChange)="onSaveToOriginalFileToggle('pdf')"
|
||||
[disabled]="isNetworkStorage">
|
||||
</p-toggleswitch>
|
||||
<label class="setting-label">{{ t('writePdf') }}</label>
|
||||
</div>
|
||||
@@ -126,7 +140,8 @@
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch
|
||||
[ngModel]="metadataPersistence.saveToOriginalFile.audiobook.enabled"
|
||||
(onChange)="onSaveToOriginalFileToggle('audiobook')">
|
||||
(onChange)="onSaveToOriginalFileToggle('audiobook')"
|
||||
[disabled]="isNetworkStorage">
|
||||
</p-toggleswitch>
|
||||
<label class="setting-label">{{ t('writeAudiobook') }}</label>
|
||||
</div>
|
||||
@@ -156,7 +171,7 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
@if ((appSettings$ | async)?.diskType === 'LOCAL') {
|
||||
@if (!isNetworkStorage) {
|
||||
<div class="setting-item">
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch
|
||||
@@ -180,12 +195,13 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
<div class="section-body" [class.network-disabled]="isNetworkStorage">
|
||||
<div class="setting-item">
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch
|
||||
[ngModel]="metadataPersistence.sidecarSettings?.enabled"
|
||||
(onChange)="onSidecarToggle('enabled')">
|
||||
(onChange)="onSidecarToggle('enabled')"
|
||||
[disabled]="isNetworkStorage">
|
||||
</p-toggleswitch>
|
||||
<label class="setting-label">{{ t('enableSidecar') }}</label>
|
||||
</div>
|
||||
@@ -197,7 +213,8 @@
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch
|
||||
[ngModel]="metadataPersistence.sidecarSettings?.writeOnUpdate"
|
||||
(onChange)="onSidecarToggle('writeOnUpdate')">
|
||||
(onChange)="onSidecarToggle('writeOnUpdate')"
|
||||
[disabled]="isNetworkStorage">
|
||||
</p-toggleswitch>
|
||||
<label class="setting-label">{{ t('writeOnUpdate') }}</label>
|
||||
</div>
|
||||
@@ -208,7 +225,8 @@
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch
|
||||
[ngModel]="metadataPersistence.sidecarSettings?.writeOnScan"
|
||||
(onChange)="onSidecarToggle('writeOnScan')">
|
||||
(onChange)="onSidecarToggle('writeOnScan')"
|
||||
[disabled]="isNetworkStorage">
|
||||
</p-toggleswitch>
|
||||
<label class="setting-label">{{ t('writeOnScan') }}</label>
|
||||
</div>
|
||||
@@ -219,7 +237,8 @@
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch
|
||||
[ngModel]="metadataPersistence.sidecarSettings?.includeCoverFile"
|
||||
(onChange)="onSidecarToggle('includeCoverFile')">
|
||||
(onChange)="onSidecarToggle('includeCoverFile')"
|
||||
[disabled]="isNetworkStorage">
|
||||
</p-toggleswitch>
|
||||
<label class="setting-label">{{ t('includeCover') }}</label>
|
||||
</div>
|
||||
|
||||
+5
@@ -62,6 +62,11 @@
|
||||
@include settings.settings-filesize-input;
|
||||
}
|
||||
|
||||
.network-disabled {
|
||||
opacity: 0.5;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.sidecar-section-header {
|
||||
margin-top: 1.5rem;
|
||||
padding-top: 1.5rem;
|
||||
|
||||
+4
-4
@@ -4,10 +4,8 @@ import {FormsModule} from '@angular/forms';
|
||||
import {AppSettingKey, AppSettings, MetadataPersistenceSettings, SaveToOriginalFileSettings, SidecarSettings} 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';
|
||||
import {AsyncPipe} from '@angular/common';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
@@ -16,7 +14,6 @@ import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
ToggleSwitch,
|
||||
FormsModule,
|
||||
Tooltip,
|
||||
AsyncPipe,
|
||||
TranslocoDirective
|
||||
],
|
||||
templateUrl: './metadata-persistence-settings-component.html',
|
||||
@@ -53,11 +50,13 @@ export class MetadataPersistenceSettingsComponent implements OnInit {
|
||||
}
|
||||
};
|
||||
|
||||
isNetworkStorage = false;
|
||||
|
||||
private readonly appSettingsService = inject(AppSettingsService);
|
||||
private readonly settingsHelper = inject(SettingsHelperService);
|
||||
private t = inject(TranslocoService);
|
||||
|
||||
readonly appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
|
||||
private readonly appSettings$ = this.appSettingsService.appSettings$;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.loadSettings();
|
||||
@@ -101,6 +100,7 @@ export class MetadataPersistenceSettingsComponent implements OnInit {
|
||||
}
|
||||
|
||||
private initializeSettings(settings: AppSettings): void {
|
||||
this.isNetworkStorage = settings.diskType !== 'LOCAL';
|
||||
if (settings.metadataPersistenceSettings) {
|
||||
const persistenceSettings = settings.metadataPersistenceSettings;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user