Add ConsentBanner variable to html template and populate it from the `datacenter.cfg` config file. Add Datacenter option to set the text and trigger the popup on login.
Signed-off-by: Gabriel Goller <g.gol...@proxmox.com> --- PVE/Service/pveproxy.pm | 4 +++- www/index.html.tpl | 3 ++- www/manager6/dc/OptionView.js | 5 +++++ www/manager6/window/LoginWindow.js | 13 ++++++++++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/PVE/Service/pveproxy.pm b/PVE/Service/pveproxy.pm index ac1085457f2e..151ba34f8a52 100755 --- a/PVE/Service/pveproxy.pm +++ b/PVE/Service/pveproxy.pm @@ -217,9 +217,10 @@ sub get_index { $token = PVE::AccessControl::assemble_csrf_prevention_token($username); } } + my $dc_conf = PVE::Cluster::cfs_read_file('datacenter.cfg'); + my $consent_text = $dc_conf->{'consent-text'}; if (!$lang) { - my $dc_conf = PVE::Cluster::cfs_read_file('datacenter.cfg'); $lang = $dc_conf->{language} // 'en'; } @@ -251,6 +252,7 @@ sub get_index { version => "$version", wtversion => $wtversion, theme => $theme, + consenttext => $consent_text }; # by default, load the normal index diff --git a/www/index.html.tpl b/www/index.html.tpl index 46dc877bcaf2..d53a867522dd 100644 --- a/www/index.html.tpl +++ b/www/index.html.tpl @@ -41,7 +41,8 @@ defaultLang: '[% lang %]', NodeName: '[% nodename %]', UserName: '[% username %]', - CSRFPreventionToken: '[% token %]' + CSRFPreventionToken: '[% token %]', + ConsentText: '[% consenttext %]' }; </script> <script type="text/javascript" src="/proxmoxlib.js?ver=[% wtversion %]"></script> diff --git a/www/manager6/dc/OptionView.js b/www/manager6/dc/OptionView.js index b200fd12dcc9..13336f1f6022 100644 --- a/www/manager6/dc/OptionView.js +++ b/www/manager6/dc/OptionView.js @@ -516,6 +516,11 @@ Ext.define('PVE.dc.OptionView', { }, }; + me.add_textareafield_row('consent-text', gettext('Consent Text'), { + deleteEmpty: true, + onlineHelp: 'consent_banner', + }); + me.selModel = Ext.create('Ext.selection.RowModel', {}); Ext.apply(me, { diff --git a/www/manager6/window/LoginWindow.js b/www/manager6/window/LoginWindow.js index aaeca3550289..bcf9b7be364d 100644 --- a/www/manager6/window/LoginWindow.js +++ b/www/manager6/window/LoginWindow.js @@ -18,9 +18,20 @@ Ext.define('PVE.window.LoginWindow', { }, controller: { - xclass: 'Ext.app.ViewController', + init: async function() { + if (Proxmox.ConsentText) { + Ext.create("Proxmox.window.ConsentModal", { + autoShow: true, + consent: Proxmox.Markdown.parse( + Ext.htmlEncode( + Proxmox.Utils.base64ToUtf8( + Proxmox.ConsentText))), + }); + } + }, + onLogon: async function() { var me = this; -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel