Skip to content

Commit

Permalink
setup vscode for consistent JS formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatson committed Dec 7, 2023
1 parent a641717 commit ec63e1c
Show file tree
Hide file tree
Showing 15 changed files with 1,684 additions and 1,347 deletions.
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
44 changes: 25 additions & 19 deletions crates/librqbit/webui/index.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>rqbit web 4.0.0-beta.0</title>
<link rel="icon" type="image/svg+xml" href="assets/logo.svg" />
<!-- Include Bootstrap CSS -->
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM"
crossorigin="anonymous"
/>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css"
integrity="sha384-4LISF5TTJX/fLmGSxO53rV4miRxdg84mZsxmO8Rx5jGtp/LbrixFETvWa5a6sESd"
crossorigin="anonymous"
/>
</head>

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>rqbit web 4.0.0-beta.0</title>
<link rel="icon" type="image/svg+xml" href="assets/logo.svg">
<!-- Include Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css"
integrity="sha384-4LISF5TTJX/fLmGSxO53rV4miRxdg84mZsxmO8Rx5jGtp/LbrixFETvWa5a6sESd" crossorigin="anonymous">
</head>

<body>
<div id="app"></div>
<script type="module" src="src/main.tsx"></script>
</body>

</html>
<body>
<div id="app"></div>
<script type="module" src="src/main.tsx"></script>
</body>
</html>
15 changes: 15 additions & 0 deletions crates/librqbit/webui/node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions crates/librqbit/webui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/librqbit/webui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"devDependencies": {
"@types/react": "^18.2.38",
"@types/react-dom": "^18.2.16",
"prettier": "3.1.0",
"typescript": "^5.3.2",
"vite": "^4.5.1"
}
}
}
181 changes: 91 additions & 90 deletions crates/librqbit/webui/src/api-types.ts
Original file line number Diff line number Diff line change
@@ -1,131 +1,132 @@
// Interface for the Torrent API response
export interface TorrentId {
id: number;
info_hash: string;
id: number;
info_hash: string;
}

export interface TorrentFile {
name: string;
length: number;
included: boolean;
name: string;
length: number;
included: boolean;
}

// Interface for the Torrent Details API response
export interface TorrentDetails {
info_hash: string,
files: Array<TorrentFile>;
info_hash: string;
files: Array<TorrentFile>;
}

export interface AddTorrentResponse {
id: number | null;
details: TorrentDetails;
output_folder: string,
seen_peers?: Array<string>;
id: number | null;
details: TorrentDetails;
output_folder: string;
seen_peers?: Array<string>;
}

export interface ListTorrentsResponse {
torrents: Array<TorrentId>;
torrents: Array<TorrentId>;
}

export interface Speed {
mbps: number;
human_readable: string;
mbps: number;
human_readable: string;
}

// Interface for the Torrent Stats API response
export interface LiveTorrentStats {
snapshot: {
have_bytes: number;
downloaded_and_checked_bytes: number;
downloaded_and_checked_pieces: number;
fetched_bytes: number;
uploaded_bytes: number;
initially_needed_bytes: number;
remaining_bytes: number;
total_bytes: number;
total_piece_download_ms: number;
peer_stats: {
queued: number;
connecting: number;
live: number;
seen: number;
dead: number;
not_needed: number;
};
};
average_piece_download_time: {
secs: number;
nanos: number;
snapshot: {
have_bytes: number;
downloaded_and_checked_bytes: number;
downloaded_and_checked_pieces: number;
fetched_bytes: number;
uploaded_bytes: number;
initially_needed_bytes: number;
remaining_bytes: number;
total_bytes: number;
total_piece_download_ms: number;
peer_stats: {
queued: number;
connecting: number;
live: number;
seen: number;
dead: number;
not_needed: number;
};
download_speed: Speed;
upload_speed: Speed;
all_time_download_speed: {
mbps: number;
human_readable: string;
};
average_piece_download_time: {
secs: number;
nanos: number;
};
download_speed: Speed;
upload_speed: Speed;
all_time_download_speed: {
mbps: number;
human_readable: string;
};
time_remaining: {
human_readable: string;
duration?: {
secs: number;
};
time_remaining: {
human_readable: string;
duration?: {
secs: number,
}
} | null;
} | null;
}

export const STATE_INITIALIZING = 'initializing';
export const STATE_PAUSED = 'paused';
export const STATE_LIVE = 'live';
export const STATE_ERROR = 'error';
export const STATE_INITIALIZING = "initializing";
export const STATE_PAUSED = "paused";
export const STATE_LIVE = "live";
export const STATE_ERROR = "error";

export interface TorrentStats {
state: 'initializing' | 'paused' | 'live' | 'error',
error: string | null,
progress_bytes: number,
finished: boolean,
total_bytes: number,
live: LiveTorrentStats | null;
state: "initializing" | "paused" | "live" | "error";
error: string | null;
progress_bytes: number;
finished: boolean;
total_bytes: number;
live: LiveTorrentStats | null;
}


export interface ErrorDetails {
id?: number,
method?: string,
path?: string,
status?: number,
statusText?: string,
text: string,
};
id?: number;
method?: string;
path?: string;
status?: number;
statusText?: string;
text: string;
}

export type Duration = number;

export interface PeerConnectionOptions {
connect_timeout?: Duration | null;
read_write_timeout?: Duration | null;
keep_alive_interval?: Duration | null;
connect_timeout?: Duration | null;
read_write_timeout?: Duration | null;
keep_alive_interval?: Duration | null;
}

export interface AddTorrentOptions {
paused?: boolean;
only_files_regex?: string | null;
only_files?: number[] | null;
overwrite?: boolean;
list_only?: boolean;
output_folder?: string | null;
sub_folder?: string | null;
peer_opts?: PeerConnectionOptions | null;
force_tracker_interval?: Duration | null;
initial_peers?: string[] | null; // Assuming SocketAddr is equivalent to a string in TypeScript
preferred_id?: number | null;
paused?: boolean;
only_files_regex?: string | null;
only_files?: number[] | null;
overwrite?: boolean;
list_only?: boolean;
output_folder?: string | null;
sub_folder?: string | null;
peer_opts?: PeerConnectionOptions | null;
force_tracker_interval?: Duration | null;
initial_peers?: string[] | null; // Assuming SocketAddr is equivalent to a string in TypeScript
preferred_id?: number | null;
}


export interface RqbitAPI {
listTorrents: () => Promise<ListTorrentsResponse>,
getTorrentDetails: (index: number) => Promise<TorrentDetails>,
getTorrentStats: (index: number) => Promise<TorrentStats>;
uploadTorrent: (data: string | File, opts?: AddTorrentOptions) => Promise<AddTorrentResponse>;

pause: (index: number) => Promise<void>;
start: (index: number) => Promise<void>;
forget: (index: number) => Promise<void>;
delete: (index: number) => Promise<void>;
}
listTorrents: () => Promise<ListTorrentsResponse>;
getTorrentDetails: (index: number) => Promise<TorrentDetails>;
getTorrentStats: (index: number) => Promise<TorrentStats>;
uploadTorrent: (
data: string | File,
opts?: AddTorrentOptions
) => Promise<AddTorrentResponse>;

pause: (index: number) => Promise<void>;
start: (index: number) => Promise<void>;
forget: (index: number) => Promise<void>;
delete: (index: number) => Promise<void>;
}
Loading

0 comments on commit ec63e1c

Please sign in to comment.