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:
@@ -107,7 +107,8 @@ export class AppMenuComponent implements OnInit {
|
||||
menu: this.libraryShelfMenuService.initializeLibraryMenuItems(library),
|
||||
label: library.name,
|
||||
type: 'Library',
|
||||
icon: 'pi pi-' + library.icon,
|
||||
icon: library.icon,
|
||||
iconType: (library.iconType || 'PRIME_NG') as 'PRIME_NG' | 'CUSTOM_SVG',
|
||||
routerLink: [`/library/${library.id}/books`],
|
||||
bookCount$: this.libraryService.getBookCount(library.id ?? 0),
|
||||
})),
|
||||
@@ -129,7 +130,8 @@ export class AppMenuComponent implements OnInit {
|
||||
items: sortedShelves.map((shelf) => ({
|
||||
label: shelf.name,
|
||||
type: 'magicShelfItem',
|
||||
icon: 'pi pi-' + shelf.icon,
|
||||
icon: shelf.icon || 'pi pi-book',
|
||||
iconType: (shelf.iconType || 'PRIME_NG') as 'PRIME_NG' | 'CUSTOM_SVG',
|
||||
menu: this.libraryShelfMenuService.initializeMagicShelfMenuItems(shelf),
|
||||
routerLink: [`/magic-shelf/${shelf.id}/books`],
|
||||
bookCount$: this.magicShelfService.getBookCount(shelf.id ?? 0),
|
||||
@@ -154,7 +156,8 @@ export class AppMenuComponent implements OnInit {
|
||||
menu: this.libraryShelfMenuService.initializeShelfMenuItems(shelf),
|
||||
label: shelf.name,
|
||||
type: 'Shelf',
|
||||
icon: 'pi pi-' + shelf.icon,
|
||||
icon: shelf.icon,
|
||||
iconType: (shelf.iconType || 'PRIME_NG') as 'PRIME_NG' | 'CUSTOM_SVG',
|
||||
routerLink: [`/shelf/${shelf.id}/books`],
|
||||
bookCount$: this.shelfService.getBookCount(shelf.id ?? 0),
|
||||
}));
|
||||
@@ -163,6 +166,7 @@ export class AppMenuComponent implements OnInit {
|
||||
label: 'Unshelved',
|
||||
type: 'Shelf',
|
||||
icon: 'pi pi-inbox',
|
||||
iconType: 'PRIME_NG' as 'PRIME_NG' | 'CUSTOM_SVG',
|
||||
routerLink: ['/unshelved-books'],
|
||||
bookCount$: this.shelfService.getUnshelvedBookCount?.() ?? of(0),
|
||||
};
|
||||
@@ -172,7 +176,8 @@ export class AppMenuComponent implements OnInit {
|
||||
items.push({
|
||||
label: koboShelf.name,
|
||||
type: 'Shelf',
|
||||
icon: 'pi pi-' + koboShelf.icon,
|
||||
icon: koboShelf.icon,
|
||||
iconType: (koboShelf.iconType || 'PRIME_NG') as 'PRIME_NG' | 'CUSTOM_SVG',
|
||||
routerLink: [`/shelf/${koboShelf.id}/books`],
|
||||
bookCount$: this.shelfService.getBookCount(koboShelf.id ?? 0),
|
||||
});
|
||||
|
||||
@@ -53,7 +53,11 @@
|
||||
tabindex="0"
|
||||
pRipple
|
||||
>
|
||||
<i [ngClass]="item.icon" class="layout-menuitem-icon"></i>
|
||||
<app-icon-display
|
||||
[icon]="getIconSelection()"
|
||||
iconClass="layout-menuitem-icon"
|
||||
size="19px"
|
||||
></app-icon-display>
|
||||
<span class="layout-menuitem-text menu-item-text">
|
||||
{{ item.label }}
|
||||
</span>
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
.menu-item-end-content {
|
||||
|
||||
@@ -10,8 +10,9 @@ import {Button} from 'primeng/button';
|
||||
import {Menu} from 'primeng/menu';
|
||||
import {UserService} from '../../../../features/settings/user-management/user.service';
|
||||
import {DialogLauncherService} from '../../../services/dialog-launcher.service';
|
||||
import {ShelfCreatorComponent} from '../../../../features/book/components/shelf-creator/shelf-creator.component';
|
||||
import {BookDialogHelperService} from '../../../../features/book/components/book-browser/BookDialogHelperService';
|
||||
import {IconDisplayComponent} from '../../../components/icon-display/icon-display.component';
|
||||
import {IconSelection} from '../../../service/icon-picker.service';
|
||||
|
||||
@Component({
|
||||
selector: '[app-menuitem]',
|
||||
@@ -24,7 +25,8 @@ import {BookDialogHelperService} from '../../../../features/book/components/book
|
||||
Ripple,
|
||||
AsyncPipe,
|
||||
Button,
|
||||
Menu
|
||||
Menu,
|
||||
IconDisplayComponent
|
||||
],
|
||||
animations: [
|
||||
trigger('children', [
|
||||
@@ -169,6 +171,15 @@ export class AppMenuitemComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
getIconSelection(): IconSelection | null {
|
||||
if (!this.item.icon) return null;
|
||||
|
||||
return {
|
||||
type: this.item.iconType || 'PRIME_NG',
|
||||
value: this.item.icon
|
||||
};
|
||||
}
|
||||
|
||||
@HostBinding('class.active-menuitem')
|
||||
get activeClass() {
|
||||
return this.active && !this.root;
|
||||
|
||||
-6
@@ -23,10 +23,4 @@ export class BackgroundUploadService {
|
||||
map(resp => resp?.url)
|
||||
);
|
||||
}
|
||||
|
||||
resetToDefault(): Observable<void> {
|
||||
return this.http.delete<void>(this.baseUrl).pipe(
|
||||
tap(() => console.log('Background reset to default'))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user