Skip to content

Commit

Permalink
Merge branch 'master' of github.com:WDaan/VueTorrent
Browse files Browse the repository at this point in the history
  • Loading branch information
WDaan committed Jan 30, 2021
2 parents e58e93d + 34ef51c commit 1f79cd9
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 35 deletions.
12 changes: 10 additions & 2 deletions src/components/Modals/TorrentDetailModal/Tabs/Info.vue
Expand Up @@ -183,15 +183,23 @@
Download Limit
</td>
<td>
{{ torrent.dl_limit | getDataValue }} {{ torrent.dl_limit | getDataUnit }}/s
{{ torrent.dl_limit | getDataValue }} {{ torrent.dl_limit | getDataUnit }}<span v-if="torrent.dl_limit !== -1"> /s </span>
</td>
</tr>
<tr>
<td class="grey--text">
Upload Limit
</td>
<td>
{{ torrent.up_limit | getDataValue }} {{ torrent.up_limit | getDataUnit }}/s
{{ torrent.up_limit | getDataValue }} {{ torrent.up_limit | getDataUnit }}<span v-if="torrent.up_limit !== -1"> /s </span>
</td>
</tr>
<tr>
<td class="grey--text">
Availability
</td>
<td>
{{ torrent.availability }}%
</td>
</tr>
</tbody>
Expand Down
25 changes: 25 additions & 0 deletions src/components/Torrent/DashboardItems/Availability.vue
@@ -0,0 +1,25 @@
<template>
<v-flex xs6 sm1 md1>
<div class="caption grey--text">
Availability
</div>
<div>
{{ availability }}
</div>
</v-flex>
</template>
<script>
export default {
name: 'Availability',
props: ['torrent'],
computed: {
availability() {
if (this.torrent.availability !== -1) {
return `${this.torrent.availability}%`
}
return 'N/A'
}
}
}
</script>
13 changes: 11 additions & 2 deletions src/components/Torrent/DashboardItems/Status.vue
Expand Up @@ -13,7 +13,7 @@
class="caption white--text px-2"
:class="state"
>
{{ torrent.state }}
{{ stateString }}
</v-chip>
</v-flex>
</template>
Expand All @@ -22,6 +22,15 @@ import { TorrentDashboardItem } from '@/mixins'
export default {
name: 'Status',
mixins: [TorrentDashboardItem],
props: ['torrent']
props: ['torrent'],
computed: {
stateString() {
if (this.torrent.forced) {
return `[F] ${this.torrent.state}`
}
return this.torrent.state
}
}
}
</script>
4 changes: 3 additions & 1 deletion src/components/Torrent/DashboardItems/index.js
Expand Up @@ -13,6 +13,7 @@ import Tags from './Tags'
import AddedOn from './AddedOn'
import Uploaded from './Uploaded'
import UploadedSession from './UploadedSession'
import Availability from './Availability'

export {
Size,
Expand All @@ -29,5 +30,6 @@ export {
AddedOn,
Uploaded,
UploadedSession,
Downloaded
Downloaded,
Availability
}
2 changes: 1 addition & 1 deletion src/components/Torrent/Torrent.vue
Expand Up @@ -3,7 +3,7 @@
flat
class="pointer noselect"
:class="{ selected: isSelected}"
@click.native.exact.prevent="showInfo(torrent.hash)"
@dblclick.prevent="showInfo(torrent.hash)"
@click.ctrl.exact.prevent="selectTorrent(torrent.hash)"
@click.shift.exact.prevent="selectUntil(torrent.hash, index)"
>
Expand Down
4 changes: 3 additions & 1 deletion src/filters.js
Expand Up @@ -85,6 +85,7 @@ export function networkSize(size) {
Vue.filter('networkSize', networkSize)

function getDataUnit(a, b) {
if (a === -1) return null
if (!a) return 'B'
const c = 1024
const e = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
Expand All @@ -96,7 +97,8 @@ function getDataUnit(a, b) {
Vue.filter('getDataUnit', getDataUnit)

function getDataValue(a, b) {
if (a == 0) return '0'
if (a === -1) return 'None'
if (!a) return '0'
const c = 1024
const d = b || 2
const f = Math.floor(Math.log(a) / Math.log(c))
Expand Down
4 changes: 3 additions & 1 deletion src/models/Torrent.js
Expand Up @@ -29,13 +29,15 @@ export default class Torrent {
this.dl_limit = data.dl_limit
this.up_limit = data.up_limit
this.ratio_limit = data.ratio_limit
this.availability = Math.round(data.availability * 100) / 100
this.forced = data.state.includes('forced')

Object.freeze(this)
}

formatState(state) {
switch (state) {
case 'forceDL':
case 'forcedDL':
case 'downloading':
return 'Downloading'
case 'metaDL':
Expand Down
7 changes: 7 additions & 0 deletions src/router.js
Expand Up @@ -2,6 +2,7 @@ import Vue from 'vue'
import Router from 'vue-router'
import Dashboard from '@/views/Dashboard.vue'
import Login from '@/views/Login.vue'
import MagnetHandler from '@/views/MagnetHandler'
import { isAuthenticated } from '@/services/auth.js'

Vue.use(Router)
Expand All @@ -14,6 +15,11 @@ const router = new Router({
name: 'dashboard',
component: Dashboard
},
{ path: '/download=:magnet',
name: 'MagnetHandler',
component: MagnetHandler,
props: true
},
{
path: '/login',
name: 'login',
Expand All @@ -23,6 +29,7 @@ const router = new Router({
onlyWhenLoggedOut: true
}
}

]
})

Expand Down
6 changes: 4 additions & 2 deletions src/store/index.js
Expand Up @@ -73,7 +73,8 @@ export default new Vuex.Store({
{ name: 'Ratio', active: true },
{ name: 'Category', active: true },
{ name: 'Tags', active: true },
{ name: 'AddedOn', active: true }
{ name: 'AddedOn', active: true },
{ name: 'Availability', active: true }
],
doneTorrentProperties: [
{ name: 'Size', active: true },
Expand All @@ -88,7 +89,8 @@ export default new Vuex.Store({
{ name: 'Ratio', active: true },
{ name: 'Category', active: true },
{ name: 'Tags', active: true },
{ name: 'AddedOn', active: true }
{ name: 'AddedOn', active: true },
{ name: 'Availability', active: true }
]
},
categories: [],
Expand Down
14 changes: 6 additions & 8 deletions src/styles/styles.scss
Expand Up @@ -84,14 +84,7 @@ $sideborder-margin: 5px;
user-select: none; /* Non-prefixed version, currently
supported by Chrome and Opera */
}
.noselect {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
supported by Chrome and Opera */
}

.pointer {
cursor: pointer;
}
Expand All @@ -106,6 +99,11 @@ $sideborder-margin: 5px;
letter-spacing: 0;
}

.transparent {
background-color: transparent!important;
border-color: transparent!important;
}

body {
&::-webkit-scrollbar {
width: 6px;
Expand Down
17 changes: 0 additions & 17 deletions src/views/Dashboard.vue
Expand Up @@ -309,21 +309,4 @@ export default {
padding: 0;
}
}
.topBorderRadius {
border-top-left-radius: 3px !important;
border-top-right-radius: 3px !important;
border-bottom-right-radius: 0px !important;
}
.noBorderRadius {
border-radius: 0 !important;
}
.bottomBorderRadius {
border-bottom-left-radius: 3px !important;
border-bottom-right-radius: 3px !important;
}
.transparent {
background-color: transparent!important;
border-color: transparent!important;
}
</style>
17 changes: 17 additions & 0 deletions src/views/MagnetHandler.vue
@@ -0,0 +1,17 @@
<template>
<h1 class="text-center mt-5">
MagnetHandler
</h1>
</template>
<script>
import { General } from '@/mixins'
export default {
name: 'MagnetHandler',
mixins: [General],
props: ['magnet'],
created() {
this.createModal('AddModal', { initialMagnet: this.magnet })
this.$router.push('/')
}
}
</script>

0 comments on commit 1f79cd9

Please sign in to comment.