switch GUI to extjs6

This commit is contained in:
Dietmar Maurer 2016-03-31 11:42:29 +02:00
parent 49f53f2e9b
commit 8a5caad8af
8 changed files with 238 additions and 347 deletions

View File

@ -11,11 +11,11 @@ sub get_index {
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=10">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>$nodename - Proxmox Virtual Environment</title>
<link rel="stylesheet" type="text/css" href="/pve2/ext4/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="/pve2/css/ext-pve.css" />
<link rel="stylesheet" type="text/css" href="/pve2/ext6/theme-crisp/resources/theme-crisp-all.css" />
<link rel="stylesheet" type="text/css" href="/pve2/ext6/crisp/resources/charts-all.css" />
<link rel="stylesheet" type="text/css" href="/pve2/css/ext6-pve.css" />
_EOD
my $langfile = "/usr/share/pve-manager/locale/pve-lang-${lang}.js";
@ -26,9 +26,10 @@ _EOD
}
$page .= <<_EOD;
<script type="text/javascript" src="/pve2/ext4/ext-all-debug.js"></script>
<script type="text/javascript" src="/pve2/ext4/pvemanagerlib.js"></script>
<script type="text/javascript" src="/pve2/ext4/locale/ext-lang-${lang}.js"></script>
<script type="text/javascript" src="/pve2/ext6/ext-all-debug.js"></script>
<script type="text/javascript" src="/pve2/ext6/charts-debug.js"></script>
<script type="text/javascript" src="/pve2/ext6/pvemanagerlib.js"></script>
<script type="text/javascript" src="/pve2/ext6/locale/ext-lang-${lang}.js"></script>
_EOD
my $jssrc = <<_EOJS;

View File

@ -1,293 +0,0 @@
# this package will only be run in developpement mode, when extjs6=1 added
# as extra parameter
package PVE::ExtJSIndex6;
use strict;
use warnings;
sub get_index {
my ($lang, $username, $csrftoken, $console, $nodename) = @_;
my $manager_source_dir = '/usr/share/pve-manager/manager6/';
# # exit early to avoid this being run by mistake
if ( ! -d $manager_source_dir) {
return "$manager_source_dir not found";
}
my $page = <<_EOD;
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>$nodename - Proxmox Virtual Environment</title>
<link rel="stylesheet" type="text/css" href="/pve2/ext6/theme-crisp/resources/theme-crisp-all.css" />
<link rel="stylesheet" type="text/css" href="/pve2/ext6/crisp/resources/charts-all.css" />
<link rel="stylesheet" type="text/css" href="/pve2/css/ext-pve.css" />
<link rel="stylesheet" type="text/css" href="/pve2/css/ext6-pve.css" />
<script type="text/javascript" src="/pve2/ext6/ext-all-debug.js"></script>
<script type="text/javascript" src="/pve2/ext6/charts-debug.js"></script>
_EOD
my $langfile = "/usr/share/pve-manager/locale/pve-lang-${lang}.js";
if (-f $langfile) {
$page .= "<script type='text/javascript' src='/pve2/locale/pve-lang-${lang}.js'></script>";
} else {
$page .= '<script type="text/javascript">function gettext(buf) { return buf; }</script>';
}
# NB: ordering matters
my $js_files = <<_EOD;
Utils.js
Toolkit.js
Parser.js
StateProvider.js
button/Button.js
button/ConsoleButton.js
qemu/SendKeyMenu.js
qemu/CmdMenu.js
qemu/TemplateMenu.js
lxc/CmdMenu.js
VNCConsole.js
data/TimezoneStore.js
data/reader/JsonObject.js
data/PVEProxy.js
data/UpdateQueue.js
data/UpdateStore.js
data/DiffStore.js
data/ObjectStore.js
data/ResourceStore.js
data/RRDStore.js
form/VLanField.js
form/Checkbox.js
form/TextField.js
form/RRDTypeSelector.js
form/ComboGrid.js
form/KVComboBox.js
form/Boolean.js
form/CompressionSelector.js
form/PoolSelector.js
form/GroupSelector.js
form/UserSelector.js
form/RoleSelector.js
form/VMIDSelector.js
form/MemoryField.js
form/NetworkCardSelector.js
form/DiskFormatSelector.js
form/BusTypeSelector.js
form/ControllerSelector.js
form/EmailNotificationSelector.js
form/RealmComboBox.js
form/BondModeSelector.js
form/ViewSelector.js
form/NodeSelector.js
form/FileSelector.js
form/StorageSelector.js
form/BridgeSelector.js
form/SecurityGroupSelector.js
form/IPRefSelector.js
form/IPProtocolSelector.js
form/CPUModelSelector.js
form/VNCKeyboardSelector.js
form/LanguageSelector.js
form/DisplaySelector.js
form/CacheTypeSelector.js
form/SnapshotSelector.js
form/ContentTypeSelector.js
form/HotplugFeatureSelector.js
form/iScsiProviderSelector.js
form/DayOfWeekSelector.js
form/BackupModeSelector.js
form/ScsiHwSelector.js
form/FirewallPolicySelector.js
form/QemuBiosSelector.js
dc/Tasks.js
dc/Log.js
panel/StatusPanel.js
panel/RRDView.js
panel/RRDChart.js
panel/InputPanel.js
window/Edit.js
window/LoginWindow.js
window/TaskViewer.js
window/Wizard.js
window/NotesEdit.js
window/Backup.js
window/Restore.js
window/SafeDestroy.js
panel/NotesView.js
grid/CheckColumn.js
grid/SelectFeature.js
grid/ObjectGrid.js
grid/PendingObjectGrid.js
grid/ResourceGrid.js
grid/PoolMembers.js
grid/FirewallRules.js
grid/FirewallAliases.js
grid/FirewallOptions.js
tree/ResourceTree.js
panel/IPSet.js
panel/ConfigPanel.js
panel/SubConfigPanel.js
grid/BackupView.js
panel/LogView.js
panel/Firewall.js
ceph/Pool.js
ceph/OSD.js
ceph/Disks.js
ceph/Monitor.js
ceph/Crush.js
ceph/Status.js
ceph/Config.js
node/DNSEdit.js
node/DNSView.js
node/TimeView.js
node/TimeEdit.js
node/StatusView.js
node/Summary.js
node/ServiceView.js
node/NetworkEdit.js
node/NetworkView.js
node/Tasks.js
node/Subscription.js
node/APT.js
node/Config.js
qemu/StatusView.js
window/Migrate.js
window/MigrateAll.js
qemu/Monitor.js
qemu/Summary.js
qemu/OSTypeEdit.js
qemu/ProcessorEdit.js
qemu/BootOrderEdit.js
qemu/MemoryEdit.js
qemu/NetworkEdit.js
qemu/Smbios1Edit.js
qemu/CDEdit.js
qemu/HDEdit.js
qemu/HDResize.js
qemu/HDMove.js
qemu/HDThrottle.js
qemu/CPUOptions.js
qemu/DisplayEdit.js
qemu/KeyboardEdit.js
qemu/HardwareView.js
qemu/StartupEdit.js
qemu/ScsiHwEdit.js
qemu/QemuBiosEdit.js
qemu/Options.js
qemu/Snapshot.js
qemu/Clone.js
qemu/SnapshotTree.js
qemu/Config.js
qemu/CreateWizard.js
lxc/StatusView.js
lxc/Summary.js
lxc/Network.js
lxc/Resources.js
lxc/Options.js
lxc/DNS.js
lxc/Config.js
lxc/CreateWizard.js
lxc/SnapshotTree.js
lxc/Snapshot.js
lxc/ResourceEdit.js
lxc/MPResize.js
pool/StatusView.js
pool/Summary.js
pool/Config.js
storage/ContentView.js
storage/StatusView.js
storage/Summary.js
storage/Browser.js
storage/DirEdit.js
storage/NFSEdit.js
storage/GlusterFsEdit.js
storage/IScsiEdit.js
storage/LVMEdit.js
storage/LvmThinEdit.js
storage/RBDEdit.js
storage/SheepdogEdit.js
storage/ZFSEdit.js
storage/ZFSPoolEdit.js
ha/StatusView.js
ha/GroupSelector.js
ha/ResourceEdit.js
ha/Resources.js
ha/GroupEdit.js
ha/Groups.js
ha/Fencing.js
ha/Config.js
dc/Summary.js
dc/OptionView.js
dc/StorageView.js
dc/UserEdit.js
dc/UserView.js
dc/PoolView.js
dc/PoolEdit.js
dc/GroupView.js
dc/GroupEdit.js
dc/RoleView.js
dc/ACLView.js
dc/AuthView.js
dc/AuthEdit.js
dc/Backup.js
dc/Support.js
dc/SecurityGroups.js
dc/Config.js
Workspace.js
_EOD
my @files_array = split('\n', $js_files);
my $prefix = '<script type="text/javascript" src="/pve2/manager6/';
my $postifx = '"></script>';
my $include_file = '';
foreach my $file (@files_array) {
if (-e $manager_source_dir . '/' . $file) {
# will build <script type="text/javascript" src="/pve2/manager6/Workspace.js"></script>
my $include_line = join('', " ", $prefix, $file, $postifx);
$include_file = join("\n", $include_file ,$include_line);
}
}
$page .= $include_file . "\n";
my $jssrc = <<_EOJS;
if (typeof(PVE) === 'undefined') PVE = {};
PVE.UserName = '$username'
PVE.CSRFPreventionToken = '$csrftoken';
_EOJS
my $workspace = defined($console) ?
"PVE.ConsoleWorkspace" : "PVE.StdWorkspace";
$jssrc .= <<_EOJS;
// we need this (the java applet ignores the zindex)
Ext.useShims = true;
Ext.History.fieldid = 'x-history-field';
Ext.onReady(function() {
Ext.create('$workspace');
});
_EOJS
$page .= <<_EOD;
<script type="text/javascript">$jssrc</script>
</head>
<body>
<!-- Fields required for history management -->
<form id="history-form" class="x-hidden">
<input type="hidden" id="x-history-field"/>
</form>
</body>
</html>
_EOD
return $page;
}
1;

View File

@ -7,7 +7,6 @@ PERLSOURCE = \
API2Tools.pm \
API2Client.pm \
ExtJSIndex.pm \
ExtJSIndex6.pm \
TouchIndex.pm \
NoVncIndex.pm \
HTTPServer.pm \

View File

@ -18,7 +18,6 @@ use PVE::API2::Formatter::HTML;
use PVE::HTTPServer;
use PVE::ExtJSIndex;
use PVE::ExtJSIndex6;
use PVE::NoVncIndex;
use PVE::TouchIndex;
@ -40,8 +39,6 @@ my %daemon_options = (
my $daemon = __PACKAGE__->new('pveproxy', $cmdline, %daemon_options);
my $ext6_dir_exists;
sub add_dirs {
my ($result_hash, $alias, $subdir) = @_;
@ -72,18 +69,12 @@ sub init {
my $family = PVE::Tools::get_host_address_family($self->{nodename});
my $socket = $self->create_reusable_socket(8006, undef, $family);
$ext6_dir_exists = (-d '/usr/share/pve-manager/ext6');
my $dirs = {};
add_dirs($dirs, '/pve2/locale/', '/usr/share/pve-manager/locale/');
add_dirs($dirs, '/pve2/touch/', '/usr/share/pve-manager/touch/');
add_dirs($dirs, '/pve2/ext4/', '/usr/share/pve-manager/ext4/');
if ($ext6_dir_exists) { # only add ext6 dirs if they exist
add_dirs($dirs, '/pve2/ext6/', '/usr/share/pve-manager/ext6/');
add_dirs($dirs, '/pve2/manager6/', '/usr/share/pve-manager/manager6/');
}
add_dirs($dirs, '/pve2/ext6/', '/usr/share/pve-manager/ext6/');
add_dirs($dirs, '/pve2/manager6/', '/usr/share/pve-manager/manager6/');
add_dirs($dirs, '/pve2/images/' => '/usr/share/pve-manager/images/');
add_dirs($dirs, '/pve2/css/' => '/usr/share/pve-manager/css/');
@ -203,19 +194,12 @@ sub get_index {
$mobile = $args->{mobile} ? 1 : 0;
}
my $ext6;
if (defined($args->{ext6})) {
$ext6 = $args->{ext6} ? 1 : 0;
}
my $page;
if (defined($args->{console}) && $args->{novnc}) {
$page = PVE::NoVncIndex::get_index($lang, $username, $token, $args->{console}, $nodename);
} elsif ($mobile) {
$page = PVE::TouchIndex::get_index($lang, $username, $token, $args->{console}, $nodename);
} elsif ($ext6 && $ext6_dir_exists) {
$page = PVE::ExtJSIndex6::get_index($lang, $username, $token, $args->{console}, $nodename);
} else {
$page = PVE::ExtJSIndex::get_index($lang, $username, $token, $args->{console}, $nodename);
}

View File

@ -1,5 +1,4 @@
# Note: please add ext6 for extJS 6 development
SUBDIRS = images ext4 css manager bootstrap touch mobile
SUBDIRS = images ext6 css manager6 bootstrap touch mobile
all: ${SUBDIRS}

View File

@ -3,7 +3,7 @@ include ../../defines.mk
all:
.PHONY: install
install: ext-pve.css ext6-pve.css
install: ext6-pve.css
install -d ${WWWCSSDIR}
install -m 0644 -o www-data -g www-data $? ${WWWCSSDIR}

226
www/manager6/Makefile Normal file
View File

@ -0,0 +1,226 @@
include ../../defines.mk
JSSRC= \
Utils.js \
Toolkit.js \
Parser.js \
StateProvider.js \
button/Button.js \
button/ConsoleButton.js \
qemu/SendKeyMenu.js \
qemu/CmdMenu.js \
qemu/TemplateMenu.js \
lxc/CmdMenu.js \
VNCConsole.js \
data/TimezoneStore.js \
data/reader/JsonObject.js \
data/PVEProxy.js \
data/UpdateQueue.js \
data/UpdateStore.js \
data/DiffStore.js \
data/ObjectStore.js \
data/ResourceStore.js \
data/RRDStore.js \
form/VLanField.js \
form/Checkbox.js \
form/TextField.js \
form/RRDTypeSelector.js \
form/ComboGrid.js \
form/KVComboBox.js \
form/Boolean.js \
form/CompressionSelector.js \
form/PoolSelector.js \
form/GroupSelector.js \
form/UserSelector.js \
form/RoleSelector.js \
form/VMIDSelector.js \
form/MemoryField.js \
form/NetworkCardSelector.js \
form/DiskFormatSelector.js \
form/BusTypeSelector.js \
form/ControllerSelector.js \
form/EmailNotificationSelector.js \
form/RealmComboBox.js \
form/BondModeSelector.js \
form/ViewSelector.js \
form/NodeSelector.js \
form/FileSelector.js \
form/StorageSelector.js \
form/BridgeSelector.js \
form/SecurityGroupSelector.js \
form/IPRefSelector.js \
form/IPProtocolSelector.js \
form/CPUModelSelector.js \
form/VNCKeyboardSelector.js \
form/LanguageSelector.js \
form/DisplaySelector.js \
form/CacheTypeSelector.js \
form/SnapshotSelector.js \
form/ContentTypeSelector.js \
form/HotplugFeatureSelector.js \
form/iScsiProviderSelector.js \
form/DayOfWeekSelector.js \
form/BackupModeSelector.js \
form/ScsiHwSelector.js \
form/FirewallPolicySelector.js \
form/QemuBiosSelector.js \
dc/Tasks.js \
dc/Log.js \
panel/StatusPanel.js \
panel/RRDView.js \
panel/RRDChart.js \
panel/InputPanel.js \
window/Edit.js \
window/LoginWindow.js \
window/TaskViewer.js \
window/Wizard.js \
window/NotesEdit.js \
window/Backup.js \
window/Restore.js \
window/SafeDestroy.js \
panel/NotesView.js \
grid/SelectFeature.js \
grid/ObjectGrid.js \
grid/PendingObjectGrid.js \
grid/ResourceGrid.js \
grid/PoolMembers.js \
grid/FirewallRules.js \
grid/FirewallAliases.js \
grid/FirewallOptions.js \
tree/ResourceTree.js \
panel/IPSet.js \
panel/ConfigPanel.js \
panel/SubConfigPanel.js \
grid/BackupView.js \
panel/LogView.js \
panel/Firewall.js \
ceph/Pool.js \
ceph/OSD.js \
ceph/Disks.js \
ceph/Monitor.js \
ceph/Crush.js \
ceph/Status.js \
ceph/Config.js \
node/DNSEdit.js \
node/DNSView.js \
node/TimeView.js \
node/TimeEdit.js \
node/StatusView.js \
node/Summary.js \
node/ServiceView.js \
node/NetworkEdit.js \
node/NetworkView.js \
node/Tasks.js \
node/Subscription.js \
node/APT.js \
node/Config.js \
qemu/StatusView.js \
window/Migrate.js \
window/MigrateAll.js \
qemu/Monitor.js \
qemu/Summary.js \
qemu/OSTypeEdit.js \
qemu/ProcessorEdit.js \
qemu/BootOrderEdit.js \
qemu/MemoryEdit.js \
qemu/NetworkEdit.js \
qemu/Smbios1Edit.js \
qemu/CDEdit.js \
qemu/HDEdit.js \
qemu/HDResize.js \
qemu/HDMove.js \
qemu/HDThrottle.js \
qemu/CPUOptions.js \
qemu/DisplayEdit.js \
qemu/KeyboardEdit.js \
qemu/HardwareView.js \
qemu/StartupEdit.js \
qemu/ScsiHwEdit.js \
qemu/QemuBiosEdit.js \
qemu/Options.js \
qemu/Snapshot.js \
qemu/Clone.js \
qemu/SnapshotTree.js \
qemu/Config.js \
qemu/CreateWizard.js \
lxc/StatusView.js \
lxc/Summary.js \
lxc/Network.js \
lxc/Resources.js \
lxc/Options.js \
lxc/DNS.js \
lxc/Config.js \
lxc/CreateWizard.js \
lxc/SnapshotTree.js \
lxc/Snapshot.js \
lxc/ResourceEdit.js \
lxc/MPResize.js \
pool/StatusView.js \
pool/Summary.js \
pool/Config.js \
storage/ContentView.js \
storage/StatusView.js \
storage/Summary.js \
storage/Browser.js \
storage/DirEdit.js \
storage/NFSEdit.js \
storage/GlusterFsEdit.js \
storage/IScsiEdit.js \
storage/LVMEdit.js \
storage/LvmThinEdit.js \
storage/RBDEdit.js \
storage/SheepdogEdit.js \
storage/ZFSEdit.js \
storage/ZFSPoolEdit.js \
ha/StatusView.js \
ha/GroupSelector.js \
ha/ResourceEdit.js \
ha/Resources.js \
ha/GroupEdit.js \
ha/Groups.js \
ha/Fencing.js \
ha/Config.js \
dc/Summary.js \
dc/OptionView.js \
dc/StorageView.js \
dc/UserEdit.js \
dc/UserView.js \
dc/PoolView.js \
dc/PoolEdit.js \
dc/GroupView.js \
dc/GroupEdit.js \
dc/RoleView.js \
dc/ACLView.js \
dc/AuthView.js \
dc/AuthEdit.js \
dc/Backup.js \
dc/Support.js \
dc/SecurityGroups.js \
dc/Config.js \
Workspace.js
lint: ${JSSRC}
jslint ${JSSRC}
pvemanagerlib.js: ${JSSRC}
cat ${JSSRC} >$@.tmp
mv $@.tmp $@
all: pvemanagerlib.js
.PHONY: install
install: pvemanagerlib.js
install -d ${WWWBASEDIR}/root
install -d ${WWWEXT6DIR}
install -m 0644 -o www-data -g www-data pvemanagerlib.js ${WWWEXT6DIR}
.PHONY: distclean
distclean: clean
.PHONY: clean
clean:
find . -name '*~' -exec rm {} ';'
rm -rf pvemanagerlib.js

View File

@ -1,25 +0,0 @@
pveproxy with ExtJS 6 developpement mini howto
==============================================
unpack the ExtJS 6 sources, and copy them to /usr/share/pve-manager/ext6
cd www/ext6/
make install
symlink the ext6 dir in pve-manager to the manager5 directory
cd /usr/share/pve-manager
ln -s PATH_TO_YOUR_GIT_REPO/www/manager6
restart pveproxy
systemctl pveproxy restart
access the PVE proxy with ExtJS 6
https://localhost:8006/?ext6=1
With the extra parameter **ext6=1**, pve-proxy will call the function **PVE::ExtJSIndex6::get_index()**
which returns a HTML page, with all javascript symlinked from your git repository.
Provided you included the javascript files in **PVE/ExtJSIndex6.pm**, after editing a file in the git repository, a simple refresh is enough to see your changes in the browser.