refactor(frontend): rename booklore-ui to frontend
- Frontend path: - rename the tracked Angular app tree from `booklore-ui/` to `frontend/` - preserve file contents during the move so this commit stays focused on the path change itself - Frontend docs: - update the moved frontend README and contribution guide where they refer to the renamed folder - keep those edits limited to path references introduced by the directory rename
This commit is contained in:
+436
@@ -0,0 +1,436 @@
|
||||
<ng-container *transloco="let t; prefix: 'settingsNaming'">
|
||||
<div class="file-naming-container">
|
||||
<div class="settings-header">
|
||||
<h2 class="settings-title">
|
||||
<i class="pi pi-file"></i>
|
||||
{{ t('title') }}
|
||||
<app-external-doc-link docType="fileNamePatterns"></app-external-doc-link>
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
{{ t('description') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="warning-notice">
|
||||
<i class="pi pi-exclamation-triangle"></i>
|
||||
<div>
|
||||
<strong>{{ t('warning.title') }}</strong> {{ t('warning.text') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-bolt"></i>
|
||||
{{ t('defaultPattern.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">{{ t('defaultPattern.sectionDesc') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
<div class="default-pattern-card">
|
||||
<div class="pattern-input-container">
|
||||
<div class="pattern-input-row">
|
||||
<input
|
||||
pInputText
|
||||
id="defaultPattern"
|
||||
[(ngModel)]="defaultPattern"
|
||||
[placeholder]="t('defaultPattern.placeholder')"
|
||||
(input)="onDefaultPatternChange(defaultPattern)"
|
||||
class="pattern-input"/>
|
||||
<p-button
|
||||
[label]="'common.save' | transloco"
|
||||
icon="pi pi-save"
|
||||
(onClick)="savePatterns()"
|
||||
severity="success"
|
||||
[outlined]="true"
|
||||
[disabled]="!!defaultErrorMessage">
|
||||
</p-button>
|
||||
</div>
|
||||
@if (defaultErrorMessage) {
|
||||
<span class="error-text">{{ defaultErrorMessage }}</span>
|
||||
}
|
||||
<div class="preview-row">
|
||||
<span class="preview-label">
|
||||
<i class="pi pi-eye"></i>
|
||||
{{ t('defaultPattern.preview') }}
|
||||
</span>
|
||||
<code class="preview-value">{{ generateDefaultPreview() }}</code>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-folder"></i>
|
||||
{{ t('libraryOverrides.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('libraryOverrides.sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
@if (libraries.length === 0) {
|
||||
<div class="empty-state">
|
||||
<i class="pi pi-folder-open"></i>
|
||||
<p class="empty-title">{{ t('libraryOverrides.emptyTitle') }}</p>
|
||||
<p class="empty-subtitle">{{ t('libraryOverrides.emptySubtitle') }}</p>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="libraries-list">
|
||||
@for (library of libraries; track library.id) {
|
||||
<div class="library-item" [class.has-pattern]="library.fileNamingPattern">
|
||||
<div class="library-header">
|
||||
<div class="library-info">
|
||||
<div class="library-icon">
|
||||
<i [class]="'pi pi-' + library.icon"></i>
|
||||
</div>
|
||||
<span class="library-name">{{ library.name }}</span>
|
||||
@if (library.fileNamingPattern) {
|
||||
<span class="custom-badge">{{ t('libraryOverrides.custom') }}</span>
|
||||
} @else {
|
||||
<span class="default-badge">{{ t('libraryOverrides.usingDefault') }}</span>
|
||||
}
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
severity="secondary"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[rounded]="true"
|
||||
(onClick)="clearLibraryPattern(library)"
|
||||
[disabled]="!library.fileNamingPattern"
|
||||
[pTooltip]="t('libraryOverrides.clearPattern')">
|
||||
</p-button>
|
||||
</div>
|
||||
<div class="library-body">
|
||||
<div class="pattern-input-container">
|
||||
<input
|
||||
pInputText
|
||||
[(ngModel)]="library.fileNamingPattern"
|
||||
[placeholder]="t('libraryOverrides.placeholder')"
|
||||
(input)="onLibraryPatternChange(library)"
|
||||
class="pattern-input"/>
|
||||
<div class="preview-row">
|
||||
<span class="preview-label">
|
||||
<i class="pi pi-eye"></i>
|
||||
{{ t('libraryOverrides.preview') }}
|
||||
</span>
|
||||
<code class="preview-value">{{ generateLibraryPreview(library) }}</code>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="actions-row">
|
||||
<p-button
|
||||
[label]="t('libraryOverrides.saveAll')"
|
||||
(onClick)="saveLibraryPatterns()"
|
||||
severity="success"
|
||||
icon="pi pi-save"
|
||||
[outlined]="true">
|
||||
</p-button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
{{ t('placeholders.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('placeholders.sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
<div class="placeholders-grid">
|
||||
<div class="placeholder-group">
|
||||
<h4 class="group-title">
|
||||
<i class="pi pi-hashtag"></i>
|
||||
{{ t('placeholders.available') }}
|
||||
</h4>
|
||||
<div class="placeholder-list">
|
||||
<div class="placeholder-item"><code>{{ '{title}' }}</code><span>{{ t('placeholders.title') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{subtitle}' }}</code><span>{{ t('placeholders.subtitle') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{authors}' }}</code><span>{{ t('placeholders.authors') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{year}' }}</code><span>{{ t('placeholders.year') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{series}' }}</code><span>{{ t('placeholders.series') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{seriesIndex}' }}</code><span>{{ t('placeholders.seriesIndex') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{language}' }}</code><span>{{ t('placeholders.language') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{publisher}' }}</code><span>{{ t('placeholders.publisher') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{isbn}' }}</code><span>{{ t('placeholders.isbn') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{currentFilename}' }}</code><span>{{ t('placeholders.currentFilename') }}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="placeholder-group">
|
||||
<h4 class="group-title">
|
||||
<i class="pi pi-code"></i>
|
||||
{{ t('placeholders.optionalBlocks') }}
|
||||
</h4>
|
||||
<p class="group-description" [innerHTML]="t('placeholders.optionalDesc', { syntax: '{<...>}' })">
|
||||
</p>
|
||||
<div class="example-block">
|
||||
<div class="example-pattern">
|
||||
<span class="pattern-prefix">{{ t('placeholders.pattern') }}</span>
|
||||
<code>{{ '{<{seriesIndex} - >{title}' }}</code>
|
||||
</div>
|
||||
<div class="example-results">
|
||||
<div class="result-item">
|
||||
<span class="result-prefix">{{ t('placeholders.withIndex') }}</span>
|
||||
<code>01 - Dune</code>
|
||||
</div>
|
||||
<div class="result-item">
|
||||
<span class="result-prefix">{{ t('placeholders.without') }}</span>
|
||||
<code>Dune</code>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="placeholder-group">
|
||||
<h4 class="group-title">
|
||||
<i class="pi pi-replay"></i>
|
||||
{{ t('placeholders.elseClause') }}
|
||||
</h4>
|
||||
<p class="group-description" [innerHTML]="t('placeholders.elseDesc')">
|
||||
</p>
|
||||
<div class="example-block">
|
||||
<div class="example-pattern">
|
||||
<span class="pattern-prefix">{{ t('placeholders.pattern') }}</span>
|
||||
<code>{{ '{<{series}|Standalone>/{title}' }}</code>
|
||||
</div>
|
||||
<div class="example-results">
|
||||
<div class="result-item">
|
||||
<span class="result-prefix">{{ t('placeholders.withSeries') }}</span>
|
||||
<code>The Kingkiller Chronicle/The Name of the Wind</code>
|
||||
</div>
|
||||
<div class="result-item">
|
||||
<span class="result-prefix">{{ t('placeholders.withoutSeries') }}</span>
|
||||
<code>Standalone/The Name of the Wind</code>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="placeholder-group">
|
||||
<h4 class="group-title">
|
||||
<i class="pi pi-wrench"></i>
|
||||
{{ t('placeholders.modifiers') }}
|
||||
</h4>
|
||||
<p class="group-description" [innerHTML]="t('placeholders.modifiersDesc')">
|
||||
</p>
|
||||
<div class="placeholder-list">
|
||||
<div class="placeholder-item"><code>{{ '{authors:first}' }}</code><span>{{ t('placeholders.modFirst') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{authors:sort}' }}</code><span>{{ t('placeholders.modSort') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{title:initial}' }}</code><span>{{ t('placeholders.modInitial') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{title:upper}' }}</code><span>{{ t('placeholders.modUpper') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{title:lower}' }}</code><span>{{ t('placeholders.modLower') }}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-eye"></i>
|
||||
{{ t('examples.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('examples.sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
<div class="examples-container">
|
||||
<div class="metadata-reference">
|
||||
<div class="metadata-panel metadata-panel-full">
|
||||
<div class="metadata-panel-header">
|
||||
<i class="pi pi-check-circle metadata-icon-full"></i>
|
||||
<span>{{ t('examples.fullMetadata') }}</span>
|
||||
</div>
|
||||
<div class="metadata-grid">
|
||||
<span class="metadata-key">title</span><code class="metadata-val">The Name of the Wind</code>
|
||||
<span class="metadata-key">subtitle</span><code class="metadata-val">Special Edition</code>
|
||||
<span class="metadata-key">authors</span><code class="metadata-val">Patrick Rothfuss</code>
|
||||
<span class="metadata-key">series</span><code class="metadata-val">The Kingkiller Chronicle</code>
|
||||
<span class="metadata-key">seriesIndex</span><code class="metadata-val">01</code>
|
||||
<span class="metadata-key">year</span><code class="metadata-val">2007</code>
|
||||
</div>
|
||||
</div>
|
||||
<div class="metadata-panel metadata-panel-partial">
|
||||
<div class="metadata-panel-header">
|
||||
<i class="pi pi-question-circle metadata-icon-partial"></i>
|
||||
<span>{{ t('examples.partialMetadata') }}</span>
|
||||
</div>
|
||||
<div class="metadata-grid">
|
||||
<span class="metadata-key">title</span><code class="metadata-val">Project Hail Mary</code>
|
||||
<span class="metadata-key">subtitle</span><em class="metadata-val not-set">{{ t('examples.notSet') }}</em>
|
||||
<span class="metadata-key">authors</span><code class="metadata-val">Andy Weir</code>
|
||||
<span class="metadata-key">year</span><code class="metadata-val">2021</code>
|
||||
<span class="metadata-key">series</span><em class="metadata-val not-set">{{ t('examples.notSet') }}</em>
|
||||
<span class="metadata-key">seriesIndex</span><em class="metadata-val not-set">{{ t('examples.notSet') }}</em>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="example-category">
|
||||
<h4 class="category-title">
|
||||
<i class="pi pi-hashtag"></i>
|
||||
{{ t('examples.basicGroup') }}
|
||||
</h4>
|
||||
<div class="example-grid">
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.basicPattern') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors} - {title}' }}</code></span>
|
||||
<span class="result-col"><code>Patrick Rothfuss - The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.seriesInFolder') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors}/{series}/{seriesIndex} - {title}' }}</code></span>
|
||||
<span class="result-col"><code>Patrick Rothfuss/The Kingkiller Chronicle/01 - The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.titleSubtitle') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title}: {subtitle}' }}</code></span>
|
||||
<span class="result-col"><code>The Name of the Wind: Special Edition.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.absolutePath') }}</span>
|
||||
<span class="pattern-col"><code>{{ '/{authors}/{title}' }}</code></span>
|
||||
<span class="result-col"><code>/Patrick Rothfuss/The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.folderOnly') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title}/' }}</code></span>
|
||||
<span class="result-col"><code>The Name of the Wind/name_of_the_wind_original.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.yearPrefix') }}</span>
|
||||
<span class="pattern-col"><code>{{ '({year}) {title}' }}</code></span>
|
||||
<span class="result-col"><code>(2007) The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section-divider"><hr></div>
|
||||
|
||||
<div class="example-category">
|
||||
<h4 class="category-title">
|
||||
<i class="pi pi-code"></i>
|
||||
{{ t('examples.conditionalGroup') }}
|
||||
</h4>
|
||||
<div class="example-grid">
|
||||
<div class="example-row-conditional">
|
||||
<span class="pattern-label">{{ t('examples.optionalBlock') }}</span>
|
||||
<span class="pattern-col"><code>{{ '<{seriesIndex}. >{title}' }}</code></span>
|
||||
<div class="result-col-dual">
|
||||
<span class="result-with"><i class="pi pi-check-circle"></i> <code>01. The Name of the Wind.epub</code></span>
|
||||
<span class="result-without"><i class="pi pi-question-circle"></i> <code>Project Hail Mary.epub</code></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="example-row-conditional">
|
||||
<span class="pattern-label">{{ t('examples.subtitleConditional') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title}<: {subtitle}>' }}</code></span>
|
||||
<div class="result-col-dual">
|
||||
<span class="result-with"><i class="pi pi-check-circle"></i> <code>The Name of the Wind: Special Edition.epub</code></span>
|
||||
<span class="result-without"><i class="pi pi-question-circle"></i> <code>Project Hail Mary.epub</code></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="example-row-conditional">
|
||||
<span class="pattern-label">{{ t('examples.multipleOptional') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors}/<{series}/><{seriesIndex}. >{title}< ({year})>' }}</code></span>
|
||||
<div class="result-col-dual">
|
||||
<span class="result-with"><i class="pi pi-check-circle"></i> <code>Patrick Rothfuss/The Kingkiller Chronicle/01. The Name of the Wind (2007).epub</code></span>
|
||||
<span class="result-without"><i class="pi pi-question-circle"></i> <code>Andy Weir/Project Hail Mary (2021).epub</code></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="example-row-conditional">
|
||||
<span class="pattern-label">{{ t('examples.elseClause') }}</span>
|
||||
<span class="pattern-col"><code>{{ '<{series}|Standalone>/{title}' }}</code></span>
|
||||
<div class="result-col-dual">
|
||||
<span class="result-with"><i class="pi pi-check-circle"></i> <code>The Kingkiller Chronicle/The Name of the Wind.epub</code></span>
|
||||
<span class="result-without"><i class="pi pi-question-circle"></i> <code>Standalone/Project Hail Mary.epub</code></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="example-row-conditional">
|
||||
<span class="pattern-label">{{ t('examples.elseClauseFallback') }}</span>
|
||||
<span class="pattern-col"><code>{{ '<{series}/{seriesIndex} - {title}|{title}>' }}</code></span>
|
||||
<div class="result-col-dual">
|
||||
<span class="result-with"><i class="pi pi-check-circle"></i> <code>The Kingkiller Chronicle/01 - The Name of the Wind.epub</code></span>
|
||||
<span class="result-without"><i class="pi pi-question-circle"></i> <code>Project Hail Mary.epub</code></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="example-row-conditional">
|
||||
<span class="pattern-label">{{ t('examples.elseWithModifier') }}</span>
|
||||
<span class="pattern-col"><code>{{ '<{series}|{authors:sort}>/{title}' }}</code></span>
|
||||
<div class="result-col-dual">
|
||||
<span class="result-with"><i class="pi pi-check-circle"></i> <code>The Kingkiller Chronicle/The Name of the Wind.epub</code></span>
|
||||
<span class="result-without"><i class="pi pi-question-circle"></i> <code>Weir, Andy/Project Hail Mary.epub</code></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section-divider"><hr></div>
|
||||
|
||||
<div class="example-category">
|
||||
<h4 class="category-title">
|
||||
<i class="pi pi-wrench"></i>
|
||||
{{ t('examples.modifiersGroup') }}
|
||||
</h4>
|
||||
<div class="example-grid">
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.modifierSort') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors:sort}/{title}' }}</code></span>
|
||||
<span class="result-col"><code>Rothfuss, Patrick/The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.modifierInitial') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors:initial}/{authors:sort}/{title}' }}</code></span>
|
||||
<span class="result-col"><code>R/Rothfuss, Patrick/The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.modFirst') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors:first}/{title}' }}</code></span>
|
||||
<span class="result-col"><code>Patrick Rothfuss/The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.modUpper') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title:upper}' }}</code></span>
|
||||
<span class="result-col"><code>THE NAME OF THE WIND.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.modLower') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title:lower}' }}</code></span>
|
||||
<span class="result-col"><code>the name of the wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.letterFolder') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title:initial}/{authors}/{title}' }}</code></span>
|
||||
<span class="result-col"><code>T/Patrick Rothfuss/The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.combinedMods') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors:sort} - {title:lower}' }}</code></span>
|
||||
<span class="result-col"><code>Rothfuss, Patrick - the name of the wind.epub</code></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
+586
@@ -0,0 +1,586 @@
|
||||
@use '../../../shared/styles/settings-shared' as settings;
|
||||
|
||||
.file-naming-container {
|
||||
@include settings.settings-page-container;
|
||||
}
|
||||
|
||||
@include settings.settings-page-header;
|
||||
@include settings.settings-section-divider;
|
||||
|
||||
.settings-title {
|
||||
@include settings.settings-page-title;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.settings-description {
|
||||
@include settings.settings-page-description;
|
||||
}
|
||||
|
||||
.warning-notice {
|
||||
margin-top: -2rem;
|
||||
margin-bottom: 1rem;
|
||||
@include settings.settings-warning-notice;
|
||||
}
|
||||
|
||||
.settings-card {
|
||||
@include settings.settings-card;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
@include settings.settings-section-header;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
@include settings.settings-section-title;
|
||||
}
|
||||
|
||||
.section-description {
|
||||
@include settings.settings-section-description;
|
||||
}
|
||||
|
||||
.section-body {
|
||||
@include settings.settings-section-body;
|
||||
}
|
||||
|
||||
// Empty state
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 3rem 2rem;
|
||||
text-align: center;
|
||||
color: var(--p-text-muted-color);
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
border-radius: 6px;
|
||||
|
||||
.pi {
|
||||
font-size: 2.5rem;
|
||||
margin-bottom: 1rem;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.empty-title {
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
margin: 0 0 0.5rem 0;
|
||||
color: var(--p-text-color);
|
||||
}
|
||||
|
||||
.empty-subtitle {
|
||||
font-size: settings.$settings-section-description-size;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Default pattern card
|
||||
.default-pattern-card {
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-left: 3px solid var(--p-primary-color);
|
||||
border-radius: 6px;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.pattern-input-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.pattern-input-row {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
align-items: flex-start;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
p-button {
|
||||
align-self: flex-end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pattern-input {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.error-text {
|
||||
@include settings.settings-error-text;
|
||||
}
|
||||
|
||||
.preview-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-top: 0.25rem;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.preview-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
color: var(--p-text-muted-color);
|
||||
font-size: settings.$settings-section-description-size;
|
||||
white-space: nowrap;
|
||||
|
||||
.pi {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.preview-value {
|
||||
color: var(--p-green-400);
|
||||
font-size: settings.$settings-section-description-size;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
// Libraries list
|
||||
.libraries-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.library-item {
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-left: 3px solid var(--p-content-border-color);
|
||||
border-radius: 6px;
|
||||
transition: border-color 0.2s ease, background 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: color-mix(in srgb, var(--ground-background) 40%, var(--p-surface-800) 60%);
|
||||
}
|
||||
|
||||
&.has-pattern {
|
||||
border-left-color: var(--p-primary-color);
|
||||
}
|
||||
}
|
||||
|
||||
.library-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: 0.75rem 1rem;
|
||||
border-bottom: 1px dashed var(--p-content-border-color);
|
||||
|
||||
@media (max-width: 600px) {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
.library-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.library-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background: color-mix(in srgb, var(--p-primary-color) 15%, transparent);
|
||||
color: var(--p-primary-color);
|
||||
border-radius: 6px;
|
||||
flex-shrink: 0;
|
||||
|
||||
.pi {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
|
||||
.library-name {
|
||||
font-weight: 600;
|
||||
font-size: 0.9375rem;
|
||||
color: var(--p-text-color);
|
||||
}
|
||||
|
||||
.custom-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 0.125rem 0.5rem;
|
||||
background: color-mix(in srgb, var(--p-primary-color) 15%, transparent);
|
||||
color: var(--p-primary-color);
|
||||
border-radius: 12px;
|
||||
font-size: 0.625rem;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.default-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 0.125rem 0.5rem;
|
||||
background: color-mix(in srgb, #6b7280 15%, transparent);
|
||||
color: #6b7280;
|
||||
border-radius: 12px;
|
||||
font-size: 0.625rem;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.library-body {
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.actions-row {
|
||||
@include settings.settings-actions-row;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
// Placeholders Reference Section
|
||||
.placeholders-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 1rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.placeholder-group {
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
border-radius: 6px;
|
||||
padding: 1rem;
|
||||
border-left: 3px solid var(--p-primary-color);
|
||||
|
||||
@media (max-width: 768px) {
|
||||
padding: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.group-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: settings.$settings-label-size;
|
||||
font-weight: 600;
|
||||
color: var(--p-text-color);
|
||||
margin: 0 0 0.75rem 0;
|
||||
|
||||
.pi {
|
||||
color: var(--p-primary-color);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
|
||||
.group-description {
|
||||
font-size: settings.$settings-section-description-size;
|
||||
line-height: 1.5;
|
||||
color: var(--p-text-muted-color);
|
||||
margin: 0 0 0.75rem 0;
|
||||
|
||||
code {
|
||||
color: var(--p-orange-400);
|
||||
font-size: settings.$settings-description-size;
|
||||
}
|
||||
}
|
||||
|
||||
.placeholder-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
|
||||
.placeholder-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
font-size: settings.$settings-section-description-size;
|
||||
|
||||
code {
|
||||
color: var(--p-orange-400);
|
||||
font-size: settings.$settings-description-size;
|
||||
min-width: 130px;
|
||||
}
|
||||
|
||||
span {
|
||||
color: var(--p-text-muted-color);
|
||||
}
|
||||
}
|
||||
|
||||
.example-block {
|
||||
background: color-mix(in srgb, var(--p-surface-800) 30%, transparent);
|
||||
border-radius: 4px;
|
||||
padding: 0.75rem;
|
||||
}
|
||||
|
||||
.example-pattern {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
|
||||
.pattern-prefix {
|
||||
font-size: settings.$settings-description-size;
|
||||
color: var(--p-text-muted-color);
|
||||
}
|
||||
|
||||
code {
|
||||
color: var(--p-orange-400);
|
||||
font-size: settings.$settings-section-description-size;
|
||||
}
|
||||
}
|
||||
|
||||
.example-results {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.result-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: settings.$settings-section-description-size;
|
||||
|
||||
.result-prefix {
|
||||
font-size: settings.$settings-description-size;
|
||||
color: var(--p-text-muted-color);
|
||||
min-width: 70px;
|
||||
}
|
||||
|
||||
code {
|
||||
color: var(--p-green-400);
|
||||
font-size: settings.$settings-description-size;
|
||||
}
|
||||
}
|
||||
|
||||
// Pattern Examples Section
|
||||
.examples-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.metadata-reference {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.metadata-panel {
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
padding: 1rem 1.25rem;
|
||||
border-radius: 6px;
|
||||
border-left: 3px solid var(--p-content-border-color);
|
||||
|
||||
&.metadata-panel-full {
|
||||
border-left-color: var(--p-green-400);
|
||||
}
|
||||
|
||||
&.metadata-panel-partial {
|
||||
border-left-color: var(--p-orange-400);
|
||||
}
|
||||
}
|
||||
|
||||
.metadata-panel-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: settings.$settings-label-size;
|
||||
font-weight: 600;
|
||||
color: var(--p-text-color);
|
||||
margin-bottom: 0.875rem;
|
||||
padding-bottom: 0.625rem;
|
||||
border-bottom: 1px solid color-mix(in srgb, var(--p-content-border-color) 50%, transparent);
|
||||
|
||||
.pi {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
|
||||
.metadata-icon-full {
|
||||
color: var(--p-green-400);
|
||||
}
|
||||
|
||||
.metadata-icon-partial {
|
||||
color: var(--p-orange-400);
|
||||
}
|
||||
|
||||
.metadata-grid {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: 0.5rem 0.75rem;
|
||||
font-size: settings.$settings-section-description-size;
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.metadata-key {
|
||||
color: var(--p-text-muted-color);
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
|
||||
&::after {
|
||||
content: ':';
|
||||
}
|
||||
}
|
||||
|
||||
.metadata-val {
|
||||
color: var(--p-text-color);
|
||||
font-size: settings.$settings-description-size;
|
||||
|
||||
&.not-set {
|
||||
opacity: 0.5;
|
||||
font-style: italic;
|
||||
color: var(--p-text-muted-color);
|
||||
}
|
||||
}
|
||||
|
||||
.example-category {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.category-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: settings.$settings-label-size;
|
||||
font-weight: 600;
|
||||
color: var(--p-text-color);
|
||||
margin: 0;
|
||||
|
||||
.pi {
|
||||
font-size: 0.875rem;
|
||||
color: var(--p-primary-color);
|
||||
}
|
||||
}
|
||||
|
||||
.example-grid {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.example-row {
|
||||
display: grid;
|
||||
grid-template-columns: 130px 1fr 1fr;
|
||||
gap: 0.75rem;
|
||||
padding: 0.625rem 0.75rem;
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
border-radius: 4px;
|
||||
font-size: settings.$settings-section-description-size;
|
||||
align-items: center;
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
}
|
||||
|
||||
.example-row-conditional {
|
||||
display: grid;
|
||||
grid-template-columns: 130px 1fr 1fr;
|
||||
gap: 0.75rem;
|
||||
padding: 0.625rem 0.75rem;
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
border-radius: 4px;
|
||||
font-size: settings.$settings-section-description-size;
|
||||
align-items: start;
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
}
|
||||
|
||||
.pattern-label {
|
||||
color: var(--p-text-muted-color);
|
||||
font-size: settings.$settings-section-description-size;
|
||||
white-space: nowrap;
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
font-weight: 500;
|
||||
color: var(--p-text-color);
|
||||
}
|
||||
}
|
||||
|
||||
.pattern-col {
|
||||
code {
|
||||
color: var(--p-orange-400);
|
||||
font-size: settings.$settings-description-size;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
padding-left: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.result-col {
|
||||
code {
|
||||
color: var(--p-green-400);
|
||||
font-size: settings.$settings-description-size;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
padding-left: 0.5rem;
|
||||
border-left: 2px solid var(--p-green-400);
|
||||
}
|
||||
}
|
||||
|
||||
.result-col-dual {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.375rem;
|
||||
|
||||
code {
|
||||
font-size: settings.$settings-description-size;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.pi {
|
||||
font-size: 0.625rem;
|
||||
margin-right: 0.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.result-with {
|
||||
color: var(--p-green-400);
|
||||
|
||||
.pi {
|
||||
color: var(--p-green-400);
|
||||
}
|
||||
|
||||
code {
|
||||
color: var(--p-green-400);
|
||||
}
|
||||
}
|
||||
|
||||
.result-without {
|
||||
color: var(--p-orange-400);
|
||||
|
||||
.pi {
|
||||
color: var(--p-orange-400);
|
||||
}
|
||||
|
||||
code {
|
||||
color: var(--p-orange-400);
|
||||
}
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Button} from 'primeng/button';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {AppSettingsService} from '../../../shared/service/app-settings.service';
|
||||
import {forkJoin, of} from 'rxjs';
|
||||
import {AppSettingKey} from '../../../shared/model/app-settings.model';
|
||||
import {catchError} from 'rxjs/operators';
|
||||
import {Library} from '../../book/model/library.model';
|
||||
import {LibraryService} from '../../book/service/library.service';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
import {replacePlaceholders} from '../../../shared/util/pattern-resolver';
|
||||
|
||||
@Component({
|
||||
selector: 'app-file-naming-pattern',
|
||||
templateUrl: './file-naming-pattern.component.html',
|
||||
standalone: true,
|
||||
imports: [FormsModule, Button, InputText, Tooltip, ExternalDocLinkComponent, TranslocoDirective, TranslocoPipe],
|
||||
styleUrls: ['./file-naming-pattern.component.scss'],
|
||||
})
|
||||
export class FileNamingPatternComponent implements OnInit {
|
||||
readonly exampleMetadata: Record<string, string> = {
|
||||
title: "The Name of the Wind",
|
||||
subtitle: "Special Edition",
|
||||
authors: "Patrick Rothfuss",
|
||||
year: "2007",
|
||||
series: "The Kingkiller Chronicle",
|
||||
seriesIndex: "01",
|
||||
language: "English",
|
||||
publisher: "DAW Books",
|
||||
isbn: "9780756404741",
|
||||
};
|
||||
|
||||
defaultPattern = '';
|
||||
defaultErrorMessage = '';
|
||||
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private messageService = inject(MessageService);
|
||||
private libraryService = inject(LibraryService);
|
||||
private t = inject(TranslocoService);
|
||||
|
||||
ngOnInit(): void {
|
||||
const settings = this.appSettingsService.appSettings();
|
||||
if (settings) {
|
||||
this.defaultPattern = settings.uploadPattern ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
get libraries(): Library[] {
|
||||
return this.libraryService.libraries();
|
||||
}
|
||||
|
||||
private resolvePattern(pattern: string, values: Record<string, string>): string {
|
||||
return replacePlaceholders(pattern, values);
|
||||
}
|
||||
|
||||
private appendExtensionIfMissing(path: string, ext = '.pdf'): string {
|
||||
const lastSegment = path.split('/').pop() ?? '';
|
||||
const hasExtension = /\.[a-z0-9]{2,5}$/i.test(lastSegment);
|
||||
return hasExtension ? path : path + ext;
|
||||
}
|
||||
|
||||
private generatePreview(pattern: string): string {
|
||||
let path = this.resolvePattern(pattern || '', this.exampleMetadata);
|
||||
|
||||
if (!path) return '/original_filename.pdf';
|
||||
if (path.endsWith('/')) return path + 'original_filename.pdf';
|
||||
if (path.includes('{originalFilename}')) {
|
||||
path = path.replace('{originalFilename}', 'original_filename.pdf');
|
||||
return path.startsWith('/') ? path : `/${path}`;
|
||||
}
|
||||
path = this.appendExtensionIfMissing(path);
|
||||
return path.startsWith('/') ? path : `/${path}`;
|
||||
}
|
||||
|
||||
generateDefaultPreview(): string {
|
||||
return this.generatePreview(this.defaultPattern);
|
||||
}
|
||||
|
||||
generateLibraryPreview(library: Library): string {
|
||||
return this.generatePreview(library.fileNamingPattern || this.defaultPattern);
|
||||
}
|
||||
|
||||
validatePattern(pattern: string): boolean {
|
||||
const validPatternRegex = /^[\w\s\-{}[/().<>.,:'"#|\]]*$/;
|
||||
return validPatternRegex.test(pattern);
|
||||
}
|
||||
|
||||
onDefaultPatternChange(pattern: string): void {
|
||||
this.defaultPattern = pattern;
|
||||
this.defaultErrorMessage = this.validatePattern(pattern) ? '' : this.t.translate('settingsNaming.defaultPattern.invalidChars');
|
||||
}
|
||||
|
||||
onLibraryPatternChange(_library: Library): void {
|
||||
// Optionally add per-library validation here
|
||||
}
|
||||
|
||||
clearLibraryPattern(library: Library): void {
|
||||
library.fileNamingPattern = '';
|
||||
}
|
||||
|
||||
savePatterns(): void {
|
||||
if (this.defaultErrorMessage) {
|
||||
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsNaming.defaultPattern.invalidError'));
|
||||
return;
|
||||
}
|
||||
this.appSettingsService
|
||||
.saveSettings([
|
||||
{key: AppSettingKey.UPLOAD_FILE_PATTERN, newValue: this.defaultPattern},
|
||||
])
|
||||
.subscribe({
|
||||
next: () => this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsNaming.defaultPattern.saveSuccess')),
|
||||
error: () => this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsNaming.defaultPattern.saveError')),
|
||||
});
|
||||
}
|
||||
|
||||
saveLibraryPatterns(): void {
|
||||
const patchRequests = this.libraries.map(library =>
|
||||
this.libraryService.updateLibraryFileNamingPattern(library.id!, library.fileNamingPattern || '').pipe(
|
||||
catchError(() => of(null))
|
||||
)
|
||||
);
|
||||
forkJoin(patchRequests).subscribe(results => {
|
||||
const failures = results.filter(result => result === null);
|
||||
if (failures.length === 0) {
|
||||
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsNaming.libraryOverrides.saveSuccess'));
|
||||
} else {
|
||||
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsNaming.libraryOverrides.saveError', {count: failures.length}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private showMessage(severity: 'success' | 'error', summary: string, detail: string): void {
|
||||
this.messageService.add({severity, summary, detail});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user