]>
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 checkVmMigration: function(record
) {
193 var tree
= me
.down('pveResourceTree');
194 tree
.checkVmMigration(record
);
197 onLogin: function(loginData
) {
203 PVE
.data
.ResourceStore
.startUpdate();
207 updateUserInfo: function() {
210 var ui
= me
.query('#userinfo')[0];
213 ui
.update('<div class="x-unselectable" style="white-space:nowrap;">You are logged in as "' + PVE
.UserName
+ '"</div>');
220 initComponent : function() {
224 Ext
.state
.Manager
.setProvider(Ext
.create('PVE.StateProvider'));
228 var selview
= new PVE
.form
.ViewSelector({
230 select: function(combo
, records
) {
231 if (records
&& records
.length
) {
232 var view
= combo
.getViewFilter();
233 combo
.up('pveResourceTree').setViewFilter(view
);
239 var rtree
= Ext
.createWidget('pveResourceTree', {
244 viewFilter
: selview
.getViewFilter(),
245 tbar
: [ ' ', selview
],
246 selModel
: new Ext
.selection
.TreeModel({
248 selectionchange: function(sm
, selected
) {
251 root
: 'PVE.dc.Config',
252 node
: 'PVE.node.Config',
253 qemu
: 'PVE.qemu.Config',
254 storage
: 'PVE.storage.Browser'
257 if (selected
.length
> 0) {
260 xtype
: tlckup
[n
.data
.type
|| 'root'] ||
262 layout
: { type
: 'fit' },
263 showSearch
: (n
.data
.id
=== 'root') ||
264 Ext
.isDefined(n
.data
.groupbyid
),
267 viewFilter
: selview
.getViewFilter()
278 layout
: { type
: 'border' },
297 html
: '<a class="x-unselectable" target=_blank href="http://www.proxmox.com">' +
298 '<img height=30 width=209 src="/pve2/images/proxmox_logo.png"/></a>'
303 html
: '<span class="x-panel-header-text">Proxmox Virtual Environment<br>Version ' + PVE
.GUIVersion
+ "</span>"
307 margins
: '8 10 0 10',
317 handler: function() {
318 PVE
.data
.ResourceStore
.stopUpdate();
321 var rt
= me
.down('pveResourceTree');
331 handler: function() {
332 var wiz
= Ext
.create('PVE.qemu.CreateWizard', {});
342 handler: function() {
343 var wiz
= Ext
.create('PVE.openvz.CreateWizard', {});
353 layout
: { type
: 'fit' },
357 items
: [ me
.defaultContent
]
361 xtype
: 'pveStatusPanel',