[bugfix]: actually implement size column

This commit is contained in:
Kendall Garner 2024-04-01 20:53:00 -07:00
parent 6bc778fa53
commit 2854a91700
No known key found for this signature in database
GPG key ID: 18D2767419676C87
16 changed files with 50 additions and 13 deletions

View file

@ -365,7 +365,8 @@
"albumArtist": "umělec alba",
"path": "cesta",
"discNumber": "disk",
"channels": "$t(common.channel_other)"
"channels": "$t(common.channel_other)",
"size": "$t(common.size)"
}
},
"error": {

View file

@ -310,7 +310,8 @@
"discNumber": "Disk",
"genre": "$t(entity.genre_one)",
"songCount": "$t(entity.track_other)",
"trackNumber": "Nr."
"trackNumber": "Nr.",
"size": "$t(common.size)"
}
},
"page": {

View file

@ -610,6 +610,7 @@
"rating": "rating",
"releaseDate": "release date",
"releaseYear": "year",
"size": "$t(common.size)",
"songCount": "$t(entity.track_other)",
"title": "title",
"trackNumber": "track"

View file

@ -541,7 +541,8 @@
"albumArtist": "artista de álbum",
"path": "ruta",
"discNumber": "disco",
"channels": "$t(common.channel_other)"
"channels": "$t(common.channel_other)",
"size": "$t(common.size)"
},
"config": {
"label": {

View file

@ -625,7 +625,8 @@
"artist": "$t(entity.artist_one)",
"genre": "$t(entity.genre_one)",
"songCount": "$t(entity.track_other)",
"channels": "$t(common.channel_other)"
"channels": "$t(common.channel_other)",
"size": "$t(common.size)"
}
}
}

View file

@ -572,7 +572,8 @@
"albumArtist": "artista album",
"path": "percorso",
"discNumber": "disco",
"channels": "$t(common.channel_other)"
"channels": "$t(common.channel_other)",
"size": "$t(common.size)"
}
},
"entity": {

View file

@ -353,7 +353,8 @@
"albumArtist": "アルバムアーティスト",
"path": "パス",
"discNumber": "ディスク",
"channels": "$t(common.channel_other)"
"channels": "$t(common.channel_other)",
"size": "$t(common.size)"
}
},
"error": {

View file

@ -249,7 +249,8 @@
},
"table": {
"column": {
"rating": "rating"
"rating": "rating",
"size": "$t(common.size)"
},
"config": {
"label": {

View file

@ -625,7 +625,8 @@
"albumArtist": "artysta albumu",
"path": "ścieżka",
"discNumber": "płyta",
"channels": "$t(common.channel_other)"
"channels": "$t(common.channel_other)",
"size": "$t(common.size)"
}
}
}

View file

@ -139,7 +139,8 @@
},
"column": {
"title": "titulo",
"discNumber": "disco"
"discNumber": "disco",
"size": "$t(common.size)"
}
},
"page": {

View file

@ -204,7 +204,8 @@
"trackNumber": "трек",
"genre": "$t(entity.genre_one)",
"path": "путь",
"discNumber": "диск"
"discNumber": "диск",
"size": "$t(common.size)"
}
},
"error": {

View file

@ -359,7 +359,8 @@
"albumArtist": "album artist",
"path": "putanja",
"discNumber": "disk",
"channels": "$t(common.channel_other)"
"channels": "$t(common.channel_other)",
"size": "$t(common.size)"
}
},
"error": {

View file

@ -595,7 +595,8 @@
"albumArtist": "专辑艺术家",
"path": "路径",
"channels": "$t(common.channel_other)",
"discNumber": "盘"
"discNumber": "盘",
"size": "$t(common.size)"
}
}
}

View file

@ -463,7 +463,8 @@
"bpm": "bpm",
"songCount": "$t(entity.track_other)",
"title": "標題",
"trackNumber": "音軌編號"
"trackNumber": "音軌編號",
"size": "$t(common.size)"
}
},
"action": {

View file

@ -43,6 +43,7 @@ import { useFixedTableHeader } from '/@/renderer/components/virtual-table/hooks/
import { NoteCell } from '/@/renderer/components/virtual-table/cells/note-cell';
import { RowIndexCell } from '/@/renderer/components/virtual-table/cells/row-index-cell';
import i18n from '/@/i18n/i18n';
import { formatSizeString } from '/@/renderer/utils/format-size-string';
export * from './table-config-dropdown';
export * from './table-pagination';
@ -320,6 +321,16 @@ const tableColumns: { [key: string]: ColDef } = {
},
width: 65,
},
size: {
cellRenderer: (params: ICellRendererParams) => GenericCell(params, { position: 'center' }),
colId: TableColumn.SIZE,
headerComponent: (params: IHeaderParams) =>
GenericTableHeader(params, { position: 'center' }),
headerName: i18n.t('table.column.size'),
valueGetter: (params: ValueGetterParams) =>
params.data ? formatSizeString(params.data.size) : undefined,
width: 60,
},
songCount: {
cellRenderer: (params: ICellRendererParams) => GenericCell(params, { position: 'center' }),
colId: TableColumn.SONG_COUNT,

View file

@ -0,0 +1,12 @@
const SIZES = ['B', 'KiB', 'MiB', 'GiB', 'TiB'];
export const formatSizeString = (size: number): string => {
let count = 0;
let finalSize = size;
while (finalSize > 1024) {
finalSize /= 1024;
count += 1;
}
return `${finalSize.toFixed(2)} ${SIZES[count]}`;
};