+
+
-
-
- @for (folder of folders; track folder) {
-
-
-
- {{ folder }}
-
-
-
+ class="add-folder-btn"
+ (onClick)="openDirectoryPicker()"
+ >
+
+
+ Add Book Folder
+ Browse for directories
- }
+
+ @if (folders.length === 0) {
+
+
+
+
+
No Folders Added Yet
+
+ Click the button above to add folders containing your books.
+ You can add multiple folders from different locations.
+
+
+ } @else {
+
+
+
+
+ @for (folder of folders; track folder; let i = $index) {
+
+
+
+
+ {{ folder }}
+
+
+
+ {{ getFolderName(folder) }}
+
+
+
+
+ }
+
+
+ }
-
diff --git a/booklore-ui/src/app/features/library-creator/library-creator.component.scss b/booklore-ui/src/app/features/library-creator/library-creator.component.scss
index 8b1378917..04474a4bf 100644
--- a/booklore-ui/src/app/features/library-creator/library-creator.component.scss
+++ b/booklore-ui/src/app/features/library-creator/library-creator.component.scss
@@ -1 +1,936 @@
+.library-creator {
+ width: 700px;
+ max-width: 700px;
+ margin: 0 auto;
+ padding: 1rem 0 0 0;
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ @media (max-width: 768px) {
+ width: 100%;
+ max-width: 100%;
+ padding: 0.75rem;
+ }
+}
+
+::ng-deep .custom-stepper {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ width: 100%;
+
+ .p-steppanels {
+ padding: 0 !important;
+ width: 100%;
+ }
+
+ .p-steplist {
+ padding: 0 1rem !important;
+ width: 100%;
+ }
+
+ .p-stepper-header {
+ padding: 0.875rem 1rem;
+ background: var(--card-background);
+ border: var(--card-border);
+ border-radius: 8px;
+ margin-bottom: 1.25rem;
+ transition: all 0.3s ease;
+
+ &.p-stepper-header-active {
+ background: rgba(var(--primary-color-rgb), 0.1);
+ border-color: var(--primary-color);
+
+ .step-icon {
+ color: var(--primary-color);
+ }
+
+ .step-title {
+ color: var(--primary-color);
+ font-weight: 600;
+ }
+ }
+
+ .p-stepper-separator {
+ background: var(--p-surface-700);
+ height: 2px;
+ margin: 0 0.75rem;
+ }
+ }
+
+ .p-stepper-panels {
+ background: transparent;
+ padding: 0 !important;
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ }
+
+ .p-stepper-panel {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ }
+}
+
+.step-content {
+ display: flex;
+ align-items: center;
+ gap: 0.625rem;
+
+ .step-labels {
+ display: flex;
+ flex-direction: column;
+ gap: 0.125rem;
+
+ .step-title {
+ font-size: 0.875rem;
+ font-weight: 500;
+ color: var(--text-color);
+ transition: all 0.3s ease;
+ }
+ }
+
+ @media (max-width: 640px) {
+ .step-labels {
+ display: none;
+ }
+ }
+}
+
+.step-panel-wrapper {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+}
+
+.step-panel-container {
+ width: 100%;
+ max-width: 100%;
+ display: flex;
+ flex-direction: column;
+ gap: 1.25rem;
+ padding: 1.5rem 1.5rem 2.5rem 1.5rem;
+ flex: 1;
+ overflow-y: auto;
+
+ @media (max-width: 768px) {
+ padding: 1rem;
+ }
+}
+
+.panel-header {
+ display: flex;
+ align-items: center;
+ gap: 1rem;
+ padding: 0.75rem 0;
+ background: linear-gradient(135deg, rgba(var(--primary-color-rgb), 0.1) 0%, rgba(var(--primary-color-rgb), 0.05) 100%);
+ border-radius: 10px;
+ border: 1px solid rgba(var(--primary-color-rgb), 0.2);
+
+ .header-icon-wrapper {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 48px;
+ height: 48px;
+ background: var(--primary-color);
+ border-radius: 10px;
+ box-shadow: 0 3px 8px rgba(var(--primary-color-rgb), 0.3);
+
+ .header-icon {
+ font-size: 1.5rem;
+ color: var(--primary-contrast-color);
+ }
+ }
+
+ .header-text {
+ flex: 1;
+
+ .panel-title {
+ margin: 0 0 0.25rem 0;
+ font-size: 1.25rem;
+ font-weight: 600;
+ color: var(--text-color);
+ }
+
+ .panel-description {
+ margin: 0;
+ font-size: 0.875rem;
+ color: var(--text-secondary-color);
+ }
+ }
+
+ @media (max-width: 640px) {
+ flex-direction: column;
+ text-align: center;
+ padding: 1rem;
+
+ .header-icon-wrapper {
+ width: 42px;
+ height: 42px;
+
+ .header-icon {
+ font-size: 1.25rem;
+ }
+ }
+
+ .header-text {
+ .panel-title {
+ font-size: 1.125rem;
+ }
+ }
+ }
+}
+
+.form-container {
+ display: flex;
+ flex-direction: column;
+ gap: 1rem;
+ padding: 1.25rem;
+ background: var(--card-background);
+ border: 1px solid var(--border-color);
+ border-radius: 10px;
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
+ width: 100%;
+ box-sizing: border-box;
+
+ @media (max-width: 768px) {
+ padding: 1rem;
+ }
+
+ @media (max-width: 640px) {
+ padding: 1rem;
+ }
+}
+
+.form-group {
+ display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
+ padding: 0 1rem 0 1rem;
+
+ &.highlight-group {
+ padding: 0.625rem;
+ background: var(--overlay-background);
+ border-radius: 8px;
+ border: 1px solid transparent;
+ transition: all 0.3s ease;
+ }
+
+ &.nested-group {
+ padding-left: 1rem;
+ border-left: 3px solid var(--primary-color);
+ margin-top: -0.25rem;
+ }
+}
+
+.form-label {
+ display: flex;
+ align-items: center;
+ gap: 0.375rem;
+ font-size: 0.95rem;
+ font-weight: 600;
+ color: var(--text-color);
+
+ .label-icon {
+ color: var(--primary-color);
+ }
+
+ .required-indicator {
+ color: var(--p-red-500);
+ margin-left: 0.125rem;
+ }
+}
+
+.input-wrapper {
+ position: relative;
+
+ .input-icon {
+ position: absolute;
+ right: 0.75rem;
+ top: 50%;
+ transform: translateY(-50%);
+ font-size: 1rem;
+
+ &.success {
+ color: var(--p-green-500);
+ }
+ }
+}
+
+::ng-deep .icon-select-btn {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 0.5rem;
+ width: 100%;
+ padding: 0.875rem;
+ background: var(--ground-background);
+ border: 1px dashed var(--border-color);
+ border-radius: 8px;
+ color: var(--text-color);
+ font-size: 0.875rem;
+ font-weight: 500;
+ cursor: pointer;
+ transition: all 0.3s ease;
+
+ &:hover {
+ background: var(--overlay-background);
+ border-color: var(--primary-color);
+ color: var(--primary-color);
+ transform: translateY(-1px);
+ box-shadow: 0 3px 8px rgba(var(--primary-color-rgb), 0.2);
+ }
+
+ i {
+ font-size: 1rem;
+ }
+}
+
+.selected-icon-display {
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+ padding: 0.75rem 0.875rem;
+ border: 1px solid var(--border-color);
+ border-radius: 8px;
+
+ .icon-preview {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 42px;
+ height: 42px;
+ background: var(--p-blue-400);
+ border-radius: 8px;
+ box-shadow: 0 3px 8px rgba(var(--primary-color-rgb), 0.3);
+
+ i {
+ font-size: 1.25rem;
+ color: var(--primary-contrast-color);
+ }
+ }
+
+ .icon-info {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ gap: 0.125rem;
+
+ .icon-label {
+ font-size: 0.85rem;
+ color: var(--text-secondary-color);
+ }
+
+ .icon-name {
+ font-size: 0.9rem;
+ font-weight: 500;
+ color: var(--text-color);
+ font-family: monospace;
+ }
+ }
+}
+
+.input-with-info {
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+
+ .info-tooltip {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border-radius: 50%;
+ color: var(--p-blue-500);
+ transition: all 0.2s ease;
+
+ i {
+ font-size: 1.125rem;
+ transition: all 0.2s ease;
+
+ &:hover {
+ color: var(--primary-color);
+ transform: scale(1.1);
+ }
+ }
+
+ &.large {
+ i {
+ font-size: 1.25rem;
+ }
+ }
+ }
+}
+
+.toggle-group {
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+
+ .toggle-wrapper {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ padding: 0.5rem 0.875rem;
+ background: var(--ground-background);
+ border-radius: 8px;
+ border: 1px solid var(--border-color);
+ transition: all 0.3s ease;
+
+ .toggle-label {
+ cursor: pointer;
+ user-select: none;
+
+ .toggle-status {
+ font-size: 0.9rem;
+ font-weight: 500;
+
+ &.active {
+ color: var(--p-green-500);
+ }
+
+ &.inactive {
+ color: var(--text-secondary-color);
+ }
+ }
+ }
+ }
+
+ .info-tooltip {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border-radius: 50%;
+ color: var(--p-blue-500);
+ transition: all 0.2s ease;
+
+ i {
+ font-size: 1.125rem;
+ transition: all 0.2s ease;
+
+ &:hover {
+ color: var(--primary-color);
+ transform: scale(1.1);
+ }
+ }
+
+ &.large {
+ i {
+ font-size: 1.25rem;
+ }
+ }
+ }
+}
+
+.divider {
+ height: 1px;
+ background: linear-gradient(90deg, transparent, var(--border-color), transparent);
+ margin: 0.25rem 0;
+}
+
+.directories-container {
+ display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
+ padding: 1.25rem;
+ background: var(--card-background);
+ border: 1px solid var(--border-color);
+ border-radius: 10px;
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
+ min-height: 300px;
+ width: 100%;
+ box-sizing: border-box;
+
+ @media (max-width: 768px) {
+ padding: 1rem;
+ }
+
+ @media (max-width: 640px) {
+ padding: 1rem;
+ }
+}
+
+.add-folder-section {
+ ::ng-deep .add-folder-btn {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ gap: 1rem;
+ width: 100%;
+ padding: 0.5rem 1rem 0 1rem;
+ border: none;
+ border-radius: 8px;
+ cursor: pointer;
+ transition: all 0.3s ease;
+ box-shadow: 0 3px 8px rgba(var(--primary-color-rgb), 0.3);
+
+ &:hover {
+ transform: translateY(-1px);
+ box-shadow: 0 4px 12px rgba(var(--primary-color-rgb), 0.4);
+ }
+
+ i {
+ font-size: 1.5rem;
+ }
+
+ .btn-content {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 0.125rem;
+
+ .btn-title {
+ font-size: 0.9375rem;
+ font-weight: 600;
+ }
+
+ .btn-subtitle {
+ font-size: 0.8rem;
+ opacity: 0.9;
+ }
+ }
+ }
+}
+
+.empty-state {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ text-align: center;
+ padding-bottom: 2rem;
+
+ .empty-icon-wrapper {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 80px;
+ height: 80px;
+ background: var(--overlay-background);
+ border-radius: 50%;
+ margin-bottom: 1rem;
+
+ .empty-icon {
+ font-size: 2.5rem;
+ color: var(--text-secondary-color);
+ opacity: 0.5;
+ }
+ }
+
+ .empty-title {
+ margin: 0 0 0.5rem 0;
+ font-size: 1.125rem;
+ font-weight: 600;
+ color: var(--text-color);
+ }
+
+ .empty-description {
+ margin: 0;
+ font-size: 0.875rem;
+ color: var(--text-secondary-color);
+ max-width: 400px;
+ line-height: 1.5;
+ }
+}
+
+.folders-list {
+ display: flex;
+ flex-direction: column;
+ gap: 1rem;
+
+ .list-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 0.5rem 0.75rem;
+ background: var(--overlay-background);
+ border-radius: 6px;
+
+ .folder-count {
+ display: flex;
+ align-items: center;
+ gap: 0.375rem;
+ font-size: 0.9rem;
+ font-weight: 600;
+ color: var(--text-color);
+
+ i {
+ color: var(--primary-color);
+ }
+ }
+ }
+}
+
+.folders-grid {
+ display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
+ max-height: 400px;
+ overflow-y: auto;
+ padding-right: 0.25rem;
+
+ &::-webkit-scrollbar {
+ width: 6px;
+ }
+
+ &::-webkit-scrollbar-track {
+ background: var(--overlay-background);
+ border-radius: 3px;
+ }
+
+ &::-webkit-scrollbar-thumb {
+ background: var(--border-color);
+ border-radius: 3px;
+ transition: background 0.2s ease;
+
+ &:hover {
+ background: var(--primary-color);
+ }
+ }
+
+ scrollbar-width: thin;
+ scrollbar-color: var(--border-color) var(--overlay-background);
+}
+
+.folder-card {
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+ padding: 0.875rem;
+ background: var(--ground-background);
+ border: 1px solid var(--border-color);
+ border-radius: 8px;
+ transition: all 0.3s ease;
+
+ &:hover {
+ border-color: var(--primary-color);
+ transform: translateX(3px);
+ box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
+
+ .folder-icon {
+ color: var(--primary-color);
+ transform: scale(1.08);
+ }
+ }
+
+ .folder-icon-section {
+ position: relative;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+
+ .folder-icon-wrapper {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 38px;
+ height: 38px;
+ background: var(--overlay-background);
+ border-radius: 8px;
+
+ .folder-icon {
+ font-size: 1.125rem;
+ color: var(--text-secondary-color);
+ transition: all 0.3s ease;
+ }
+ }
+
+ .folder-number {
+ position: absolute;
+ bottom: -3px;
+ right: -3px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 18px;
+ height: 18px;
+ background: var(--primary-color);
+ color: var(--primary-contrast-color);
+ border-radius: 50%;
+ font-size: 0.6875rem;
+ font-weight: 600;
+ border: 1px solid var(--ground-background);
+ }
+ }
+
+ .folder-details {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ gap: 0.25rem;
+ min-width: 0;
+
+ .folder-path {
+ font-size: 0.9rem;
+ color: var(--text-color);
+ font-weight: 500;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .folder-meta {
+ display: flex;
+ align-items: center;
+ gap: 0.25rem;
+ font-size: 0.75rem;
+ color: var(--text-secondary-color);
+
+ i {
+ font-size: 0.6875rem;
+ }
+
+ span {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+ }
+ }
+}
+
+.panel-footer {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 0.75rem;
+ padding: 1.25rem 1rem 0 1rem;
+ background: var(--card-background);
+ border-top: 1px solid var(--border-color);
+ box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
+ flex-shrink: 0;
+
+ .footer-right {
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+ }
+
+ @media (max-width: 640px) {
+ flex-direction: column;
+ padding: 1rem;
+
+ .footer-right {
+ width: 100%;
+ flex-direction: column;
+ }
+ }
+}
+
+.validation-status,
+.validation-message {
+ display: flex;
+ align-items: center;
+ gap: 0.375rem;
+ padding: 0.375rem;
+ font-weight: 500;
+ border-radius: 6px;
+ font-size: 0.9rem;
+
+ i {
+ font-size: 0.95rem;
+ }
+
+ &.error {
+ background: rgba(239, 68, 68, 0.1);
+ color: rgb(239, 68, 68);
+ border: 1px solid rgba(239, 68, 68, 0.3);
+
+ i {
+ color: rgb(239, 68, 68);
+ }
+ }
+
+ &.success {
+ background: rgba(34, 197, 94, 0.1);
+ color: rgb(34, 197, 94);
+ border: 1px solid rgba(34, 197, 94, 0.3);
+
+ i {
+ color: rgb(34, 197, 94);
+ }
+ }
+}
+
+@media (max-width: 640px) {
+ .library-creator {
+ width: 100%;
+ padding: 0.5rem;
+ max-width: 100%;
+ }
+
+ .step-panel-container {
+ gap: 1rem;
+ padding: 0.75rem;
+ }
+
+ .form-container,
+ .directories-container {
+ padding: 1rem;
+ }
+
+ .folder-card {
+ flex-direction: column;
+ align-items: flex-start;
+
+ .folder-icon-section {
+ align-self: flex-start;
+ }
+
+ .folder-details {
+ width: 100%;
+ }
+ }
+}
+
+@media (max-width: 480px) {
+ .library-creator {
+ width: 100%;
+ padding: 0.25rem;
+ max-width: 100%;
+ }
+
+ .custom-stepper {
+ .p-stepper-header {
+ padding: 0.5rem 0.5rem;
+ font-size: 0.95rem;
+ margin-bottom: 0.75rem;
+ }
+ .p-steplist {
+ padding: 0 0.5rem !important;
+ }
+ }
+
+ .step-panel-container {
+ padding: 0.75rem 0.5rem 1.25rem 0.5rem;
+ gap: 0.75rem;
+ }
+
+ .panel-header {
+ padding: 0.5rem;
+ .header-icon-wrapper {
+ width: 36px;
+ height: 36px;
+ .header-icon {
+ font-size: 1rem;
+ }
+ }
+ .header-text {
+ .panel-title {
+ font-size: 1rem;
+ }
+ .panel-description {
+ font-size: 0.75rem;
+ }
+ }
+ }
+
+ .form-container,
+ .directories-container {
+ padding: 0.5rem;
+ min-width: 0;
+ }
+
+ .form-group {
+ padding: 0 0.5rem 0 0.5rem;
+ gap: 0.25rem;
+ &.highlight-group {
+ padding: 0.25rem;
+ }
+ &.nested-group {
+ padding-left: 0.5rem;
+ }
+ }
+
+ .step-content {
+ gap: 0.375rem;
+ }
+
+ .panel-footer {
+ padding: 0.75rem 0.5rem 0 0.5rem;
+ gap: 0.5rem;
+ .footer-right {
+ gap: 0.5rem;
+ }
+ }
+
+ .folder-card {
+ padding: 0.5rem;
+ gap: 0.5rem;
+ .folder-icon-section {
+ .folder-icon-wrapper {
+ width: 28px;
+ height: 28px;
+ .folder-icon {
+ font-size: 0.95rem;
+ }
+ }
+ .folder-number {
+ width: 14px;
+ height: 14px;
+ font-size: 0.6rem;
+ }
+ }
+ .folder-details {
+ .folder-path {
+ font-size: 0.8rem;
+ }
+ .folder-meta {
+ font-size: 0.65rem;
+ }
+ }
+ }
+
+ .selected-icon-display {
+ padding: 0.5rem 0.5rem;
+ gap: 0.5rem;
+ .icon-preview {
+ width: 32px;
+ height: 32px;
+ i {
+ font-size: 1rem;
+ }
+ }
+ .icon-info {
+ .icon-label {
+ font-size: 0.75rem;
+ }
+ .icon-name {
+ font-size: 0.8rem;
+ }
+ }
+ }
+
+ .add-folder-section {
+ .add-folder-btn {
+ gap: 0.5rem;
+ padding: 0.25rem 0.5rem 0 0.5rem;
+ .btn-title {
+ font-size: 0.8rem;
+ }
+ .btn-subtitle {
+ font-size: 0.7rem;
+ }
+ }
+ }
+
+ .empty-state {
+ padding-bottom: 1rem;
+ .empty-icon-wrapper {
+ width: 48px;
+ height: 48px;
+ .empty-icon {
+ font-size: 1.5rem;
+ }
+ }
+ .empty-title {
+ font-size: 0.95rem;
+ }
+ .empty-description {
+ font-size: 0.75rem;
+ max-width: 90vw;
+ }
+ }
+}
diff --git a/booklore-ui/src/app/features/library-creator/library-creator.component.ts b/booklore-ui/src/app/features/library-creator/library-creator.component.ts
index 671f29781..34ba4187f 100644
--- a/booklore-ui/src/app/features/library-creator/library-creator.component.ts
+++ b/booklore-ui/src/app/features/library-creator/library-creator.component.ts
@@ -4,22 +4,22 @@ import {DirectoryPickerComponent} from '../../shared/components/directory-picker
import {MessageService} from 'primeng/api';
import {Router} from '@angular/router';
import {LibraryService} from '../book/service/library.service';
-import {Button} from 'primeng/button';
import {TableModule} from 'primeng/table';
import {Step, StepList, StepPanel, StepPanels, Stepper} from 'primeng/stepper';
import {FormsModule} from '@angular/forms';
import {InputText} from 'primeng/inputtext';
-import {Library, LibraryScanMode, BookFileType} from '../book/model/library.model';
+import {BookFileType, Library, LibraryScanMode} from '../book/model/library.model';
import {ToggleSwitch} from 'primeng/toggleswitch';
import {Tooltip} from 'primeng/tooltip';
import {IconPickerService} from '../../shared/service/icon-picker.service';
import {Select} from 'primeng/select';
+import {Button} from 'primeng/button';
@Component({
selector: 'app-library-creator',
standalone: true,
templateUrl: './library-creator.component.html',
- imports: [Button, TableModule, StepPanel, FormsModule, InputText, Stepper, StepList, Step, StepPanels, ToggleSwitch, Tooltip, Select],
+ imports: [TableModule, StepPanel, FormsModule, InputText, Stepper, StepList, Step, StepPanels, ToggleSwitch, Tooltip, Select, Button],
styleUrl: './library-creator.component.scss'
})
export class LibraryCreatorComponent implements OnInit {
@@ -81,9 +81,13 @@ export class LibraryCreatorComponent implements OnInit {
contentStyle: {overflow: 'hidden'},
baseZIndex: 10
});
- this.directoryPickerDialogRef.onClose.subscribe((selectedFolder: string) => {
- if (selectedFolder) {
- this.addFolder(selectedFolder);
+ this.directoryPickerDialogRef.onClose.subscribe((selectedFolders: string[] | null) => {
+ if (selectedFolders && selectedFolders.length > 0) {
+ selectedFolders.forEach(folder => {
+ if (!this.folders.includes(folder)) {
+ this.addFolder(folder);
+ }
+ });
}
});
}
@@ -176,4 +180,12 @@ export class LibraryCreatorComponent implements OnInit {
});
}
}
+
+ getFolderName(path: string): string {
+ if (!path || typeof path !== 'string') {
+ return '';
+ }
+ const parts = path.split('/').filter(p => p);
+ return parts[parts.length - 1] || path;
+ }
}
diff --git a/booklore-ui/src/app/shared/components/directory-picker/directory-picker.component.html b/booklore-ui/src/app/shared/components/directory-picker/directory-picker.component.html
index a286bd76e..069bd2475 100644
--- a/booklore-ui/src/app/shared/components/directory-picker/directory-picker.component.html
+++ b/booklore-ui/src/app/shared/components/directory-picker/directory-picker.component.html
@@ -1,35 +1,139 @@
-
-
-
-
+
+
-
-
-
- |
- Name |
-
-
-
-
-
- @if (product === '...') {
-
+
+
+
+
+
+
+ @if (searchQuery) {
+
+ }
+
+
+
+
+
+
+
+ Current Path:
+
+
+ {{ selectedProductName || '/' }}
+
+ @if (selectedFolders.length > 0) {
+
+
+ {{ selectedFolders.length }} selected
+
+ }
+
+
+
+ @if (isLoading) {
+
+
+ Loading directories...
+
+ } @else if (filteredPaths.length === 0) {
+
+
+
+ @if (searchQuery) {
+ No folders match your search
+ } @else {
+ This directory is empty
}
- @if (product !== '...') {
-
- }
- |
- {{ product }} |
-
-
-
+
+
+ } @else {
+
+ @for (folder of filteredPaths; track folder) {
+
+
+
+
+
+
+
+ {{ getFolderName(folder) }}
+ {{ folder }}
+
+
+
+
+ }
+
+ }
+
+
+
diff --git a/booklore-ui/src/app/shared/components/directory-picker/directory-picker.component.scss b/booklore-ui/src/app/shared/components/directory-picker/directory-picker.component.scss
index 5790ffaac..85f971c76 100644
--- a/booklore-ui/src/app/shared/components/directory-picker/directory-picker.component.scss
+++ b/booklore-ui/src/app/shared/components/directory-picker/directory-picker.component.scss
@@ -6,3 +6,453 @@
width: 100% !important;
}
}
+
+.directory-picker {
+ display: flex;
+ flex-direction: column;
+ width: 800px;
+ max-width: 90vw;
+ max-height: 85vh;
+ background: var(--p-content-background);
+ border-radius: 12px;
+ overflow: hidden;
+
+ @media (max-width: 768px) {
+ width: 95vw;
+ height: 90vh;
+ }
+}
+
+.picker-header {
+ padding: 0 1.5rem 2rem 1.5rem;
+ border-bottom: 1px solid var(--p-content-border-color);
+ background: var(--card-background);
+
+ .header-title {
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+ color: var(--text-color);
+
+ i {
+ color: var(--primary-color);
+ }
+ }
+
+ .text-secondary {
+ color: var(--text-secondary-color);
+ }
+}
+
+.breadcrumb-container {
+ padding: 0.75rem 1.5rem;
+ border-bottom: 1px solid var(--p-content-border-color);
+
+ ::ng-deep {
+ .p-breadcrumb {
+ background: transparent;
+ border: none;
+ padding: 0;
+
+ .p-breadcrumb-list {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.25rem;
+ }
+
+ .p-breadcrumb-home {
+ .p-menuitem-link {
+ color: var(--primary-color);
+ transition: all 0.2s;
+
+ &:hover {
+ color: var(--primary-hover-color);
+ background: var(--p-surface-800);
+ border-radius: 6px;
+ }
+ }
+ }
+
+ .p-menuitem-link {
+ color: var(--text-color);
+ padding: 0.5rem 0.75rem;
+ border-radius: 6px;
+ transition: all 0.2s;
+
+ &:hover {
+ background: var(--p-surface-800);
+ color: var(--primary-color);
+ }
+ }
+
+ .p-breadcrumb-chevron {
+ color: var(--text-secondary-color);
+ margin: 0 0.25rem;
+ }
+ }
+ }
+}
+
+.search-bar {
+ display: flex;
+ gap: 0.75rem;
+ padding: 1rem 1.5rem;
+ background: var(--card-background);
+ border-bottom: 1px solid var(--p-content-border-color);
+
+ .search-input-wrapper {
+ position: relative;
+ flex: 1;
+
+ ::ng-deep {
+ .p-inputicon {
+ color: var(--text-secondary-color);
+ }
+ }
+
+ .clear-icon {
+ position: absolute;
+ right: 1rem;
+ top: 50%;
+ transform: translateY(-50%);
+ color: var(--text-secondary-color);
+ cursor: pointer;
+ transition: color 0.2s;
+ z-index: 1;
+
+ &:hover {
+ color: var(--text-color);
+ }
+ }
+ }
+
+ .up-button {
+ padding: 0.75rem 1rem;
+ border-radius: 8px;
+ }
+}
+
+.current-path {
+ display: flex;
+ align-items: center;
+ gap: 1rem;
+ padding: 0.75rem 1.5rem;
+ background: var(--overlay-background);
+ border-bottom: 1px solid var(--p-content-border-color);
+ font-size: 0.875rem;
+
+ .path-label {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ color: var(--text-secondary-color);
+ font-weight: 500;
+ white-space: nowrap;
+
+ i {
+ color: var(--primary-color);
+ }
+ }
+
+ .path-value {
+ color: var(--text-color);
+ font-family: monospace;
+ background: var(--p-surface-900);
+ padding: 0.375rem 0.75rem;
+ border-radius: 6px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ flex: 1;
+ }
+
+ .selected-count {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ padding: 0.2rem 0.5rem;
+ background: var(--p-sky-500);
+ color: white;
+ border-radius: 6px;
+ font-weight: 500;
+ white-space: nowrap;
+
+ i {
+ font-size: 0.875rem;
+ }
+ }
+}
+
+.directory-list {
+ flex: 1;
+ overflow-y: auto;
+ padding: 1rem 1.5rem;
+ background: var(--ground-background);
+
+ &::-webkit-scrollbar {
+ width: 8px;
+ }
+
+ &::-webkit-scrollbar-track {
+ background: var(--overlay-background);
+ }
+
+ &::-webkit-scrollbar-thumb {
+ background: var(--p-surface-700);
+ border-radius: 4px;
+
+ &:hover {
+ background: var(--p-surface-600);
+ }
+ }
+}
+
+.loading-state {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ height: 100%;
+ color: var(--text-secondary-color);
+
+ ::ng-deep .custom-spinner {
+ .p-progress-spinner-circle {
+ stroke: var(--primary-color);
+ }
+ }
+}
+
+.empty-state {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ height: 100%;
+ color: var(--text-secondary-color);
+
+ .empty-icon {
+ font-size: 4rem;
+ color: var(--p-surface-700);
+ margin-bottom: 1rem;
+ }
+
+ .empty-text {
+ font-size: 1rem;
+ margin: 0;
+ }
+}
+
+.folder-grid {
+ display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
+}
+
+.folder-item {
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+ padding: 0.4rem 1rem;
+ background: var(--card-background);
+ border: 1px solid var(--p-content-border-color);
+ border-radius: 8px;
+ transition: all 0.2s;
+
+ &.checked {
+ background: rgba(var(--primary-color-rgb), 0.05);
+ border-color: var(--primary-color);
+ }
+
+ &:hover {
+ background: var(--overlay-background);
+ border-color: var(--primary-color);
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
+
+ .folder-icon {
+ color: var(--primary-color);
+ transform: scale(1.1);
+ }
+
+ .navigate-icon {
+ opacity: 1;
+ transform: translateX(4px);
+ }
+ }
+
+ &.selected {
+ .folder-content {
+ background: rgba(var(--primary-color-rgb), 0.1);
+ }
+ }
+
+ .folder-checkbox {
+ display: flex;
+ align-items: center;
+ padding: 0.25rem;
+ cursor: pointer;
+
+ ::ng-deep {
+ .p-checkbox {
+ .p-checkbox-box {
+ width: 20px;
+ height: 20px;
+ border-radius: 4px;
+ }
+ }
+ }
+ }
+
+ .folder-content {
+ flex: 1;
+ display: flex;
+ align-items: center;
+ gap: 1rem;
+ cursor: pointer;
+ padding: 0.5rem;
+ margin: -0.5rem;
+ border-radius: 6px;
+ transition: all 0.2s;
+
+ &:hover {
+ background: rgba(var(--primary-color-rgb), 0.05);
+ }
+ }
+
+ .folder-icon-wrapper {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 40px;
+ height: 40px;
+ background: var(--overlay-background);
+ border-radius: 8px;
+
+ .folder-icon {
+ font-size: 1.5rem;
+ color: var(--text-secondary-color);
+ transition: all 0.2s;
+ }
+ }
+
+ .folder-info {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ gap: 0.25rem;
+ min-width: 0;
+
+ .folder-name {
+ color: var(--text-color);
+ font-weight: 500;
+ font-size: 0.95rem;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .folder-path {
+ color: var(--text-secondary-color);
+ font-size: 0.8rem;
+ font-family: monospace;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+ }
+
+ .navigate-icon {
+ color: var(--text-secondary-color);
+ opacity: 0;
+ transition: all 0.2s;
+ }
+}
+
+.picker-footer {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: 0.75rem;
+ padding: 1rem 1.5rem;
+ border-top: 1px solid var(--p-content-border-color);
+ background: var(--card-background);
+ margin-bottom: 2rem;
+
+ .footer-info {
+ flex: 1;
+
+ .selection-info {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ color: var(--text-secondary-color);
+ font-size: 0.9rem;
+
+ i {
+ color: var(--primary-color);
+ }
+ }
+ }
+
+ .footer-actions {
+ display: flex;
+ gap: 0.75rem;
+
+ button {
+ min-width: 120px;
+ }
+ }
+}
+
+@media (max-width: 768px) {
+ .directory-picker {
+ border-radius: 0;
+ }
+
+ .picker-header,
+ .search-bar,
+ .current-path,
+ .directory-list,
+ .picker-footer {
+ padding-left: 1rem;
+ padding-right: 1rem;
+ }
+
+ .folder-item {
+ .folder-info {
+ .folder-path {
+ display: none;
+ }
+ }
+ }
+
+ .current-path {
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 0.5rem;
+
+ .path-value {
+ width: 100%;
+ }
+
+ .selected-count {
+ align-self: flex-start;
+ }
+ }
+
+ .picker-footer {
+ flex-direction: column;
+ align-items: stretch;
+
+ .footer-info {
+ text-align: center;
+ }
+
+ .footer-actions {
+ width: 100%;
+
+ button {
+ flex: 1;
+ }
+ }
+ }
+}
diff --git a/booklore-ui/src/app/shared/components/directory-picker/directory-picker.component.ts b/booklore-ui/src/app/shared/components/directory-picker/directory-picker.component.ts
index cc91cb092..2ff051111 100644
--- a/booklore-ui/src/app/shared/components/directory-picker/directory-picker.component.ts
+++ b/booklore-ui/src/app/shared/components/directory-picker/directory-picker.component.ts
@@ -1,26 +1,50 @@
import {Component, inject, OnInit} from '@angular/core';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {UtilityService} from './utility.service';
-import {Button} from 'primeng/button';
import {TableModule} from 'primeng/table';
-
import {InputText} from 'primeng/inputtext';
+import {CommonModule} from '@angular/common';
+import {FormsModule} from '@angular/forms';
+import {ProgressSpinner} from 'primeng/progressspinner';
+import {Breadcrumb} from 'primeng/breadcrumb';
+import {MenuItem} from 'primeng/api';
+import {CheckboxModule} from 'primeng/checkbox';
+import {InputIcon} from 'primeng/inputicon';
+import {Button} from 'primeng/button';
+import {IconField} from 'primeng/iconfield';
+import {Tooltip} from 'primeng/tooltip';
@Component({
selector: 'app-directory-picker-v2',
standalone: true,
templateUrl: './directory-picker.component.html',
imports: [
- Button,
TableModule,
- InputText
-],
+ InputText,
+ CommonModule,
+ FormsModule,
+ ProgressSpinner,
+ Breadcrumb,
+ CheckboxModule,
+ InputIcon,
+ Button,
+ InputIcon,
+ IconField,
+ Tooltip
+ ],
styleUrls: ['./directory-picker.component.scss']
})
export class DirectoryPickerComponent implements OnInit {
value: any;
- paths: string[] = ['...'];
+ paths: string[] = [];
+ filteredPaths: string[] = [];
selectedProductName: string = '';
+ selectedFolders: string[] = [];
+ selectedFoldersMap: { [key: string]: boolean } = {};
+ searchQuery: string = '';
+ isLoading: boolean = false;
+ breadcrumbItems: MenuItem[] = [];
+ home: MenuItem = {icon: 'pi pi-home', command: () => this.navigateToRoot()};
private utilityService = inject(UtilityService);
private dynamicDialogRef = inject(DynamicDialogRef);
@@ -31,32 +55,117 @@ export class DirectoryPickerComponent implements OnInit {
}
getFolders(path: string): void {
- this.utilityService.getFolders(path).subscribe(
- (folders: string[]) => {
- this.paths = ['...', ...folders];
+ this.isLoading = true;
+ this.utilityService.getFolders(path).subscribe({
+ next: (folders: string[]) => {
+ this.paths = folders;
+ this.filteredPaths = folders;
+ this.isLoading = false;
+ this.updateBreadcrumb(path);
+ folders.forEach(folder => {
+ this.selectedFoldersMap[folder] = this.selectedFolders.includes(folder);
+ });
},
- (error) => {
+ error: (error) => {
console.error('Error fetching folders:', error);
+ this.isLoading = false;
}
- );
+ });
+ }
+
+ updateBreadcrumb(path: string): void {
+ if (path === '/' || path === '') {
+ this.breadcrumbItems = [];
+ return;
+ }
+
+ const parts = path.split('/').filter(p => p);
+ this.breadcrumbItems = parts.map((part, index) => {
+ const fullPath = '/' + parts.slice(0, index + 1).join('/');
+ return {
+ label: part,
+ command: () => this.navigateToPath(fullPath)
+ };
+ });
+ }
+
+ navigateToRoot(): void {
+ this.selectedProductName = '/';
+ this.getFolders('/');
+ this.searchQuery = '';
+ }
+
+ navigateToPath(path: string): void {
+ this.selectedProductName = path;
+ this.getFolders(path);
+ this.searchQuery = '';
}
onRowClick(path: string): void {
- if (path === '...') {
- if (this.selectedProductName === '' || this.selectedProductName === '/') {
- this.getFolders('/');
- } else {
- const result = this.selectedProductName.substring(0, this.selectedProductName.lastIndexOf('/')) || '/';
- this.selectedProductName = result;
- this.getFolders(result);
- }
+ this.selectedProductName = path;
+ this.getFolders(path);
+ this.searchQuery = '';
+ }
+
+ toggleFolderSelection(path: string, event?: Event): void {
+ if (event) {
+ event.stopPropagation();
+ }
+
+ const index = this.selectedFolders.indexOf(path);
+ if (index > -1) {
+ this.selectedFolders.splice(index, 1);
+ this.selectedFoldersMap[path] = false;
} else {
- this.selectedProductName = path;
- this.getFolders(path);
+ this.selectedFolders.push(path);
+ this.selectedFoldersMap[path] = true;
}
}
+ onCheckboxChange(path: string, checked: boolean): void {
+ const index = this.selectedFolders.indexOf(path);
+ if (checked && index === -1) {
+ this.selectedFolders.push(path);
+ } else if (!checked && index > -1) {
+ this.selectedFolders.splice(index, 1);
+ }
+ }
+
+ isFolderSelected(path: string): boolean {
+ return this.selectedFolders.includes(path);
+ }
+
+ goUp(): void {
+ if (this.selectedProductName === '' || this.selectedProductName === '/') {
+ return;
+ }
+ const result = this.selectedProductName.substring(0, this.selectedProductName.lastIndexOf('/')) || '/';
+ this.selectedProductName = result;
+ this.getFolders(result);
+ this.searchQuery = '';
+ }
+
+ onSearch(): void {
+ if (!this.searchQuery.trim()) {
+ this.filteredPaths = this.paths;
+ return;
+ }
+
+ const query = this.searchQuery.toLowerCase();
+ this.filteredPaths = this.paths.filter(path =>
+ path.toLowerCase().includes(query)
+ );
+ }
+
onSelect(): void {
- this.dynamicDialogRef.close(this.selectedProductName);
+ this.dynamicDialogRef.close(this.selectedFolders);
+ }
+
+ onCancel(): void {
+ this.dynamicDialogRef.close(null);
+ }
+
+ getFolderName(path: string): string {
+ return path.split('/').filter(p => p).pop() || path;
}
}
diff --git a/booklore-ui/src/app/shared/services/dialog-launcher.service.ts b/booklore-ui/src/app/shared/services/dialog-launcher.service.ts
index 5012765c9..b3652f783 100644
--- a/booklore-ui/src/app/shared/services/dialog-launcher.service.ts
+++ b/booklore-ui/src/app/shared/services/dialog-launcher.service.ts
@@ -50,8 +50,7 @@ export class DialogLauncherService {
openLibraryCreatorDialog(): void {
this.open({
component: LibraryCreatorComponent,
- header: 'Create New Library',
- top: '15%'
+ header: 'Create New Library'
});
}