diff --git a/services/torrent-webui/.env.example b/services/torrent-webui/.env.example index 7bbc02f..02eeb13 100644 --- a/services/torrent-webui/.env.example +++ b/services/torrent-webui/.env.example @@ -1,2 +1,2 @@ -SERVER_PORT = 3100 +SERVER_PORT = 3300 TORRENT_CLIENT_IPC_SOCKET = /tmp/torrent_client.sock diff --git a/services/torrent-webui/index.html b/services/torrent-webui/index.html index bb74da7..72b64e0 100644 --- a/services/torrent-webui/index.html +++ b/services/torrent-webui/index.html @@ -6,7 +6,7 @@ Autoplex Torrent - +
diff --git a/services/torrent-webui/package.json b/services/torrent-webui/package.json index 0c3cfcb..129ddc0 100644 --- a/services/torrent-webui/package.json +++ b/services/torrent-webui/package.json @@ -15,6 +15,7 @@ "start:dev": "nodemon" }, "dependencies": { + "@fortawesome/fontawesome-free": "^5.15.3", "fastify": "^3.14.1", "fastify-formbody": "^5.0.0", "fastify-http-proxy": "^5.0.0", @@ -22,6 +23,8 @@ "fastify-static": "^4.0.1", "node-ipc": "^9.1.4", "vue": "^3.0.5", + "vue-router": "^4.0.6", + "vuedraggable": "^4.0.1", "websocket": "^1.0.33" }, "devDependencies": { diff --git a/services/torrent-webui/src/server/index.ts b/services/torrent-webui/src/server/index.ts index aa971db..f623404 100644 --- a/services/torrent-webui/src/server/index.ts +++ b/services/torrent-webui/src/server/index.ts @@ -54,23 +54,30 @@ server.get("/api/torrent/:infoHash", async (request, reply) => { server.post("/api/torrent/add", async (request, reply) => { let result: string[] = []; - if (request.isMultipart()) { - let files = request.files(); - for await (let file of files) { - let torrentFile = await file.toBuffer(); - let infoHash = await ipc.add(torrentFile); - result.push(infoHash); - } - } else { - assert(request.body !== undefined, "Invalid request: empty body"); - let links = (request.body)["link"]; - assert(links !== undefined, "Invalid request: empty links"); - for (let link of (Array.isArray(links) ? links : [links])) { - let infoHash = await ipc.add(link); - result.push(infoHash); - } + if (request.isMultipart()) { + let files = request.files(); + for await (let file of files) { + let torrentFile = await file.toBuffer(); + let infoHash = await ipc.add(torrentFile); + result.push(infoHash); } - return { result: result }; + } else { + assert(request.body !== undefined, "Invalid request: empty body"); + let links = (request.body)["link"]; + assert(links !== undefined, "Invalid request: empty links"); + for (let link of (Array.isArray(links) ? links : [links])) { + let infoHash = await ipc.add(link); + result.push(infoHash); + } + } + return { result: result }; +}); + +server.delete("/api/torrent/remove/:infoHash", async (request, reply) => { + let infoHash: string = (request.params)["infoHash"]; + assert(infoHash != undefined); + await ipc.remove(infoHash); + return {} }); // ------------------------------------------------------------------------------------------------- diff --git a/services/torrent-webui/tailwind.config.js b/services/torrent-webui/tailwind.config.js index 2b88bc2..8ceda6e 100644 --- a/services/torrent-webui/tailwind.config.js +++ b/services/torrent-webui/tailwind.config.js @@ -2,7 +2,14 @@ module.exports = { purge: ["./index.html", "src/app/*.{vue,ts}"], darkMode: false, // or 'media' or 'class' theme: { - extend: {}, + extend: { + colors: { + ui: { + bg: "#191726", + fg: "#202332", + } + }, + }, }, variants: { extend: {}, diff --git a/services/torrent-webui/yarn.lock b/services/torrent-webui/yarn.lock index 011d38e..fd8dbc3 100644 --- a/services/torrent-webui/yarn.lock +++ b/services/torrent-webui/yarn.lock @@ -34,6 +34,11 @@ "@fastify/forwarded" "^1.0.0" ipaddr.js "^2.0.0" +"@fortawesome/fontawesome-free@^5.15.3": + version "5.15.3" + resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.3.tgz#c36ffa64a2a239bf948541a97b6ae8d729e09a9a" + integrity sha512-rFnSUN/QOtnOAgqFRooTA3H57JLDm0QEG/jPdk+tLQNL/eWd+Aok8g3qCI+Q1xuDPWpGW/i9JySpJVsq8Q0s9w== + "@fullhuman/postcss-purgecss@^3.1.3": version "3.1.3" resolved "https://registry.yarnpkg.com/@fullhuman/postcss-purgecss/-/postcss-purgecss-3.1.3.tgz#47af7b87c9bfb3de4bc94a38f875b928fffdf339" @@ -2144,6 +2149,11 @@ sonic-boom@^1.0.2: atomic-sleep "^1.0.0" flatstr "^1.0.12" +sortablejs@1.10.2: + version "1.10.2" + resolved "https://registry.yarnpkg.com/sortablejs/-/sortablejs-1.10.2.tgz#6e40364d913f98b85a14f6678f92b5c1221f5290" + integrity sha512-YkPGufevysvfwn5rfdlGyrGjt7/CRHwvRPogD/lC+TnvcN29jDpCifKP+rBqf+LRldfXSTh+0CGLcSg0VIxq3A== + source-map-support@^0.5.17: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" @@ -2470,6 +2480,11 @@ vite@^2.1.5: optionalDependencies: fsevents "~2.3.1" +vue-router@^4.0.6: + version "4.0.6" + resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-4.0.6.tgz#91750db507d26642f225b0ec6064568e5fe448d6" + integrity sha512-Y04llmK2PyaESj+N33VxLjGCUDuv9t4q2OpItEGU7POZiuQZaugV6cJpE6Qm1sVFtxufodLKN2y2dQl9nk0Reg== + vue-tsc@^0.0.15: version "0.0.15" resolved "https://registry.yarnpkg.com/vue-tsc/-/vue-tsc-0.0.15.tgz#2951f0479bf0b966c828748927e8ea5b82a15070" @@ -2486,6 +2501,13 @@ vue@^3.0.5: "@vue/runtime-dom" "3.0.11" "@vue/shared" "3.0.11" +vuedraggable@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/vuedraggable/-/vuedraggable-4.0.1.tgz#3bcaab0808b7944030b7d9a29f9a63d59dfa12c5" + integrity sha512-7qN5jhB1SLfx5P+HCm3JUW+pvgA1bSLgYLSVOeLWBDH9z+zbaEH0OlyZBVMLOxFR+JUHJjwDD0oy7T4r9TEgDA== + dependencies: + sortablejs "1.10.2" + websocket@^1.0.33: version "1.0.33" resolved "https://registry.yarnpkg.com/websocket/-/websocket-1.0.33.tgz#407f763fc58e74a3fa41ca3ae5d78d3f5e3b82a5"