diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..401ed222 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +nodemodules +src +LICENSE.md +package-lock.json +package.json +README.md \ No newline at end of file diff --git a/package.json b/package.json index be2c13d1..95b0a07d 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "serve": "vue-cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint", - "start" : "nodemon server.js" + "start" : "nodemon server/server.js" }, "dependencies": { "apexcharts": "^3.6.5", diff --git a/server/config/config.example.json b/server/config/config.example.json index 22f68733..2551b2e9 100644 --- a/server/config/config.example.json +++ b/server/config/config.example.json @@ -1,8 +1,8 @@ { "qbit_user": "admin", "qbit_pass": "adminadmin", - "qbit_host": "https://qbit.mydomain.com", + "qbit_host": "https://qbittorrent.mydomain.com", "web_user": "username", "web_pass": " password", - "web_host": "https://vuetr.mydomain.me" + "web_host": "https://vuetorrent.mydomain.com" } diff --git a/server/server.js b/server/server.js index 4d5ae12f..6fe0ac5e 100644 --- a/server/server.js +++ b/server/server.js @@ -18,7 +18,7 @@ const upload = multer({ const app = express(); app.use(express.json()); -app.use(express.static('./src/dist')); +app.use(express.static('dist')); app.use(function(req, res, next) { res.header('Access-Control-Allow-Origin', '*'); @@ -119,7 +119,7 @@ app.delete('/upload', upload.single('file'), (req, res) => { return res.send('deleted file'); }); -app.listen(3000, () => console.log(`Server listening on port 3000!`)); +app.listen(3009, () => console.log(`Server listening on port 3009!`)); //clear the tmp directory on every boot const directory = path.resolve(__dirname + '/tmp'); diff --git a/src/components/Navbar.vue b/src/components/Navbar.vue index 2b9aaa07..ef293e2a 100644 --- a/src/components/Navbar.vue +++ b/src/components/Navbar.vue @@ -3,9 +3,7 @@ - + Vue Torrent @@ -22,7 +20,7 @@ pause - + autorenew @@ -187,6 +185,10 @@ export default { removeTorrents() { this.$store.dispatch("REMOVE_TORRENTS"); }, + refreshTorrents() { + this.$store.state.init_torrents = false; + this.$store.dispatch("REFRESH_TORRENTS"); + }, closeSnackbar() { this.$store.state.snackbar = false; } diff --git a/src/config/config.example.json b/src/config/config.example.json index 22f68733..2551b2e9 100644 --- a/src/config/config.example.json +++ b/src/config/config.example.json @@ -1,8 +1,8 @@ { "qbit_user": "admin", "qbit_pass": "adminadmin", - "qbit_host": "https://qbit.mydomain.com", + "qbit_host": "https://qbittorrent.mydomain.com", "web_user": "username", "web_pass": " password", - "web_host": "https://vuetr.mydomain.me" + "web_host": "https://vuetorrent.mydomain.com" } diff --git a/src/services/qbit.js b/src/services/qbit.js index d292750a..53d0e551 100644 --- a/src/services/qbit.js +++ b/src/services/qbit.js @@ -1,6 +1,6 @@ const axios = require('axios'); -const info = require('./config/config.json'); +const info = require('../config/config.json'); class Qbit { constructor() { @@ -45,13 +45,17 @@ class Qbit { } async remove_torrents(torrents) { - let res = await this._axios.post('/remove', torrents); + let res = await this._axios.post('/remove', torrents) return res.data; } async login(credentials) { - let res = await this._axios.post('/login', credentials); - return res.data; + let timeout = false; + let res = await this._axios.post('/login', credentials).catch(error => { + if (error.code === 'ECONNABORTED') timeout = true; + else throw error; + }); + return timeout ? 'timeout' : res.data; } } diff --git a/src/services/store.js b/src/services/store.js index 60a6c2d3..69cb031a 100644 --- a/src/services/store.js +++ b/src/services/store.js @@ -18,6 +18,7 @@ export default new Vuex.Store({ upload_data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], download_data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], torrents: [], + init_torrents : false, selected_torrents: [], network_error: false, snackbar_error: false, @@ -40,7 +41,8 @@ export default new Vuex.Store({ state.error_msg = 'Lost connection with server, reload page'; state.snackbar_error = true; }); - state.torrents = torrents.map(a => ({...a})); + state.torrents = torrents.map(a => ({ ...a })); + state.init_torrents = true; }, REFRESH_SESSION_STATS: async state => { let _stats = await qbit.get_sessions_stats(); @@ -122,38 +124,47 @@ export default new Vuex.Store({ }, LOGIN: async (state, payload) => { let res = await qbit.login(payload); - switch (res) { - case 'No such user': - state.snackbar_error = true; - state.error_msg = 'No such user!'; - setTimeout(() => { - state.snackbar_error = false; - }, 4000); - break; - case 'Wrong password!': - state.snackbar_error = true; - state.error_msg = 'Wrong password!'; - setTimeout(() => { - state.snackbar_error = false; - }, 4000); - break; - case 'SUCCES': - state.snackbar = true; - state.succes_msg = 'Succesfully logged in!'; - state.authenticated = true; - setTimeout(() => { - state.snackbar = false; - }, 4000); - break; - default: - state.snackbar_error = true; - state.error_msg = 'Something went wrong'; - setTimeout(() => { - state.snackbar_error = false; - }, 4000); - break; + if (res == 'timeout') { + state.loading = false; + state.snackbar_error = true; + state.error_msg = 'Express server timed out!'; + setTimeout(() => { + state.snackbar_error = false; + }, 4000); + } else { + switch (res) { + case 'No such user': + state.snackbar_error = true; + state.error_msg = 'No such user!'; + setTimeout(() => { + state.snackbar_error = false; + }, 4000); + break; + case 'Wrong password!': + state.snackbar_error = true; + state.error_msg = 'Wrong password!'; + setTimeout(() => { + state.snackbar_error = false; + }, 4000); + break; + case 'SUCCES': + state.snackbar = true; + state.succes_msg = 'Succesfully logged in!'; + state.authenticated = true; + setTimeout(() => { + state.snackbar = false; + }, 4000); + break; + default: + state.snackbar_error = true; + state.error_msg = 'Something went wrong'; + setTimeout(() => { + state.snackbar_error = false; + }, 4000); + break; + } + state.loading = false; } - state.loading = false; } }, actions: { diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index 8ebefd9d..604b0b0e 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -16,8 +16,15 @@ @keyup.enter.native="sortBy" > - -
+ +
+ +
+
+
+

No active Torrents!

+
+
- -
- -
-
@@ -127,7 +129,7 @@ export default { }; }, computed: { - ...mapState(["torrents"]) + ...mapState(["torrents", "init_torrents"]) }, methods: { ...mapMutations(["SORT_TORRENTS"]),