- Add option to sort sidebar shelf and library

- Move user settings to a separate table
- Make settings tabs' elements more consistent
This commit is contained in:
adityachandelgit
2025-05-16 20:34:05 -06:00
committed by Aditya Chandel
parent 4cb82d2ba7
commit 5d1dd1576c
95 changed files with 1161 additions and 746 deletions
@@ -1,79 +0,0 @@
<div class="flex flex-col space-y-6 p-4">
<table class="min-w-full table-auto border-collapse custom-table">
<thead>
<tr>
<th class="px-4 py-2 text-left font-semibold text-gray-300">Book Field</th>
<th class="px-4 py-2 text-left font-semibold text-gray-300">3rd Priority</th>
<th class="px-4 py-2 text-left font-semibold text-gray-300">2nd Priority</th>
<th class="px-4 py-2 text-left font-semibold text-gray-300">1st Priority</th>
</tr>
</thead>
<tbody>
<tr>
<td class="px-4 py-2 text-gray-300">All Other Fields</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="allP3.value"
(onChange)="syncProvider($event, 'p3')"
placeholder="Select All"
class="w-full">
</p-select>
</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="allP2.value"
(onChange)="syncProvider($event, 'p2')"
placeholder="Select All"
class="w-full">
</p-select>
</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="allP1.value"
(onChange)="syncProvider($event, 'p1')"
placeholder="Select All"
class="w-full">
</p-select>
</td>
</tr>
<tr *ngFor="let field of fields" [hidden]="field === 'cover' && !refreshCovers">
<td class="px-4 py-2 text-gray-300">{{ field | titlecase }}</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p3"
placeholder="Unset"
class="w-full">
</p-select>
</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p2"
placeholder="Unset"
class="w-full">
</p-select>
</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p1"
placeholder="Unset"
class="w-full">
</p-select>
</td>
</tr>
</tbody>
</table>
<div class="flex flex-row items-center justify-between">
<div class="flex gap-10">
<div class="flex flex-row items-center gap-4 justify-start">
<p>Refresh covers: </p>
<p-checkbox [(ngModel)]="refreshCovers" [binary]="true"></p-checkbox>
</div>
<div class="flex flex-row items-center gap-4 justify-start">
<p>Merge categories: </p>
<p-checkbox [(ngModel)]="mergeCategories" [binary]="true"></p-checkbox>
</div>
</div>
<div class="flex flex-row gap-6">
<p-button severity="warn" outlined="true" label="Reset" (onClick)="reset()"></p-button>
<p-button label="Save" outlined="true" (onClick)="submit()"></p-button>
</div>
</div>
</div>
@@ -1,4 +0,0 @@
.custom-table {
border: 1px solid var(--border-color);
border-radius: var(--card-border);
}
@@ -1,97 +0,0 @@
import {Component, Output, EventEmitter, inject, Input, OnInit, OnChanges, SimpleChanges} from '@angular/core';
import {Select, SelectChangeEvent} from 'primeng/select';
import {FormsModule} from '@angular/forms';
import {NgForOf, TitleCasePipe} from '@angular/common';
import {Checkbox} from 'primeng/checkbox';
import {Button} from 'primeng/button';
import {MessageService} from 'primeng/api';
import {FieldOptions, FieldProvider, MetadataRefreshOptions} from '../../model/request/metadata-refresh-options.model';
@Component({
selector: 'app-metadata-advanced-fetch-options',
templateUrl: './metadata-advanced-fetch-options.component.html',
imports: [Select, FormsModule, NgForOf, Checkbox, Button, TitleCasePipe],
styleUrl: './metadata-advanced-fetch-options.component.scss',
standalone: true
})
export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
@Output() metadataOptionsSubmitted: EventEmitter<MetadataRefreshOptions> = new EventEmitter<MetadataRefreshOptions>();
fields: (keyof FieldOptions)[] = ['title', 'description', 'authors', 'categories', 'cover'];
providers: string[] = ['Amazon', 'Google', 'GoodReads'];
refreshCovers: boolean = false;
mergeCategories: boolean = false;
allP3 = {placeholder: 'Set All', value: null as string | null};
allP2 = {placeholder: 'Set All', value: null as string | null};
allP1 = {placeholder: 'Set All', value: null as string | null};
fieldOptions: FieldOptions = {
title: {p3: null, p2: null, p1: null},
description: {p3: null, p2: null, p1: null},
authors: {p3: null, p2: null, p1: null},
categories: {p3: null, p2: null, p1: null},
cover: {p3: null, p2: null, p1: null}
};
private messageService = inject(MessageService);
@Input() currentMetadataOptions!: MetadataRefreshOptions;
ngOnChanges(changes: SimpleChanges): void {
if (changes['currentMetadataOptions'] && this.currentMetadataOptions) {
this.refreshCovers = this.currentMetadataOptions.refreshCovers || false;
this.mergeCategories = this.currentMetadataOptions.mergeCategories || false;
this.fieldOptions = this.currentMetadataOptions.fieldOptions || this.fieldOptions;
this.allP3.value = this.currentMetadataOptions.allP3 || null;
this.allP2.value = this.currentMetadataOptions.allP2 || null;
this.allP1.value = this.currentMetadataOptions.allP1 || null;
}
}
syncProvider(event: SelectChangeEvent, providerType: keyof FieldProvider) {
for (const field of Object.keys(this.fieldOptions)) {
this.fieldOptions[field as keyof FieldOptions][providerType] = event.value;
}
}
submit() {
const allP3Selected = Object.keys(this.fieldOptions).every(field => {
return this.fieldOptions[field as keyof FieldOptions].p3 !== null;
});
if (allP3Selected) {
const metadataRefreshOptions: MetadataRefreshOptions = {
allP1: this.allP1.value,
allP2: this.allP2.value,
allP3: this.allP3.value,
refreshCovers: this.refreshCovers,
mergeCategories: this.mergeCategories,
fieldOptions: this.fieldOptions
};
this.metadataOptionsSubmitted.emit(metadataRefreshOptions);
} else {
this.messageService.add({
severity: 'error',
summary: 'Error',
life: 5000,
detail: 'At least one provider must be selected for all the book fields.'
});
}
}
reset() {
this.allP3.value = null;
this.allP2.value = null;
this.allP1.value = null;
for (const field of Object.keys(this.fieldOptions)) {
this.fieldOptions[field as keyof FieldOptions] = {
p3: null,
p2: null,
p1: null
};
}
}
}