Skip to content

Commit

Permalink
feat: basic limit share ratio #308
Browse files Browse the repository at this point in the history
  • Loading branch information
Daan Wijns committed Nov 1, 2021
1 parent b069ce4 commit 2c1fc34
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 2 deletions.
89 changes: 89 additions & 0 deletions src/components/Modals/ShareLimitModal.vue
@@ -0,0 +1,89 @@
<template>
<v-dialog
v-model="dialog"
scrollable
content-class="rounded-form"
max-width="500px"
:fullscreen="isPhone"
>
<v-card>
<v-card-title class="pa-0">
<v-toolbar-title class="ma-4 primarytext--text">
<h3>Limit ratio</h3>
</v-toolbar-title>
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col>
<v-text-field
v-model="limit"
autofocus
clearable
label="Ratio Limit"
:prepend-inner-icon="mdiSpeedometer"
@focus="$event.target.select()"
@keydown.enter="setLimit"
/>
</v-col>
</v-row>
</v-container>
</v-card-text>
<v-divider />
<v-card-actions class="justify-end">
<v-btn
class="accent white--text elevation-0 px-4"
@click="setLimit"
>
Save
</v-btn>
<v-btn
class="error white--text elevation-0 px-4"
@click="close"
>
Cancel
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>

<script>
import { mapGetters } from 'vuex'
import { mdiSpeedometer, mdiClose } from '@mdi/js'
import { Modal, FullScreenModal } from '@/mixins'
import qbit from '@/services/qbit'
export default {
name: 'ShareLimitModal',
mixins: [Modal, FullScreenModal],
props: {
mode: String,
hash: String
},
data() {
return {
limit: '',
mdiSpeedometer, mdiClose
}
},
computed: {
...mapGetters(['getTorrent']),
torrent() {
return this.getTorrent(this.hash)
},
isPhone() {
return this.$vuetify.breakpoint.xsOnly
}
},
methods: {
setLimit() {
console.log(this.limit || -2)
qbit.setShareLimit([this.hash], this.limit || -2, -2)
this.close()
},
close() {
this.dialog = false
}
}
}
</script>
13 changes: 11 additions & 2 deletions src/components/Torrent/TorrentRightClickMenu.vue
Expand Up @@ -232,6 +232,12 @@
Upload
</v-list-item-title>
</v-list-item>
<v-list-item @click="setShareLimit()">
<v-icon>{{ mdiAccountGroup }}</v-icon>
<v-list-item-title class="ml-2">
Share
</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
<v-menu
Expand Down Expand Up @@ -293,7 +299,7 @@ import qbit from '@/services/qbit'
import { General, TorrentSelect } from '@/mixins'
import {
mdiBullhorn, mdiPlaylistCheck, mdiArrowUp, mdiArrowDown, mdiPriorityLow,
mdiInformation, mdiRenameBox, mdiFolder, mdiDelete,
mdiInformation, mdiRenameBox, mdiFolder, mdiDelete, mdiAccountGroup,
mdiPlay, mdiPause, mdiSelect, mdiPriorityHigh, mdiChevronRight,
mdiFastForward, mdiShape, mdiHeadCog, mdiCheckboxMarked, mdiCheckboxBlankOutline,
mdiSpeedometerSlow, mdiChevronUp, mdiChevronDown, mdiContentCopy, mdiMagnet
Expand All @@ -317,7 +323,7 @@ export default {
{ name: 'bottom', icon: mdiPriorityLow, action: 'bottomPrio' }
],
mdiDelete, mdiPlay, mdiPause, mdiSelect, mdiFastForward,
mdiFolder, mdiRenameBox, mdiInformation, mdiMagnet,
mdiFolder, mdiRenameBox, mdiInformation, mdiMagnet, mdiAccountGroup,
mdiPlaylistCheck, mdiPriorityHigh, mdiBullhorn, mdiChevronRight,
mdiShape, mdiHeadCog, mdiCheckboxMarked, mdiCheckboxBlankOutline,
mdiSpeedometerSlow, mdiChevronUp, mdiChevronDown, mdiContentCopy
Expand Down Expand Up @@ -388,6 +394,9 @@ export default {
setLimit(mode) {
this.createModal('SpeedLimitModal', { hash: this.torrent.hash, mode })
},
setShareLimit() {
this.createModal('ShareLimitModal', { hash: this.torrent.hash })
},
forceResume() {
qbit.forceStartTorrents(this.hashes)
},
Expand Down

0 comments on commit 2c1fc34

Please sign in to comment.