aboutsummaryrefslogtreecommitdiffstats
path: root/src/web
diff options
context:
space:
mode:
authorcopilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>2025-12-07 01:01:28 +0000
committercopilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>2025-12-07 01:01:28 +0000
commit68d0b046479c118529ccf5ccd7b22f66e0be2695 (patch)
tree02e406e716a15905a465dc814d4a48467f727e66 /src/web
parent0fadbff23d1c8074aa47d4ab2c98fbf27719d251 (diff)
downloadslskd-68d0b046479c118529ccf5ccd7b22f66e0be2695.tar.gz
Add info icon with transfer details popup to Size column
Co-authored-by: jpdillingham <17145758+jpdillingham@users.noreply.github.com>
Diffstat (limited to 'src/web')
-rw-r--r--src/web/src/components/Transfers/TransferList.jsx134
1 files changed, 129 insertions, 5 deletions
diff --git a/src/web/src/components/Transfers/TransferList.jsx b/src/web/src/components/Transfers/TransferList.jsx
index b81049ec..963d7333 100644
--- a/src/web/src/components/Transfers/TransferList.jsx
+++ b/src/web/src/components/Transfers/TransferList.jsx
@@ -1,4 +1,9 @@
-import { formatBytes, formatBytesAsUnit, getFileName } from '../../lib/util';
+import {
+ formatBytes,
+ formatBytesAsUnit,
+ formatDate,
+ getFileName,
+} from '../../lib/util';
import React, { Component } from 'react';
import {
Button,
@@ -6,6 +11,7 @@ import {
Header,
Icon,
List,
+ Popup,
Progress,
Table,
} from 'semantic-ui-react';
@@ -38,6 +44,53 @@ const formatBytesTransferred = ({ size, transferred }) => {
return `${t}/${s} ${sExtension}`;
};
+// Convert camelCase to Title Case with spaces
+const formatFieldName = (fieldName) => {
+ return fieldName
+ .replaceAll(/([A-Z])/gu, ' $1')
+ .replace(/^./u, (string) => string.toUpperCase())
+ .trim();
+};
+
+// Format value based on field type
+const formatValue = (key, value) => {
+ if (value === null || value === undefined) {
+ return 'N/A';
+ }
+
+ // Format datetime fields
+ if (
+ (key.toLowerCase().includes('at') || key.toLowerCase().includes('time')) &&
+ typeof value === 'string' &&
+ value.includes(':')
+ ) {
+ // Check if it's a duration (HH:MM:SS format)
+ if (/^\d{2}:\d{2}:\d{2}/u.test(value)) {
+ return value;
+ }
+
+ // Otherwise it's a datetime
+ return formatDate(value);
+ }
+
+ // Format byte-related fields
+ if (key.toLowerCase().includes('bytes') || key === 'size') {
+ return formatBytes(value);
+ }
+
+ // Format speed
+ if (key.toLowerCase().includes('speed')) {
+ return `${formatBytes(value)}/s`;
+ }
+
+ // Format percentage
+ if (key.toLowerCase().includes('percent')) {
+ return `${value.toFixed(2)}%`;
+ }
+
+ return value.toString();
+};
+
class TransferList extends Component {
constructor(props) {
super(props);
@@ -67,6 +120,52 @@ class TransferList extends Component {
this.setState((previousState) => ({ isFolded: !previousState.isFolded }));
};
+ renderTransferDetails = (file) => {
+ // Fields to display in the popup
+ const fields = [
+ 'id',
+ 'username',
+ 'direction',
+ 'filename',
+ 'size',
+ 'startOffset',
+ 'state',
+ 'stateDescription',
+ 'requestedAt',
+ 'enqueuedAt',
+ 'startedAt',
+ 'endedAt',
+ 'bytesTransferred',
+ 'averageSpeed',
+ 'bytesRemaining',
+ 'elapsedTime',
+ 'percentComplete',
+ 'remainingTime',
+ ];
+
+ return (
+ <Table
+ basic="very"
+ compact
+ size="small"
+ >
+ <Table.Body>
+ {fields.map((field) => {
+ const value = file[field];
+ return (
+ <Table.Row key={field}>
+ <Table.Cell style={{ fontWeight: 'bold', paddingRight: '1em' }}>
+ {formatFieldName(field)}
+ </Table.Cell>
+ <Table.Cell>{formatValue(field, value)}</Table.Cell>
+ </Table.Row>
+ );
+ })}
+ </Table.Body>
+ </Table>
+ );
+ };
+
render() {
const { directoryName, files, onSelectionChange } = this.props;
const { isFolded } = this.state;
@@ -172,10 +271,35 @@ class TransferList extends Component {
)}
</Table.Cell>
<Table.Cell className="transferlist-size">
- {formatBytesTransferred({
- size: f.size,
- transferred: f.bytesTransferred,
- })}
+ <div
+ style={{
+ alignItems: 'center',
+ display: 'flex',
+ justifyContent: 'space-between',
+ }}
+ >
+ <span>
+ {formatBytesTransferred({
+ size: f.size,
+ transferred: f.bytesTransferred,
+ })}
+ </span>
+ <Popup
+ content={this.renderTransferDetails(f)}
+ on="click"
+ position="left center"
+ style={{ maxWidth: '600px' }}
+ trigger={
+ <Icon
+ color="grey"
+ link
+ name="info circle"
+ style={{ margin: 0 }}
+ />
+ }
+ wide="very"
+ />
+ </div>
</Table.Cell>
</Table.Row>
))}