mirror of
https://github.com/idanoo/autobrr
synced 2025-07-24 17:29:12 +00:00
feat(releases): show details in list view (#1337)
* feat(releases): show details in list view * fix(releases): activitytable columns type * fix(releases): incognito mode * feat(releases): move details button * do we wanna truncate? * fix(web): release column width at full size --------- Co-authored-by: martylukyy <35452459+martylukyy@users.noreply.github.com>
This commit is contained in:
parent
7eaf499d66
commit
9992675971
8 changed files with 155 additions and 91 deletions
|
@ -84,6 +84,34 @@ export const get = <T> (obj: T, path: string|Array<any>, defValue?: string) => {
|
|||
return result === undefined ? defValue : result;
|
||||
};
|
||||
|
||||
const UNITS = ['byte', 'kilobyte', 'megabyte', 'gigabyte', 'terabyte', 'petabyte']
|
||||
const BYTES_PER_KB = 1000
|
||||
|
||||
|
||||
/**
|
||||
* Format bytes as human-readable text.
|
||||
*
|
||||
* @param sizeBytes Number of bytes.
|
||||
*
|
||||
* @return Formatted string.
|
||||
*/
|
||||
export function humanFileSize(sizeBytes: number | bigint): string {
|
||||
let size = Math.abs(Number(sizeBytes))
|
||||
|
||||
let u = 0
|
||||
while (size >= BYTES_PER_KB && u < UNITS.length - 1) {
|
||||
size /= BYTES_PER_KB
|
||||
++u
|
||||
}
|
||||
|
||||
return new Intl.NumberFormat([], {
|
||||
style: 'unit',
|
||||
unit: UNITS[u],
|
||||
unitDisplay: 'short',
|
||||
maximumFractionDigits: 1,
|
||||
}).format(size)
|
||||
}
|
||||
|
||||
export const RandomLinuxIsos = (count: number) => {
|
||||
const linuxIsos = [
|
||||
"ubuntu-20.04.4-lts-focal-fossa-desktop-amd64-secure-boot",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue