From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 311869628 for ; Wed, 8 Mar 2023 17:42:16 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0E9E5989B for ; Wed, 8 Mar 2023 17:41:46 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 8 Mar 2023 17:41:45 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 12648462F8 for ; Wed, 8 Mar 2023 17:41:45 +0100 (CET) From: Stefan Sterz To: pbs-devel@lists.proxmox.com Date: Wed, 8 Mar 2023 17:41:39 +0100 Message-Id: <20230308164141.2468914-1-s.sterz@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230308161840.2396113-1-s.sterz@proxmox.com> References: <20230308161840.2396113-1-s.sterz@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.093 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox-backup-proxy.rs] Subject: [pbs-devel] [PATCH proxmox-backup v1 1/3] proxy/ui: implement theme switcher X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Mar 2023 16:42:16 -0000 adds a theme switcher to the ui and handles the necessary cookies in the backend. this requires a bump of the widget toolkit so the necessary widgets are present. Signed-off-by: Stefan Sterz --- src/bin/proxmox-backup-proxy.rs | 19 +++++++++++++++++++ www/MainView.js | 8 ++++++++ www/index.hbs | 7 +++++++ 3 files changed, 34 insertions(+) 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}} -- 2.30.2