From 4745c4a42dbc286bf88ca72146cc057a0eb387c9 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Fri, 30 Dec 2022 21:11:09 -0800 Subject: [PATCH] Add card/table types for album artists --- src/renderer/components/card/card-rows.tsx | 31 +++++++++++++++++++ .../components/virtual-table/index.tsx | 24 ++++++++++++++ src/renderer/types.ts | 3 ++ 3 files changed, 58 insertions(+) diff --git a/src/renderer/components/card/card-rows.tsx b/src/renderer/components/card/card-rows.tsx index 2ff8b30e..67e62db1 100644 --- a/src/renderer/components/card/card-rows.tsx +++ b/src/renderer/components/card/card-rows.tsx @@ -178,3 +178,34 @@ export const ALBUM_CARD_ROWS: { [key: string]: CardRow } = { property: 'songCount', }, }; + +export const ALBUMARTIST_CARD_ROWS: { [key: string]: CardRow } = { + albumCount: { + property: 'albumCount', + }, + duration: { + property: 'duration', + }, + genres: { + property: 'genres', + }, + lastPlayedAt: { + property: 'lastPlayedAt', + }, + name: { + property: 'name', + route: { + route: AppRoute.LIBRARY_ALBUMARTISTS_DETAIL, + slugs: [{ idProperty: 'id', slugProperty: 'albumArtistId' }], + }, + }, + playCount: { + property: 'playCount', + }, + rating: { + property: 'rating', + }, + songCount: { + property: 'songCount', + }, +}; diff --git a/src/renderer/components/virtual-table/index.tsx b/src/renderer/components/virtual-table/index.tsx index b56a401f..fc00a69b 100644 --- a/src/renderer/components/virtual-table/index.tsx +++ b/src/renderer/components/virtual-table/index.tsx @@ -57,12 +57,28 @@ const tableColumns: { [key: string]: ColDef } = { valueGetter: (params: ValueGetterParams) => params.data ? params.data.albumArtists : undefined, }, + albumCount: { + cellRenderer: (params: ICellRendererParams) => GenericCell(params, { position: 'center' }), + colId: TableColumn.ALBUM_COUNT, + field: 'albumCount', + headerComponent: (params: IHeaderParams) => GenericTableHeader(params, { position: 'center' }), + headerName: 'Albums', + valueGetter: (params: ValueGetterParams) => (params.data ? params.data.albumCount : undefined), + }, artist: { cellRenderer: ArtistCell, colId: TableColumn.ARTIST, headerName: 'Artist', valueGetter: (params: ValueGetterParams) => (params.data ? params.data.artists : undefined), }, + biography: { + cellRenderer: (params: ICellRendererParams) => GenericCell(params, { position: 'left' }), + colId: TableColumn.BIOGRAPHY, + field: 'biography', + headerComponent: (params: IHeaderParams) => GenericTableHeader(params, { position: 'left' }), + headerName: 'Biography', + valueGetter: (params: ValueGetterParams) => (params.data ? params.data.biography : undefined), + }, bitRate: { cellRenderer: (params: ICellRendererParams) => GenericCell(params, { position: 'left' }), colId: TableColumn.BIT_RATE, @@ -175,6 +191,14 @@ const tableColumns: { [key: string]: ColDef } = { return (params.node?.rowIndex || 0) + 1; }, }, + songCount: { + cellRenderer: (params: ICellRendererParams) => GenericCell(params, { position: 'center' }), + colId: TableColumn.SONG_COUNT, + field: 'songCount', + headerComponent: (params: IHeaderParams) => GenericTableHeader(params, { position: 'center' }), + headerName: 'Songs', + valueGetter: (params: ValueGetterParams) => (params.data ? params.data.songCount : undefined), + }, title: { cellRenderer: (params: ICellRendererParams) => GenericCell(params, { position: 'left', primary: true }), diff --git a/src/renderer/types.ts b/src/renderer/types.ts index fb5a4d9e..83fda025 100644 --- a/src/renderer/types.ts +++ b/src/renderer/types.ts @@ -133,7 +133,9 @@ export type AdvancedFilterGroup = { export enum TableColumn { ALBUM = 'album', ALBUM_ARTIST = 'albumArtist', + ALBUM_COUNT = 'albumCount', ARTIST = 'artist', + BIOGRAPHY = 'biography', BIT_RATE = 'bitRate', BPM = 'bpm', CHANNELS = 'channels', @@ -149,6 +151,7 @@ export enum TableColumn { RATING = 'rating', RELEASE_DATE = 'releaseDate', ROW_INDEX = 'rowIndex', + SONG_COUNT = 'songCount', // SKIP = 'skip', TITLE = 'title', TITLE_COMBINED = 'titleCombined',