Skip to content

Commit

Permalink
Tweak field types of numeric fields
Browse files Browse the repository at this point in the history
Issue #194
  • Loading branch information
qu1ck committed Apr 28, 2024
1 parent 09501a7 commit 1f79360
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/components/tables/torrenttable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const AllFields: readonly TableField[] = [
accessorFn: (t) => t.peersGettingFromUs * 1e+6 + t.cachedPeersTotal,
},
{ name: "eta", label: "ETA", component: EtaField },
{ name: "uploadRatio", label: "Ratio", component: PositiveNumberField },
{ name: "uploadRatio", label: "Ratio", component: FixedDecimalField },
{
name: "trackerStats",
label: "Tracker",
Expand All @@ -142,8 +142,8 @@ const AllFields: readonly TableField[] = [
{ name: "activityDate", label: "Last active", component: DateDiffField },
{ name: "downloadDir", label: "Path", component: StringField },
{ name: "bandwidthPriority", label: "Priority", component: PriorityField },
{ name: "id", label: "ID", component: StringField },
{ name: "queuePosition", label: "Queue position", component: StringField },
{ name: "id", label: "ID", component: PositiveNumberField },
{ name: "queuePosition", label: "Queue position", component: PositiveNumberField },
{ name: "secondsSeeding", label: "Seeding time", component: TimeField },
{ name: "isPrivate", label: "Private", component: StringField },
{ name: "labels", label: "Labels", component: LabelsField },
Expand Down Expand Up @@ -217,6 +217,15 @@ function PositiveNumberField(props: TableFieldProps) {
);
}

function FixedDecimalField(props: TableFieldProps) {
const num = props.torrent[props.fieldName];
return (
<div style={{ width: "100%", textAlign: "right" }}>
{num < 0 ? "" : Number(num).toFixed(2)}
</div>
);
}

function UploadRatioField(props: TableFieldProps) {
return (
<div style={{ width: "100%", textAlign: "right" }}>
Expand Down

0 comments on commit 1f79360

Please sign in to comment.