mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2025-02-26 12:21:00 +03:00
fix: Repair broken keybinds (#942)
This commit is contained in:
parent
3d3b1bf4d8
commit
5a861deeb2
6 changed files with 60 additions and 40 deletions
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<v-dialog v-model="dialog" content-class="rounded-form" max-width="300px" @keydown.enter.prevent="hasInitialFeed ? edit : create">
|
||||
<v-dialog v-model="dialog" content-class="rounded-form" max-width="300px" @keydown.enter.prevent="submit">
|
||||
<v-card>
|
||||
<v-card-title class="pa-0">
|
||||
<v-toolbar-title class="ma-4 primarytext--text">
|
||||
|
@ -9,20 +9,17 @@
|
|||
<v-card-text>
|
||||
<v-form ref="feedForm" class="px-6 mt-3">
|
||||
<v-container v-if="!hasInitialFeed">
|
||||
<v-text-field v-model="feed.url" :label="$t('modals.newFeed.url')" required />
|
||||
<v-text-field v-model="feed.url" :rules="rules" :label="$t('modals.newFeed.url')" required />
|
||||
</v-container>
|
||||
<v-container>
|
||||
<v-text-field v-model="feed.name" :label="$t('modals.newFeed.feedName')" required />
|
||||
<v-text-field v-model="feed.name" :rules="rules" :label="$t('modals.newFeed.feedName')" required />
|
||||
</v-container>
|
||||
</v-form>
|
||||
</v-card-text>
|
||||
<v-divider />
|
||||
<v-card-actions class="justify-end">
|
||||
<v-btn v-if="!hasInitialFeed" class="accent white--text elevation-0 px-4" @click="create">
|
||||
{{ $t('create') }}
|
||||
</v-btn>
|
||||
<v-btn v-else class="accent white--text elevation-0 px-4" @click="edit">
|
||||
{{ $t('edit') }}
|
||||
<v-btn class="accent white--text elevation-0 px-4" @click="submit">
|
||||
{{ $t(hasInitialFeed ? 'edit' : 'create') }}
|
||||
</v-btn>
|
||||
<v-btn class="error white--text elevation-0 px-4" @click="cancel">
|
||||
{{ $t('cancel') }}
|
||||
|
@ -46,6 +43,9 @@ export default defineComponent({
|
|||
},
|
||||
data: () => ({
|
||||
feed: { url: '', name: '' },
|
||||
rules: [
|
||||
(v: string) => !!v || 'Required'
|
||||
],
|
||||
mdiCancel,
|
||||
mdiTagPlus,
|
||||
mdiPencil
|
||||
|
@ -61,18 +61,23 @@ export default defineComponent({
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
async create() {
|
||||
await qbit.createFeed(this.feed)
|
||||
this.cancel()
|
||||
},
|
||||
cancel() {
|
||||
this.$store.commit('FETCH_FEEDS')
|
||||
this.dialog = false
|
||||
},
|
||||
async create() {
|
||||
await qbit.createFeed(this.feed)
|
||||
this.cancel()
|
||||
},
|
||||
async edit() {
|
||||
await qbit.editFeed(this.initialFeed.name, this.feed.name)
|
||||
this.$toast.success(this.$t('toast.feedSaved'))
|
||||
this.cancel()
|
||||
},
|
||||
async submit() {
|
||||
if (this.feed.name === '' || this.feed.url === '') return
|
||||
if (this.hasInitialFeed) await this.edit()
|
||||
else await this.create()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { i18n } from '@/plugins/i18n'
|
||||
import type { StoreState } from '@/types/vuetorrent'
|
||||
import { formatSize } from '@/filters'
|
||||
import {Torrent} from "@/models";
|
||||
|
||||
export default {
|
||||
getAppVersion: (state: StoreState) => () => state.version,
|
||||
|
@ -23,7 +24,7 @@ export default {
|
|||
getTorrentCountString: (state: StoreState, getters: any) => () => {
|
||||
if (state.selected_torrents.length) {
|
||||
let selectedSize = state.selected_torrents
|
||||
.map(getters.getTorrent)
|
||||
.map((hash: string): Torrent => getters.getTorrent(hash))
|
||||
.filter(torrent => torrent !== undefined)
|
||||
.map(torrent => torrent.size)
|
||||
.reduce((partialSum, newVal) => partialSum + newVal, 0)
|
||||
|
|
|
@ -63,7 +63,7 @@ import qbit from '@/services/qbit'
|
|||
import {Log} from '@/types/qbit/models'
|
||||
import {LogType} from '@/enums/qbit'
|
||||
import dayjs from "dayjs";
|
||||
import {mapState} from "vuex";
|
||||
import {mapGetters, mapState} from "vuex";
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Logs',
|
||||
|
@ -90,6 +90,7 @@ export default defineComponent({
|
|||
},
|
||||
computed: {
|
||||
...mapState(['webuiSettings']),
|
||||
...mapGetters(['getModals']),
|
||||
lastFetchedId() {
|
||||
return this.logs.length > 0 ? this.logs[this.logs.length-1].id : -1
|
||||
},
|
||||
|
@ -141,7 +142,7 @@ export default defineComponent({
|
|||
this.$router.back()
|
||||
},
|
||||
handleKeyboardShortcut(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape') {
|
||||
if (e.key === 'Escape' && this.getModals().length === 0) {
|
||||
this.close()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
<script lang="ts">
|
||||
import { General } from '@/mixins'
|
||||
import { mapState } from 'vuex'
|
||||
import {mapGetters, mapState } from 'vuex'
|
||||
import { defineComponent } from 'vue'
|
||||
import { FeedArticle } from '@/types/vuetorrent/rss'
|
||||
import { Feed, FeedRule } from '@/types/vuetorrent'
|
||||
|
@ -105,6 +105,7 @@ export default defineComponent({
|
|||
},
|
||||
computed: {
|
||||
...mapState(['rss']),
|
||||
...mapGetters(['getModals']),
|
||||
articles(): FeedArticle[] {
|
||||
const articles: FeedArticle[] = []
|
||||
;(this.rss as RssState).feeds.forEach((feed: Feed) => {
|
||||
|
@ -141,7 +142,7 @@ export default defineComponent({
|
|||
this.$store.commit('FETCH_FEEDS')
|
||||
},
|
||||
handleKeyboardShortcut(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape') {
|
||||
if (e.key === 'Escape' && this.getModals().length === 0) {
|
||||
this.close()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
import { mapState } from 'vuex'
|
||||
import { mapGetters } from 'vuex'
|
||||
import { mdiClose, mdiDownload, mdiToyBrick } from '@mdi/js'
|
||||
import qbit from '@/services/qbit'
|
||||
import { General } from '@/mixins'
|
||||
|
@ -108,7 +108,7 @@ export default defineComponent({
|
|||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(['searchPlugins']),
|
||||
...mapGetters(['getSearchPlugins', 'getModals']),
|
||||
categories() {
|
||||
const cats = [
|
||||
{ text: 'Movies', value: 'movies' },
|
||||
|
@ -130,7 +130,7 @@ export default defineComponent({
|
|||
{ text: 'Only enabled', value: 'enabled' }
|
||||
]
|
||||
|
||||
this.searchPlugins.filter((plugin: SearchPlugin) => plugin.enabled).forEach((plugin: SearchPlugin) => plugins.push({ text: plugin.fullName, value: plugin.name }))
|
||||
this.getSearchPlugins().filter((plugin: SearchPlugin) => plugin.enabled).forEach((plugin: SearchPlugin) => plugins.push({ text: plugin.fullName, value: plugin.name }))
|
||||
|
||||
return plugins
|
||||
},
|
||||
|
@ -140,9 +140,11 @@ export default defineComponent({
|
|||
},
|
||||
async mounted() {
|
||||
await this.$store.dispatch('FETCH_SEARCH_PLUGINS')
|
||||
document.addEventListener('keydown', this.handleKeyboardShortcut)
|
||||
},
|
||||
async beforeDestroy() {
|
||||
await this.stopSearch()
|
||||
document.removeEventListener('keydown', this.handleKeyboardShortcut)
|
||||
},
|
||||
methods: {
|
||||
openPluginManager() {
|
||||
|
@ -174,10 +176,16 @@ export default defineComponent({
|
|||
downloadTorrent(item: SearchResult) {
|
||||
this.createModal('AddModal', { initialMagnet: item.fileUrl })
|
||||
},
|
||||
customFilter(value, search, item) {
|
||||
const searchArr = search.trim().toLowerCase().split(' ')
|
||||
|
||||
return value != null && search != null && typeof value === 'string' && searchArr.every(i => value.toString().toLowerCase().indexOf(i) !== -1)
|
||||
customFilter(value: any, search: string | null, item: any) {
|
||||
return value != null
|
||||
&& search != null
|
||||
&& typeof value === 'string'
|
||||
&& search.trim().toLowerCase().split(' ').every(i => value.toString().toLowerCase().indexOf(i) !== -1)
|
||||
},
|
||||
handleKeyboardShortcut(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape' && this.getModals().length === 0) {
|
||||
this.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
<v-row class="ma-0 pa-0">
|
||||
<v-tabs v-model="tab" align-with-title show-arrows background-color="primary">
|
||||
<v-tabs-slider color="white" />
|
||||
<v-tabs-slider color="white"/>
|
||||
<v-tab class="white--text" href="#overview">
|
||||
<h4>{{ $t('modals.detail.tabTitleOverview') }}</h4>
|
||||
</v-tab>
|
||||
|
@ -41,22 +41,23 @@
|
|||
<v-card-text class="pa-0">
|
||||
<v-tabs-items v-model="tab" touchless>
|
||||
<v-tab-item eager value="overview">
|
||||
<Overview v-if="torrent" :is-active="tab === 'overview'" :torrent="torrent" />
|
||||
<Overview v-if="torrent" :is-active="tab === 'overview'" :torrent="torrent"/>
|
||||
</v-tab-item>
|
||||
<v-tab-item eager value="info">
|
||||
<Info v-if="torrent" :is-active="tab === 'info'" :torrent="torrent" />
|
||||
<Info v-if="torrent" :is-active="tab === 'info'" :torrent="torrent"/>
|
||||
</v-tab-item>
|
||||
<v-tab-item eager value="trackers">
|
||||
<Trackers :is-active="tab === 'trackers'" :hash="hash" />
|
||||
<Trackers :is-active="tab === 'trackers'" :hash="hash"/>
|
||||
</v-tab-item>
|
||||
<v-tab-item eager value="peers">
|
||||
<DetailPeers :is-active="tab === 'peers'" :hash="hash" />
|
||||
<DetailPeers :is-active="tab === 'peers'" :hash="hash"/>
|
||||
</v-tab-item>
|
||||
<v-tab-item eager value="content">
|
||||
<Content :is-active="tab === 'content'" :hash="hash" />
|
||||
<Content :is-active="tab === 'content'" :hash="hash"/>
|
||||
</v-tab-item>
|
||||
<v-tab-item eager value="tagsAndCategories">
|
||||
<TorrentTagsAndCategories v-if="torrent" :torrent="torrent" :is-active="tab === 'tagsAndCategories'" :hash="hash" />
|
||||
<TorrentTagsAndCategories v-if="torrent" :torrent="torrent" :is-active="tab === 'tagsAndCategories'"
|
||||
:hash="hash"/>
|
||||
</v-tab-item>
|
||||
</v-tabs-items>
|
||||
</v-card-text>
|
||||
|
@ -65,14 +66,15 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { mapGetters } from 'vuex'
|
||||
import { Content, Info, DetailPeers, Trackers, TorrentTagsAndCategories } from '../components/TorrentDetail/Tabs'
|
||||
import { mdiClose } from '@mdi/js'
|
||||
import {defineComponent} from 'vue'
|
||||
import {mapGetters} from 'vuex'
|
||||
import {Content, DetailPeers, Info, TorrentTagsAndCategories, Trackers} from '../components/TorrentDetail/Tabs'
|
||||
import {mdiClose} from '@mdi/js'
|
||||
import Overview from "@/components/TorrentDetail/Tabs/Overview.vue";
|
||||
|
||||
export default {
|
||||
export default defineComponent({
|
||||
name: 'TorrentDetail',
|
||||
components: { Overview, Content, Info, DetailPeers, Trackers, TorrentTagsAndCategories },
|
||||
components: {Overview, Content, Info, DetailPeers, Trackers, TorrentTagsAndCategories},
|
||||
data() {
|
||||
return {
|
||||
tab: null,
|
||||
|
@ -80,9 +82,10 @@ export default {
|
|||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['getTorrent']),
|
||||
...mapGetters(['getTorrent', 'getModals']),
|
||||
torrent() {
|
||||
return this.getTorrent(this.hash)
|
||||
//@ts-expect-error: TS2339: Property 'getTorrent' does not exist on type 'CreateComponentPublicInstance...'
|
||||
return this.getTorrent(this.hash as string)
|
||||
},
|
||||
hash(): string {
|
||||
return this.$route.params.hash
|
||||
|
@ -101,10 +104,11 @@ export default {
|
|||
this.$router.back()
|
||||
},
|
||||
handleKeyboardShortcut(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape') {
|
||||
//@ts-expect-error: TS2339: Property 'getModals' does not exist on type 'CreateComponentPublicInstance...'
|
||||
if (e.key === 'Escape' && this.getModals().length === 0) {
|
||||
this.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
|
Loading…
Add table
Reference in a new issue