]>
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 me
.onLogin(loginData
);
33 showLogin: function() {
36 PVE
.Utils
.authClear();
41 me
.login
= Ext
.create('PVE.window.LoginWindow', {
42 handler: function(data
) {
44 me
.updateLoginData(data
);
52 initComponent : function() {
55 Ext
.tip
.QuickTipManager
.init();
57 // fixme: what about other errors
58 Ext
.Ajax
.on('requestexception', function(conn
, response
, options
) {
59 if (response
.status
== 401) { // auth failure
64 document
.title
= me
.title
;
68 if (!PVE
.Utils
.authOK()) {
72 me
.onLogin(me
.loginData
);
76 Ext
.TaskManager
.start({
78 var ticket
= PVE
.Utils
.authOK();
79 if (!ticket
|| !PVE
.UserName
) {
85 username
: PVE
.UserName
,
88 url
: '/api2/json/access/ticket',
90 success: function(response
, opts
) {
91 // cookie is automatically updated
92 var obj
= Ext
.decode(response
.responseText
);
93 me
.updateLoginData(obj
.data
);
103 Ext
.define('PVE.ConsoleWorkspace', {
104 extend
: 'PVE.Workspace',
109 alias
: ['widget.pveConsoleWorkspace'],
111 title
: 'Proxmox Console',
113 initComponent : function() {
116 var param
= Ext
.Object
.fromQueryString(window
.location
.search
);
117 var consoleType
= me
.consoleType
|| param
.console
;
120 if (consoleType
=== 'kvm') {
121 me
.title
= "VM " + param
.vmid
;
123 xtype
: 'pveKVMConsole',
125 nodename
: param
.node
,
128 } else if (consoleType
=== 'shell') {
129 me
.title
= "node " + param
.node
+ " - Proxmox Shell";
132 nodename
: param
.node
,
139 html
: 'Error: No such console type'
144 layout
: { type
: 'fit' },
153 Ext
.define('PVE.StdWorkspace', {
154 extend
: 'PVE.Workspace',
159 'PVE.form.ViewSelector',
160 'PVE.data.ResourceStore',
161 'PVE.tree.ResourceTree'
164 alias
: ['widget.pveStdWorkspace'],
168 title
: 'Nothing selected',
172 setContent: function(comp
) {
176 comp
= me
.defaultContent
;
179 var cont
= me
.child('#content');
180 cont
.removeAll(true);
185 selectById: function(nodeid
) {
187 var tree
= me
.down('pveResourceTree');
188 tree
.selectById(nodeid
);
191 onLogin: function(loginData
) {
197 PVE
.data
.ResourceStore
.startUpdate();
201 updateUserInfo: function() {
204 var ui
= me
.query('#userinfo')[0];
207 ui
.update('<div class="x-unselectable" style="white-space:nowrap;">You are logged in as "' + PVE
.UserName
+ '"</div>');
214 initComponent : function() {
218 Ext
.state
.Manager
.setProvider(Ext
.create('PVE.StateProvider'));
222 var selview
= new PVE
.form
.ViewSelector({
224 select: function(combo
, records
) {
225 if (records
&& records
.length
) {
226 var view
= combo
.getViewFilter();
227 combo
.up('pveResourceTree').setViewFilter(view
);
233 var rtree
= Ext
.createWidget('pveResourceTree', {
238 viewFilter
: selview
.getViewFilter(),
239 tbar
: [ ' ', selview
],
240 selModel
: new Ext
.selection
.TreeModel({
242 selectionchange: function(sm
, selected
) {
245 root
: 'PVE.dc.Config',
246 node
: 'PVE.node.Config',
247 qemu
: 'PVE.qemu.Config',
248 storage
: 'PVE.storage.Browser'
251 if (selected
.length
> 0) {
254 xtype
: tlckup
[n
.data
.type
|| 'root'] ||
256 layout
: { type
: 'fit' },
257 showSearch
: (n
.data
.id
=== 'root') ||
258 Ext
.isDefined(n
.data
.groupbyid
),
260 viewFilter
: selview
.getViewFilter()
271 layout
: { type
: 'border' },
290 html
: '<a class="x-unselectable" target=_blank href="http://www.proxmox.com">' +
291 '<img height=30 width=209 src="/pve2/images/proxmox_logo.png"/></a>'
296 html
: '<span class="x-panel-header-text">Proxmox Virtual Environment<br>Version ' + PVE
.GUIVersion
+ "</span>"
300 margins
: '8 10 0 10',
310 handler: function() {
311 PVE
.data
.ResourceStore
.stopUpdate();
314 var rt
= me
.down('pveResourceTree');
324 handler: function() {
325 var wiz
= Ext
.create('PVE.qemu.CreateWizard', {});
335 handler: function() {
336 var wiz
= Ext
.create('PVE.openvz.CreateWizard', {});
346 layout
: { type
: 'fit' },
350 items
: [ me
.defaultContent
]
354 xtype
: 'pveStatusPanel',