diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index e4cb413a..85b6a123 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -94,6 +94,21 @@ fn get_language(headers: &http::HeaderMap) -> String { } } +fn get_theme(headers: &http::HeaderMap) -> String { + let exists = |t: &str| { + Path::new(&format!( + "/usr/share/javascript/proxmox-widget-toolkit/themes/theme-{t}.css" + )) + .exists() + }; + + match cookie_from_header(headers, "PBSThemeCookie") { + Some(theme) if theme == "auto" => theme, + Some(theme) if theme != "__default__" && exists(&theme) => theme, + _ => String::from(""), + } +} + async fn get_index_future(env: RestEnvironment, parts: Parts) -> Response
{ let auth_id = env.get_auth_id(); let api = env.api_config(); @@ -133,11 +148,15 @@ async fn get_index_future(env: RestEnvironment, parts: Parts) -> Response } } + let theme = get_theme(&parts.headers); + let data = json!({ "NodeName": nodename, "UserName": user, "CSRFPreventionToken": csrf_token, "language": get_language(&parts.headers), + "theme": theme, + "auto": theme == "auto", "debug": debug, }); diff --git a/www/MainView.js b/www/MainView.js index d8f89979..0f09f676 100644 --- a/www/MainView.js +++ b/www/MainView.js @@ -247,6 +247,14 @@ Ext.define('PBS.MainView', { text: gettext('My Settings'), handler: () => Ext.create('PBS.window.Settings').show(), }, + { + iconCls: 'fa fa-paint-brush', + text: gettext('Theme'), + handler: () => Ext.create('Proxmox.window.ThemeEditWindow', { + cookieName: 'PBSThemeCookie', + autoShow: true, + }), + }, { iconCls: 'fa fa-language', text: gettext('Language'), diff --git a/www/index.hbs b/www/index.hbs index 1b8ea710..824268e3 100644 --- a/www/index.hbs +++ b/www/index.hbs @@ -12,6 +12,13 @@ + {{~#if theme}} + {{~#if auto}} + + {{~else}} + + {{~/if}} + {{~/if}} {{#if language}} {{else}}