[bugfix]: actually implement size column
This commit is contained in:
parent
6bc778fa53
commit
2854a91700
16 changed files with 50 additions and 13 deletions
|
@ -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": {
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -610,6 +610,7 @@
|
|||
"rating": "rating",
|
||||
"releaseDate": "release date",
|
||||
"releaseYear": "year",
|
||||
"size": "$t(common.size)",
|
||||
"songCount": "$t(entity.track_other)",
|
||||
"title": "title",
|
||||
"trackNumber": "track"
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -353,7 +353,8 @@
|
|||
"albumArtist": "アルバムアーティスト",
|
||||
"path": "パス",
|
||||
"discNumber": "ディスク",
|
||||
"channels": "$t(common.channel_other)"
|
||||
"channels": "$t(common.channel_other)",
|
||||
"size": "$t(common.size)"
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
|
|
|
@ -249,7 +249,8 @@
|
|||
},
|
||||
"table": {
|
||||
"column": {
|
||||
"rating": "rating"
|
||||
"rating": "rating",
|
||||
"size": "$t(common.size)"
|
||||
},
|
||||
"config": {
|
||||
"label": {
|
||||
|
|
|
@ -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)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,7 +139,8 @@
|
|||
},
|
||||
"column": {
|
||||
"title": "titulo",
|
||||
"discNumber": "disco"
|
||||
"discNumber": "disco",
|
||||
"size": "$t(common.size)"
|
||||
}
|
||||
},
|
||||
"page": {
|
||||
|
|
|
@ -204,7 +204,8 @@
|
|||
"trackNumber": "трек",
|
||||
"genre": "$t(entity.genre_one)",
|
||||
"path": "путь",
|
||||
"discNumber": "диск"
|
||||
"discNumber": "диск",
|
||||
"size": "$t(common.size)"
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -595,7 +595,8 @@
|
|||
"albumArtist": "专辑艺术家",
|
||||
"path": "路径",
|
||||
"channels": "$t(common.channel_other)",
|
||||
"discNumber": "盘"
|
||||
"discNumber": "盘",
|
||||
"size": "$t(common.size)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -463,7 +463,8 @@
|
|||
"bpm": "bpm",
|
||||
"songCount": "$t(entity.track_other)",
|
||||
"title": "標題",
|
||||
"trackNumber": "音軌編號"
|
||||
"trackNumber": "音軌編號",
|
||||
"size": "$t(common.size)"
|
||||
}
|
||||
},
|
||||
"action": {
|
||||
|
|
|
@ -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,
|
||||
|
|
12
src/renderer/utils/format-size-string.ts
Normal file
12
src/renderer/utils/format-size-string.ts
Normal 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]}`;
|
||||
};
|
Reference in a new issue