perf: Add qbit refresh interval setting (#923)

This commit is contained in:
Rémi Marseault 2023-07-03 07:12:05 +02:00 committed by GitHub
parent 31ad072c7f
commit d2cae697b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 42 additions and 21 deletions

View file

@ -44,6 +44,16 @@
<v-checkbox v-model="settings.showShutdownButton" hide-details class="ma-0 pa-0" :label="$t('modals.settings.vueTorrent.general.showShutdownButton')" /> <v-checkbox v-model="settings.showShutdownButton" hide-details class="ma-0 pa-0" :label="$t('modals.settings.vueTorrent.general.showShutdownButton')" />
</v-list-item> </v-list-item>
<v-list-item class="mb-3">
<v-text-field
v-model="settings.refreshInterval"
type="number"
dense
outlined
:hint="$t('modals.settings.vueTorrent.general.refreshIntervalHint')"
:label="$t('modals.settings.vueTorrent.general.refreshInterval')" />
</v-list-item>
<v-list-item class="mb-3"> <v-list-item class="mb-3">
<v-row> <v-row>
<v-col cols="12" sm="6" md="3"> <v-col cols="12" sm="6" md="3">
@ -86,7 +96,9 @@
</v-col> </v-col>
<v-col cols="6" md="2" class="d-flex align-center justify-start"> <v-col cols="6" md="2" class="d-flex align-center justify-start">
<h3> <h3>
<a target="_blank" :href="`https://github.com/WDaan/VueTorrent/releases/tag/v${version}`">{{ version }}</a> <span v-if="!version">undefined</span>
<a v-else-if="version.endsWith('-dev')" target="_blank" href="https://github.com/WDaan/VueTorrent/">{{ version }}</a>
<a v-else target="_blank" :href="`https://github.com/WDaan/VueTorrent/releases/tag/v${version}`">{{ version }}</a>
</h3> </h3>
</v-col> </v-col>

View file

@ -161,8 +161,7 @@ export function getVersion() {
return 'import.meta.env.VITE_PACKAGE_VERSION' return 'import.meta.env.VITE_PACKAGE_VERSION'
} }
// return import.meta.env['VITE_PACKAGE_VERSION'] return `${import.meta.env['VITE_PACKAGE_VERSION']}-dev`
return 'undefined'
} }
export function getBaseURL() { export function getBaseURL() {

View file

@ -269,6 +269,8 @@
"dateFormat": "Date Format", "dateFormat": "Date Format",
"openSideBarOnStart": "Open Side Bar on launch", "openSideBarOnStart": "Open Side Bar on launch",
"showShutdownButton": "Show shutdown button", "showShutdownButton": "Show shutdown button",
"refreshInterval": "qBittorrent API refresh interval",
"refreshIntervalHint": "In milliseconds",
"currentVersion": "Current Version", "currentVersion": "Current Version",
"qbittorrentVersion": "QBittorrent Version", "qbittorrentVersion": "QBittorrent Version",
"registerMagnet": "Register magnet links", "registerMagnet": "Register magnet links",

View file

@ -42,6 +42,7 @@ export const StoreStateSchema: JSONSchemaType<PersistentStoreState> = {
dateFormat: { type: 'string' }, dateFormat: { type: 'string' },
openSideBarOnStart: { type: 'boolean' }, openSideBarOnStart: { type: 'boolean' },
showShutdownButton: { type: 'boolean' }, showShutdownButton: { type: 'boolean' },
refreshInterval: { type: 'number' },
busyDesktopTorrentProperties: { $ref: '/schemas/desktopDashboardProperties' }, busyDesktopTorrentProperties: { $ref: '/schemas/desktopDashboardProperties' },
doneDesktopTorrentProperties: { $ref: '/schemas/desktopDashboardProperties' }, doneDesktopTorrentProperties: { $ref: '/schemas/desktopDashboardProperties' },
busyMobileCardProperties: { $ref: '/schemas/mobileDashboardProperties' }, busyMobileCardProperties: { $ref: '/schemas/mobileDashboardProperties' },
@ -65,6 +66,7 @@ export const StoreStateSchema: JSONSchemaType<PersistentStoreState> = {
'dateFormat', 'dateFormat',
'openSideBarOnStart', 'openSideBarOnStart',
'showShutdownButton', 'showShutdownButton',
'refreshInterval',
'busyDesktopTorrentProperties', 'busyDesktopTorrentProperties',
'doneDesktopTorrentProperties', 'doneDesktopTorrentProperties',
'busyMobileCardProperties', 'busyMobileCardProperties',

View file

@ -9,7 +9,7 @@ export default {
INIT_INTERVALS: async (store: Store<StoreState>) => { INIT_INTERVALS: async (store: Store<StoreState>) => {
store.state.intervals[0] = setInterval(() => { store.state.intervals[0] = setInterval(() => {
store.commit('updateMainData') store.commit('updateMainData')
}, 2000) }, store.state.webuiSettings.refreshInterval)
}, },
LOGIN: async (store: Store<StoreState>, payload: LoginPayload) => { LOGIN: async (store: Store<StoreState>, payload: LoginPayload) => {
const res = await qbit.login(payload) const res = await qbit.login(payload)

View file

@ -81,7 +81,6 @@ export default new Vuex.Store<StoreState>({
plugins: [vuexPersist.plugin], plugins: [vuexPersist.plugin],
state: { state: {
authenticated: false, authenticated: false,
oldSettingsDetected: false,
categories: [], categories: [],
dashboard: { dashboard: {
currentPage: 1, currentPage: 1,
@ -93,6 +92,7 @@ export default new Vuex.Store<StoreState>({
isUpdatingMainData: false, isUpdatingMainData: false,
latestSelectedTorrent: -1, latestSelectedTorrent: -1,
modals: [], modals: [],
oldSettingsDetected: false,
rid: 0, rid: 0,
rss: { rss: {
feeds: [], feeds: [],
@ -135,6 +135,7 @@ export default new Vuex.Store<StoreState>({
dateFormat: 'DD/MM/YYYY, HH:mm:ss', dateFormat: 'DD/MM/YYYY, HH:mm:ss',
openSideBarOnStart: true, openSideBarOnStart: true,
showShutdownButton: true, showShutdownButton: true,
refreshInterval: 2000,
busyDesktopTorrentProperties: JSON.parse(JSON.stringify(desktopPropertiesTemplate)), busyDesktopTorrentProperties: JSON.parse(JSON.stringify(desktopPropertiesTemplate)),
doneDesktopTorrentProperties: JSON.parse(JSON.stringify(desktopPropertiesTemplate)), doneDesktopTorrentProperties: JSON.parse(JSON.stringify(desktopPropertiesTemplate)),
busyMobileCardProperties: JSON.parse(JSON.stringify(mobilePropertiesTemplate)), busyMobileCardProperties: JSON.parse(JSON.stringify(mobilePropertiesTemplate)),

View file

@ -28,6 +28,7 @@ export default interface WebUISettings {
dateFormat: string dateFormat: string
openSideBarOnStart: boolean openSideBarOnStart: boolean
showShutdownButton: boolean showShutdownButton: boolean
refreshInterval: number
busyDesktopTorrentProperties: TorrentProperty[] busyDesktopTorrentProperties: TorrentProperty[]
doneDesktopTorrentProperties: TorrentProperty[] doneDesktopTorrentProperties: TorrentProperty[]
busyMobileCardProperties: TorrentProperty[] busyMobileCardProperties: TorrentProperty[]

View file

@ -16,19 +16,19 @@ export function generateMultiple(count: number = 1): Torrent[] {
export function generateTorrent(data: any): Torrent { export function generateTorrent(data: any): Torrent {
return new Torrent({ return new Torrent({
name: data.name, name: data.name,
hash: faker.datatype.uuid(), hash: faker.string.uuid(),
size: faker.datatype.number({ min: 1000000, max: 50000000000 }), size: faker.number.int({ min: 1000000, max: 50000000000 }),
tags: [], tags: [],
progress: faker.datatype.number({ min: 0, max: 1, precision: 0.01 }), progress: faker.number.int({ min: 0, max: 1, precision: 0.01 }),
state: faker.helpers.arrayElement(['done', 'downloading', 'fail', 'paused', 'queued', 'seeding', 'checking', 'stalled', 'metadata', 'moving']), state: faker.helpers.arrayElement(['done', 'downloading', 'fail', 'paused', 'queued', 'seeding', 'checking', 'stalled', 'metadata', 'moving']),
eta: faker.datatype.number({ min: 1000, max: 900000 }), eta: faker.number.int({ min: 1000, max: 900000 }),
availability: faker.datatype.number({ min: 0, max: 1, precision: 0.01 }), availability: faker.number.int({ min: 0, max: 1, precision: 0.01 }),
added_on: faker.date.recent(), added_on: faker.date.recent(),
ratio: faker.datatype.number({ min: 0, max: 1, precision: 0.01 }), ratio: faker.number.int({ min: 0, max: 1, precision: 0.01 }),
num_leechs: faker.datatype.number({ min: 1, max: 20 }), num_leechs: faker.number.int({ min: 1, max: 20 }),
num_complete: faker.datatype.number({ min: 1, max: 500 }), num_complete: faker.number.int({ min: 1, max: 500 }),
num_seeds: faker.datatype.number({ min: 1, max: 25 }), num_seeds: faker.number.int({ min: 1, max: 25 }),
num_incomplete: faker.datatype.number({ min: 1, max: 500 }), num_incomplete: faker.number.int({ min: 1, max: 500 }),
save_path: faker.system.filePath(), save_path: faker.system.filePath(),
category: faker.helpers.arrayElement(['ISO', 'Other', 'Movie', 'Music', 'TV']) category: faker.helpers.arrayElement(['ISO', 'Other', 'Movie', 'Music', 'TV'])
}) })

View file

@ -330,6 +330,11 @@ export default {
} }
} }
}, },
created() {
this.$store.commit('FETCH_CATEGORIES')
this.$store.commit('FETCH_TAGS')
if (this.input) this.searchFilterEnabled = true
},
mounted() { mounted() {
this.$store.dispatch('INIT_INTERVALS') this.$store.dispatch('INIT_INTERVALS')
document.addEventListener('keydown', this.handleKeyboardShortcut) document.addEventListener('keydown', this.handleKeyboardShortcut)
@ -342,11 +347,6 @@ export default {
this.$store.dispatch('ALERT_OLD_SETTINGS') this.$store.dispatch('ALERT_OLD_SETTINGS')
} }
}, },
created() {
this.$store.commit('FETCH_CATEGORIES')
this.$store.commit('FETCH_TAGS')
if (this.input) this.searchFilterEnabled = true
},
beforeDestroy() { beforeDestroy() {
this.$store.commit('REMOVE_INTERVALS') this.$store.commit('REMOVE_INTERVALS')
document.removeEventListener('keydown', this.handleKeyboardShortcut) document.removeEventListener('keydown', this.handleKeyboardShortcut)

View file

@ -20,6 +20,7 @@ describe('General', () => {
$store: { $store: {
getters: { getAppVersion: vi.fn() }, getters: { getAppVersion: vi.fn() },
state: { state: {
version: 'test',
webuiSettings: { webuiSettings: {
showCurrentSpeed: 100, showCurrentSpeed: 100,
showSpeedGraph: true, showSpeedGraph: true,

View file

@ -33,6 +33,9 @@ exports[`General > render correctly 1`] = `
<v-list-item-stub data-v-7da6d3e2=\\"\\" activeclass=\\"\\" tag=\\"div\\" class=\\"mb-3\\"> <v-list-item-stub data-v-7da6d3e2=\\"\\" activeclass=\\"\\" tag=\\"div\\" class=\\"mb-3\\">
<v-checkbox-stub data-v-7da6d3e2=\\"\\" errorcount=\\"1\\" errormessages=\\"\\" messages=\\"\\" rules=\\"\\" successmessages=\\"\\" backgroundcolor=\\"\\" hidedetails=\\"true\\" ripple=\\"true\\" valuecomparator=\\"[Function]\\" indeterminateicon=\\"$checkboxIndeterminate\\" officon=\\"$checkboxOff\\" onicon=\\"$checkboxOn\\" class=\\"ma-0 pa-0\\"></v-checkbox-stub> <v-checkbox-stub data-v-7da6d3e2=\\"\\" errorcount=\\"1\\" errormessages=\\"\\" messages=\\"\\" rules=\\"\\" successmessages=\\"\\" backgroundcolor=\\"\\" hidedetails=\\"true\\" ripple=\\"true\\" valuecomparator=\\"[Function]\\" indeterminateicon=\\"$checkboxIndeterminate\\" officon=\\"$checkboxOff\\" onicon=\\"$checkboxOn\\" class=\\"ma-0 pa-0\\"></v-checkbox-stub>
</v-list-item-stub> </v-list-item-stub>
<v-list-item-stub data-v-7da6d3e2=\\"\\" activeclass=\\"\\" tag=\\"div\\" class=\\"mb-3\\">
<v-text-field-stub data-v-7da6d3e2=\\"\\" errorcount=\\"1\\" errormessages=\\"\\" messages=\\"\\" rules=\\"\\" successmessages=\\"\\" backgroundcolor=\\"\\" dense=\\"true\\" loaderheight=\\"2\\" clearicon=\\"$clear\\" outlined=\\"true\\" type=\\"number\\"></v-text-field-stub>
</v-list-item-stub>
<v-list-item-stub data-v-7da6d3e2=\\"\\" activeclass=\\"\\" tag=\\"div\\" class=\\"mb-3\\"> <v-list-item-stub data-v-7da6d3e2=\\"\\" activeclass=\\"\\" tag=\\"div\\" class=\\"mb-3\\">
<v-row-stub data-v-7da6d3e2=\\"\\" tag=\\"div\\"> <v-row-stub data-v-7da6d3e2=\\"\\" tag=\\"div\\">
<v-col-stub data-v-7da6d3e2=\\"\\" cols=\\"12\\" sm=\\"6\\" md=\\"3\\" tag=\\"div\\"> <v-col-stub data-v-7da6d3e2=\\"\\" cols=\\"12\\" sm=\\"6\\" md=\\"3\\" tag=\\"div\\">
@ -55,7 +58,7 @@ exports[`General > render correctly 1`] = `
<h3 data-v-7da6d3e2=\\"\\"></h3> <h3 data-v-7da6d3e2=\\"\\"></h3>
</v-col-stub> </v-col-stub>
<v-col-stub data-v-7da6d3e2=\\"\\" cols=\\"6\\" md=\\"2\\" tag=\\"div\\" class=\\"d-flex align-center justify-start\\"> <v-col-stub data-v-7da6d3e2=\\"\\" cols=\\"6\\" md=\\"2\\" tag=\\"div\\" class=\\"d-flex align-center justify-start\\">
<h3 data-v-7da6d3e2=\\"\\"><a data-v-7da6d3e2=\\"\\" target=\\"_blank\\" href=\\"https://github.com/WDaan/VueTorrent/releases/tag/vundefined\\"></a></h3> <h3 data-v-7da6d3e2=\\"\\"><span data-v-7da6d3e2=\\"\\">undefined</span></h3>
</v-col-stub> </v-col-stub>
<v-col-stub data-v-7da6d3e2=\\"\\" cols=\\"6\\" md=\\"2\\" tag=\\"div\\" class=\\"d-flex align-center justify-end\\"> <v-col-stub data-v-7da6d3e2=\\"\\" cols=\\"6\\" md=\\"2\\" tag=\\"div\\" class=\\"d-flex align-center justify-end\\">
<h3 data-v-7da6d3e2=\\"\\"></h3> <h3 data-v-7da6d3e2=\\"\\"></h3>