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:
@@ -0,0 +1,295 @@
|
||||
<ng-container *transloco="let t; prefix: 'libraryCreator.creator'">
|
||||
<div class="library-creator">
|
||||
<header class="dialog-header">
|
||||
<div class="header-content">
|
||||
<div class="header-icon">
|
||||
<i class="pi pi-book"></i>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h1>{{ mode === 'edit' ? t('titleEdit') : t('titleNew') }}</h1>
|
||||
<p>{{ t('subtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
[text]="true"
|
||||
[rounded]="true"
|
||||
severity="secondary"
|
||||
(onClick)="closeDialog()"
|
||||
/>
|
||||
</header>
|
||||
|
||||
<div class="dialog-body">
|
||||
<section class="form-section">
|
||||
<div class="section-header">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
<span>{{ t('libraryDetails') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="form-row two-col">
|
||||
<div class="form-field">
|
||||
<label>
|
||||
{{ t('nameLabel') }} <span class="required">*</span>
|
||||
</label>
|
||||
<div class="input-container">
|
||||
<input
|
||||
pInputText
|
||||
[(ngModel)]="chosenLibraryName"
|
||||
[placeholder]="t('namePlaceholder')"
|
||||
class="input-full"
|
||||
/>
|
||||
@if (chosenLibraryName.trim()) {
|
||||
<i class="pi pi-check-circle field-status success"></i>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label>
|
||||
{{ t('iconLabel') }}
|
||||
</label>
|
||||
@if (!selectedIcon) {
|
||||
<button class="icon-picker-trigger" (click)="openIconPicker()" type="button">
|
||||
<i class="pi pi-plus"></i>
|
||||
<span>{{ t('chooseIcon') }}</span>
|
||||
</button>
|
||||
} @else {
|
||||
<div class="icon-selected">
|
||||
<div class="icon-preview">
|
||||
<app-icon-display [icon]="selectedIcon" size="16px" />
|
||||
</div>
|
||||
<span class="icon-value">
|
||||
@if (selectedIcon.type === 'PRIME_NG') {
|
||||
{{ selectedIcon.value }}
|
||||
} @else {
|
||||
{{ t('customSvg') }}
|
||||
}
|
||||
</span>
|
||||
<button class="icon-clear" (click)="clearSelectedIcon()" type="button">
|
||||
<i class="pi pi-times"></i>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="form-section">
|
||||
<div class="section-header">
|
||||
<i class="pi pi-folder-open"></i>
|
||||
<span>{{ t('bookFolders') }}</span>
|
||||
<span class="section-badge">{{ folders.length }}</span>
|
||||
</div>
|
||||
|
||||
<div class="folders-zone">
|
||||
<div class="folder-structure-hint">
|
||||
<i class="pi pi-exclamation-triangle"></i>
|
||||
<span [innerHTML]="t('folderStructureHint')"></span>
|
||||
</div>
|
||||
|
||||
<button class="add-folder-trigger" (click)="openDirectoryPicker()" type="button">
|
||||
<i class="pi pi-plus-circle"></i>
|
||||
<span>{{ t('addFolder') }}</span>
|
||||
</button>
|
||||
|
||||
@if (folders.length > 0) {
|
||||
<div class="folders-list">
|
||||
@for (folder of folders; track folder; let i = $index) {
|
||||
<div class="folder-item">
|
||||
<div class="folder-info">
|
||||
<i class="pi pi-folder"></i>
|
||||
<span class="folder-path" [pTooltip]="folder" tooltipPosition="top">
|
||||
{{ folder }}
|
||||
</span>
|
||||
</div>
|
||||
<button class="folder-remove" (click)="removeFolder(i)" type="button">
|
||||
<i class="pi pi-times"></i>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="form-section">
|
||||
<div class="section-header">
|
||||
<i class="pi pi-cog"></i>
|
||||
<span>{{ t('options') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="options-list">
|
||||
<div class="option-row">
|
||||
<div class="option-label">
|
||||
<span>{{ t('watchFolders') }}</span>
|
||||
<i
|
||||
class="pi pi-question-circle info-icon"
|
||||
[pTooltip]="t('watchFoldersTooltip')"
|
||||
tooltipPosition="top"
|
||||
></i>
|
||||
</div>
|
||||
<p-toggleswitch [(ngModel)]="watch" />
|
||||
</div>
|
||||
|
||||
<div class="option-row">
|
||||
<div class="option-label">
|
||||
<span>{{ t('metadataSource') }}</span>
|
||||
<i
|
||||
class="pi pi-question-circle info-icon"
|
||||
[pTooltip]="t('metadataSourceTooltip')"
|
||||
tooltipPosition="top"
|
||||
></i>
|
||||
</div>
|
||||
<p-select
|
||||
[(ngModel)]="metadataSource"
|
||||
[options]="metadataSourceOptions"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
[placeholder]="t('metadataSourcePlaceholder')"
|
||||
class="metadata-source-select"
|
||||
appendTo="body"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="option-row">
|
||||
<div class="option-label">
|
||||
<span>{{ t('organizationMode') }}</span>
|
||||
<i
|
||||
class="pi pi-question-circle info-icon"
|
||||
[pTooltip]="organizationMode === 'AUTO_DETECT' ? t('organizationModeLockedTooltip') : t('organizationModeTooltip')"
|
||||
tooltipPosition="top"
|
||||
></i>
|
||||
</div>
|
||||
<p-select
|
||||
[(ngModel)]="organizationMode"
|
||||
[options]="organizationModeOptions"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
[disabled]="organizationMode === 'AUTO_DETECT'"
|
||||
class="metadata-source-select"
|
||||
appendTo="body"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="option-divider"></div>
|
||||
|
||||
<div class="option-row option-row-stacked">
|
||||
<div class="option-label">
|
||||
<span>{{ t('formatPriority') }}</span>
|
||||
<i
|
||||
class="pi pi-question-circle info-icon"
|
||||
[pTooltip]="t('formatPriorityTooltip')"
|
||||
tooltipPosition="top"
|
||||
></i>
|
||||
</div>
|
||||
<div
|
||||
class="format-chips"
|
||||
cdkDropList
|
||||
cdkDropListOrientation="mixed"
|
||||
[cdkDropListData]="formatPriority"
|
||||
(cdkDropListDropped)="onFormatPriorityDrop($event)"
|
||||
>
|
||||
@for (format of formatPriority; track format.type; let i = $index) {
|
||||
<div class="format-chip" cdkDrag>
|
||||
<span class="chip-rank">{{ i + 1 }}</span>
|
||||
<span class="chip-label">{{ format.type }}</span>
|
||||
<i class="pi pi-arrows-alt drag-indicator" cdkDragHandle></i>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="option-row">
|
||||
<div class="option-label">
|
||||
<span>{{ t('allowedFormats') }}</span>
|
||||
<i
|
||||
class="pi pi-question-circle info-icon"
|
||||
[pTooltip]="t('allowedFormatsTooltip')"
|
||||
tooltipPosition="top"
|
||||
></i>
|
||||
</div>
|
||||
<div class="allow-all-toggle">
|
||||
<p-checkbox
|
||||
[(ngModel)]="allowAllFormats"
|
||||
[binary]="true"
|
||||
inputId="allowAll"
|
||||
(onChange)="onAllowAllFormatsChange()"
|
||||
/>
|
||||
<label for="allowAll" class="allow-all-label">{{ t('allowAll') }}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (!allowAllFormats) {
|
||||
<div class="format-checkboxes">
|
||||
@for (format of allBookFormats; track format.type) {
|
||||
<div class="format-checkbox-item" [class.has-warning]="getFormatWarning(format.type)">
|
||||
<p-checkbox
|
||||
[ngModel]="isFormatSelected(format.type)"
|
||||
[binary]="true"
|
||||
[inputId]="'format-' + format.type"
|
||||
(onChange)="onFormatCheckboxChange(format.type, $event.checked)"
|
||||
/>
|
||||
<label [for]="'format-' + format.type" class="format-checkbox-label">
|
||||
{{ format.label }}
|
||||
</label>
|
||||
@if (getFormatWarning(format.type); as warning) {
|
||||
<i
|
||||
class="pi pi-exclamation-triangle warning-icon"
|
||||
[pTooltip]="warning"
|
||||
tooltipPosition="top"
|
||||
></i>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@if (hasAnyFormatWarning()) {
|
||||
<div class="format-warning-message">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
<span>{{ t('deselectedFormatsWarning') }}</span>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<footer class="dialog-footer">
|
||||
<div class="validation-status">
|
||||
@if (!isLibraryDetailsValid() || !isDirectorySelectionValid()) {
|
||||
<div class="status-message warning">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
<span>
|
||||
@if (!chosenLibraryName.trim()) {
|
||||
{{ t('validation.enterName') }}
|
||||
} @else if (!selectedIcon) {
|
||||
{{ t('validation.selectIcon') }}
|
||||
} @else {
|
||||
{{ t('validation.addFolder') }}
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="status-message ready">
|
||||
<i class="pi pi-check-circle"></i>
|
||||
<span>{{ mode === 'edit' ? t('validation.readyUpdate') : t('validation.readyCreate') }}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="footer-actions">
|
||||
<p-button
|
||||
[label]="'common.cancel' | transloco"
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
(onClick)="closeDialog()"
|
||||
/>
|
||||
<p-button
|
||||
[label]="mode === 'edit' ? t('buttonUpdate') : t('buttonCreate')"
|
||||
[icon]="mode === 'edit' ? 'pi pi-save' : 'pi pi-check'"
|
||||
severity="primary"
|
||||
[disabled]="!isLibraryDetailsValid() || !isDirectorySelectionValid()"
|
||||
(onClick)="createOrUpdateLibrary()"
|
||||
/>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</ng-container>
|
||||
@@ -0,0 +1,704 @@
|
||||
.library-creator {
|
||||
max-width: 90vw;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 90vh;
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
// Header
|
||||
.dialog-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 1.25rem 1.5rem;
|
||||
background: var(--overlay-background);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
|
||||
.header-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.875rem;
|
||||
}
|
||||
|
||||
.header-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
background: var(--primary-color);
|
||||
border-radius: 10px;
|
||||
|
||||
i {
|
||||
font-size: 1.25rem;
|
||||
color: var(--primary-contrast-color);
|
||||
}
|
||||
}
|
||||
|
||||
.header-text {
|
||||
h1 {
|
||||
margin: 0;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0.125rem 0 0;
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-secondary-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Body
|
||||
.dialog-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 1.75rem 2rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: var(--border-color);
|
||||
border-radius: 3px;
|
||||
|
||||
&:hover {
|
||||
background: var(--primary-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sections
|
||||
.form-section {
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.75rem;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.03em;
|
||||
color: var(--text-secondary-color);
|
||||
|
||||
i {
|
||||
font-size: 0.9rem;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.section-badge {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 20px;
|
||||
height: 20px;
|
||||
padding: 0 0.375rem;
|
||||
background: var(--primary-color);
|
||||
color: var(--primary-contrast-color);
|
||||
border-radius: 10px;
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Form Fields
|
||||
.form-row {
|
||||
display: flex;
|
||||
gap: 1.25rem;
|
||||
|
||||
&.two-col {
|
||||
.form-field {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 520px) {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
.form-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
|
||||
label {
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-color);
|
||||
|
||||
.required {
|
||||
color: var(--p-red-400);
|
||||
}
|
||||
}
|
||||
|
||||
.input-container {
|
||||
position: relative;
|
||||
|
||||
.input-full {
|
||||
width: 100%;
|
||||
padding-right: 2.25rem;
|
||||
}
|
||||
|
||||
.field-status {
|
||||
position: absolute;
|
||||
right: 0.75rem;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
font-size: 0.9rem;
|
||||
|
||||
&.success {
|
||||
color: var(--p-green-500);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Icon picker
|
||||
.icon-picker-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
padding: 0.875rem 1rem;
|
||||
background: var(--ground-background);
|
||||
border: 1px dashed var(--border-color);
|
||||
border-radius: 8px;
|
||||
color: var(--text-secondary-color);
|
||||
font-size: 0.875rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--primary-color);
|
||||
color: var(--primary-color);
|
||||
background: var(--overlay-background);
|
||||
}
|
||||
|
||||
i {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
|
||||
.icon-selected {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
padding: 0.625rem 0.875rem;
|
||||
background: var(--ground-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
|
||||
.icon-preview {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
background: var(--primary-color);
|
||||
border-radius: 5px;
|
||||
color: var(--primary-contrast-color);
|
||||
}
|
||||
|
||||
.icon-value {
|
||||
flex: 1;
|
||||
font-size: 0.875rem;
|
||||
font-family: monospace;
|
||||
color: var(--text-color);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.icon-clear {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
color: var(--text-secondary-color);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: rgba(239, 68, 68, 0.15);
|
||||
color: var(--p-red-400);
|
||||
}
|
||||
|
||||
i {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.folder-structure-hint {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
padding: 0.625rem 0.75rem;
|
||||
background: rgba(234, 179, 8, 0.08);
|
||||
border: 1px solid rgba(234, 179, 8, 0.25);
|
||||
border-radius: 6px;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--text-secondary-color);
|
||||
line-height: 1.5;
|
||||
|
||||
i {
|
||||
font-size: 0.9rem;
|
||||
color: rgb(234, 179, 8);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--p-primary-color);
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Folders zone
|
||||
.folders-zone {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
padding: 1.25rem;
|
||||
background: var(--ground-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.add-folder-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
padding: 0.875rem;
|
||||
background: transparent;
|
||||
border: 1px dashed var(--border-color);
|
||||
border-radius: 6px;
|
||||
color: var(--primary-color);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: var(--overlay-background);
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
|
||||
i {
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.folders-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.625rem;
|
||||
max-height: 180px;
|
||||
overflow-y: auto;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: var(--border-color);
|
||||
border-radius: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.folder-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem 0.875rem;
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 6px;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--primary-color);
|
||||
|
||||
.folder-info i {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
}
|
||||
|
||||
.folder-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
min-width: 0;
|
||||
|
||||
i {
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-secondary-color);
|
||||
flex-shrink: 0;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.folder-path {
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-color);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.folder-remove {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
color: var(--text-secondary-color);
|
||||
cursor: pointer;
|
||||
opacity: 0.6;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
background: rgba(239, 68, 68, 0.15);
|
||||
color: var(--p-red-400);
|
||||
}
|
||||
|
||||
i {
|
||||
font-size: 0.6875rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.empty-hint {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
padding: 1rem;
|
||||
color: var(--text-secondary-color);
|
||||
font-size: 0.875rem;
|
||||
|
||||
i {
|
||||
font-size: 0.9rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
// Options section
|
||||
.options-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
padding: 1rem 1.25rem;
|
||||
background: var(--ground-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.option-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
|
||||
p-toggleswitch {
|
||||
--p-toggleswitch-checked-background: var(--p-green-500);
|
||||
--p-toggleswitch-checked-hover-background: var(--p-green-600);
|
||||
}
|
||||
|
||||
&.option-row-stacked {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 0.625rem;
|
||||
}
|
||||
}
|
||||
|
||||
.option-divider {
|
||||
height: 1px;
|
||||
background: var(--border-color);
|
||||
margin: 0.25rem 0;
|
||||
}
|
||||
|
||||
.option-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-color);
|
||||
|
||||
.info-icon {
|
||||
font-size: 0.8rem;
|
||||
color: var(--text-secondary-color);
|
||||
opacity: 0.6;
|
||||
cursor: help;
|
||||
transition: opacity 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Allowed formats
|
||||
.allow-all-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
|
||||
.allow-all-label {
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-color);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.format-checkboxes {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.625rem 1.25rem;
|
||||
padding: 0.875rem;
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.format-checkbox-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
min-width: 90px;
|
||||
|
||||
.format-checkbox-label {
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-color);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.warning-icon {
|
||||
font-size: 0.75rem;
|
||||
color: var(--p-orange-400);
|
||||
margin-left: 0.125rem;
|
||||
}
|
||||
|
||||
&.has-warning {
|
||||
.format-checkbox-label {
|
||||
color: var(--p-orange-400);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
::ng-deep .metadata-source-select {
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
.format-warning-message {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.625rem 0.75rem;
|
||||
background: rgba(234, 179, 8, 0.1);
|
||||
border: 1px solid var(--p-orange-400);
|
||||
border-radius: 6px;
|
||||
font-size: 0.75rem;
|
||||
color: var(--p-orange-400);
|
||||
|
||||
i {
|
||||
flex-shrink: 0;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
}
|
||||
|
||||
// Format chips
|
||||
.format-chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.format-chip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.4rem 0.625rem;
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 6px;
|
||||
cursor: grab;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
|
||||
.chip-rank {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background: var(--primary-color);
|
||||
color: var(--primary-contrast-color);
|
||||
border-radius: 50%;
|
||||
font-size: 0.625rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.chip-label {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.drag-indicator {
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-secondary-color);
|
||||
opacity: 0.5;
|
||||
cursor: grab;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.cdk-drag-preview {
|
||||
box-sizing: border-box;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
|
||||
background: var(--overlay-background);
|
||||
border: 1px solid var(--primary-color);
|
||||
}
|
||||
|
||||
.cdk-drag-placeholder {
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
.cdk-drag-animating {
|
||||
transition: transform 150ms cubic-bezier(0, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
// Footer
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: 1rem 1.5rem;
|
||||
background: var(--overlay-background);
|
||||
border-top: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.validation-status {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
.status-message {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
|
||||
i {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
&.warning {
|
||||
color: var(--p-orange-400);
|
||||
}
|
||||
|
||||
&.ready {
|
||||
color: var(--p-green-500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.footer-actions {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
// Responsive
|
||||
@media (max-width: 520px) {
|
||||
.library-creator {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
border-radius: 0;
|
||||
max-height: 100vh;
|
||||
}
|
||||
|
||||
.dialog-header {
|
||||
padding: 1rem;
|
||||
|
||||
.header-icon {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
|
||||
i {
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.header-text h1 {
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-body {
|
||||
padding: 1.5rem;
|
||||
gap: 1.75rem;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
flex-direction: column;
|
||||
padding: 1rem;
|
||||
gap: 0.75rem;
|
||||
|
||||
.validation-status {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.footer-actions {
|
||||
width: 100%;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Router} from '@angular/router';
|
||||
import {LibraryService} from '../book/service/library.service';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Library, MetadataSource, OrganizationMode} from '../book/model/library.model';
|
||||
import {BookType} from '../book/model/book.model';
|
||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {IconPickerService, IconSelection} from '../../shared/service/icon-picker.service';
|
||||
import {Button} from 'primeng/button';
|
||||
import {IconDisplayComponent} from '../../shared/components/icon-display/icon-display.component';
|
||||
import {DialogLauncherService} from '../../shared/services/dialog-launcher.service';
|
||||
import {switchMap} from 'rxjs/operators';
|
||||
import {map} from 'rxjs';
|
||||
import {CdkDragDrop, DragDropModule, moveItemInArray} from '@angular/cdk/drag-drop';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {Select} from 'primeng/select';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-library-creator',
|
||||
standalone: true,
|
||||
templateUrl: './library-creator.component.html',
|
||||
imports: [FormsModule, InputText, ToggleSwitch, Tooltip, Button, IconDisplayComponent, DragDropModule, Checkbox, Select, TranslocoDirective, TranslocoPipe],
|
||||
styleUrl: './library-creator.component.scss'
|
||||
})
|
||||
export class LibraryCreatorComponent implements OnInit {
|
||||
chosenLibraryName: string = '';
|
||||
folders: string[] = [];
|
||||
selectedIcon: IconSelection | null = null;
|
||||
|
||||
mode!: string;
|
||||
library!: Library | undefined;
|
||||
editModeLibraryName: string = '';
|
||||
watch: boolean = false;
|
||||
formatPriority: {type: BookType, label: string}[] = [];
|
||||
allowAllFormats: boolean = true;
|
||||
selectedAllowedFormats: Set<BookType> = new Set();
|
||||
formatCounts: Record<string, number> = {};
|
||||
metadataSource: MetadataSource = 'EMBEDDED';
|
||||
organizationMode: OrganizationMode = 'BOOK_PER_FILE';
|
||||
|
||||
metadataSourceOptions: {label: string, value: string}[] = [];
|
||||
organizationModeOptions: {label: string, value: string}[] = [];
|
||||
|
||||
readonly allBookFormats: {type: BookType, label: string}[] = [
|
||||
{type: 'EPUB', label: 'EPUB'},
|
||||
{type: 'PDF', label: 'PDF'},
|
||||
{type: 'CBX', label: 'CBX (CBZ/CBR/CB7)'},
|
||||
{type: 'MOBI', label: 'MOBI'},
|
||||
{type: 'AZW3', label: 'AZW3'},
|
||||
{type: 'FB2', label: 'FB2'},
|
||||
{type: 'AUDIOBOOK', label: 'Audiobook'}
|
||||
];
|
||||
|
||||
private dialogLauncherService = inject(DialogLauncherService);
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
private libraryService = inject(LibraryService);
|
||||
private messageService = inject(MessageService);
|
||||
private router = inject(Router);
|
||||
private iconPicker = inject(IconPickerService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
ngOnInit(): void {
|
||||
this.metadataSourceOptions = [
|
||||
{label: this.t.translate('libraryCreator.creator.metadataSourceEmbedded'), value: 'EMBEDDED'},
|
||||
{label: this.t.translate('libraryCreator.creator.metadataSourceSidecar'), value: 'SIDECAR'},
|
||||
{label: this.t.translate('libraryCreator.creator.metadataSourcePreferSidecar'), value: 'PREFER_SIDECAR'},
|
||||
{label: this.t.translate('libraryCreator.creator.metadataSourcePreferEmbedded'), value: 'PREFER_EMBEDDED'},
|
||||
{label: this.t.translate('libraryCreator.creator.metadataSourceNone'), value: 'NONE'}
|
||||
];
|
||||
this.initializeFormatPriority();
|
||||
this.initializeAllowedFormats();
|
||||
this.initializeOrganizationModeOptions();
|
||||
|
||||
const data = this.dynamicDialogConfig?.data;
|
||||
if (data?.mode === 'edit') {
|
||||
this.mode = data.mode;
|
||||
this.library = this.libraryService.findLibraryById(data.libraryId);
|
||||
if (this.library) {
|
||||
const {name, icon, iconType, paths, watch, formatPriority, allowedFormats} = this.library;
|
||||
this.chosenLibraryName = name;
|
||||
this.editModeLibraryName = name;
|
||||
|
||||
if (icon != null && iconType) {
|
||||
if (iconType === 'CUSTOM_SVG') {
|
||||
this.selectedIcon = {type: 'CUSTOM_SVG', value: icon};
|
||||
} else {
|
||||
const value = icon.slice(0, 6) === 'pi pi-' ? icon : `pi pi-${icon}`;
|
||||
this.selectedIcon = {type: 'PRIME_NG', value: value};
|
||||
}
|
||||
}
|
||||
|
||||
this.watch = watch;
|
||||
if (formatPriority && formatPriority.length > 0) {
|
||||
this.formatPriority = formatPriority.map(type =>
|
||||
this.allBookFormats.find(f => f.type === type)!
|
||||
).filter(f => f !== undefined);
|
||||
const existingTypes = new Set(formatPriority);
|
||||
this.allBookFormats.forEach(f => {
|
||||
if (!existingTypes.has(f.type)) {
|
||||
this.formatPriority.push(f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (allowedFormats && allowedFormats.length > 0) {
|
||||
this.allowAllFormats = false;
|
||||
this.selectedAllowedFormats = new Set(allowedFormats);
|
||||
} else {
|
||||
this.allowAllFormats = true;
|
||||
this.selectedAllowedFormats = new Set(this.allBookFormats.map(f => f.type));
|
||||
}
|
||||
|
||||
if (this.library.metadataSource) {
|
||||
this.metadataSource = this.library.metadataSource;
|
||||
}
|
||||
|
||||
if (this.library.organizationMode) {
|
||||
this.organizationMode = this.library.organizationMode;
|
||||
if (this.library.organizationMode === 'AUTO_DETECT') {
|
||||
this.organizationModeOptions.push({
|
||||
label: this.t.translate('libraryCreator.creator.organizationModeAutoDetect'),
|
||||
value: 'AUTO_DETECT'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.libraryService.getBookCountsByFormat(this.library.id!).subscribe(counts => {
|
||||
this.formatCounts = counts;
|
||||
});
|
||||
|
||||
this.folders = paths.map(path => path.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private initializeFormatPriority(): void {
|
||||
this.formatPriority = [...this.allBookFormats];
|
||||
}
|
||||
|
||||
private initializeOrganizationModeOptions(): void {
|
||||
this.organizationModeOptions = [
|
||||
{label: this.t.translate('libraryCreator.creator.organizationModeBookPerFile'), value: 'BOOK_PER_FILE'},
|
||||
{label: this.t.translate('libraryCreator.creator.organizationModeBookPerFolder'), value: 'BOOK_PER_FOLDER'}
|
||||
];
|
||||
}
|
||||
|
||||
private initializeAllowedFormats(): void {
|
||||
this.selectedAllowedFormats = new Set(this.allBookFormats.map(f => f.type));
|
||||
}
|
||||
|
||||
onAllowAllFormatsChange(): void {
|
||||
if (this.allowAllFormats) {
|
||||
this.selectedAllowedFormats = new Set(this.allBookFormats.map(f => f.type));
|
||||
}
|
||||
}
|
||||
|
||||
onFormatCheckboxChange(formatType: BookType, checked: boolean): void {
|
||||
if (checked) {
|
||||
this.selectedAllowedFormats.add(formatType);
|
||||
} else {
|
||||
this.selectedAllowedFormats.delete(formatType);
|
||||
}
|
||||
this.allowAllFormats = this.selectedAllowedFormats.size === this.allBookFormats.length;
|
||||
}
|
||||
|
||||
isFormatSelected(formatType: BookType): boolean {
|
||||
return this.selectedAllowedFormats.has(formatType);
|
||||
}
|
||||
|
||||
getFormatWarning(formatType: BookType): string | null {
|
||||
if (this.mode !== 'edit') return null;
|
||||
const count = this.formatCounts[formatType];
|
||||
if (count && count > 0 && !this.selectedAllowedFormats.has(formatType)) {
|
||||
return this.t.translate('libraryCreator.creator.formatWarning', {count});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
hasAnyFormatWarning(): boolean {
|
||||
if (this.mode !== 'edit') return false;
|
||||
return this.allBookFormats.some(f => this.getFormatWarning(f.type) !== null);
|
||||
}
|
||||
|
||||
closeDialog(): void {
|
||||
this.dynamicDialogRef.close();
|
||||
}
|
||||
|
||||
openDirectoryPicker(): void {
|
||||
const ref = this.dialogLauncherService.openDirectoryPickerDialog();
|
||||
ref?.onClose.subscribe((selectedFolders: string[] | null) => {
|
||||
if (selectedFolders && selectedFolders.length > 0) {
|
||||
selectedFolders.forEach(folder => {
|
||||
if (!this.folders.includes(folder)) {
|
||||
this.addFolder(folder);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
openIconPicker(): void {
|
||||
this.iconPicker.open().subscribe(icon => {
|
||||
if (icon) {
|
||||
this.selectedIcon = icon;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
addFolder(folder: string): void {
|
||||
this.folders.push(folder);
|
||||
}
|
||||
|
||||
removeFolder(index: number): void {
|
||||
this.folders.splice(index, 1);
|
||||
}
|
||||
|
||||
clearSelectedIcon(): void {
|
||||
this.selectedIcon = null;
|
||||
}
|
||||
|
||||
isLibraryDetailsValid(): boolean {
|
||||
return !!this.chosenLibraryName.trim();
|
||||
}
|
||||
|
||||
isDirectorySelectionValid(): boolean {
|
||||
return this.folders.length > 0;
|
||||
}
|
||||
|
||||
createOrUpdateLibrary(): void {
|
||||
const trimmedLibraryName = this.chosenLibraryName.trim();
|
||||
if (trimmedLibraryName && trimmedLibraryName !== this.editModeLibraryName) {
|
||||
const exists = this.libraryService.doesLibraryExistByName(trimmedLibraryName);
|
||||
if (exists) {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('libraryCreator.creator.toast.nameExistsSummary'),
|
||||
detail: this.t.translate('libraryCreator.creator.toast.nameExistsDetail'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const iconValue = this.selectedIcon?.value ?? null;
|
||||
const iconType = this.selectedIcon?.type ?? null;
|
||||
|
||||
const library: Library = {
|
||||
name: this.chosenLibraryName,
|
||||
icon: iconValue,
|
||||
iconType: iconType,
|
||||
paths: this.folders.map(folder => ({path: folder})),
|
||||
watch: this.watch,
|
||||
formatPriority: this.formatPriority.map(f => f.type),
|
||||
allowedFormats: this.allowAllFormats ? [] : Array.from(this.selectedAllowedFormats),
|
||||
metadataSource: this.metadataSource,
|
||||
organizationMode: this.organizationMode
|
||||
};
|
||||
|
||||
if (this.mode === 'edit') {
|
||||
this.libraryService.updateLibrary(library, this.library?.id).pipe(
|
||||
switchMap(() => this.libraryService.refreshLibrary(this.library!.id!))
|
||||
).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({severity: 'success', summary: this.t.translate('libraryCreator.creator.toast.updatedSummary'), detail: this.t.translate('libraryCreator.creator.toast.updatedDetail')});
|
||||
this.dynamicDialogRef.close();
|
||||
},
|
||||
error: (e) => {
|
||||
this.messageService.add({severity: 'error', summary: this.t.translate('libraryCreator.creator.toast.updateFailedSummary'), detail: this.t.translate('libraryCreator.creator.toast.updateFailedDetail')});
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.libraryService.scanLibraryPaths(library).pipe(
|
||||
switchMap(count => {
|
||||
if (count < 500) {
|
||||
return this.libraryService.createLibrary(library).pipe(
|
||||
map(createdLibrary => ({ createdLibrary, count }))
|
||||
);
|
||||
} else {
|
||||
console.warn(`Library has ${count} processable files (>500). Will use buffered loading.`);
|
||||
this.libraryService.setLargeLibraryLoading(true, count);
|
||||
return this.libraryService.createLibrary(library).pipe(
|
||||
map(createdLibrary => ({ createdLibrary, count }))
|
||||
);
|
||||
}
|
||||
})
|
||||
).subscribe({
|
||||
next: ({ createdLibrary, count }) => {
|
||||
if (createdLibrary) {
|
||||
this.router.navigate(['/library', createdLibrary.id, 'books']);
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('libraryCreator.creator.toast.createdSummary'),
|
||||
detail: count >= 500
|
||||
? this.t.translate('libraryCreator.creator.toast.createdLargeDetail', {count})
|
||||
: this.t.translate('libraryCreator.creator.toast.createdDetail')
|
||||
});
|
||||
this.dynamicDialogRef.close();
|
||||
}
|
||||
},
|
||||
error: (e) => {
|
||||
this.libraryService.setLargeLibraryLoading(false, 0);
|
||||
this.messageService.add({severity: 'error', summary: this.t.translate('libraryCreator.creator.toast.createFailedSummary'), detail: this.t.translate('libraryCreator.creator.toast.createFailedDetail')});
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onFormatPriorityDrop(event: CdkDragDrop<{type: BookType, label: string}[]>): void {
|
||||
moveItemInArray(this.formatPriority, event.previousIndex, event.currentIndex);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import { Injectable, ComponentRef, ApplicationRef, createComponent, EnvironmentInjector } from '@angular/core';
|
||||
import { LibraryLoadingComponent } from './library-loading/library-loading.component';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class LibraryLoadingService {
|
||||
private componentRef: ComponentRef<LibraryLoadingComponent> | null = null;
|
||||
|
||||
constructor(
|
||||
private appRef: ApplicationRef,
|
||||
private injector: EnvironmentInjector
|
||||
) {}
|
||||
|
||||
showBookLoadingProgress(bookTitle: string, current: number, total: number): void {
|
||||
if (this.componentRef) {
|
||||
this.updateProgress(bookTitle, current, total);
|
||||
return;
|
||||
}
|
||||
|
||||
this.componentRef = createComponent(LibraryLoadingComponent, {
|
||||
environmentInjector: this.injector
|
||||
});
|
||||
|
||||
this.componentRef.instance.updateProgress(bookTitle, current, total);
|
||||
|
||||
this.appRef.attachView(this.componentRef.hostView);
|
||||
const domElem = (this.componentRef.hostView as any).rootNodes[0] as HTMLElement;
|
||||
document.body.appendChild(domElem);
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
|
||||
updateProgress(bookTitle: string, current: number, total: number): void {
|
||||
if (this.componentRef) {
|
||||
this.componentRef.instance.updateProgress(bookTitle, current, total);
|
||||
}
|
||||
}
|
||||
|
||||
hide(): void {
|
||||
if (this.componentRef) {
|
||||
this.appRef.detachView(this.componentRef.hostView);
|
||||
this.componentRef.destroy();
|
||||
this.componentRef = null;
|
||||
document.body.style.overflow = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<ng-container *transloco="let t; prefix: 'libraryCreator.loading'">
|
||||
<div class="fullscreen-loader">
|
||||
<div class="library-loader-content">
|
||||
<div class="library-loader-header">
|
||||
<i class="pi pi-book"></i>
|
||||
<h2>{{ t('title') }}</h2>
|
||||
</div>
|
||||
|
||||
<div class="library-loader-body">
|
||||
<div class="book-title">
|
||||
@if (!isComplete) {
|
||||
<ng-container>
|
||||
{{ t('processing') }} <strong>{{ truncatedTitle }}</strong>
|
||||
</ng-container>
|
||||
}
|
||||
@if (isComplete) {
|
||||
<strong class="complete-message">
|
||||
<i class="pi pi-check-circle"></i>
|
||||
{{ t('complete') }}
|
||||
</strong>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="progress-info">
|
||||
<span>{{ current }} / {{ total }}</span>
|
||||
<span>{{ percentage }}%</span>
|
||||
</div>
|
||||
|
||||
<div class="progress-bar-container">
|
||||
<div class="progress-bar-fill" [style.width.%]="percentage"></div>
|
||||
</div>
|
||||
|
||||
@if (!isComplete) {
|
||||
<div class="loader-animation">
|
||||
<div class="dot"></div>
|
||||
<div class="dot"></div>
|
||||
<div class="dot"></div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (isComplete) {
|
||||
<div class="library-loader-footer">
|
||||
<button class="reload-button" (click)="onReload()">
|
||||
<i class="pi pi-bookmark"></i>
|
||||
{{ t('openLibrary') }}
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
.fullscreen-loader {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.85);
|
||||
backdrop-filter: blur(8px);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.library-loader-content {
|
||||
background: var(--card-background);
|
||||
padding: 2.5rem;
|
||||
border-radius: 12px;
|
||||
width: 550px;
|
||||
max-width: 90vw;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.library-loader-header {
|
||||
text-align: center;
|
||||
|
||||
i {
|
||||
font-size: 3rem;
|
||||
color: var(--primary-color);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 0 0 0.5rem 0;
|
||||
color: var(--text-color);
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.library-loader-body {
|
||||
.book-title {
|
||||
color: var(--text-color-secondary);
|
||||
margin-bottom: 1.5rem;
|
||||
margin-top: 2.5rem;
|
||||
font-size: 0.95rem;
|
||||
word-break: break-word;
|
||||
overflow-wrap: break-word;
|
||||
line-height: 1.4;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
|
||||
strong {
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.complete-message {
|
||||
color: var(--primary-color);
|
||||
font-size: 1.1rem;
|
||||
|
||||
i {
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.progress-info {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 0.5rem;
|
||||
color: var(--text-color-secondary);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.progress-bar-container {
|
||||
width: 100%;
|
||||
height: 8px;
|
||||
background: var(--card-background);
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
|
||||
.progress-bar-fill {
|
||||
height: 100%;
|
||||
background: var(--primary-color);
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
}
|
||||
|
||||
.loader-animation {
|
||||
margin-top: 1.5rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
|
||||
.dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
background: var(--primary-color);
|
||||
border-radius: 50%;
|
||||
animation: bounce 1.4s infinite ease-in-out both;
|
||||
|
||||
&:nth-child(2) {
|
||||
animation-delay: 0.2s;
|
||||
}
|
||||
|
||||
&:nth-child(3) {
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.library-loader-footer {
|
||||
margin-top: 3rem;
|
||||
text-align: center;
|
||||
|
||||
.reload-button {
|
||||
padding: 0.75rem 1.25rem;
|
||||
background: var(--primary-color);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
font-weight: 700;
|
||||
|
||||
i {
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: var(--primary-hover-color);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes bounce {
|
||||
0%, 80%, 100% {
|
||||
transform: scale(0);
|
||||
}
|
||||
40% {
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import {TranslocoDirective} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-library-loading',
|
||||
standalone: true,
|
||||
imports: [CommonModule, TranslocoDirective],
|
||||
templateUrl: './library-loading.component.html',
|
||||
styleUrl: './library-loading.component.scss'
|
||||
})
|
||||
export class LibraryLoadingComponent {
|
||||
bookTitle = '';
|
||||
current = 0;
|
||||
total = 0;
|
||||
isComplete = false;
|
||||
|
||||
get percentage(): number {
|
||||
return this.total > 0 ? Math.round((this.current / this.total) * 100) : 0;
|
||||
}
|
||||
|
||||
get truncatedTitle(): string {
|
||||
const maxLength = 50;
|
||||
return this.bookTitle.length <= maxLength
|
||||
? this.bookTitle
|
||||
: this.bookTitle.substring(0, maxLength) + '...';
|
||||
}
|
||||
|
||||
updateProgress(bookTitle: string, current: number, total: number): void {
|
||||
this.bookTitle = bookTitle;
|
||||
this.current = current;
|
||||
this.total = total;
|
||||
this.isComplete = current >= total;
|
||||
}
|
||||
|
||||
onReload(): void {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user