Add database for library

This commit is contained in:
Myx
2025-03-28 04:46:29 +01:00
committed by Myx
parent c0cfca39a2
commit 35fd50c728
17 changed files with 382 additions and 80 deletions

View File

@@ -7,7 +7,7 @@
(keyup)="filterSongs()" />
</div>
<div
*ngIf="filteredSongs.length > 0"
*ngIf="songs.length > 0"
class="basis-2/3 flex-1 overflow-y-auto scrollbar scrollbar-w-2 scrollbar-h-2 scrollbar-track-base-300 scrollbar-thumb-neutral scrollbar-thumb-rounded-full h-[calc(100vh-164px)]">
<table id="resultTable" class="table table-zebra table-pin-rows" [class.table-xs]="settingsService.isCompactTable">
<thead>
@@ -36,7 +36,7 @@
</tr>
</thead>
<tbody>
<tr *ngFor="let song of filteredSongs; trackBy: trackByFn">
<tr *ngFor="let song of songs; trackBy: trackByFn">
<td>
<input
type="checkbox"
@@ -55,13 +55,6 @@
</table>
</div>
<div
class="align-center h-[calc(100vh-169.5px)]"
*ngIf="songs.length > 1 && filteredSongs.length < 1"
style="display: flex; justify-content: center; align-items: center">
<p class="text-center" style="font-size: 1.5rem">No songs found!</p>
</div>
<div class="flex align-center justify-center items-center h-[calc(100vh-169.5px)]" *ngIf="songs.length < 1 && filteredSongs.length === 0">
<div class="flex align-center justify-center items-center h-[calc(100vh-169.5px)]" *ngIf="songs.length < 1">
<p class="text-center" style="font-size: 1.5rem">No songs added!</p>
</div>

View File

@@ -16,7 +16,6 @@ export class LibraryTableComponent implements OnInit, OnDestroy {
songs: ChartData[] = []
sortDirection: 'asc' | 'desc' = 'asc'
sortColumn: SortColumn = null
filteredSongs: ChartData[] = []
searchTerm: string = ''
allRowsSelected: boolean = false
subscriptions: Subscription[] = []
@@ -45,10 +44,9 @@ export class LibraryTableComponent implements OnInit, OnDestroy {
this.libraryService.tracks$
.subscribe(tracks => {
this.songs = tracks
this.filterSongs()
})
)
this.filteredSongs = [...this.songs]
this.subscriptions.push(
this.libraryService.selectedSongs$
.subscribe(songs =>
@@ -58,20 +56,11 @@ export class LibraryTableComponent implements OnInit, OnDestroy {
}
filterSongs(): void {
const term = this.searchTerm.toLowerCase()
this.filteredSongs = this.songs.filter(
song =>
song.name?.toLowerCase().includes(term) ||
song.artist?.toLowerCase().includes(term) ||
song.album?.toLowerCase().includes(term) ||
song.genre?.toLowerCase().includes(term) ||
song.year?.toLowerCase().includes(term) ||
song.charter?.toLowerCase().includes(term)
)
this.libraryService.getChartsBySearchTerm(this.searchTerm)
}
onColClicked(column: SortColumn) {
if (this.filteredSongs.length === 0) { return }
if (this.songs.length === 0) { return }
if (this.sortColumn !== column) {
this.sortColumn = column
@@ -84,7 +73,7 @@ export class LibraryTableComponent implements OnInit, OnDestroy {
}
if (this.sortColumn) {
this.filteredSongs.sort((a, b) => {
this.songs.sort((a, b) => {
const valueA = a[this.sortColumn! as keyof ChartData]
const valueB = b[this.sortColumn! as keyof ChartData]
@@ -116,7 +105,7 @@ export class LibraryTableComponent implements OnInit, OnDestroy {
this.allRowsSelected = !this.allRowsSelected
if (this.allRowsSelected) {
this.filteredSongs.forEach(song => this.libraryService.addToSelectedSongs(song))
this.songs.forEach(song => this.libraryService.addToSelectedSongs(song))
} else {
this.libraryService.clearSelectedSongs()
}