WIP: Arrange UI files for better structuring
This commit is contained in:
+13
-13
@@ -1,25 +1,25 @@
|
||||
import {Component, OnInit, ViewChild} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {MenuItem, MessageService} from 'primeng/api';
|
||||
import {LibraryService} from '../../service/library.service';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {LibraryService} from '../service/library.service';
|
||||
import {BookService} from '../service/book.service';
|
||||
import {map, switchMap} from 'rxjs/operators';
|
||||
import {BehaviorSubject, Observable, of} from 'rxjs';
|
||||
import {ShelfService} from '../../service/shelf.service';
|
||||
import {ShelfService} from '../service/shelf.service';
|
||||
import {ShelfAssignerComponent} from '../shelf-assigner/shelf-assigner.component';
|
||||
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {Library} from '../../model/library.model';
|
||||
import {Shelf} from '../../model/shelf.model';
|
||||
import {SortService} from '../../service/sort.service';
|
||||
import {SortOption} from '../../model/sort.model';
|
||||
import {BookState} from '../../model/state/book-state.model';
|
||||
import {Book} from '../../model/book.model';
|
||||
import {LibraryShelfMenuService} from '../../service/library-shelf-menu.service';
|
||||
import {Library} from '../model/library.model';
|
||||
import {Shelf} from '../model/shelf.model';
|
||||
import {SortService} from '../service/sort.service';
|
||||
import {SortOption} from '../model/sort.model';
|
||||
import {BookState} from '../model/state/book-state.model';
|
||||
import {Book} from '../model/book.model';
|
||||
import {LibraryShelfMenuService} from '../service/library-shelf-menu.service';
|
||||
import {SelectButtonChangeEvent} from 'primeng/selectbutton';
|
||||
import {BookTableComponent} from '../book-table/book-table.component';
|
||||
import {BookTableComponent} from './book-table/book-table.component';
|
||||
import {animate, state, style, transition, trigger} from '@angular/animations';
|
||||
import {MetadataFetchOptionsComponent} from '../../../metadata-fetch-options/metadata-fetch-options.component';
|
||||
import {MetadataRefreshType} from '../../model/request/metadata/metadata-refresh-type.enum';
|
||||
import {MetadataFetchOptionsComponent} from '../../metadata/metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
|
||||
import {MetadataRefreshType} from '../../metadata/model/request/metadata-refresh-type.enum';
|
||||
|
||||
export enum EntityType {
|
||||
LIBRARY = 'Library',
|
||||
+2
-2
@@ -5,13 +5,13 @@ import {Router} from '@angular/router';
|
||||
import {MenuModule} from 'primeng/menu';
|
||||
import {MenuItem} from 'primeng/api';
|
||||
import {DialogService} from 'primeng/dynamicdialog';
|
||||
import {ShelfAssignerComponent} from '../shelf-assigner/shelf-assigner.component';
|
||||
import {ShelfAssignerComponent} from '../../shelf-assigner/shelf-assigner.component';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {CheckboxModule} from 'primeng/checkbox';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {NgIf} from '@angular/common';
|
||||
import {Observable} from 'rxjs';
|
||||
import {BookMetadataCenterComponent} from '../../../book-metadata-center/book-metadata-center.component';
|
||||
import {BookMetadataCenterComponent} from '../../../metadata/book-metadata-center/book-metadata-center.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-card',
|
||||
+1
-1
@@ -4,7 +4,7 @@ import {NgIf} from '@angular/common';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {Rating} from 'primeng/rating';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {BookMetadataCenterComponent} from '../../../book-metadata-center/book-metadata-center.component';
|
||||
import {BookMetadataCenterComponent} from '../../../metadata/book-metadata-center/book-metadata-center.component';
|
||||
import {DialogService} from 'primeng/dynamicdialog';
|
||||
import {Book} from '../../model/book.model';
|
||||
import {SortOption} from '../../model/sort.model';
|
||||
+12
-11
@@ -1,29 +1,30 @@
|
||||
import {Component, OnDestroy, OnInit} from '@angular/core';
|
||||
import {Subject, Subscription} from 'rxjs';
|
||||
import {catchError, debounceTime, distinctUntilChanged, switchMap} from 'rxjs/operators';
|
||||
import {Book} from '../../model/book.model';
|
||||
import {Book} from '../model/book.model';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {InputTextModule} from 'primeng/inputtext';
|
||||
import {NgForOf, NgIf} from '@angular/common';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Router} from '@angular/router';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {BookMetadataCenterComponent} from '../../../book-metadata-center/book-metadata-center.component';
|
||||
import {BookService} from '../service/book.service';
|
||||
import {BookMetadataCenterComponent} from '../../metadata/book-metadata-center/book-metadata-center.component';
|
||||
import {DialogService} from 'primeng/dynamicdialog';
|
||||
import {Button} from 'primeng/button';
|
||||
import {NgForOf, NgIf} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-search',
|
||||
templateUrl: './search.component.html',
|
||||
selector: 'app-book-searcher',
|
||||
templateUrl: './book-searcher.component.html',
|
||||
imports: [
|
||||
FormsModule,
|
||||
InputTextModule,
|
||||
NgForOf,
|
||||
Button,
|
||||
NgIf,
|
||||
Button
|
||||
NgForOf
|
||||
],
|
||||
styleUrls: ['./search.component.scss']
|
||||
styleUrls: ['./book-searcher.component.scss'],
|
||||
standalone: true
|
||||
})
|
||||
export class SearchComponent implements OnInit, OnDestroy {
|
||||
export class BookSearcherComponent implements OnInit, OnDestroy {
|
||||
searchQuery: string = '';
|
||||
books: Book[] = [];
|
||||
#searchSubject = new Subject<string>();
|
||||
@@ -1,46 +0,0 @@
|
||||
<div class="config-panel-content">
|
||||
|
||||
<div class="config-panel-colors">
|
||||
<span class="config-panel-label">Primary</span>
|
||||
<div>
|
||||
@for (primaryColor of primaryColors(); track primaryColor.name) {
|
||||
<button
|
||||
type="button"
|
||||
[title]="primaryColor.name"
|
||||
(click)="updateColors($event, 'primary', primaryColor)"
|
||||
[ngClass]="{ 'active-color': primaryColor.name === selectedPrimaryColor() }"
|
||||
[style]="{ 'background-color': primaryColor.name === 'noir' ? 'var(--text-color)' : primaryColor.palette['500'] || 'transparent' }"
|
||||
></button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="config-panel-colors">
|
||||
<span class="config-panel-label">Surface</span>
|
||||
<div>
|
||||
@for (surface of surfaces; track surface.name) {
|
||||
<button
|
||||
type="button"
|
||||
[title]="surface.name"
|
||||
(click)="updateColors($event, 'surface', surface)"
|
||||
[ngClass]="{ 'active-color': selectedSurfaceColor() ? selectedSurfaceColor() === surface.name : surface.name === 'zinc' }"
|
||||
[style]="{'background-color': surface.name === 'noir' ? 'var(--text-color)' : surface.palette['500'] }">
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="config-panel-settings">
|
||||
<span class="config-panel-label">Presets</span>
|
||||
<p-selectbutton [options]="presets" [ngModel]="selectedPreset()" (ngModelChange)="onPresetChange($event)" [allowEmpty]="false" size="small"/>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<div class="flex-1">
|
||||
<div class="config-panel-settings">
|
||||
<span class="config-panel-label">Ripple</span>
|
||||
<p-toggleswitch [(ngModel)]="ripple"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -1,369 +0,0 @@
|
||||
import {CommonModule, isPlatformBrowser} from '@angular/common';
|
||||
import {Component, computed, inject, PLATFORM_ID} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {$t, updatePreset, updateSurfacePalette} from '@primeng/themes';
|
||||
import Aura from '@primeng/themes/aura';
|
||||
import Lara from '@primeng/themes/lara';
|
||||
import Material from '@primeng/themes/material';
|
||||
import Nora from '@primeng/themes/nora';
|
||||
import {ButtonModule} from 'primeng/button';
|
||||
import {PrimeNG} from 'primeng/config';
|
||||
import {InputSwitchModule} from 'primeng/inputswitch';
|
||||
import {RadioButtonModule} from 'primeng/radiobutton';
|
||||
import {SelectButton} from 'primeng/selectbutton';
|
||||
import {ToggleSwitchModule} from 'primeng/toggleswitch';
|
||||
import {AppConfigService} from '../../service/app-config.service';
|
||||
|
||||
interface ColorPalette {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
interface Palette {
|
||||
name: string;
|
||||
palette: ColorPalette;
|
||||
}
|
||||
|
||||
const presets = {
|
||||
Aura,
|
||||
Material,
|
||||
Lara,
|
||||
Nora
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'app-configurator',
|
||||
standalone: true,
|
||||
templateUrl: './configurator.component.html',
|
||||
host: {
|
||||
class: 'config-panel hidden'
|
||||
},
|
||||
imports: [CommonModule, FormsModule, InputSwitchModule, ButtonModule, RadioButtonModule, SelectButton, ToggleSwitchModule]
|
||||
})
|
||||
export class AppConfiguratorComponent {
|
||||
|
||||
get ripple() {
|
||||
return this.config.ripple();
|
||||
}
|
||||
|
||||
set ripple(value: boolean) {
|
||||
this.config.ripple.set(value);
|
||||
}
|
||||
|
||||
config: PrimeNG = inject(PrimeNG);
|
||||
configService: AppConfigService = inject(AppConfigService);
|
||||
presets = Object.keys(presets);
|
||||
platformId = inject(PLATFORM_ID);
|
||||
|
||||
surfaces = [
|
||||
{
|
||||
name: 'slate',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#f8fafc',
|
||||
100: '#f1f5f9',
|
||||
200: '#e2e8f0',
|
||||
300: '#cbd5e1',
|
||||
400: '#94a3b8',
|
||||
500: '#64748b',
|
||||
600: '#475569',
|
||||
700: '#334155',
|
||||
800: '#1e293b',
|
||||
900: '#0f172a',
|
||||
950: '#020617'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'gray',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#f9fafb',
|
||||
100: '#f3f4f6',
|
||||
200: '#e5e7eb',
|
||||
300: '#d1d5db',
|
||||
400: '#9ca3af',
|
||||
500: '#6b7280',
|
||||
600: '#4b5563',
|
||||
700: '#374151',
|
||||
800: '#1f2937',
|
||||
900: '#111827',
|
||||
950: '#030712'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'zinc',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#fafafa',
|
||||
100: '#f4f4f5',
|
||||
200: '#e4e4e7',
|
||||
300: '#d4d4d8',
|
||||
400: '#a1a1aa',
|
||||
500: '#71717a',
|
||||
600: '#52525b',
|
||||
700: '#3f3f46',
|
||||
800: '#27272a',
|
||||
900: '#18181b',
|
||||
950: '#09090b'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'neutral',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#fafafa',
|
||||
100: '#f5f5f5',
|
||||
200: '#e5e5e5',
|
||||
300: '#d4d4d4',
|
||||
400: '#a3a3a3',
|
||||
500: '#737373',
|
||||
600: '#525252',
|
||||
700: '#404040',
|
||||
800: '#262626',
|
||||
900: '#171717',
|
||||
950: '#0a0a0a'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'stone',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#fafaf9',
|
||||
100: '#f5f5f4',
|
||||
200: '#e7e5e4',
|
||||
300: '#d6d3d1',
|
||||
400: '#a8a29e',
|
||||
500: '#78716c',
|
||||
600: '#57534e',
|
||||
700: '#44403c',
|
||||
800: '#292524',
|
||||
900: '#1c1917',
|
||||
950: '#0c0a09'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'soho',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#ececec',
|
||||
100: '#dedfdf',
|
||||
200: '#c4c4c6',
|
||||
300: '#adaeb0',
|
||||
400: '#97979b',
|
||||
500: '#7f8084',
|
||||
600: '#6a6b70',
|
||||
700: '#55565b',
|
||||
800: '#3f4046',
|
||||
900: '#2c2c34',
|
||||
950: '#16161d'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'viva',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#f3f3f3',
|
||||
100: '#e7e7e8',
|
||||
200: '#cfd0d0',
|
||||
300: '#b7b8b9',
|
||||
400: '#9fa1a1',
|
||||
500: '#87898a',
|
||||
600: '#6e7173',
|
||||
700: '#565a5b',
|
||||
800: '#3e4244',
|
||||
900: '#262b2c',
|
||||
950: '#0e1315'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'ocean',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#fbfcfc',
|
||||
100: '#F7F9F8',
|
||||
200: '#EFF3F2',
|
||||
300: '#DADEDD',
|
||||
400: '#B1B7B6',
|
||||
500: '#828787',
|
||||
600: '#5F7274',
|
||||
700: '#415B61',
|
||||
800: '#29444E',
|
||||
900: '#183240',
|
||||
950: '#0c1920'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
selectedPrimaryColor = computed(() => {
|
||||
return this.configService.appState().primary;
|
||||
});
|
||||
|
||||
selectedSurfaceColor = computed(() => this.configService.appState().surface);
|
||||
|
||||
selectedPreset = computed(() => this.configService.appState().preset);
|
||||
|
||||
primaryColors = computed(() => {
|
||||
// @ts-ignore
|
||||
const presetPalette = presets[this.configService.appState().preset].primitive;
|
||||
const colors = ['emerald', 'green', 'lime', 'orange', 'amber', 'yellow', 'teal', 'cyan', 'sky', 'blue', 'indigo', 'violet', 'purple', 'fuchsia', 'pink', 'rose'];
|
||||
const palettes: Palette[] = [{ name: 'noir', palette: {} }];
|
||||
|
||||
colors.forEach((color) => {
|
||||
palettes.push({
|
||||
name: color,
|
||||
palette: presetPalette[color] || {}, // Fallback to an empty object
|
||||
});
|
||||
});
|
||||
|
||||
return palettes;
|
||||
});
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
this.onPresetChange(this.configService.appState().preset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getPresetExt() {
|
||||
const color = this.primaryColors().find((c) => c.name === this.selectedPrimaryColor());
|
||||
|
||||
if (color!.name === 'noir') {
|
||||
return {
|
||||
semantic: {
|
||||
primary: {
|
||||
50: '{surface.50}',
|
||||
100: '{surface.100}',
|
||||
200: '{surface.200}',
|
||||
300: '{surface.300}',
|
||||
400: '{surface.400}',
|
||||
500: '{surface.500}',
|
||||
600: '{surface.600}',
|
||||
700: '{surface.700}',
|
||||
800: '{surface.800}',
|
||||
900: '{surface.900}',
|
||||
950: '{surface.950}'
|
||||
},
|
||||
colorScheme: {
|
||||
dark: {
|
||||
primary: {
|
||||
color: '{primary.50}',
|
||||
contrastColor: '{primary.950}',
|
||||
hoverColor: '{primary.200}',
|
||||
activeColor: '{primary.300}'
|
||||
},
|
||||
highlight: {
|
||||
background: '{primary.50}',
|
||||
focusBackground: '{primary.300}',
|
||||
color: '{primary.950}',
|
||||
focusColor: '{primary.950}'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
if (this.configService.appState().preset === 'Nora') {
|
||||
return {
|
||||
semantic: {
|
||||
primary: color!.palette,
|
||||
colorScheme: {
|
||||
dark: {
|
||||
primary: {
|
||||
color: '{primary.500}',
|
||||
contrastColor: '{surface.900}',
|
||||
hoverColor: '{primary.400}',
|
||||
activeColor: '{primary.300}'
|
||||
},
|
||||
highlight: {
|
||||
background: '{primary.500}',
|
||||
focusBackground: '{primary.400}',
|
||||
color: '{surface.900}',
|
||||
focusColor: '{surface.900}'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
} else if (this.configService.appState().preset === 'Material') {
|
||||
return {
|
||||
semantic: {
|
||||
primary: color!.palette,
|
||||
colorScheme: {
|
||||
dark: {
|
||||
primary: {
|
||||
color: '{primary.400}',
|
||||
contrastColor: '{surface.900}',
|
||||
hoverColor: '{primary.300}',
|
||||
activeColor: '{primary.200}'
|
||||
},
|
||||
highlight: {
|
||||
background: 'color-mix(in srgb, {primary.400}, transparent 84%)',
|
||||
focusBackground: 'color-mix(in srgb, {primary.400}, transparent 76%)',
|
||||
color: 'rgba(255,255,255,.87)',
|
||||
focusColor: 'rgba(255,255,255,.87)'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
semantic: {
|
||||
primary: color!.palette,
|
||||
colorScheme: {
|
||||
dark: {
|
||||
primary: {
|
||||
color: '{primary.400}',
|
||||
contrastColor: '{surface.900}',
|
||||
hoverColor: '{primary.300}',
|
||||
activeColor: '{primary.200}'
|
||||
},
|
||||
highlight: {
|
||||
background: 'color-mix(in srgb, {primary.400}, transparent 84%)',
|
||||
focusBackground: 'color-mix(in srgb, {primary.400}, transparent 76%)',
|
||||
color: 'rgba(255,255,255,.87)',
|
||||
focusColor: 'rgba(255,255,255,.87)'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateColors(event: any, type: string, color: any) {
|
||||
if (type === 'primary') {
|
||||
this.configService.appState.update((state) => ({...state, primary: color.name}));
|
||||
} else if (type === 'surface') {
|
||||
this.configService.appState.update((state) => ({...state, surface: color.name}));
|
||||
}
|
||||
this.applyTheme(type, color);
|
||||
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
applyTheme(type: string, color: any) {
|
||||
if (type === 'primary') {
|
||||
updatePreset(this.getPresetExt());
|
||||
} else if (type === 'surface') {
|
||||
updateSurfacePalette(color.palette);
|
||||
}
|
||||
}
|
||||
|
||||
onPresetChange(event: any) {
|
||||
this.configService.appState.update((state) => ({...state, preset: event}));
|
||||
// @ts-ignore
|
||||
const preset = presets[event];
|
||||
const surfacePalette = this.surfaces.find((s) => s.name === this.selectedSurfaceColor())?.palette;
|
||||
if (this.configService.appState().preset === 'Material') {
|
||||
document.body.classList.add('material');
|
||||
this.config.ripple.set(true);
|
||||
} else {
|
||||
document.body.classList.remove('material');
|
||||
this.config.ripple.set(false);
|
||||
}
|
||||
$t().preset(preset).preset(this.getPresetExt()).surfacePalette(surfacePalette).use({useDefaultOptions: true});
|
||||
}
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
<div class="dashboard-scroller-container">
|
||||
|
||||
<h2 class="dashboard-scroller-title">{{ title }}</h2>
|
||||
|
||||
<div class="no-books-container" *ngIf="!(bookState$ | async)?.error && (bookState$ | async)?.loaded && (bookState$ | async)?.books?.length === 0">
|
||||
<p class="no-books-text">
|
||||
{{ bookListType === 'lastRead' ? "You haven't read any books yet!" : "No books have been added to BookLore!" }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="no-books-container" *ngIf="(bookState$ | async)?.error">
|
||||
<p class="no-books-text">Failed to load books! :(</p>
|
||||
</div>
|
||||
|
||||
<div *ngIf="!(bookState$ | async)?.loaded && !(bookState$ | async)?.error">
|
||||
<p-progressSpinner></p-progressSpinner>
|
||||
</div>
|
||||
|
||||
<div class="infinite-scroller"
|
||||
infiniteScroll
|
||||
[infiniteScrollDistance]="2"
|
||||
[infiniteScrollThrottle]="50"
|
||||
#scrollContainer
|
||||
[horizontal]="true">
|
||||
<div class="infinite-scroller-a-book" *ngFor="let book of (bookState$ | async)?.books">
|
||||
<app-book-card [book]="book" [isCheckboxEnabled]="false"></app-book-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
.dashboard-scroller-container {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.dashboard-scroller-title {
|
||||
font-size: 1.5rem;
|
||||
color: var(--text-color);
|
||||
margin-bottom: 10px;
|
||||
padding: 5px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.no-books-text {
|
||||
font-size: 0.95rem;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.no-books-container {
|
||||
padding-top: 3rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.infinite-scroller {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
scroll-snap-type: x mandatory;
|
||||
padding: 5px;
|
||||
gap: 20px;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.infinite-scroller-a-book {
|
||||
overflow: hidden;
|
||||
background-color: var(--card-background);
|
||||
border-radius: 8px;
|
||||
flex: 0 0 9.5%;
|
||||
scroll-snap-align: start;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { BookService } from '../../service/book.service';
|
||||
import { BookState } from '../../model/state/book-state.model';
|
||||
import { BookCardComponent } from '../book-card/book-card.component';
|
||||
import { InfiniteScrollDirective } from 'ngx-infinite-scroll';
|
||||
import { AsyncPipe, NgForOf, NgIf } from '@angular/common';
|
||||
import {ProgressSpinnerModule} from 'primeng/progressspinner';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard-scroller',
|
||||
templateUrl: './dashboard-scroller.component.html',
|
||||
styleUrls: ['./dashboard-scroller.component.scss'],
|
||||
imports: [
|
||||
InfiniteScrollDirective,
|
||||
NgForOf,
|
||||
NgIf,
|
||||
BookCardComponent,
|
||||
AsyncPipe,
|
||||
ProgressSpinnerModule
|
||||
],
|
||||
})
|
||||
export class DashboardScrollerComponent implements OnInit {
|
||||
|
||||
@Input() bookListType: 'lastRead' | 'latestAdded' = 'lastRead';
|
||||
@Input() title: string = 'Last Read Books';
|
||||
@ViewChild('scrollContainer') scrollContainer!: ElementRef;
|
||||
|
||||
bookState$: Observable<BookState> | undefined;
|
||||
|
||||
constructor(private bookService: BookService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
if (this.bookListType === 'lastRead') {
|
||||
this.bookState$ = this.bookService.bookState$.pipe(
|
||||
map((state: BookState) => ({
|
||||
...state,
|
||||
books: (state.books || [])
|
||||
.filter(book => book.lastReadTime)
|
||||
.sort((a, b) => new Date(b.lastReadTime!).getTime() - new Date(a.lastReadTime!).getTime())
|
||||
.slice(0, 25)
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
if (this.bookListType === 'latestAdded') {
|
||||
this.bookState$ = this.bookService.bookState$.pipe(
|
||||
map((state: BookState) => ({
|
||||
...state,
|
||||
books: (state.books || [])
|
||||
.filter(book => book.addedOn)
|
||||
.sort((a, b) => new Date(b.addedOn!).getTime() - new Date(a.addedOn!).getTime())
|
||||
.slice(0, 25)
|
||||
}))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<div class="dashboard">
|
||||
|
||||
<div class="dashboard-no-library" *ngIf="isLibrariesEmpty$ | async; else dashboardScroller">
|
||||
<h1 class="no-library-header">
|
||||
Looks like you haven't added a library yet. Let's add one!
|
||||
</h1>
|
||||
<p-button
|
||||
label="Add a Library"
|
||||
icon="pi pi-plus"
|
||||
styleClass="p-button-rounded p-button-outlined"
|
||||
(click)="createNewLibrary()">
|
||||
</p-button>
|
||||
</div>
|
||||
|
||||
<ng-template #dashboardScroller>
|
||||
<app-dashboard-scroller [bookListType]="'lastRead'" title="Last Read Books"></app-dashboard-scroller>
|
||||
<app-dashboard-scroller [bookListType]="'latestAdded'" title="Latest Added Books"></app-dashboard-scroller>
|
||||
</ng-template>
|
||||
|
||||
</div>
|
||||
@@ -1,29 +0,0 @@
|
||||
.dashboard {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.dashboard .no-library-header {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 1rem;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.dashboard-no-library {
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
.dashboard .p-dialog {
|
||||
max-width: 90%;
|
||||
}
|
||||
|
||||
::ng-deep .p-dialog-mask {
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
::ng-deep .p-dialog-mask {
|
||||
backdrop-filter: blur(3px);
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Button} from 'primeng/button';
|
||||
import {AsyncPipe, NgIf} from '@angular/common';
|
||||
import {LibraryCreatorComponent} from '../library-creator/library-creator.component';
|
||||
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {DashboardScrollerComponent} from '../dashboard-scroller/dashboard-scroller.component';
|
||||
import {LibraryService} from '../../service/library.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {map} from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home-page',
|
||||
templateUrl: './dashboard.component.html',
|
||||
styleUrls: ['./dashboard.component.scss'],
|
||||
imports: [
|
||||
Button,
|
||||
NgIf,
|
||||
DashboardScrollerComponent,
|
||||
AsyncPipe
|
||||
],
|
||||
providers: [DialogService],
|
||||
})
|
||||
export class DashboardComponent {
|
||||
isLibrariesEmpty$: Observable<boolean>;
|
||||
ref: DynamicDialogRef | undefined;
|
||||
|
||||
constructor(private libraryService: LibraryService, public dialogService: DialogService) {
|
||||
this.isLibrariesEmpty$ = this.libraryService.libraryState$.pipe(
|
||||
map(state => !state.libraries || state.libraries.length === 0)
|
||||
);
|
||||
}
|
||||
|
||||
createNewLibrary() {
|
||||
this.ref = this.dialogService.open(LibraryCreatorComponent, {
|
||||
header: 'Create New Library',
|
||||
modal: true,
|
||||
closable: true,
|
||||
width: '675px',
|
||||
height: '480px',
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: '15%',
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<div style="margin-bottom: 1.5rem; display: flex; align-items: center; gap: 1rem;">
|
||||
<input
|
||||
id="disabled-input"
|
||||
type="text"
|
||||
pInputText
|
||||
[value]="selectedProductName"
|
||||
[disabled]="true"
|
||||
[ngStyle]="{ 'width': '100%', 'padding': '0.5rem', 'font-size': '1rem' }"
|
||||
/>
|
||||
<p-button label="Select" severity="success" [ngStyle]="{ 'width': '100px' }" (click)="onSelect()"/>
|
||||
</div>
|
||||
<ng-container>
|
||||
<div style="overflow-x: auto;">
|
||||
<p-table [value]="paths" [tableStyle]="{ 'min-width': '50rem' }" class="product-table">
|
||||
<ng-template pTemplate="header">
|
||||
<tr>
|
||||
<th [style.width]="'10%'">Type</th>
|
||||
<th [style.width]="'90%'">Name</th>
|
||||
</tr>
|
||||
</ng-template>
|
||||
|
||||
<ng-template pTemplate="body" let-product>
|
||||
<tr (click)="onRowClick(product)">
|
||||
<td>
|
||||
<i *ngIf="product === '...'" class="pi pi-arrow-up"></i>
|
||||
<i *ngIf="product !== '...'" class="pi pi-folder-open"></i>
|
||||
</td>
|
||||
<td>{{ product }}</td>
|
||||
</tr>
|
||||
</ng-template>
|
||||
</p-table>
|
||||
</div>
|
||||
</ng-container>
|
||||
@@ -1,53 +0,0 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {UtilityService} from '../../service/utility.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-directory-picker-v2',
|
||||
standalone: false,
|
||||
templateUrl: './directory-picker.component.html',
|
||||
styleUrls: ['./directory-picker.component.scss']
|
||||
})
|
||||
export class DirectoryPickerComponent implements OnInit {
|
||||
value: any;
|
||||
paths: string[] = ['...'];
|
||||
selectedProductName: string = '';
|
||||
|
||||
constructor(private utilityService: UtilityService, private dynamicDialogRef: DynamicDialogRef) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
const initialPath = '/';
|
||||
this.getFolders(initialPath);
|
||||
}
|
||||
|
||||
getFolders(path: string): void {
|
||||
this.utilityService.getFolders(path).subscribe(
|
||||
(folders: string[]) => {
|
||||
this.paths = ['...', ...folders];
|
||||
},
|
||||
(error) => {
|
||||
console.error('Error fetching folders:', error);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
this.selectedProductName = path;
|
||||
this.getFolders(path);
|
||||
}
|
||||
}
|
||||
|
||||
onSelect(): void {
|
||||
this.dynamicDialogRef.close(this.selectedProductName);
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
<div class="card">
|
||||
|
||||
<div class="flex">
|
||||
<p-dropdown
|
||||
[options]="(libraryState$ | async)?.libraries || []"
|
||||
optionLabel="name"
|
||||
placeholder="Select Library"
|
||||
[(ngModel)]="selectedLibrary">
|
||||
</p-dropdown>
|
||||
</div>
|
||||
|
||||
<div class="flex">
|
||||
<p-dropdown
|
||||
[options]="selectedLibrary?.paths"
|
||||
placeholder="Select Upload Location"
|
||||
[(ngModel)]="selectedPath"
|
||||
[disabled]="!selectedLibrary">
|
||||
</p-dropdown>
|
||||
</div>
|
||||
|
||||
<div class="flex">
|
||||
<div class="button-container">
|
||||
<p-button
|
||||
severity="info"
|
||||
label="Choose"
|
||||
icon="pi pi-file"
|
||||
(click)="triggerFileInput(fileInput)"
|
||||
[disabled]="!selectedPath || isUploading">
|
||||
</p-button>
|
||||
<span *ngIf="selectedFileName" class="file-name">{{ selectedFileName }}</span>
|
||||
</div>
|
||||
<input
|
||||
type="file"
|
||||
#fileInput
|
||||
style="display: none;"
|
||||
(change)="onFileSelected($event)"
|
||||
[disabled]="!selectedPath || isUploading"/>
|
||||
</div>
|
||||
|
||||
<div class="flex">
|
||||
<p-button
|
||||
[label]="isUploading ? 'Uploading...' : 'Upload'"
|
||||
[disabled]="!isFormValid() || isUploading"
|
||||
icon="pi pi-cloud-upload"
|
||||
(click)="uploadFile()">
|
||||
</p-button>
|
||||
<div class="error-message-container">
|
||||
<span *ngIf="errorMessage" class="error-message">{{ errorMessage }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -1,28 +0,0 @@
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.flex + .flex {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.button-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.file-name {
|
||||
font-weight: bold;
|
||||
color: var(--text-color-secondary);
|
||||
}
|
||||
|
||||
.error-message-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
color: var(--red-600);
|
||||
margin-left: 10px;
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Library} from '../../model/library.model';
|
||||
import {FileUploadService} from '../../service/file-upload.service';
|
||||
import {Button} from 'primeng/button';
|
||||
import {AsyncPipe, NgIf} from '@angular/common';
|
||||
import {DropdownModule} from 'primeng/dropdown';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {ToastService} from '../../service/toast.service';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {LibraryService} from '../../service/library.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {LibraryState} from '../../model/state/library-state.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-file-upload-v2',
|
||||
templateUrl: './file-upload.component.html',
|
||||
styleUrls: ['./file-upload.component.scss'],
|
||||
imports: [
|
||||
Button,
|
||||
NgIf,
|
||||
DropdownModule,
|
||||
FormsModule,
|
||||
AsyncPipe
|
||||
],
|
||||
})
|
||||
export class FileUploadComponent {
|
||||
libraryState$: Observable<LibraryState>;
|
||||
selectedLibrary: Library | null = null;
|
||||
selectedPath: string = '';
|
||||
selectedFileName: string = '';
|
||||
isUploading: boolean = false;
|
||||
errorMessage: string | null = null;
|
||||
|
||||
constructor(
|
||||
private libraryService: LibraryService,
|
||||
private fileUploadService: FileUploadService,
|
||||
private toastService: ToastService,
|
||||
private dynamicDialogRef: DynamicDialogRef) {
|
||||
this.libraryState$ = this.libraryService.libraryState$;
|
||||
}
|
||||
|
||||
triggerFileInput(fileInput: HTMLInputElement): void {
|
||||
fileInput.click();
|
||||
}
|
||||
|
||||
onFileSelected(event: Event): void {
|
||||
const input = event.target as HTMLInputElement;
|
||||
if (input && input.files) {
|
||||
const file = input.files[0];
|
||||
if (file) {
|
||||
this.selectedFileName = file.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
isFormValid(): boolean {
|
||||
return !!this.selectedLibrary && !!this.selectedPath && !!this.selectedFileName;
|
||||
}
|
||||
|
||||
uploadFile(): void {
|
||||
this.errorMessage = null;
|
||||
if (!this.isFormValid()) {
|
||||
return;
|
||||
}
|
||||
const fileInput = document.querySelector('input[type="file"]') as HTMLInputElement;
|
||||
if (!fileInput || !fileInput.files || fileInput.files.length === 0) {
|
||||
return;
|
||||
}
|
||||
const file = fileInput.files[0];
|
||||
const libraryId = this.selectedLibrary?.id ? this.selectedLibrary.id.toString() : '';
|
||||
const path = this.selectedPath || '';
|
||||
this.isUploading = true;
|
||||
this.fileUploadService.uploadFile(file, libraryId, path)
|
||||
.subscribe(
|
||||
(response) => {
|
||||
console.log('File uploaded successfully');
|
||||
this.toastService.showSuccess("File uploaded", file.name);
|
||||
this.isUploading = false;
|
||||
this.dynamicDialogRef.close();
|
||||
},
|
||||
(error) => {
|
||||
this.isUploading = false;
|
||||
this.toastService.showError("Upload failed", error.error.message);
|
||||
this.errorMessage = "Upload failed. " + error.error.message + ".";
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<p-dialog
|
||||
[(visible)]="iconDialogVisible"
|
||||
header="Select an Icon"
|
||||
[modal]="true"
|
||||
[draggable]="false"
|
||||
[style]="{ width: '500px', height: '500px' }">
|
||||
<input type="text" placeholder="Search icons..." [(ngModel)]="searchText" class="icon-search"/>
|
||||
<div class="icon-grid">
|
||||
<div
|
||||
*ngFor="let icon of filteredIcons()"
|
||||
class="icon-item"
|
||||
(click)="selectIcon(icon)"
|
||||
[class.selected]="icon === selectedIcon">
|
||||
<i [class]="icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</p-dialog>
|
||||
@@ -1,32 +0,0 @@
|
||||
.icon-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(25px, 1fr));
|
||||
gap: 30px;
|
||||
}
|
||||
|
||||
.icon-item {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.icon-search {
|
||||
width: 100%;
|
||||
padding: 8px 12px;
|
||||
font-size: 16px;
|
||||
border: 1px solid var(--text-color-secondary);
|
||||
border-radius: 4px;
|
||||
margin-bottom: 15px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.icon-search:focus {
|
||||
border-color: var(--primary-color);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.icon-search::placeholder {
|
||||
color: var(--text-color-secondary);
|
||||
opacity: 1;
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
import {Component, EventEmitter, Output} from '@angular/core';
|
||||
import {DialogModule} from 'primeng/dialog';
|
||||
import {NgForOf} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-icon-picker',
|
||||
templateUrl: './icon-picker.component.html',
|
||||
styleUrls: ['./icon-picker.component.scss'],
|
||||
imports: [
|
||||
DialogModule,
|
||||
NgForOf,
|
||||
FormsModule
|
||||
],
|
||||
})
|
||||
export class IconPickerComponent {
|
||||
iconDialogVisible: boolean = false;
|
||||
selectedIcon: string | null = null;
|
||||
searchText: string = '';
|
||||
iconCategories: string[] = [
|
||||
"address-book", "align-center", "align-justify", "align-left", "align-right", "android",
|
||||
"angle-double-down", "angle-double-left", "angle-double-right", "angle-double-up", "angle-down", "angle-left",
|
||||
"angle-right", "angle-up", "apple", "arrow-circle-down", "arrow-circle-left", "arrow-circle-right",
|
||||
"arrow-circle-up", "arrow-down-left-and-arrow-up-right-to-center", "arrow-down-left", "arrow-down-right", "arrow-down", "arrow-left",
|
||||
"arrow-right-arrow-left", "arrow-right", "arrow-up-left", "arrow-up-right-and-arrow-down-left-from-center", "arrow-up-right", "arrow-up",
|
||||
"arrows-alt", "arrows-h", "arrows-v", "asterisks", "at", "backward", "ban", "barcode", "bars", "bell-slash", "bell", "bitcoin",
|
||||
"bolt", "book", "bookmark-fill", "bookmark", "box", "briefcase", "building-columns", "building", "bullseye", "calculator", "calendar-clock", "calendar-minus",
|
||||
"calendar-plus", "calendar-times", "calendar", "camera", "car", "caret-down", "caret-left", "caret-right", "caret-up", "cart-arrow-down", "cart-minus", "cart-plus",
|
||||
"chart-bar", "chart-line", "chart-pie", "chart-scatter", "check-circle", "check-square", "check", "chevron-circle-down", "chevron-circle-left", "chevron-circle-right",
|
||||
"chevron-circle-up", "chevron-down", "chevron-left", "chevron-right", "chevron-up", "circle-fill", "circle-off", "circle-on", "circle", "clipboard", "clock", "clone", "cloud-download", "cloud-upload",
|
||||
"cloud", "code", "cog", "comment", "comments", "compass", "copy", "credit-card", "crown", "database", "delete-left", "desktop",
|
||||
"directions-alt", "directions", "discord", "dollar", "download", "eject", "ellipsis-h", "ellipsis-v", "envelope", "equals", "eraser", "ethereum",
|
||||
"euro", "exclamation-circle", "exclamation-triangle", "expand", "external-link", "eye-slash", "eye", "face-smile", "facebook", "fast-backward", "fast-forward", "file-arrow-up",
|
||||
"file-check", "file-edit", "file-excel", "file-export", "file-import", "file-o", "file-pdf", "file-plus", "file-word", "file", "filter-fill", "filter-slash",
|
||||
"filter", "flag-fill", "flag", "folder-open", "folder-plus", "folder", "forward", "gauge", "gift", "github", "globe", "google",
|
||||
"graduation-cap", "hammer", "hashtag", "headphones", "heart-fill", "heart", "history", "home", "hourglass", "id-card", "image", "images",
|
||||
"inbox", "indian-rupee", "info-circle", "info", "instagram", "key", "language", "lightbulb", "link", "linkedin", "list-check", "list",
|
||||
"lock-open", "lock", "map-marker", "map", "mars", "megaphone", "microchip-ai", "microchip", "microphone", "microsoft", "minus-circle", "minus",
|
||||
"mobile", "money-bill", "moon", "objects-column", "palette", "paperclip", "pause-circle", "pause", "paypal", "pen-to-square", "pencil", "percentage",
|
||||
"phone", "pinterest", "play-circle", "play", "plus-circle", "plus", "pound", "power-off", "prime", "print", "qrcode", "question-circle",
|
||||
"question", "receipt", "reddit", "refresh", "replay", "reply", "save", "search-minus", "search-plus", "search", "send", "server",
|
||||
"share-alt", "shield", "shop", "shopping-bag", "shopping-cart", "sign-in", "sign-out", "sitemap", "slack", "sliders-h", "sliders-v", "sort-alpha-alt-down",
|
||||
"sort-alpha-alt-up", "sort-alpha-down", "sort-alpha-up", "sort-alt-slash", "sort-alt", "sort-amount-down-alt", "sort-amount-down", "sort-amount-up-alt",
|
||||
"sort-amount-up", "sort-down-fill", "sort-down", "sort-numeric-alt-down",
|
||||
"sort-numeric-alt-up", "sort-numeric-down", "sort-numeric-up", "sort-up-fill", "sort-up", "sort", "sparkles", "spinner-dotted", "spinner", "star-fill", "star-half-fill", "star-half",
|
||||
"star", "step-backward-alt", "step-backward", "step-forward-alt", "step-forward", "stop-circle", "stop", "stopwatch", "sun", "sync", "table", "tablet",
|
||||
"tag", "tags", "telegram", "th-large", "thumbs-down-fill", "thumbs-down", "thumbs-up-fill", "thumbs-up", "thumbtack", "ticket", "tiktok", "times-circle",
|
||||
"times", "trash", "trophy", "truck", "turkish-lira", "twitch", "twitter", "undo", "unlock", "upload", "user-edit", "user-minus",
|
||||
"user-plus", "user", "users", "venus", "verified", "video", "vimeo", "volume-down", "volume-off", "volume-up", "wallet", "warehouse",
|
||||
"wave-pulse", "whatsapp", "wifi", "window-maximize", "window-minimize", "wrench", "youtube"
|
||||
];
|
||||
|
||||
icons: string[] = this.createIconList(this.iconCategories);
|
||||
|
||||
@Output() iconSelected = new EventEmitter<string>();
|
||||
|
||||
createIconList(categories: string[]): string[] {
|
||||
return categories.map(iconName => `pi pi-${iconName}`);
|
||||
}
|
||||
|
||||
filteredIcons(): string[] {
|
||||
if (!this.searchText) {
|
||||
return this.icons;
|
||||
}
|
||||
return this.icons.filter(icon => icon.toLowerCase().includes(this.searchText.toLowerCase()));
|
||||
}
|
||||
|
||||
open() {
|
||||
this.iconDialogVisible = true;
|
||||
}
|
||||
|
||||
selectIcon(icon: string) {
|
||||
this.selectedIcon = icon;
|
||||
this.iconDialogVisible = false;
|
||||
this.iconSelected.emit(icon);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
export interface MenuChangeEvent {
|
||||
key: string;
|
||||
routeEvent?: boolean;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<div class="layout-wrapper" [ngClass]="containerClass">
|
||||
<app-topbar></app-topbar>
|
||||
<div class="layout-sidebar layout-sidebar-custom">
|
||||
<app-sidebar></app-sidebar>
|
||||
</div>
|
||||
<div class="layout-main-container">
|
||||
<div class="layout-main">
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout-mask"></div>
|
||||
</div>
|
||||
@@ -1,130 +0,0 @@
|
||||
import { Component, OnDestroy, Renderer2, ViewChild } from '@angular/core';
|
||||
import {NavigationEnd, Router, RouterOutlet} from '@angular/router';
|
||||
import { filter, Subscription } from 'rxjs';
|
||||
import { LayoutService } from "./service/app.layout.service";
|
||||
import { AppSidebarComponent } from "./app.sidebar.component";
|
||||
import { AppTopBarComponent } from './app.topbar.component';
|
||||
import {NgClass} from '@angular/common';
|
||||
import {ToastModule} from 'primeng/toast';
|
||||
|
||||
@Component({
|
||||
selector: 'app-layout',
|
||||
imports: [
|
||||
RouterOutlet,
|
||||
AppSidebarComponent,
|
||||
AppTopBarComponent,
|
||||
NgClass,
|
||||
ToastModule
|
||||
],
|
||||
templateUrl: './app.layout.component.html'
|
||||
})
|
||||
export class AppLayoutComponent implements OnDestroy {
|
||||
|
||||
overlayMenuOpenSubscription: Subscription;
|
||||
|
||||
menuOutsideClickListener: any;
|
||||
|
||||
profileMenuOutsideClickListener: any;
|
||||
|
||||
@ViewChild(AppSidebarComponent) appSidebar!: AppSidebarComponent;
|
||||
|
||||
@ViewChild(AppTopBarComponent) appTopbar!: AppTopBarComponent;
|
||||
|
||||
constructor(public layoutService: LayoutService, public renderer: Renderer2, public router: Router) {
|
||||
this.overlayMenuOpenSubscription = this.layoutService.overlayOpen$.subscribe(() => {
|
||||
if (!this.menuOutsideClickListener) {
|
||||
this.menuOutsideClickListener = this.renderer.listen('document', 'click', event => {
|
||||
const isOutsideClicked = !(this.appSidebar.el.nativeElement.isSameNode(event.target) || this.appSidebar.el.nativeElement.contains(event.target)
|
||||
|| this.appTopbar.menuButton.nativeElement.isSameNode(event.target) || this.appTopbar.menuButton.nativeElement.contains(event.target));
|
||||
|
||||
if (isOutsideClicked) {
|
||||
this.hideMenu();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!this.profileMenuOutsideClickListener) {
|
||||
this.profileMenuOutsideClickListener = this.renderer.listen('document', 'click', event => {
|
||||
const isOutsideClicked = !(this.appTopbar.menu.nativeElement.isSameNode(event.target) || this.appTopbar.menu.nativeElement.contains(event.target)
|
||||
|| this.appTopbar.topbarMenuButton.nativeElement.isSameNode(event.target) || this.appTopbar.topbarMenuButton.nativeElement.contains(event.target));
|
||||
|
||||
if (isOutsideClicked) {
|
||||
this.hideProfileMenu();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (this.layoutService.state.staticMenuMobileActive) {
|
||||
this.blockBodyScroll();
|
||||
}
|
||||
});
|
||||
|
||||
this.router.events.pipe(filter(event => event instanceof NavigationEnd))
|
||||
.subscribe(() => {
|
||||
this.hideMenu();
|
||||
this.hideProfileMenu();
|
||||
});
|
||||
}
|
||||
|
||||
hideMenu() {
|
||||
this.layoutService.state.overlayMenuActive = false;
|
||||
this.layoutService.state.staticMenuMobileActive = false;
|
||||
this.layoutService.state.menuHoverActive = false;
|
||||
if (this.menuOutsideClickListener) {
|
||||
this.menuOutsideClickListener();
|
||||
this.menuOutsideClickListener = null;
|
||||
}
|
||||
this.unblockBodyScroll();
|
||||
}
|
||||
|
||||
hideProfileMenu() {
|
||||
this.layoutService.state.profileSidebarVisible = false;
|
||||
if (this.profileMenuOutsideClickListener) {
|
||||
this.profileMenuOutsideClickListener();
|
||||
this.profileMenuOutsideClickListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
blockBodyScroll(): void {
|
||||
if (document.body.classList) {
|
||||
document.body.classList.add('blocked-scroll');
|
||||
}
|
||||
else {
|
||||
document.body.className += ' blocked-scroll';
|
||||
}
|
||||
}
|
||||
|
||||
unblockBodyScroll(): void {
|
||||
if (document.body.classList) {
|
||||
document.body.classList.remove('blocked-scroll');
|
||||
}
|
||||
else {
|
||||
document.body.className = document.body.className.replace(new RegExp('(^|\\b)' +
|
||||
'blocked-scroll'.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
|
||||
}
|
||||
}
|
||||
|
||||
get containerClass() {
|
||||
return {
|
||||
'layout-theme-light': this.layoutService.config().colorScheme === 'light',
|
||||
'layout-theme-dark': this.layoutService.config().colorScheme === 'dark',
|
||||
'layout-overlay': this.layoutService.config().menuMode === 'overlay',
|
||||
'layout-static': this.layoutService.config().menuMode === 'static',
|
||||
'layout-static-inactive': this.layoutService.state.staticMenuDesktopInactive && this.layoutService.config().menuMode === 'static',
|
||||
'layout-overlay-active': this.layoutService.state.overlayMenuActive,
|
||||
'layout-mobile-active': this.layoutService.state.staticMenuMobileActive,
|
||||
'p-input-filled': this.layoutService.config().inputStyle === 'filled',
|
||||
'p-ripple-disabled': !this.layoutService.config().ripple
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.overlayMenuOpenSubscription) {
|
||||
this.overlayMenuOpenSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
if (this.menuOutsideClickListener) {
|
||||
this.menuOutsideClickListener();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { InputTextModule } from 'primeng/inputtext';
|
||||
import { SidebarModule } from 'primeng/sidebar';
|
||||
import { BadgeModule } from 'primeng/badge';
|
||||
import { RadioButtonModule } from 'primeng/radiobutton';
|
||||
import { InputSwitchModule } from 'primeng/inputswitch';
|
||||
import { RippleModule } from 'primeng/ripple';
|
||||
import { AppMenuComponent } from './app.menu.component';
|
||||
import { AppMenuitemComponent } from './app.menuitem.component';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { AppTopBarComponent } from './app.topbar.component';
|
||||
import { AppSidebarComponent } from "./app.sidebar.component";
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
FormsModule,
|
||||
HttpClientModule,
|
||||
BrowserAnimationsModule,
|
||||
InputTextModule,
|
||||
SidebarModule,
|
||||
BadgeModule,
|
||||
RadioButtonModule,
|
||||
InputSwitchModule,
|
||||
RippleModule,
|
||||
RouterModule,
|
||||
AppMenuitemComponent,
|
||||
AppTopBarComponent,
|
||||
AppMenuComponent,
|
||||
AppSidebarComponent,
|
||||
]
|
||||
})
|
||||
export class AppLayoutModule { }
|
||||
@@ -1,26 +0,0 @@
|
||||
<ul class="layout-menu">
|
||||
<ng-container *ngIf="homeMenu$ | async as homeMenu">
|
||||
<ng-container *ngFor="let item of homeMenu; let i = index;">
|
||||
<li app-menuitem *ngIf="!item.separator" [item]="item" [index]="i" [root]="true"></li>
|
||||
<li *ngIf="item.separator" class="menu-separator"></li>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</ul>
|
||||
|
||||
<ul class="layout-menu">
|
||||
<ng-container *ngIf="libraryMenu$ | async as libraryMenu">
|
||||
<ng-container *ngFor="let item of libraryMenu; let i = index;">
|
||||
<li app-menuitem *ngIf="!item.separator" [item]="item" [index]="i" [root]="true"></li>
|
||||
<li *ngIf="item.separator" class="menu-separator"></li>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</ul>
|
||||
|
||||
<ul class="layout-menu">
|
||||
<ng-container *ngIf="shelfMenu$ | async as shelfMenu">
|
||||
<ng-container *ngFor="let item of shelfMenu; let i = index;">
|
||||
<li app-menuitem *ngIf="!item.separator" [item]="item" [index]="i" [root]="true"></li>
|
||||
<li *ngIf="item.separator" class="menu-separator"></li>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</ul>
|
||||
@@ -1,80 +0,0 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {AppMenuitemComponent} from './app.menuitem.component';
|
||||
import {AsyncPipe, NgForOf, NgIf} from '@angular/common';
|
||||
import {MenuModule} from 'primeng/menu';
|
||||
import {LibraryService} from '../../service/library.service';
|
||||
import {Observable, of} from 'rxjs';
|
||||
import {map} from 'rxjs/operators';
|
||||
import {ShelfService} from '../../service/shelf.service';
|
||||
import {BookService} from '../../service/book.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-menu',
|
||||
imports: [AppMenuitemComponent, NgIf, NgForOf, MenuModule, AsyncPipe],
|
||||
templateUrl: './app.menu.component.html',
|
||||
})
|
||||
export class AppMenuComponent implements OnInit {
|
||||
libraryMenu$: Observable<any> | undefined;
|
||||
shelfMenu$: Observable<any> | undefined;
|
||||
homeMenu$: Observable<any> | undefined;
|
||||
|
||||
constructor(private libraryService: LibraryService, private shelfService: ShelfService, private bookService: BookService) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.libraryMenu$ = this.libraryService.libraryState$.pipe(
|
||||
map((state) => [
|
||||
{
|
||||
label: 'Library',
|
||||
separator: false,
|
||||
items: state.libraries?.map((library) => ({
|
||||
label: library.name,
|
||||
icon: 'pi pi-' + library.icon,
|
||||
routerLink: [`/library/${library.id}/books`],
|
||||
bookCount$: this.libraryService.getBookCount(library.id ?? 0),
|
||||
})) || [],
|
||||
},
|
||||
])
|
||||
);
|
||||
|
||||
this.shelfMenu$ = this.shelfService.shelfState$.pipe(
|
||||
map((state) => [
|
||||
{
|
||||
label: 'Shelves',
|
||||
separator: false,
|
||||
items: state.shelves?.map((shelf) => ({
|
||||
label: shelf.name,
|
||||
icon: 'pi pi-' + shelf.icon,
|
||||
routerLink: [`/shelf/${shelf.id}/books`],
|
||||
bookCount$: this.shelfService.getBookCount(shelf.id ?? 0),
|
||||
})) || [],
|
||||
},
|
||||
])
|
||||
);
|
||||
|
||||
this.homeMenu$ = this.bookService.bookState$.pipe(
|
||||
map((bookState) => {
|
||||
return [
|
||||
{
|
||||
label: 'Home',
|
||||
separator: false,
|
||||
items: [
|
||||
{
|
||||
label: 'Dashboard',
|
||||
icon: 'pi pi-fw pi-home',
|
||||
routerLink: ['/'],
|
||||
},
|
||||
{
|
||||
label: 'All Books',
|
||||
icon: 'pi pi-fw pi-book',
|
||||
routerLink: ['/all-books'],
|
||||
bookCount$: of(bookState.books ? bookState.books.length : 0),
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { MenuChangeEvent } from './api/menuchangeevent';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MenuService {
|
||||
|
||||
private menuSource = new Subject<MenuChangeEvent>();
|
||||
private resetSource = new Subject();
|
||||
|
||||
menuSource$ = this.menuSource.asObservable();
|
||||
resetSource$ = this.resetSource.asObservable();
|
||||
|
||||
onMenuStateChange(event: MenuChangeEvent) {
|
||||
this.menuSource.next(event);
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.resetSource.next(true);
|
||||
}
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
import {ChangeDetectorRef, Component, Host, HostBinding, Input, OnDestroy, OnInit} from '@angular/core';
|
||||
import {NavigationEnd, Router, RouterLink, RouterLinkActive} from '@angular/router';
|
||||
import {animate, state, style, transition, trigger} from '@angular/animations';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {filter} from 'rxjs/operators';
|
||||
import {MenuService} from './app.menu.service';
|
||||
import {LayoutService} from './service/app.layout.service';
|
||||
import {AsyncPipe, NgClass, NgForOf, NgIf} from '@angular/common';
|
||||
import {Ripple} from 'primeng/ripple';
|
||||
|
||||
@Component({
|
||||
selector: '[app-menuitem]',
|
||||
template: `
|
||||
<ng-container>
|
||||
|
||||
<div *ngIf="root && item.visible !== false" class="layout-menuitem-root-text">{{ item.label }}</div>
|
||||
|
||||
<a *ngIf="(!item.routerLink || item.items) && item.visible !== false" [attr.href]="item.url"
|
||||
(click)="itemClick($event)"
|
||||
[ngClass]="item.class" [attr.target]="item.target" tabindex="0" pRipple>
|
||||
<i [ngClass]="item.icon" class="layout-menuitem-icon"></i>
|
||||
<span class="layout-menuitem-text">
|
||||
{{ item.label }}
|
||||
</span>
|
||||
<i class="pi pi-fw pi-angle-down layout-submenu-toggler" *ngIf="item.items"></i>
|
||||
</a>
|
||||
|
||||
<a *ngIf="(item.routerLink && !item.items) && item.visible !== false" (click)="itemClick($event)"
|
||||
[ngClass]="item.class"
|
||||
[routerLink]="item.routerLink" routerLinkActive="active-route"
|
||||
[routerLinkActiveOptions]="item.routerLinkActiveOptions||{ paths: 'exact', queryParams: 'ignored', matrixParams: 'ignored', fragment: 'ignored' }"
|
||||
[fragment]="item.fragment" [queryParamsHandling]="item.queryParamsHandling"
|
||||
[preserveFragment]="item.preserveFragment"
|
||||
[skipLocationChange]="item.skipLocationChange" [replaceUrl]="item.replaceUrl" [state]="item.state"
|
||||
[queryParams]="item.queryParams"
|
||||
[attr.target]="item.target" tabindex="0" pRipple>
|
||||
<i [ngClass]="item.icon" class="layout-menuitem-icon"></i>
|
||||
<span class="layout-menuitem-text w-full">
|
||||
{{ item.label }}
|
||||
<span *ngIf="item.bookCount$ | async as bookCount">
|
||||
{{ bookCount }}
|
||||
</span>
|
||||
</span>
|
||||
<i class="pi pi-fw pi-angle-down layout-submenu-toggler" *ngIf="item.items"></i>
|
||||
</a>
|
||||
|
||||
<ul *ngIf="item.items && item.visible !== false" [@children]="submenuAnimation">
|
||||
<ng-template ngFor let-child let-i="index" [ngForOf]="item.items">
|
||||
<li app-menuitem [item]="child" [index]="i" [parentKey]="key" [class]="child.badgeClass"></li>
|
||||
</ng-template>
|
||||
</ul>
|
||||
</ng-container>
|
||||
`,
|
||||
imports: [
|
||||
RouterLink,
|
||||
RouterLinkActive,
|
||||
NgClass,
|
||||
NgForOf,
|
||||
Ripple,
|
||||
NgIf,
|
||||
AsyncPipe
|
||||
],
|
||||
animations: [
|
||||
trigger('children', [
|
||||
state('collapsed', style({
|
||||
height: '0'
|
||||
})),
|
||||
state('expanded', style({
|
||||
height: '*'
|
||||
})),
|
||||
transition('collapsed <=> expanded', animate('400ms cubic-bezier(0.86, 0, 0.07, 1)'))
|
||||
])
|
||||
]
|
||||
})
|
||||
export class AppMenuitemComponent implements OnInit, OnDestroy {
|
||||
@Input() item: any;
|
||||
@Input() index!: number;
|
||||
@Input() @HostBinding('class.layout-root-menuitem') root!: boolean;
|
||||
@Input() parentKey!: string;
|
||||
|
||||
active = false;
|
||||
menuSourceSubscription: Subscription;
|
||||
menuResetSubscription: Subscription;
|
||||
key: string = "";
|
||||
|
||||
constructor(public router: Router, private menuService: MenuService) {
|
||||
this.menuSourceSubscription = this.menuService.menuSource$.subscribe(value => {
|
||||
Promise.resolve(null).then(() => {
|
||||
if (value.routeEvent) {
|
||||
this.active = (value.key === this.key || value.key.startsWith(this.key + '-')) ? true : false;
|
||||
} else {
|
||||
if (value.key !== this.key && !value.key.startsWith(this.key + '-')) {
|
||||
this.active = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this.menuResetSubscription = this.menuService.resetSource$.subscribe(() => {
|
||||
this.active = false;
|
||||
});
|
||||
|
||||
this.router.events.pipe(filter(event => event instanceof NavigationEnd))
|
||||
.subscribe(params => {
|
||||
if (this.item.routerLink) {
|
||||
this.updateActiveStateFromRoute();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.key = this.parentKey ? this.parentKey + '-' + this.index : String(this.index);
|
||||
if (this.item.routerLink) {
|
||||
this.updateActiveStateFromRoute();
|
||||
}
|
||||
}
|
||||
|
||||
updateActiveStateFromRoute() {
|
||||
let activeRoute = this.router.isActive(this.item.routerLink[0], {
|
||||
paths: 'exact',
|
||||
queryParams: 'ignored',
|
||||
matrixParams: 'ignored',
|
||||
fragment: 'ignored'
|
||||
});
|
||||
if (activeRoute) {
|
||||
this.menuService.onMenuStateChange({key: this.key, routeEvent: true});
|
||||
}
|
||||
}
|
||||
|
||||
itemClick(event: Event) {
|
||||
if (this.item.disabled) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (this.item.command) {
|
||||
this.item.command({originalEvent: event, item: this.item});
|
||||
}
|
||||
if (this.item.items) {
|
||||
this.active = !this.active;
|
||||
}
|
||||
this.menuService.onMenuStateChange({key: this.key});
|
||||
}
|
||||
|
||||
get submenuAnimation() {
|
||||
return this.root ? 'expanded' : (this.active ? 'expanded' : 'collapsed');
|
||||
}
|
||||
|
||||
@HostBinding('class.active-menuitem')
|
||||
get activeClass() {
|
||||
return this.active && !this.root;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.menuSourceSubscription) {
|
||||
this.menuSourceSubscription.unsubscribe();
|
||||
}
|
||||
if (this.menuResetSubscription) {
|
||||
this.menuResetSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<app-menu></app-menu>
|
||||
@@ -1,3 +0,0 @@
|
||||
.layout-sidebar-custom {
|
||||
width: 250px !important;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import { Component, ElementRef } from '@angular/core';
|
||||
import { LayoutService } from "./service/app.layout.service";
|
||||
import {AppMenuComponent} from './app.menu.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sidebar',
|
||||
imports: [
|
||||
AppMenuComponent
|
||||
],
|
||||
templateUrl: './app.sidebar.component.html'
|
||||
})
|
||||
export class AppSidebarComponent {
|
||||
constructor(public layoutService: LayoutService, public el: ElementRef) { }
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
<div class="layout-topbar">
|
||||
|
||||
<a class="layout-topbar-logo" routerLink="">
|
||||
<span class="flex">
|
||||
<p>Book</p>
|
||||
<p class="half-title text-3xl">lore</p>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<p-button
|
||||
#menubutton
|
||||
icon="pi pi-arrow-left"
|
||||
[rounded]="true"
|
||||
[outlined]="true"
|
||||
(click)="toggleMenu()"
|
||||
[ngClass]="{ 'rotate-right': !isMenuVisible, 'rotate-left': isMenuVisible }"
|
||||
>
|
||||
</p-button>
|
||||
|
||||
<div class="topbar-right-items">
|
||||
<app-search></app-search>
|
||||
<ul class="topbar-items">
|
||||
<p-divider layout="vertical" />
|
||||
<li>
|
||||
<i class="pi pi-wave-pulse" style="font-size: 1.5rem"
|
||||
(click)="toggleEventDisplay()"
|
||||
(mouseenter)="onMouseEnter()"
|
||||
(mouseleave)="onMouseLeave()"
|
||||
[class.pulsating]="eventHighlight"
|
||||
[class.highlight]="eventHighlight"></i>
|
||||
<div *ngIf="showEvents" class="live-event-container" (mouseleave)="onMouseLeave()">
|
||||
<p *ngIf="latestEvent.timestamp">{{ latestEvent.timestamp }}</p>
|
||||
<p>{{ latestEvent.message }}</p>
|
||||
</div>
|
||||
</li>
|
||||
<p-divider layout="vertical" />
|
||||
<li>
|
||||
<a class="topbar-item">
|
||||
<i class="pi pi-plus-circle text-surface-700 dark:text-surface-100" (click)="openLibraryCreatorDialog()"
|
||||
pTooltip="Create New Library" tooltipPosition="top"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="topbar-item">
|
||||
<i class="pi pi-upload text-surface-700 dark:text-surface-100" (click)="openFileUploadDialog()"
|
||||
pTooltip="Upload book" tooltipPosition="top"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li class="relative">
|
||||
<button type="button" class="topbar-item config-item" enterActiveClass="animate-scalein" enterFromClass="hidden" leaveActiveClass="animate-fadeout" leaveToClass="hidden" pStyleClass="@next" [hideOnOutsideClick]="true">
|
||||
<i class="pi pi-palette"></i>
|
||||
</button>
|
||||
<app-configurator></app-configurator>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -1,38 +0,0 @@
|
||||
.live-event-container {
|
||||
position: absolute;
|
||||
top: 43px;
|
||||
right: -180px;
|
||||
width: 500px;
|
||||
background: var(--card-background);
|
||||
border: 0.5px solid var(--primary-color);
|
||||
border-radius: 4px;
|
||||
padding: 12px;
|
||||
overflow-x: hidden;
|
||||
/*z-index: 1000;*/
|
||||
word-wrap: break-word;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.highlight {
|
||||
color: red !important;
|
||||
}
|
||||
|
||||
@keyframes pulsate {
|
||||
0% {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.25);
|
||||
opacity: 0.8;
|
||||
}
|
||||
100% {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.pulsating {
|
||||
animation: pulsate 1.5s infinite ease-in-out;
|
||||
}
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
import {Component, ElementRef, OnDestroy, ViewChild} from '@angular/core';
|
||||
import {MenuItem} from 'primeng/api';
|
||||
import {LayoutService} from './service/app.layout.service';
|
||||
import {RouterLink} from '@angular/router';
|
||||
import {DialogService as PrimeDialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {LibraryCreatorComponent} from '../library-creator/library-creator.component';
|
||||
import {TooltipModule} from 'primeng/tooltip';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {InputTextModule} from 'primeng/inputtext';
|
||||
import {SearchComponent} from '../search/search.component';
|
||||
import {FileUploadComponent} from '../file-upload/file-upload.component';
|
||||
import {NgClass, NgIf} from '@angular/common';
|
||||
import {EventService} from '../../service/event.service';
|
||||
import {LogNotification} from '../../model/log-notification.model';
|
||||
import {Button} from 'primeng/button';
|
||||
import {AppConfiguratorComponent} from '../configurator/configurator.component';
|
||||
import {StyleClass} from 'primeng/styleclass';
|
||||
import {Divider} from 'primeng/divider';
|
||||
|
||||
@Component({
|
||||
selector: 'app-topbar',
|
||||
templateUrl: './app.topbar.component.html',
|
||||
styleUrls: ['./app.topbar.component.scss'],
|
||||
imports: [
|
||||
RouterLink,
|
||||
TooltipModule,
|
||||
FormsModule,
|
||||
InputTextModule,
|
||||
SearchComponent,
|
||||
NgIf,
|
||||
Button,
|
||||
AppConfiguratorComponent,
|
||||
StyleClass,
|
||||
NgClass,
|
||||
Divider
|
||||
],
|
||||
})
|
||||
export class AppTopBarComponent implements OnDestroy {
|
||||
items!: MenuItem[];
|
||||
ref: DynamicDialogRef | undefined;
|
||||
|
||||
latestEvent: LogNotification = {message: 'No recent notifications...'};
|
||||
eventHighlight: boolean = false;
|
||||
showEvents: boolean = false;
|
||||
eventTimeout: any;
|
||||
|
||||
@ViewChild('menubutton') menuButton!: ElementRef;
|
||||
@ViewChild('topbarmenubutton') topbarMenuButton!: ElementRef;
|
||||
@ViewChild('topbarmenu') menu!: ElementRef;
|
||||
|
||||
constructor(public layoutService: LayoutService, public dialogService: PrimeDialogService, private eventService: EventService) {
|
||||
this.eventService.latestEvent$.subscribe(event => {
|
||||
this.latestEvent = event;
|
||||
});
|
||||
this.eventService.eventHighlight$.subscribe(highlight => {
|
||||
this.eventHighlight = highlight;
|
||||
});
|
||||
}
|
||||
|
||||
isMenuVisible: boolean = true;
|
||||
|
||||
toggleMenu() {
|
||||
this.isMenuVisible = !this.isMenuVisible;
|
||||
this.layoutService.onMenuToggle();
|
||||
}
|
||||
|
||||
onMouseEnter() {
|
||||
this.showEvents = true;
|
||||
}
|
||||
|
||||
onMouseLeave() {
|
||||
this.showEvents = false;
|
||||
}
|
||||
|
||||
toggleEventDisplay(): void {
|
||||
this.showEvents = !this.showEvents;
|
||||
}
|
||||
|
||||
openLibraryCreatorDialog(): void {
|
||||
this.ref = this.dialogService.open(LibraryCreatorComponent, {
|
||||
header: 'Create New Library',
|
||||
modal: true,
|
||||
closable: true,
|
||||
width: '675px',
|
||||
height: '480px',
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: '15%',
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
openFileUploadDialog() {
|
||||
this.ref = this.dialogService.open(FileUploadComponent, {
|
||||
header: 'Upload Book',
|
||||
modal: true,
|
||||
closable: true,
|
||||
width: '600px',
|
||||
height: '330px',
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: '15%',
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.ref) {
|
||||
this.ref.close();
|
||||
}
|
||||
clearTimeout(this.eventTimeout);
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
import { Injectable, effect, signal } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
export interface AppConfig {
|
||||
inputStyle: string;
|
||||
colorScheme: string;
|
||||
theme: string;
|
||||
ripple: boolean;
|
||||
menuMode: string;
|
||||
scale: number;
|
||||
}
|
||||
|
||||
interface LayoutState {
|
||||
staticMenuDesktopInactive: boolean;
|
||||
overlayMenuActive: boolean;
|
||||
profileSidebarVisible: boolean;
|
||||
configSidebarVisible: boolean;
|
||||
staticMenuMobileActive: boolean;
|
||||
menuHoverActive: boolean;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class LayoutService {
|
||||
_config: AppConfig = {
|
||||
ripple: false,
|
||||
inputStyle: 'outlined',
|
||||
menuMode: 'static',
|
||||
colorScheme: 'light',
|
||||
theme: 'lara-light-indigo',
|
||||
scale: 14,
|
||||
};
|
||||
|
||||
config = signal<AppConfig>(this._config);
|
||||
|
||||
state: LayoutState = {
|
||||
staticMenuDesktopInactive: false,
|
||||
overlayMenuActive: false,
|
||||
profileSidebarVisible: false,
|
||||
configSidebarVisible: false,
|
||||
staticMenuMobileActive: false,
|
||||
menuHoverActive: false,
|
||||
};
|
||||
|
||||
private configUpdate = new Subject<AppConfig>();
|
||||
|
||||
private overlayOpen = new Subject<any>();
|
||||
|
||||
configUpdate$ = this.configUpdate.asObservable();
|
||||
|
||||
overlayOpen$ = this.overlayOpen.asObservable();
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const config = this.config();
|
||||
if (this.updateStyle(config)) {
|
||||
this.changeTheme();
|
||||
}
|
||||
this.changeScale(config.scale);
|
||||
this.onConfigUpdate();
|
||||
});
|
||||
}
|
||||
|
||||
updateStyle(config: AppConfig) {
|
||||
return (
|
||||
config.theme !== this._config.theme ||
|
||||
config.colorScheme !== this._config.colorScheme
|
||||
);
|
||||
}
|
||||
|
||||
onMenuToggle() {
|
||||
if (this.isOverlay()) {
|
||||
this.state.overlayMenuActive = !this.state.overlayMenuActive;
|
||||
if (this.state.overlayMenuActive) {
|
||||
this.overlayOpen.next(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isDesktop()) {
|
||||
this.state.staticMenuDesktopInactive =
|
||||
!this.state.staticMenuDesktopInactive;
|
||||
} else {
|
||||
this.state.staticMenuMobileActive =
|
||||
!this.state.staticMenuMobileActive;
|
||||
|
||||
if (this.state.staticMenuMobileActive) {
|
||||
this.overlayOpen.next(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
isOverlay() {
|
||||
return this.config().menuMode === 'overlay';
|
||||
}
|
||||
|
||||
isDesktop() {
|
||||
return window.innerWidth > 991;
|
||||
}
|
||||
|
||||
onConfigUpdate() {
|
||||
this._config = { ...this.config() };
|
||||
this.configUpdate.next(this.config());
|
||||
}
|
||||
|
||||
changeTheme() {
|
||||
const config = this.config();
|
||||
const themeLink = <HTMLLinkElement>document.getElementById('theme-css');
|
||||
const themeLinkHref = themeLink.getAttribute('href')!;
|
||||
const newHref = themeLinkHref
|
||||
.split('/')
|
||||
.map((el) =>
|
||||
el == this._config.theme
|
||||
? (el = config.theme)
|
||||
: el == `theme-${this._config.colorScheme}`
|
||||
? (el = `theme-${config.colorScheme}`)
|
||||
: el
|
||||
)
|
||||
.join('/');
|
||||
|
||||
this.replaceThemeLink(newHref);
|
||||
}
|
||||
replaceThemeLink(href: string) {
|
||||
const id = 'theme-css';
|
||||
let themeLink = <HTMLLinkElement>document.getElementById(id);
|
||||
const cloneLinkElement = <HTMLLinkElement>themeLink.cloneNode(true);
|
||||
|
||||
cloneLinkElement.setAttribute('href', href);
|
||||
cloneLinkElement.setAttribute('id', id + '-clone');
|
||||
|
||||
themeLink.parentNode!.insertBefore(
|
||||
cloneLinkElement,
|
||||
themeLink.nextSibling
|
||||
);
|
||||
cloneLinkElement.addEventListener('load', () => {
|
||||
themeLink.remove();
|
||||
cloneLinkElement.setAttribute('id', id);
|
||||
});
|
||||
}
|
||||
|
||||
changeScale(value: number) {
|
||||
document.documentElement.style.fontSize = `${value}px`;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
import {Component, ViewChild} from '@angular/core';
|
||||
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {DirectoryPickerComponent} from '../directory-picker/directory-picker.component';
|
||||
import {DirectoryPickerComponent} from '../../utilities/directory-picker/directory-picker.component';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Router} from '@angular/router';
|
||||
import {LibraryService} from '../../service/library.service';
|
||||
import {IconPickerComponent} from '../icon-picker/icon-picker.component';
|
||||
import {LibraryService} from '../service/library.service';
|
||||
import {IconPickerComponent} from '../../utilities/icon-picker/icon-picker.component';
|
||||
import {take} from 'rxjs';
|
||||
|
||||
@Component({
|
||||
@@ -1,7 +0,0 @@
|
||||
import {MetadataProvider} from '../../provider.model';
|
||||
|
||||
export interface BookAutoMetadataRefresh {
|
||||
bookIds: number[],
|
||||
metadataProvider: MetadataProvider,
|
||||
replaceCover: boolean
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
export interface FetchMetadataRequest {
|
||||
bookId: number,
|
||||
providers: string[],
|
||||
title: string,
|
||||
isbn: string,
|
||||
author: string
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import {MetadataProvider} from '../../provider.model';
|
||||
|
||||
export interface LibraryAutoMetadataRefreshRequest {
|
||||
libraryId: number,
|
||||
metadataProvider: MetadataProvider,
|
||||
replaceCover: boolean
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
export interface MetadataRefreshOptions {
|
||||
defaultProvider: string;
|
||||
refreshCovers: boolean;
|
||||
fieldOptions?: FieldOptions;
|
||||
}
|
||||
|
||||
export interface FieldProvider {
|
||||
default: string | null;
|
||||
p2: string | null;
|
||||
p1: string | null;
|
||||
}
|
||||
|
||||
export interface FieldOptions {
|
||||
title: FieldProvider;
|
||||
description: FieldProvider;
|
||||
authors: FieldProvider;
|
||||
categories: FieldProvider;
|
||||
cover: FieldProvider;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import {MetadataRefreshType} from './metadata-refresh-type.enum';
|
||||
import {MetadataRefreshOptions} from './metadata-refresh-options.model';
|
||||
|
||||
export interface MetadataRefreshRequest {
|
||||
refreshType: MetadataRefreshType;
|
||||
libraryId?: number;
|
||||
bookIds?: Set<number>;
|
||||
refreshOptions: MetadataRefreshOptions;
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
export enum MetadataRefreshType {
|
||||
BOOKS = 'BOOKS',
|
||||
LIBRARY = 'LIBRARY'
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import {Component, NgZone, OnDestroy, OnInit} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {NgxExtendedPdfViewerModule, ScrollModeType} from 'ngx-extended-pdf-viewer';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {BookService} from '../service/book.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-pdf-viewer',
|
||||
@@ -8,8 +8,8 @@ import {Shelf} from '../model/shelf.model';
|
||||
import {MetadataService} from './metadata.service';
|
||||
import {MetadataProvider} from '../model/provider.model';
|
||||
import {DialogService} from 'primeng/dynamicdialog';
|
||||
import {MetadataFetchOptionsComponent} from '../../metadata-fetch-options/metadata-fetch-options.component';
|
||||
import {MetadataRefreshType} from '../model/request/metadata/metadata-refresh-type.enum';
|
||||
import {MetadataFetchOptionsComponent} from '../../metadata/metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
|
||||
import {MetadataRefreshType} from '../../metadata/model/request/metadata-refresh-type.enum';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Observable} from "rxjs";
|
||||
import {FetchMetadataRequest} from "../model/request/metadata/fetch-metadata-request.model";
|
||||
import {FetchMetadataRequest} from "../../metadata/model/request/fetch-metadata-request.model";
|
||||
import {BookMetadata, FetchedMetadata} from "../model/book.model";
|
||||
import {BookMetadataBI} from "../model/book-metadata-for-book-info.model";
|
||||
import {tap} from "rxjs/operators";
|
||||
import {BookService} from "./book.service";
|
||||
import {MetadataRefreshRequest} from '../model/request/metadata/metadata-refresh-request.model';
|
||||
import {MetadataRefreshRequest} from '../../metadata/model/request/metadata-refresh-request.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
||||
+6
-6
@@ -1,14 +1,14 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog';
|
||||
import { Book } from '../../model/book.model';
|
||||
import { Book } from '../model/book.model';
|
||||
import { MessageService } from 'primeng/api';
|
||||
import { ShelfService } from '../../service/shelf.service';
|
||||
import { ShelfService } from '../service/shelf.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { BookService } from '../../service/book.service';
|
||||
import { BookService } from '../service/book.service';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
import { Shelf } from '../../model/shelf.model';
|
||||
import { IconPickerComponent } from '../icon-picker/icon-picker.component';
|
||||
import { ShelfState } from '../../model/state/shelf-state.model';
|
||||
import { Shelf } from '../model/shelf.model';
|
||||
import { IconPickerComponent } from '../../utilities/icon-picker/icon-picker.component';
|
||||
import { ShelfState } from '../model/state/shelf-state.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shelf-assigner',
|
||||
Reference in New Issue
Block a user