[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", "albumArtist": "umělec alba",
"path": "cesta", "path": "cesta",
"discNumber": "disk", "discNumber": "disk",
"channels": "$t(common.channel_other)" "channels": "$t(common.channel_other)",
"size": "$t(common.size)"
} }
}, },
"error": { "error": {

View file

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

View file

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

View file

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

View file

@ -625,7 +625,8 @@
"artist": "$t(entity.artist_one)", "artist": "$t(entity.artist_one)",
"genre": "$t(entity.genre_one)", "genre": "$t(entity.genre_one)",
"songCount": "$t(entity.track_other)", "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", "albumArtist": "artista album",
"path": "percorso", "path": "percorso",
"discNumber": "disco", "discNumber": "disco",
"channels": "$t(common.channel_other)" "channels": "$t(common.channel_other)",
"size": "$t(common.size)"
} }
}, },
"entity": { "entity": {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -463,7 +463,8 @@
"bpm": "bpm", "bpm": "bpm",
"songCount": "$t(entity.track_other)", "songCount": "$t(entity.track_other)",
"title": "標題", "title": "標題",
"trackNumber": "音軌編號" "trackNumber": "音軌編號",
"size": "$t(common.size)"
} }
}, },
"action": { "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 { NoteCell } from '/@/renderer/components/virtual-table/cells/note-cell';
import { RowIndexCell } from '/@/renderer/components/virtual-table/cells/row-index-cell'; import { RowIndexCell } from '/@/renderer/components/virtual-table/cells/row-index-cell';
import i18n from '/@/i18n/i18n'; import i18n from '/@/i18n/i18n';
import { formatSizeString } from '/@/renderer/utils/format-size-string';
export * from './table-config-dropdown'; export * from './table-config-dropdown';
export * from './table-pagination'; export * from './table-pagination';
@ -320,6 +321,16 @@ const tableColumns: { [key: string]: ColDef } = {
}, },
width: 65, 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: { songCount: {
cellRenderer: (params: ICellRendererParams) => GenericCell(params, { position: 'center' }), cellRenderer: (params: ICellRendererParams) => GenericCell(params, { position: 'center' }),
colId: TableColumn.SONG_COUNT, 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]}`;
};