mirror of
https://github.com/zoriya/flood.git
synced 2026-06-02 02:56:05 +00:00
client: migrate Torrent Details Modal to TypeScript
This commit is contained in:
@@ -3,4 +3,37 @@ const torrentFilePropsMap = {
|
||||
methods: ['f.path=', 'f.path_components=', 'f.priority=', 'f.size_bytes=', 'f.size_chunks=', 'f.completed_chunks='],
|
||||
} as const;
|
||||
|
||||
export interface TorrentContent {
|
||||
index: number;
|
||||
path: string;
|
||||
filename: string;
|
||||
percentComplete: number;
|
||||
priority: number;
|
||||
sizeBytes: number;
|
||||
}
|
||||
|
||||
export interface TorrentContentTree {
|
||||
files?: Array<TorrentContent>;
|
||||
directories?: {
|
||||
[directoryName: string]: TorrentContentTree;
|
||||
};
|
||||
}
|
||||
|
||||
export interface TorrentContentSelection {
|
||||
type: 'file' | 'directory';
|
||||
depth: number;
|
||||
path: Array<string>;
|
||||
select: boolean;
|
||||
}
|
||||
|
||||
export interface TorrentContentSelectionTree {
|
||||
isSelected?: boolean;
|
||||
files?: {
|
||||
[fileName: string]: TorrentContent & {isSelected: boolean};
|
||||
};
|
||||
directories?: {
|
||||
[directoryName: string]: TorrentContentSelectionTree;
|
||||
};
|
||||
}
|
||||
|
||||
export default torrentFilePropsMap;
|
||||
|
||||
@@ -29,4 +29,21 @@ const torrentPeerPropsMap = {
|
||||
],
|
||||
} as const;
|
||||
|
||||
export interface TorrentPeer {
|
||||
index: number;
|
||||
country: string;
|
||||
address: string;
|
||||
completedPercent: number;
|
||||
clientVersion: string;
|
||||
downloadRate: number;
|
||||
downloadTotal: number;
|
||||
uploadRate: number;
|
||||
uploadTotal: number;
|
||||
id: string;
|
||||
peerRate: number;
|
||||
peerTotal: number;
|
||||
isEncrypted: boolean;
|
||||
isIncoming: boolean;
|
||||
}
|
||||
|
||||
export default torrentPeerPropsMap;
|
||||
|
||||
@@ -3,4 +3,14 @@ const torrentTrackerPropsMap = {
|
||||
methods: ['t.group=', 't.url=', 't.id=', 't.min_interval=', 't.normal_interval=', 't.type='],
|
||||
} as const;
|
||||
|
||||
export interface TorrentTracker {
|
||||
index: number;
|
||||
id: string;
|
||||
url: string;
|
||||
type: number;
|
||||
group: number;
|
||||
minInterval: number;
|
||||
normalInterval: number;
|
||||
}
|
||||
|
||||
export default torrentTrackerPropsMap;
|
||||
|
||||
+10
-46
@@ -1,4 +1,7 @@
|
||||
import {TorrentStatus} from '../constants/torrentStatusMap';
|
||||
import type {TorrentContentTree} from '../constants/torrentFilePropsMap';
|
||||
import type {TorrentPeer} from '../constants/torrentPeerPropsMap';
|
||||
import type {TorrentStatus} from '../constants/torrentStatusMap';
|
||||
import type {TorrentTracker} from '../constants/torrentTrackerPropsMap';
|
||||
|
||||
export interface Duration {
|
||||
years?: number;
|
||||
@@ -11,47 +14,9 @@ export interface Duration {
|
||||
}
|
||||
|
||||
export interface TorrentDetails {
|
||||
fileTree: {
|
||||
files: Array<{
|
||||
index: number;
|
||||
filename: string;
|
||||
path: string;
|
||||
percentComplete: number;
|
||||
priority: number;
|
||||
sizeBytes: number;
|
||||
}>;
|
||||
peers: Array<TorrentPeer>;
|
||||
trackers: Array<TorrentTracker>;
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: Unite with torrentPeerPropsMap when it is TS.
|
||||
export interface TorrentPeer {
|
||||
index: number;
|
||||
country: string;
|
||||
address: string;
|
||||
completedPercent: number;
|
||||
clientVersion: string;
|
||||
downloadRate: number;
|
||||
downloadTotal: number;
|
||||
uploadRate: number;
|
||||
uploadTotal: number;
|
||||
id: string;
|
||||
peerRate: number;
|
||||
peerTotal: number;
|
||||
isEncrypted: boolean;
|
||||
isIncoming: boolean;
|
||||
}
|
||||
|
||||
// TODO: Unite with torrentTrackerPropsMap when it is TS.
|
||||
export interface TorrentTracker {
|
||||
index: number;
|
||||
id: string;
|
||||
url: string;
|
||||
type: number;
|
||||
group: number;
|
||||
minInterval: number;
|
||||
normalInterval: number;
|
||||
peers: Array<TorrentPeer>;
|
||||
trackers: Array<TorrentTracker>;
|
||||
fileTree: TorrentContentTree;
|
||||
}
|
||||
|
||||
// TODO: Rampant over-fetching of torrent properties. Need to remove unused items.
|
||||
@@ -62,15 +27,14 @@ export interface TorrentProperties {
|
||||
basePath: string;
|
||||
bytesDone: number;
|
||||
comment: string;
|
||||
dateAdded: string;
|
||||
dateCreated: string;
|
||||
dateAdded: number;
|
||||
dateCreated: number;
|
||||
details: TorrentDetails;
|
||||
directory: string;
|
||||
downRate: number;
|
||||
downTotal: number;
|
||||
eta: 'Infinity' | Duration;
|
||||
hash: string;
|
||||
ignoreScheduler: boolean;
|
||||
isActive: boolean;
|
||||
isComplete: boolean;
|
||||
isHashing: string;
|
||||
@@ -83,7 +47,7 @@ export interface TorrentProperties {
|
||||
peersConnected: number;
|
||||
peersTotal: number;
|
||||
percentComplete: number;
|
||||
priority: string;
|
||||
priority: number;
|
||||
ratio: number;
|
||||
seedingTime: string;
|
||||
seedsConnected: number;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export default {
|
||||
capitalize: (string: string): string => string.charAt(0).toUpperCase() + string.slice(1),
|
||||
withoutTrailingSlash: (input: string): string => input.replace(/\/{1,}$/, ''),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user