Added option to update page title with stats.

This commit is contained in:
ArabCoders 2024-12-29 21:17:17 +03:00
parent 6b930bb388
commit 1f2db7ad5e
4 changed files with 14 additions and 1 deletions

View file

@ -91,6 +91,7 @@ Certain values can be set via environment variables, using the `-e` parameter on
* __YTP_EXTRACT_INFO_TIMEOUT__: The timeout for extracting video information. Defaults to `70`. * __YTP_EXTRACT_INFO_TIMEOUT__: The timeout for extracting video information. Defaults to `70`.
* __YTP_DB_FILE__: The path to the SQLite database file. Defaults to `{config_path}/ytptube.db`. * __YTP_DB_FILE__: The path to the SQLite database file. Defaults to `{config_path}/ytptube.db`.
* __YTP_MANUAL_ARCHIVE__: The path to the manual archive file. Defaults to `{config_path}/manual_archive.log`. * __YTP_MANUAL_ARCHIVE__: The path to the manual archive file. Defaults to `{config_path}/manual_archive.log`.
* __YTP_UI_UPDATE_TITLE__: Whether to update the title of the page with the current stats. Defaults to `true`.
## Running behind a reverse proxy ## Running behind a reverse proxy

View file

@ -55,6 +55,7 @@ class Config:
db_file: str = "{config_path}/ytptube.db" db_file: str = "{config_path}/ytptube.db"
manual_archive: str = "{config_path}/archive.manual.log" manual_archive: str = "{config_path}/archive.manual.log"
ui_update_title: bool = True
# immutable config vars. # immutable config vars.
version: str = APP_VERSION version: str = APP_VERSION
@ -144,6 +145,7 @@ class Config:
"access_log", "access_log",
"remove_files", "remove_files",
"ignore_ui", "ignore_ui",
"ui_update_title",
) )
_frontend_vars: tuple = ( _frontend_vars: tuple = (
@ -156,6 +158,7 @@ class Config:
"started", "started",
"url_prefix", "url_prefix",
"remove_files", "remove_files",
"ui_update_title",
) )
@staticmethod @staticmethod

View file

@ -31,7 +31,7 @@
</div> </div>
<div class="navbar-item" v-if="config.tasks.length > 0"> <div class="navbar-item" v-if="config.tasks.length > 0">
<NuxtLink class="button is-dark has-tooltip-bottom" to="/tasks"> <NuxtLink class="button is-dark has-tooltip-bottom" to="/tasks">
<span class="icon"><i class="fa-solid fa-tasks" /></span> <span class="icon"><i class="fa-solid fa-tasks" /></span>
<span class="is-hidden-mobile">Tasks</span> <span class="is-hidden-mobile">Tasks</span>
</NuxtLink> </NuxtLink>
@ -135,6 +135,14 @@ const applyPreferredColorScheme = scheme => {
onMounted(async () => { onMounted(async () => {
try { try {
if (config.app.ui_update_title) {
const s = useStateStore()
useHead({ title: `YTPTube: ( ${Object.keys(s.queue).length || 0} | ${Object.keys(s.history).length || 0} )` })
watch([s.queue, s.history], () => {
const title = `YTPTube: ( ${Object.keys(s.queue.length) || 0} | ${Object.keys(s.history.length) || 0} )`
useHead({ title })
})
}
applyPreferredColorScheme(selectedTheme.value) applyPreferredColorScheme(selectedTheme.value)
} catch (e) { } catch (e) {
} }

View file

@ -4,6 +4,7 @@ const CONFIG_KEYS = {
download_path: '/downloads', download_path: '/downloads',
keep_archive: false, keep_archive: false,
remove_files: false, remove_files: false,
ui_update_title: true,
output_template: '', output_template: '',
ytdlp_version: '', ytdlp_version: '',
version: '', version: '',