Columns customize (#1975)
* Columns customization Related issue: #1471 Related issue: #1832 Related issue: #1354 Related issue: #1929
This commit is contained in:
@@ -29,6 +29,18 @@
|
|||||||
"displayRatioWithFilter": {
|
"displayRatioWithFilter": {
|
||||||
"label": "Display filtered torrents list ratio",
|
"label": "Display filtered torrents list ratio",
|
||||||
"info": "If disabled, only the global ratio will be display. The global ratio will still use the labels if set"
|
"info": "If disabled, only the global ratio will be display. The global ratio will still use the labels if set"
|
||||||
|
},
|
||||||
|
"columns": {
|
||||||
|
"label": "Select columns to display",
|
||||||
|
"data": {
|
||||||
|
"down": "Down",
|
||||||
|
"up": "Up",
|
||||||
|
"eta": "ETA",
|
||||||
|
"progress": "Progress"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nameColumnSize": {
|
||||||
|
"label": "Change the name column size"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -84,10 +96,6 @@
|
|||||||
"text": "Unable to communicate with your Torrent clients. Please check your configuration"
|
"text": "Unable to communicate with your Torrent clients. Please check your configuration"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"loading": {
|
|
||||||
"title": "Loading",
|
|
||||||
"description": "Establishing a connection"
|
|
||||||
},
|
|
||||||
"popover": {
|
"popover": {
|
||||||
"introductionPrefix": "Managed by",
|
"introductionPrefix": "Managed by",
|
||||||
"metrics": {
|
"metrics": {
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ describe('TorrentTile', () => {
|
|||||||
speedLimitOfActiveTorrents: 10,
|
speedLimitOfActiveTorrents: 10,
|
||||||
displayStaleTorrents: false,
|
displayStaleTorrents: false,
|
||||||
displayRatioWithFilter: false,
|
displayRatioWithFilter: false,
|
||||||
|
columns: [],
|
||||||
|
nameColumnSize: 0,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const torrents: NormalizedTorrent[] = [
|
const torrents: NormalizedTorrent[] = [
|
||||||
@@ -62,6 +64,8 @@ describe('TorrentTile', () => {
|
|||||||
speedLimitOfActiveTorrents: 10,
|
speedLimitOfActiveTorrents: 10,
|
||||||
displayStaleTorrents: true,
|
displayStaleTorrents: true,
|
||||||
displayRatioWithFilter: false,
|
displayRatioWithFilter: false,
|
||||||
|
columns: [],
|
||||||
|
nameColumnSize: 0,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const torrents: NormalizedTorrent[] = [
|
const torrents: NormalizedTorrent[] = [
|
||||||
@@ -100,6 +104,8 @@ describe('TorrentTile', () => {
|
|||||||
speedLimitOfActiveTorrents: 10,
|
speedLimitOfActiveTorrents: 10,
|
||||||
displayStaleTorrents: true,
|
displayStaleTorrents: true,
|
||||||
displayRatioWithFilter: false,
|
displayRatioWithFilter: false,
|
||||||
|
columns: [],
|
||||||
|
nameColumnSize: 0,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const torrents: NormalizedTorrent[] = [
|
const torrents: NormalizedTorrent[] = [
|
||||||
@@ -138,6 +144,8 @@ describe('TorrentTile', () => {
|
|||||||
speedLimitOfActiveTorrents: 10,
|
speedLimitOfActiveTorrents: 10,
|
||||||
displayStaleTorrents: true,
|
displayStaleTorrents: true,
|
||||||
displayRatioWithFilter: false,
|
displayRatioWithFilter: false,
|
||||||
|
columns: [],
|
||||||
|
nameColumnSize: 0,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const torrents: NormalizedTorrent[] = [
|
const torrents: NormalizedTorrent[] = [
|
||||||
@@ -192,6 +200,8 @@ describe('TorrentTile', () => {
|
|||||||
speedLimitOfActiveTorrents: 10,
|
speedLimitOfActiveTorrents: 10,
|
||||||
displayStaleTorrents: true,
|
displayStaleTorrents: true,
|
||||||
displayRatioWithFilter: false,
|
displayRatioWithFilter: false,
|
||||||
|
columns: [],
|
||||||
|
nameColumnSize: 0,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const torrents: NormalizedTorrent[] = [
|
const torrents: NormalizedTorrent[] = [
|
||||||
@@ -230,6 +240,8 @@ describe('TorrentTile', () => {
|
|||||||
speedLimitOfActiveTorrents: 10,
|
speedLimitOfActiveTorrents: 10,
|
||||||
displayStaleTorrents: true,
|
displayStaleTorrents: true,
|
||||||
displayRatioWithFilter: false,
|
displayRatioWithFilter: false,
|
||||||
|
columns: [],
|
||||||
|
nameColumnSize: 0,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const torrents: NormalizedTorrent[] = [
|
const torrents: NormalizedTorrent[] = [
|
||||||
@@ -268,6 +280,8 @@ describe('TorrentTile', () => {
|
|||||||
speedLimitOfActiveTorrents: 10,
|
speedLimitOfActiveTorrents: 10,
|
||||||
displayStaleTorrents: true,
|
displayStaleTorrents: true,
|
||||||
displayRatioWithFilter: false,
|
displayRatioWithFilter: false,
|
||||||
|
columns: [],
|
||||||
|
nameColumnSize: 0,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const torrents: NormalizedTorrent[] = [constructTorrent('HH', 'I am completed', true, 0, 0)];
|
const torrents: NormalizedTorrent[] = [constructTorrent('HH', 'I am completed', true, 0, 0)];
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import {
|
|||||||
Center,
|
Center,
|
||||||
Flex,
|
Flex,
|
||||||
Group,
|
Group,
|
||||||
Loader,
|
|
||||||
Popover,
|
Popover,
|
||||||
Progress,
|
Progress,
|
||||||
Stack,
|
Stack,
|
||||||
@@ -16,7 +15,7 @@ import { IconFileDownload } from '@tabler/icons-react';
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import duration from 'dayjs/plugin/duration';
|
import duration from 'dayjs/plugin/duration';
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||||
import { MRT_TableContainer, useMantineReactTable, type MRT_ColumnDef } from 'mantine-react-table';
|
import { type MRT_ColumnDef, MRT_TableContainer, useMantineReactTable } from 'mantine-react-table';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { MIN_WIDTH_MOBILE } from '~/constants/constants';
|
import { MIN_WIDTH_MOBILE } from '~/constants/constants';
|
||||||
@@ -29,6 +28,7 @@ import {
|
|||||||
|
|
||||||
import { useGetDownloadClientsQueue } from '../download-speed/useGetNetworkSpeed';
|
import { useGetDownloadClientsQueue } from '../download-speed/useGetNetworkSpeed';
|
||||||
import { defineWidget } from '../helper';
|
import { defineWidget } from '../helper';
|
||||||
|
import { WidgetLoading } from '../loading';
|
||||||
import { IWidget } from '../widgets';
|
import { IWidget } from '../widgets';
|
||||||
import { TorrentQueuePopover } from './TorrentQueueItem';
|
import { TorrentQueuePopover } from './TorrentQueueItem';
|
||||||
|
|
||||||
@@ -69,6 +69,18 @@ const definition = defineWidget({
|
|||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
info: true,
|
info: true,
|
||||||
},
|
},
|
||||||
|
columns: {
|
||||||
|
type: 'multi-select',
|
||||||
|
defaultValue: ['up', 'down', 'eta', 'progress'],
|
||||||
|
data: [{ value: 'up' }, { value: 'down' }, { value: 'eta' }, { value: 'progress' }],
|
||||||
|
},
|
||||||
|
nameColumnSize: {
|
||||||
|
type: 'slider',
|
||||||
|
defaultValue: 2,
|
||||||
|
min: 1,
|
||||||
|
max: 4,
|
||||||
|
step: 1,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
gridstack: {
|
gridstack: {
|
||||||
minWidth: 2,
|
minWidth: 2,
|
||||||
@@ -146,8 +158,7 @@ function TorrentTile({ widget }: TorrentTileProps) {
|
|||||||
</Popover.Dropdown>
|
</Popover.Dropdown>
|
||||||
</Popover>
|
</Popover>
|
||||||
),
|
),
|
||||||
maxSize: 1,
|
maxSize: widget.properties.nameColumnSize,
|
||||||
size: 1,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'totalSelected',
|
accessorKey: 'totalSelected',
|
||||||
@@ -184,7 +195,7 @@ function TorrentTile({ widget }: TorrentTileProps) {
|
|||||||
Cell: ({ cell, row }) => (
|
Cell: ({ cell, row }) => (
|
||||||
<Flex>
|
<Flex>
|
||||||
<Text className={useStyles().classes.noTextBreak}>
|
<Text className={useStyles().classes.noTextBreak}>
|
||||||
{(Number(cell.getValue()) * 100).toFixed(1)}%
|
{(Number(cell.getValue()) * 100).toPrecision(3)}%
|
||||||
</Text>
|
</Text>
|
||||||
<Progress
|
<Progress
|
||||||
radius="lg"
|
radius="lg"
|
||||||
@@ -240,9 +251,10 @@ function TorrentTile({ widget }: TorrentTileProps) {
|
|||||||
columnVisibility: {
|
columnVisibility: {
|
||||||
isCompleted: false,
|
isCompleted: false,
|
||||||
dateAdded: false,
|
dateAdded: false,
|
||||||
uploadSpeed: width > MIN_WIDTH_MOBILE,
|
uploadSpeed: widget.properties.columns.includes('up') && width > MIN_WIDTH_MOBILE,
|
||||||
downloadSpeed: width > MIN_WIDTH_MOBILE,
|
downloadSpeed: widget.properties.columns.includes('down') && width > MIN_WIDTH_MOBILE,
|
||||||
eta: width > MIN_WIDTH_MOBILE,
|
eta: widget.properties.columns.includes('eta') && width > MIN_WIDTH_MOBILE,
|
||||||
|
progress: widget.properties.columns.includes('progress'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -259,21 +271,7 @@ function TorrentTile({ widget }: TorrentTileProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isInitialLoading || !data) {
|
if (isInitialLoading || !data) {
|
||||||
return (
|
return <WidgetLoading />;
|
||||||
<Stack
|
|
||||||
align="center"
|
|
||||||
justify="center"
|
|
||||||
style={{
|
|
||||||
height: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Loader />
|
|
||||||
<Stack align="center" spacing={0}>
|
|
||||||
<Text>{t('card.loading.title')}</Text>
|
|
||||||
<Text color="dimmed">{t('card.loading.description')}</Text>
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.apps.length === 0) {
|
if (data.apps.length === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user