[pve-devel] r5965 - in pve-manager/pve2/www/new: . grid
svn-commits at proxmox.com
svn-commits at proxmox.com
Thu May 12 08:27:12 CEST 2011
Author: dietmar
Date: 2011-05-12 08:27:12 +0200 (Thu, 12 May 2011)
New Revision: 5965
Modified:
pve-manager/pve2/www/new/VNCConsole.js
pve-manager/pve2/www/new/Workspace.js
pve-manager/pve2/www/new/grid/ResourceGrid.js
pve-manager/pve2/www/new/index.pl
Log:
cleanups
Modified: pve-manager/pve2/www/new/VNCConsole.js
===================================================================
--- pve-manager/pve2/www/new/VNCConsole.js 2011-05-11 11:20:56 UTC (rev 5964)
+++ pve-manager/pve2/www/new/VNCConsole.js 2011-05-12 06:27:12 UTC (rev 5965)
@@ -134,12 +134,12 @@
autoScroll: me.toplevel ? false : true,
items: box,
reloadApplet: function() {
- Ext.Ajax.request({
+ PVE.Utils.API2Request({
url: me.url,
params: me.params,
method: me.method || 'POST',
failure: function(response, opts) {
- box.update("Error " + response.status + ": " + response.statusText);
+ box.update("Error " + response.htmlStatus);
},
success: function(response, opts) {
var obj = Ext.decode(response.responseText);
@@ -280,7 +280,7 @@
Ext.apply(me, {
tbar: tbar,
- url: "/api2/json/nodes/" + me.nodename + "/qemu/" + me.vmid + "/vncproxy"
+ url: "/nodes/" + me.nodename + "/qemu/" + me.vmid + "/vncproxy"
});
me.callParent();
@@ -326,7 +326,7 @@
Ext.apply(me, {
tbar: tbar,
- url: "/api2/json/nodes/" + me.nodename + "/vncshell"
+ url: "/nodes/" + me.nodename + "/vncshell"
});
me.callParent();
Modified: pve-manager/pve2/www/new/Workspace.js
===================================================================
--- pve-manager/pve2/www/new/Workspace.js 2011-05-11 11:20:56 UTC (rev 5964)
+++ pve-manager/pve2/www/new/Workspace.js 2011-05-12 06:27:12 UTC (rev 5965)
@@ -1,15 +1,134 @@
+/*
+ * Workspace base class
+ *
+ * popup login window when auth fails (call onLogin handler)
+ * fixme: update (re-login) ticket at regular interval
+ *
+ */
+
Ext.define('PVE.Workspace', {
extend: 'Ext.container.Viewport',
- requires: [
+ requires: [
+ 'Ext.tip.*',
+ 'PVE.Utils',
+ 'PVE.window.LoginWindow'
+ ],
+
+ title: 'Proxmox Virtual Environment',
+
+ loginData: null, // Data from last login call
+
+ onLogin: function(loginData) {},
+
+ showLogin: function() {
+ var me = this;
+
+ PVE.Utils.authClear();
+ PVE.UserName = null;
+ me.loginData = null;
+
+ if (!me.login) {
+ me.login = Ext.create('PVE.window.LoginWindow', {
+ handler: function(data) {
+ me.login = null;
+ me.loginData = data;
+ PVE.CSRFPreventionToken = data.CSRFPreventionToken;
+ PVE.UserName = data.username;
+ me.onLogin(me.loginData);
+ }
+ });
+ }
+ me.onLogin(null);
+ me.login.show();
+ },
+
+ initComponent : function() {
+ var me = this;
+
+ Ext.tip.QuickTipManager.init();
+
+ // fixme: what about other errors
+ Ext.Ajax.on('requestexception', function(conn, response, options) {
+ if (response.status == 401) { // auth failure
+ me.showLogin();
+ }
+ });
+
+ document.title = me.title;
+
+ me.callParent();
+
+ if (!PVE.Utils.authOK())
+ me.showLogin();
+ else
+ if (me.loginData)
+ me.onLogin(me.loginData);
+ }
+});
+
+Ext.define('PVE.ConsoleWorkspace', {
+ extend: 'PVE.Workspace',
+ requires: [
+ 'PVE.KVMConsole'
+ ],
+
+ alias: ['widget.pveConsoleWorkspace'],
+
+ title: 'Proxmox Console',
+
+ initComponent : function() {
+ var me = this;
+
+ var param = Ext.Object.fromQueryString(window.location.search);
+ var consoleType = me.consoleType || param.console;
+
+ var content;
+ if (consoleType === 'kvm') {
+ me.title = "VM " + param.vmid;
+ content = {
+ xtype: 'pveKVMConsole',
+ vmid: param.vmid,
+ nodename: param.node,
+ toplevel: true
+ };
+ } else if (consoleType === 'shell') {
+ me.title = "node " + param.node + " - Proxmox Shell"
+ content = {
+ xtype: 'pveShell',
+ nodename: param.node,
+ toplevel: true
+ };
+ } else {
+ content = {
+ border: false,
+ bodyPadding: 10,
+ html: 'Error: No such console type'
+ };
+ }
+
+ Ext.apply(me, {
+ layout: 'fit',
+ border: false,
+ items: content
+ });
+
+ me.callParent();
+ }
+});
+
+Ext.define('PVE.StdWorkspace', {
+ extend: 'PVE.Workspace',
+ requires: [
+ 'Ext.History',
+ 'Ext.state.*',
'Ext.selection.*',
- 'PVE.window.LoginWindow',
- 'PVE.Utils',
'PVE.form.ViewSelector',
'PVE.data.ResourceStore',
'PVE.tree.ResourceTree'
],
- alias: ['widget.pveWorkspace'],
+ alias: ['widget.pveStdWorkspace'],
+
// private
defaultContent: {
title: 'Nothing selected',
@@ -34,28 +153,13 @@
tree.selectById(nodeid);
},
- showLogin: function() {
+ onLogin: function(loginData) {
var me = this;
- PVE.Utils.authClear();
- PVE.UserName = null;
+ me.updateUserInfo();
- if (!me.login) {
-
- me.login = Ext.create('PVE.window.LoginWindow', {
- handler: function(data) {
- me.login = null;
-
- PVE.CSRFPreventionToken = data.CSRFPreventionToken;
- PVE.UserName = data.username;
-
- me.updateUserInfo();
- PVE.data.ResourceStore.startUpdate();
- }
- });
- }
- me.login.show();
- me.updateUserInfo();
+ if (loginData)
+ PVE.data.ResourceStore.startUpdate();
},
updateUserInfo: function() {
@@ -74,13 +178,11 @@
initComponent : function() {
var me = this;
- // fixme: what about other errors
- Ext.Ajax.on('requestexception', function(conn, response, options) {
- if (response.status == 401) { // auth failure
- me.showLogin();
- }
- });
+ Ext.History.init();
+ Ext.state.Manager.setProvider(Ext.create('PVE.StateProvider'));
+ //document.title = ;
+
var selview = new PVE.form.ViewSelector({
listeners: {
select: function(combo, records) {
@@ -132,7 +234,6 @@
Ext.apply(me, {
layout: 'border',
border: false,
-
items: [
{
region: 'north',
@@ -224,13 +325,9 @@
]
});
- PVE.Workspace.superclass.initComponent.call(me);
-
- if (!PVE.Utils.authOK())
- me.showLogin();
- else
- me.updateUserInfo();
+ me.callParent();
+ me.updateUserInfo();
}
});
Modified: pve-manager/pve2/www/new/grid/ResourceGrid.js
===================================================================
--- pve-manager/pve2/www/new/grid/ResourceGrid.js 2011-05-11 11:20:56 UTC (rev 5964)
+++ pve-manager/pve2/www/new/grid/ResourceGrid.js 2011-05-12 06:27:12 UTC (rev 5965)
@@ -185,7 +185,7 @@
},
listeners: {
itemdblclick: function(v, record) {
- var ws = me.up('pveWorkspace');
+ var ws = me.up('pveStdWorkspace');
ws.selectById(record.data.id);
},
destroy: function() {
Modified: pve-manager/pve2/www/new/index.pl
===================================================================
--- pve-manager/pve2/www/new/index.pl 2011-05-11 11:20:56 UTC (rev 5964)
+++ pve-manager/pve2/www/new/index.pl 2011-05-12 06:27:12 UTC (rev 5965)
@@ -40,97 +40,34 @@
my $cgi = CGI->new($r);
my %args = $cgi->Vars();
-my $console = $args{console};
-my $vmid = $args{vmid} ? PVE::JSONSchema::pve_verify_vmid($args{vmid}) : 0;
-my $node = $args{node} ? PVE::JSONSchema::pve_verify_node_name($args{node}) : '';
+my $workspace = defined($args{console}) ?
+ "PVE.ConsoleWorkspace" : "PVE.StdWorkspace";
-my $title = "Proxmox Virtual Environment";
-if (defined($console)) {
- if ($console eq 'kvm') {
- my $name = "VM $vmid"; # fixme: use real VM name
- $title = "$name - Proxmox Console";
- } elsif ($console eq 'shell') {
- $title = "node $node - Proxmox Shell";
- } else {
- die "unsupported console type";
- }
-}
-
my $jssrc = <<_EOJS;
if (!PVE) PVE = {};
PVE.GUIVersion = '$version';
PVE.UserName = '$username';
PVE.CSRFPreventionToken = '$token';
+Ext.require(['*', '$workspace']);
+
// we need this (the java applet ignores the zindex)
Ext.useShims = true;
-Ext.require([
- '*',
- 'Ext.state.*',
- 'Ext.tip.*',
- 'PVE.StateProvider',
- 'PVE.VNCConsole',
- 'PVE.Workspace']);
+Ext.History.fieldid = 'x-history-field';
-Ext.tip.QuickTipManager.init();
+Ext.onReady(function() { Ext.create('$workspace');});
_EOJS
-if (defined($console)) {
+$jssrc .= "";
- if ($console eq 'kvm') {
-
- $jssrc .= <<_EOJS;
- Ext.onReady(function() {
- Ext.create('Ext.container.Viewport', {
- layout: 'fit',
- renderTo: Ext.getBody(),
- items: {
- xtype: 'pveKVMConsole',
- vmid: '$vmid',
- nodename: '$node',
- toplevel: true
- }
- });
- });
-_EOJS
- } elsif ($console eq 'shell') {
- $jssrc .= <<_EOJS;
- Ext.onReady(function() {
- Ext.create('Ext.container.Viewport', {
- layout: 'fit',
- renderTo: Ext.getBody(),
- items: {
- xtype: 'pveShell',
- nodename: '$node',
- toplevel: true
- }
- });
- });
-_EOJS
-}
-
-} else {
-
- $jssrc .= <<_EOJS;
-
- Ext.History.fieldid = 'x-history-field';
-
- Ext.onReady(function() {
- Ext.History.init();
- Ext.state.Manager.setProvider(Ext.create('PVE.StateProvider'));
- Ext.create('PVE.Workspace');
- });
-_EOJS
-}
-
my $page = <<_EOD;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title id='title'>$title</title>
+ <title>Proxmox Virtual Environment</title>
<link rel="stylesheet" type="text/css" href="/pve2/ext4/resources/css/ext-all-debug.css" />
<link rel="stylesheet" type="text/css" href="/pve2/css/ext-pve.css" />
More information about the pve-devel
mailing list