]>
git.proxmox.com Git - pve-manager.git/blob - www/manager/Workspace.js
4 * popup login window when auth fails (call onLogin handler)
5 * update (re-login) ticket every 15 minutes
9 Ext
.define('PVE.Workspace', {
10 extend
: 'Ext.container.Viewport',
14 'PVE.window.LoginWindow'
17 title
: 'Proxmox Virtual Environment',
19 loginData
: null, // Data from last login call
21 onLogin: function(loginData
) {},
24 updateLoginData: function(loginData
) {
26 me
.loginData
= loginData
;
27 PVE
.CSRFPreventionToken
= loginData
.CSRFPreventionToken
;
28 PVE
.UserName
= loginData
.username
;
29 var expire
= Ext
.Date
.add(new Date(), Ext
.Date
.HOUR
, 2);
30 Ext
.util
.Cookies
.set('PVEAuthCookie', loginData
.ticket
, expire
);
31 me
.onLogin(loginData
);
35 showLogin: function() {
38 PVE
.Utils
.authClear();
43 me
.login
= Ext
.create('PVE.window.LoginWindow', {
44 handler: function(data
) {
46 me
.updateLoginData(data
);
54 initComponent : function() {
57 Ext
.tip
.QuickTipManager
.init();
59 // fixme: what about other errors
60 Ext
.Ajax
.on('requestexception', function(conn
, response
, options
) {
61 if (response
.status
== 401) { // auth failure
66 document
.title
= me
.title
;
70 if (!PVE
.Utils
.authOK()) {
74 me
.onLogin(me
.loginData
);
78 Ext
.TaskManager
.start({
80 var ticket
= PVE
.Utils
.authOK();
81 if (!ticket
|| !PVE
.UserName
) {
87 username
: PVE
.UserName
,
90 url
: '/api2/json/access/ticket',
92 success: function(response
, opts
) {
93 var obj
= Ext
.decode(response
.responseText
);
94 me
.updateLoginData(obj
.data
);
104 Ext
.define('PVE.ConsoleWorkspace', {
105 extend
: 'PVE.Workspace',
110 alias
: ['widget.pveConsoleWorkspace'],
112 title
: gettext('Console'),
114 initComponent : function() {
117 var param
= Ext
.Object
.fromQueryString(window
.location
.search
);
118 var consoleType
= me
.consoleType
|| param
.console
;
121 if (consoleType
=== 'kvm') {
122 me
.title
= "VM " + param
.vmid
;
124 me
.title
+= " ('" + param
.vmname
+ "')";
127 xtype
: 'pveKVMConsole',
129 nodename
: param
.node
,
130 vmname
: param
.vmname
,
133 } else if (consoleType
=== 'openvz') {
134 me
.title
= "CT " + param
.vmid
;
136 me
.title
+= " ('" + param
.vmname
+ "')";
139 xtype
: 'pveOpenVZConsole',
141 nodename
: param
.node
,
142 vmname
: param
.vmname
,
145 } else if (consoleType
=== 'shell') {
146 me
.title
= "node '" + param
.node
;
149 nodename
: param
.node
,
156 html
: 'Error: No such console type'
161 layout
: { type
: 'fit' },
170 Ext
.define('PVE.StdWorkspace', {
171 extend
: 'PVE.Workspace',
173 alias
: ['widget.pveStdWorkspace'],
176 setContent: function(comp
) {
179 var cont
= me
.child('#content');
180 cont
.removeAll(true);
183 PVE
.Utils
.setErrorMask(cont
, false);
188 PVE
.Utils
.setErrorMask(cont
, 'nothing selected');
192 selectById: function(nodeid
) {
194 var tree
= me
.down('pveResourceTree');
195 tree
.selectById(nodeid
);
198 checkVmMigration: function(record
) {
200 var tree
= me
.down('pveResourceTree');
201 tree
.checkVmMigration(record
);
204 onLogin: function(loginData
) {
210 PVE
.data
.ResourceStore
.startUpdate();
214 updateUserInfo: function() {
217 var ui
= me
.query('#userinfo')[0];
220 var msg
= Ext
.String
.format(gettext("You are logged in as {0}"), "'" + PVE
.UserName
+ "'");
221 ui
.update('<div class="x-unselectable" style="white-space:nowrap;">' + msg
+ '</div>');
228 initComponent : function() {
232 Ext
.state
.Manager
.setProvider(Ext
.create('PVE.StateProvider'));
234 var selview
= new PVE
.form
.ViewSelector({});
236 var rtree
= Ext
.createWidget('pveResourceTree', {
237 viewFilter
: selview
.getViewFilter(),
239 selModel
: new Ext
.selection
.TreeModel({
241 selectionchange: function(sm
, selected
) {
244 root
: 'PVE.dc.Config',
245 node
: 'PVE.node.Config',
246 qemu
: 'PVE.qemu.Config',
247 openvz
: 'PVE.openvz.Config',
248 storage
: 'PVE.storage.Browser',
249 pool
: 'pvePoolConfig'
252 if (selected
.length
> 0) {
255 xtype
: tlckup
[n
.data
.type
|| 'root'] ||
257 layout
: { type
: 'fit' },
258 showSearch
: (n
.data
.id
=== 'root') ||
259 Ext
.isDefined(n
.data
.groupbyid
),
262 viewFilter
: selview
.getViewFilter()
272 selview
.on('select', function(combo
, records
) {
273 if (records
&& records
.length
) {
274 var view
= combo
.getViewFilter();
275 rtree
.setViewFilter(view
);
280 layout
: { type
: 'border' },
299 html
: '<a class="x-unselectable" target=_blank href="http://www.proxmox.com">' +
300 '<img height=30 width=209 src="/pve2/images/proxmox_logo.png"/></a>'
305 html
: '<span class="x-panel-header-text">Proxmox Virtual Environment<br>' + gettext('Version') + ' ' + PVE
.GUIVersion
+ "</span>"
309 margins
: '8 10 0 10',
318 text
: gettext("Logout"),
319 handler: function() {
320 PVE
.data
.ResourceStore
.stopUpdate();
323 var rt
= me
.down('pveResourceTree');
332 text
: gettext("Create VM"),
333 handler: function() {
334 var wiz
= Ext
.create('PVE.qemu.CreateWizard', {});
343 text
: gettext("Create CT"),
344 handler: function() {
345 var wiz
= Ext
.create('PVE.openvz.CreateWizard', {});
355 layout
: { type
: 'fit' },
365 layout
: { type
: 'vbox', align
: 'stretch' },
369 items
: [ selview
, rtree
]
372 xtype
: 'pveStatusPanel',