mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2024-11-25 19:05:51 +03:00
fix: peers not showing up (#660)
This commit is contained in:
parent
bc5695b870
commit
d8ca97d928
2 changed files with 46 additions and 55 deletions
|
@ -1,36 +1,38 @@
|
||||||
<template>
|
<template>
|
||||||
<v-card flat>
|
<v-card flat>
|
||||||
<v-card-text class="pa-0">
|
<v-card-text class="pa-0">
|
||||||
<v-data-table v-if="peers" v-model="selectedPeers" dense show-select :headers="headers" :items="peers" :items-per-page="-1" item-key="key" mobile-breakpoint="0">
|
<v-data-table v-if="peers" v-model="selectedPeers" dense show-select :headers="headers" :items="peers"
|
||||||
|
:items-per-page="-1" item-key="key" mobile-breakpoint="0">
|
||||||
<template #body="{ items }">
|
<template #body="{ items }">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="item in items" :key="item.key">
|
<tr v-for="item in items" :key="item.key">
|
||||||
<td>
|
<td>
|
||||||
<v-checkbox v-model="selectedPeers" :value="item.key" hide-details class="pa-0 ma-0" color="accent" />
|
<v-checkbox v-model="selectedPeers" :value="item.key" hide-details class="pa-0 ma-0" color="accent"/>
|
||||||
</td>
|
</td>
|
||||||
<td class="ip">
|
<td class="ip">
|
||||||
<template v-if="item.country_code">
|
<template v-if="item.country_code">
|
||||||
<img v-if="isWindows" class="country-flag" :title="item.country" :alt="codeToFlag(item.country_code).char" :src="codeToFlag(item.country_code).url" />
|
<img v-if="isWindows" class="country-flag" :title="item.country"
|
||||||
<template v-else>
|
:alt="codeToFlag(item.country_code).char" :src="codeToFlag(item.country_code).url"/>
|
||||||
{{ codeToFlag(item.country_code).char }}
|
<template v-else>
|
||||||
</template>
|
{{ codeToFlag(item.country_code).char }}
|
||||||
</template>
|
</template>
|
||||||
{{ item.ip }}
|
</template>
|
||||||
<span class="grey--text">:{{ item.port }}</span>
|
{{ item.ip }}
|
||||||
</td>
|
<span class="grey--text">:{{ item.port }}</span>
|
||||||
<td>{{ item.connection }}</td>
|
</td>
|
||||||
<td :title="item.flags_desc">
|
<td>{{ item.connection }}</td>
|
||||||
{{ item.flags }}
|
<td :title="item.flags_desc">
|
||||||
</td>
|
{{ item.flags }}
|
||||||
<td>{{ item.client }}</td>
|
</td>
|
||||||
<td>{{ item.progress | progress }}</td>
|
<td>{{ item.client }}</td>
|
||||||
<td>{{ item.dl_speed | networkSpeed }}</td>
|
<td>{{ item.progress | progress }}</td>
|
||||||
<td>{{ item.downloaded | networkSize }}</td>
|
<td>{{ item.dl_speed | networkSpeed }}</td>
|
||||||
<td>{{ item.up_speed | networkSpeed }}</td>
|
<td>{{ item.downloaded | networkSize }}</td>
|
||||||
<td>{{ item.uploaded | networkSize }}</td>
|
<td>{{ item.up_speed | networkSpeed }}</td>
|
||||||
<td>{{ item.relevance | progress }}</td>
|
<td>{{ item.uploaded | networkSize }}</td>
|
||||||
<td>{{ item.files }}</td>
|
<td>{{ item.relevance | progress }}</td>
|
||||||
</tr>
|
<td>{{ item.files }}</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</template>
|
</template>
|
||||||
</v-data-table>
|
</v-data-table>
|
||||||
|
@ -46,10 +48,11 @@
|
||||||
<h3>Add Peers</h3>
|
<h3>Add Peers</h3>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-textarea v-model="newPeers" label="Peers" rows="1" required autofocus auto-grow clearable hint="One link per line" />
|
<v-textarea v-model="newPeers" label="Peers" rows="1" required autofocus auto-grow clearable
|
||||||
|
hint="One link per line"/>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-spacer />
|
<v-spacer/>
|
||||||
<v-btn color="red darken-1" text @click="closeAddPeers">Cancel</v-btn>
|
<v-btn color="red darken-1" text @click="closeAddPeers">Cancel</v-btn>
|
||||||
<v-btn color="green darken-1" text @click="addPeers">Add</v-btn>
|
<v-btn color="green darken-1" text @click="addPeers">Add</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
|
@ -70,21 +73,15 @@ export default {
|
||||||
mixins: [FullScreenModal],
|
mixins: [FullScreenModal],
|
||||||
props: { hash: String, isActive: Boolean },
|
props: { hash: String, isActive: Boolean },
|
||||||
data: () => ({
|
data: () => ({
|
||||||
|
rid: 0,
|
||||||
peersDialog: false,
|
peersDialog: false,
|
||||||
refreshTimer: '',
|
refreshTimer: '',
|
||||||
peersObj: null,
|
peersObj: null,
|
||||||
newPeers: '',
|
newPeers: '',
|
||||||
selectedPeers: []
|
selectedPeers: [],
|
||||||
|
isWindows
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
rid: {
|
|
||||||
get() {
|
|
||||||
return this.$store.state.rid
|
|
||||||
},
|
|
||||||
set(val) {
|
|
||||||
this.$store.state.rid = val
|
|
||||||
}
|
|
||||||
},
|
|
||||||
peers() {
|
peers() {
|
||||||
return map(this.peersObj, (value, key) => merge({}, value, { key }))
|
return map(this.peersObj, (value, key) => merge({}, value, { key }))
|
||||||
},
|
},
|
||||||
|
@ -107,32 +104,24 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
isActive(active) {
|
isActive(active) {
|
||||||
if (active) {
|
if (active) {
|
||||||
this.getTorrentPeers()
|
this.refreshTimer = setInterval(() => this.getTorrentPeers(), 2000)
|
||||||
this.refreshTimer = setInterval(
|
|
||||||
function () {
|
|
||||||
this.getTorrentPeers()
|
|
||||||
}.bind(this),
|
|
||||||
2000
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(this.refreshTimer)
|
clearInterval(this.refreshTimer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {},
|
created() {},
|
||||||
beforeDestroy() {},
|
beforeDestroy() {
|
||||||
|
clearInterval(this.refreshTimer)
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
codeToFlag(val) {
|
codeToFlag(val) {
|
||||||
return codeToFlag(val)
|
return codeToFlag(val)
|
||||||
},
|
},
|
||||||
isWindows() {
|
|
||||||
return isWindows()
|
|
||||||
},
|
|
||||||
async getTorrentPeers() {
|
async getTorrentPeers() {
|
||||||
const data = await qbit.getTorrentPeers(this.hash, this.rid + 1 || undefined)
|
const data = await qbit.getTorrentPeers(this.hash, this.rid + 1 || undefined)
|
||||||
|
|
||||||
this.rid = data.rid
|
this.rid = data.rid
|
||||||
|
|
||||||
this.peersObj = data.peers
|
this.peersObj = data.peers
|
||||||
},
|
},
|
||||||
async addPeers() {
|
async addPeers() {
|
||||||
|
@ -141,9 +130,8 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
qbit.addTorrentPeers([this.hash], this.newPeers.split('\n'))
|
await qbit.addTorrentPeers([this.hash], this.newPeers.split('\n'))
|
||||||
this.newPeers = ''
|
this.newPeers = ''
|
||||||
await this.getTorrentPeers()
|
|
||||||
this.peersDialog = false
|
this.peersDialog = false
|
||||||
},
|
},
|
||||||
closeAddPeers() {
|
closeAddPeers() {
|
||||||
|
@ -153,9 +141,8 @@ export default {
|
||||||
async banPeers() {
|
async banPeers() {
|
||||||
if (this.selectedPeers.length === 0) return
|
if (this.selectedPeers.length === 0) return
|
||||||
|
|
||||||
qbit.banPeers(this.selectedPeers)
|
await qbit.banPeers(this.selectedPeers)
|
||||||
this.selectedPeers = []
|
this.selectedPeers = []
|
||||||
await this.getTorrentPeers()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,13 +170,16 @@ export default {
|
||||||
&:first-child {
|
&:first-child {
|
||||||
padding: 0 0 0 8px !important;
|
padding: 0 0 0 8px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
padding-right: 8px !important;
|
padding-right: 8px !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.v-data-table-header) {
|
:deep(.v-data-table-header) {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(td) {
|
:deep(td) {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,7 @@ export class QBitApi {
|
||||||
return this.axios.get('/sync/torrentPeers', {
|
return this.axios.get('/sync/torrentPeers', {
|
||||||
params: { hash, rid }
|
params: { hash, rid }
|
||||||
})
|
})
|
||||||
|
.then(r => r.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
async setTorrentName(hash: string, name: string): Promise<void> {
|
async setTorrentName(hash: string, name: string): Promise<void> {
|
||||||
|
|
Loading…
Reference in a new issue