[pve-devel] [PATCH manager v2 01/22] add proxmox-widget-toolkit to pve gui

Dominik Csapak d.csapak at proxmox.com
Mon Jan 15 15:17:49 CET 2018


we will use components from proxmox-widget-toolkit rather than
directly from pve-manager

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/Service/pveproxy.pm  | 11 +++++++++++
 debian/control           |  1 +
 www/index.html.tpl       |  8 ++++++++
 www/touch/index.html.tpl | 12 ++++++++++--
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/PVE/Service/pveproxy.pm b/PVE/Service/pveproxy.pm
index ec1eb9a5..628e734a 100755
--- a/PVE/Service/pveproxy.pm
+++ b/PVE/Service/pveproxy.pm
@@ -52,6 +52,7 @@ my $basedirs = {
     docs => '/usr/share/pve-docs',
     fontawesome => '/usr/share/fonts-font-awesome',
     xtermjs => '/usr/share/pve-xtermjs',
+    widgettoolkit => '/usr/share/javascript/proxmox-widget-toolkit',
 };
 
 sub init {
@@ -113,6 +114,9 @@ sub init {
 	    '/favicon.ico' => {
 		file => "$basedirs->{manager}/images/favicon.ico",
 	    },
+	    '/proxmoxlib.js' => {
+		file => "$basedirs->{widgettoolkit}/proxmoxlib.js",
+	    },
 	},
 	dirs => $dirs,
     };
@@ -209,6 +213,12 @@ sub get_index {
     my $ver = PVE::pvecfg::version();
     my $release = PVE::pvecfg::release();
 
+    my $wtversionraw = PVE::Tools::file_read_firstline("$basedirs->{widgettoolkit}/proxmoxlib.js");
+    my $wtversion;
+    if ($wtversionraw =~ m|^// (.*)$|) {
+	$wtversion = $1;
+    };
+
     my $vars = {
 	lang => $lang,
 	langfile => $langfile,
@@ -218,6 +228,7 @@ sub get_index {
 	nodename => $nodename,
 	debug => $server->{debug},
 	version => "$ver-$release",
+	wtversion => $wtversion,
     };
 
     # by default, load the normal index
diff --git a/debian/control b/debian/control
index c7d5a717..c5469c50 100644
--- a/debian/control
+++ b/debian/control
@@ -55,6 +55,7 @@ Depends: apt-transport-https,
          novnc-pve,
          perl (>= 5.10.0-19),
          postfix | mail-transport-agent,
+         proxmox-widget-toolkit (>= 1.0-8),
          pve-cluster (>= 5.0-17),
          pve-container,
          pve-docs,
diff --git a/www/index.html.tpl b/www/index.html.tpl
index 6bbdea18..147d3492 100644
--- a/www/index.html.tpl
+++ b/www/index.html.tpl
@@ -23,6 +23,14 @@
     <script type="text/javascript" src="/pve2/ext6/ext-all.js"></script>
     <script type="text/javascript" src="/pve2/ext6/charts.js"></script>
     [% END %]
+    <script type="text/javascript">
+    Proxmox = {
+	Setup: { auth_cookie_name: 'PVEAuthCookie' },
+	UserName: '[% username %]',
+	CSRFPreventionToken: '[% token %]'
+    };
+    </script>
+    <script type="text/javascript" src="/proxmoxlib.js?ver=[% wtversion %]"></script>
     <script type="text/javascript" src="/pve2/js/pvemanagerlib.js?ver=[% version %]"></script>
     <script type="text/javascript" src="/pve2/ext6/locale/locale-[% lang %].js"></script>
 
diff --git a/www/touch/index.html.tpl b/www/touch/index.html.tpl
index 931c6845..f5787b6d 100644
--- a/www/touch/index.html.tpl
+++ b/www/touch/index.html.tpl
@@ -7,14 +7,22 @@
     <link rel="icon" sizes="128x128" href="/pve2/images/logo-128.png" />
     <link rel="apple-touch-icon" sizes="128x128" href="/pve2/images/logo-128.png" />
     <link rel="stylesheet" type="text/css" href="/pve2/touch/resources/css/sencha-touch.css" />
-    <link rel="stylesheet" type="text/css" href="/pve2/touch/resources/css/pve.css" />
+    <link rel="stylesheet" type="text/css" href="/pve2/touch/resources/css/pve.css?ver=[% version %]" />
     [% IF langfile %]
     <script type='text/javascript' src='/pve2/locale/pve-lang-[% lang %].js'></script>
     [% ELSE %]
     <script type="text/javascript">function gettext(buf) { return buf; }</script>
     [% END %]
+    <script type="text/javascript">
+    Proxmox = {
+	Setup: { auth_cookie_name: 'PVEAuthCookie' },
+	UserName: '[ % username %]',
+	CSRFPreventionToken: '[% token %]'
+    };
+    </script>
     <script type="text/javascript" src="/pve2/touch/sencha-touch-all-debug.js"></script>
-    <script type="text/javascript" src="/pve2/touch/pvemanager-mobile.js"></script>
+    <script type="text/javascript" src="/proxmoxlib.js?ver=[% wtversion %]"></script>
+    <script type="text/javascript" src="/pve2/touch/pvemanager-mobile.js?ver=[% version %]"></script>
     <script type="text/javascript">
 if (typeof(PVE) === 'undefined') PVE = {};
 PVE.UserName = '[% username %]'
-- 
2.11.0





More information about the pve-devel mailing list