]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/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',
12 title
: 'Proxmox Virtual Environment',
14 loginData
: null, // Data from last login call
16 onLogin: function(loginData
) {},
19 updateLoginData: function(loginData
) {
21 me
.loginData
= loginData
;
22 Proxmox
.Utils
.setAuthData(loginData
);
24 var rt
= me
.down('pveResourceTree');
25 rt
.setDatacenterText(loginData
.clustername
);
28 Ext
.state
.Manager
.set('GuiCap', loginData
.cap
);
31 me
.onLogin(loginData
);
35 showLogin: function() {
38 Proxmox
.Utils
.authClear();
39 Proxmox
.UserName
= null;
43 me
.login
= Ext
.create('PVE.window.LoginWindow', {
44 handler: function(data
) {
46 me
.updateLoginData(data
);
47 Proxmox
.Utils
.checked_command(function() {}); // display subscription status
55 initComponent : function() {
58 Ext
.tip
.QuickTipManager
.init();
60 // fixme: what about other errors
61 Ext
.Ajax
.on('requestexception', function(conn
, response
, options
) {
62 if (response
.status
== 401 && !PVE
.Utils
.silenceAuthFailures
) { // auth failure
69 if (!Proxmox
.Utils
.authOK()) {
73 me
.onLogin(me
.loginData
);
77 Ext
.TaskManager
.start({
79 var ticket
= Proxmox
.Utils
.authOK();
80 if (!ticket
|| !Proxmox
.UserName
) {
86 username
: Proxmox
.UserName
,
89 url
: '/api2/json/access/ticket',
91 success: function(response
, opts
) {
92 var obj
= Ext
.decode(response
.responseText
);
93 me
.updateLoginData(obj
.data
);
103 Ext
.define('PVE.StdWorkspace', {
104 extend
: 'PVE.Workspace',
106 alias
: ['widget.pveStdWorkspace'],
109 setContent: function(comp
) {
112 var cont
= me
.child('#content');
114 var lay
= cont
.getLayout();
116 var cur
= lay
.getActiveItem();
119 Proxmox
.Utils
.setErrorMask(cont
, false);
122 if (cur
!== null && lay
.getNext()) {
124 var task
= Ext
.create('Ext.util.DelayedTask', function(){
131 // helper for cleaning the content when logging out
136 selectById: function(nodeid
) {
138 var tree
= me
.down('pveResourceTree');
139 tree
.selectById(nodeid
);
142 onLogin: function(loginData
) {
148 PVE
.data
.ResourceStore
.startUpdate();
150 Proxmox
.Utils
.API2Request({
153 success: function(response
) {
154 PVE
.VersionInfo
= response
.result
.data
;
155 me
.updateVersionInfo();
161 updateUserInfo: function() {
164 var ui
= me
.query('#userinfo')[0];
166 if (Proxmox
.UserName
) {
167 var msg
= Ext
.String
.format(gettext("You are logged in as {0}"), "'" + Proxmox
.UserName
+ "'");
168 ui
.update('<div class="x-unselectable" style="white-space:nowrap;">' + msg
+ '</div>');
175 updateVersionInfo: function() {
178 var ui
= me
.query('#versioninfo')[0];
180 if (PVE
.VersionInfo
) {
181 var version
= PVE
.VersionInfo
.version
+ '-' + PVE
.VersionInfo
.release
;
182 ui
.update('Virtual Environment ' + version
);
184 ui
.update('Virtual Environment');
189 initComponent : function() {
194 var sprovider
= Ext
.create('PVE.StateProvider');
195 Ext
.state
.Manager
.setProvider(sprovider
);
197 var selview
= Ext
.create('PVE.form.ViewSelector');
199 var rtree
= Ext
.createWidget('pveResourceTree', {
200 viewFilter
: selview
.getViewFilter(),
203 selType
: 'treemodel',
205 selectionchange: function(sm
, selected
) {
206 if (selected
.length
> 0) {
209 root
: 'PVE.dc.Config',
210 node
: 'PVE.node.Config',
211 qemu
: 'PVE.qemu.Config',
212 lxc
: 'PVE.lxc.Config',
213 storage
: 'PVE.storage.Browser',
214 pool
: 'pvePoolConfig'
217 xtype
: tlckup
[n
.data
.type
|| 'root'] ||
219 showSearch
: (n
.data
.id
=== 'root') ||
220 Ext
.isDefined(n
.data
.groupbyid
),
223 viewFilter
: selview
.getViewFilter()
225 PVE
.curSelectedNode
= n
;
233 selview
.on('select', function(combo
, records
) {
235 var view
= combo
.getViewFilter();
236 rtree
.setViewFilter(view
);
240 var caps
= sprovider
.get('GuiCap');
242 var createVM
= Ext
.createWidget('button', {
246 iconCls
: 'fa fa-desktop',
247 text
: gettext("Create VM"),
248 disabled
: !caps
.vms
['VM.Allocate'],
249 handler: function() {
250 var wiz
= Ext
.create('PVE.qemu.CreateWizard', {});
255 var createCT
= Ext
.createWidget('button', {
259 iconCls
: 'fa fa-cube',
260 text
: gettext("Create CT"),
261 disabled
: !caps
.vms
['VM.Allocate'],
262 handler: function() {
263 var wiz
= Ext
.create('PVE.lxc.CreateWizard', {});
268 sprovider
.on('statechange', function(sp
, key
, value
) {
269 if (key
=== 'GuiCap' && value
) {
271 createVM
.setDisabled(!caps
.vms
['VM.Allocate']);
272 createCT
.setDisabled(!caps
.vms
['VM.Allocate']);
277 layout
: { type
: 'border' },
294 html
: '<a class="x-unselectable" target=_blank href="http://www.proxmox.com">' +
295 '<img style="padding-top:4px;padding-right:5px" src="/pve2/images/proxmox_logo.png"/></a>'
300 html
: 'Virtual Environment'
303 xtype
: 'pveGlobalSearchField',
317 iconCls
: 'fa black fa-gear',
319 handler: function() {
320 var win
= Ext
.create('PVE.window.Settings');
325 xtype
: 'proxmoxHelpButton',
328 iconCls
: 'fa fa-book x-btn-icon-el-default-toolbar-small ',
329 listenToGlobalEvent
: false,
330 onlineHelp
: 'pve_documentation_index',
331 text
: gettext('Documentation'),
341 iconCls
: 'fa fa-sign-out',
342 text
: gettext("Logout"),
343 handler: function() {
344 PVE
.data
.ResourceStore
.loadData([], false);
347 var rt
= me
.down('pveResourceTree');
348 rt
.setDatacenterText(undefined);
351 // empty the stores of the StatusPanel child items
352 var statusPanels
= Ext
.ComponentQuery
.query('pveStatusPanel grid');
353 Ext
.Array
.forEach(statusPanels
, function(comp
) {
354 if (comp
.getStore()) {
355 comp
.getStore().loadData([], false);
365 stateId
: 'pvecenter',
370 layout
: { type
: 'card' },
382 layout
: { type
: 'vbox', align
: 'stretch' },
386 items
: [ selview
, rtree
],
388 resize: function(panel
, width
, height
) {
389 var viewWidth
= me
.getSize().width
;
390 if (width
> viewWidth
- 100) {
391 panel
.setWidth(viewWidth
- 100);
397 xtype
: 'pveStatusPanel',
403 title
: gettext('Logs'),
409 resize: function(panel
, width
, height
) {
410 var viewHeight
= me
.getSize().height
;
411 if (height
> (viewHeight
- 150)) {
412 panel
.setHeight(viewHeight
- 150);
424 // on resize, center all modal windows
425 Ext
.on('resize', function(){
426 var wins
= Ext
.ComponentQuery
.query('window[modal]');
427 if (wins
.length
> 0) {
428 wins
.forEach(function(win
){
429 win
.alignTo(me
, 'c-c');