Add support for uploading and assigning custom SVG icons to libraries… (#1788)
* Add support for uploading and assigning custom SVG icons to libraries and shelves * Add few default icons
This commit is contained in:
@@ -94,11 +94,20 @@
|
||||
} @else {
|
||||
<div class="selected-icon-display">
|
||||
<div class="icon-preview">
|
||||
<i [class]="selectedIcon"></i>
|
||||
<app-icon-display
|
||||
[icon]="selectedIcon"
|
||||
size="24px"
|
||||
/>
|
||||
</div>
|
||||
<div class="icon-info">
|
||||
<span class="icon-label">Selected Icon</span>
|
||||
<span class="icon-name">{{ selectedIcon }}</span>
|
||||
<span class="icon-name">
|
||||
@if (selectedIcon.type === 'PRIME_NG') {
|
||||
{{ selectedIcon.value }}
|
||||
} @else {
|
||||
{{ selectedIcon.value }} (Custom)
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
|
||||
@@ -11,21 +11,22 @@ import {InputText} from 'primeng/inputtext';
|
||||
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 {IconPickerService, IconSelection} from '../../shared/service/icon-picker.service';
|
||||
import {Select} from 'primeng/select';
|
||||
import {Button} from 'primeng/button';
|
||||
import {IconDisplayComponent} from '../../shared/components/icon-display/icon-display.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-library-creator',
|
||||
standalone: true,
|
||||
templateUrl: './library-creator.component.html',
|
||||
imports: [TableModule, StepPanel, FormsModule, InputText, Stepper, StepList, Step, StepPanels, ToggleSwitch, Tooltip, Select, Button],
|
||||
imports: [TableModule, StepPanel, FormsModule, InputText, Stepper, StepList, Step, StepPanels, ToggleSwitch, Tooltip, Select, Button, IconDisplayComponent],
|
||||
styleUrl: './library-creator.component.scss'
|
||||
})
|
||||
export class LibraryCreatorComponent implements OnInit {
|
||||
chosenLibraryName: string = '';
|
||||
folders: string[] = [];
|
||||
selectedIcon: string | null = null;
|
||||
selectedIcon: IconSelection | null = null;
|
||||
|
||||
mode!: string;
|
||||
library!: Library | undefined;
|
||||
@@ -61,10 +62,16 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
this.mode = data.mode;
|
||||
this.library = this.libraryService.findLibraryById(data.libraryId);
|
||||
if (this.library) {
|
||||
const {name, icon, paths, watch, scanMode, defaultBookFormat} = this.library;
|
||||
const {name, icon, iconType, paths, watch, scanMode, defaultBookFormat} = this.library;
|
||||
this.chosenLibraryName = name;
|
||||
this.editModeLibraryName = name;
|
||||
this.selectedIcon = `pi pi-${icon}`;
|
||||
|
||||
if (iconType === 'CUSTOM_SVG') {
|
||||
this.selectedIcon = {type: 'CUSTOM_SVG', value: icon};
|
||||
} else {
|
||||
this.selectedIcon = {type: 'PRIME_NG', value: `pi pi-${icon}`};
|
||||
}
|
||||
|
||||
this.watch = watch;
|
||||
this.scanMode = scanMode || 'FILE_AS_BOOK';
|
||||
this.defaultBookFormat = defaultBookFormat || undefined;
|
||||
@@ -145,10 +152,14 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
}
|
||||
|
||||
createOrUpdateLibrary(): void {
|
||||
const iconValue = this.selectedIcon?.value || 'heart';
|
||||
const iconType = this.selectedIcon?.type || 'PRIME_NG';
|
||||
|
||||
if (this.mode === 'edit') {
|
||||
const library: Library = {
|
||||
name: this.chosenLibraryName,
|
||||
icon: this.selectedIcon?.replace('pi pi-', '') || 'heart',
|
||||
icon: iconValue,
|
||||
iconType: iconType,
|
||||
paths: this.folders.map(folder => ({path: folder})),
|
||||
watch: this.watch,
|
||||
scanMode: this.scanMode,
|
||||
@@ -167,7 +178,8 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
} else {
|
||||
const library: Library = {
|
||||
name: this.chosenLibraryName,
|
||||
icon: this.selectedIcon?.replace('pi pi-', '') || 'heart',
|
||||
icon: iconValue,
|
||||
iconType: iconType,
|
||||
paths: this.folders.map(folder => ({path: folder})),
|
||||
watch: this.watch,
|
||||
scanMode: this.scanMode,
|
||||
|
||||
Reference in New Issue
Block a user