aboutsummaryrefslogtreecommitdiffstats
path: root/src/web
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-03-26 12:43:46 -0500
committerGitHub <noreply@github.com>2022-03-26 12:43:46 -0500
commita5b7e657d6fe38c416dc01461424f79aa452f197 (patch)
tree347cce99c2950037ec7795a0b82f6363c86968ed /src/web
parent511748128942afa64231fbaa1ca971a354bcc1d1 (diff)
parentb8548f3b055ba5858c182604f9b098a82a3e54d5 (diff)
downloadslskd-a5b7e657d6fe38c416dc01461424f79aa452f197.tar.gz
Merge pull request #399 from slskd/meta
Improve file attribute display; show VBR flag, lossless depth/sample rate
Diffstat (limited to 'src/web')
-rw-r--r--src/web/src/components/App.css4
-rw-r--r--src/web/src/components/Shared/FileList.js6
-rw-r--r--src/web/src/lib/util.js14
3 files changed, 19 insertions, 5 deletions
diff --git a/src/web/src/components/App.css b/src/web/src/components/App.css
index 720d5f5e..6244cdf8 100644
--- a/src/web/src/components/App.css
+++ b/src/web/src/components/App.css
@@ -68,8 +68,8 @@ body {
width: 100px;
}
-.filelist-bitrate {
- width: 70px;
+.filelist-attributes {
+ width: 115px;
}
.filelist-length{
diff --git a/src/web/src/components/Shared/FileList.js b/src/web/src/components/Shared/FileList.js
index e470563f..f38e602d 100644
--- a/src/web/src/components/Shared/FileList.js
+++ b/src/web/src/components/Shared/FileList.js
@@ -1,6 +1,6 @@
import React from 'react';
-import { formatSeconds, formatBytes, getFileName } from '../../lib/util';
+import { formatSeconds, formatBytes, getFileName, formatAttributes } from '../../lib/util';
import {
Header,
@@ -44,7 +44,7 @@ const FileList = ({ directoryName, files, locked, onSelectionChange, disabled, o
</Table.HeaderCell>
<Table.HeaderCell className='filelist-filename'>File</Table.HeaderCell>
<Table.HeaderCell className='filelist-size'>Size</Table.HeaderCell>
- <Table.HeaderCell className='filelist-bitrate'>Bitrate</Table.HeaderCell>
+ <Table.HeaderCell className='filelist-attributes'>Attributes</Table.HeaderCell>
<Table.HeaderCell className='filelist-length'>Length</Table.HeaderCell>
</Table.Row>
</Table.Header>
@@ -61,7 +61,7 @@ const FileList = ({ directoryName, files, locked, onSelectionChange, disabled, o
</Table.Cell>
<Table.Cell className='filelist-filename'>{locked ? <Icon name='lock'/> : ''}{getFileName(f.filename)}</Table.Cell>
<Table.Cell className='filelist-size'>{formatBytes(f.size)}</Table.Cell>
- <Table.Cell className='filelist-bitrate'>{f.bitRate}</Table.Cell>
+ <Table.Cell className='filelist-attributes'>{formatAttributes(f)}</Table.Cell>
<Table.Cell className='filelist-length'>{formatSeconds(f.length)}</Table.Cell>
</Table.Row>
)}
diff --git a/src/web/src/lib/util.js b/src/web/src/lib/util.js
index 86bd6977..32c55090 100644
--- a/src/web/src/lib/util.js
+++ b/src/web/src/lib/util.js
@@ -34,6 +34,20 @@ export const getDirectoryName = (fullPath) => {
return path;
}
+export const formatAttributes = ({ bitRate, isVariableBitRate, bitDepth, sampleRate }) => {
+ const isLossless = !!sampleRate && !!bitDepth;
+
+ if (isLossless) {
+ return `${bitDepth}/${sampleRate/1000}kHz`;
+ }
+
+ if (isVariableBitRate) {
+ return `${bitRate}kbps, VBR`
+ }
+
+ return bitRate ? `${bitRate}kbps` : ''
+}
+
/* https://www.npmjs.com/package/js-file-download
*
* Copyright 2017 Kenneth Jiang