]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager/Workspace.js
bump version to 4.2-3
[pve-manager.git] / www / manager / Workspace.js
index e5e3afcff431f6e849d446db8d9015e66e4280cc..7233f6fba435e408d455fd6c6ae4538549a68e67 100644 (file)
@@ -8,11 +8,6 @@
 
 Ext.define('PVE.Workspace', {
     extend: 'Ext.container.Viewport',
-    requires: [             
-       'Ext.tip.*',   
-       'PVE.Utils', 
-       'PVE.window.LoginWindow'
-    ],
 
     title: 'Proxmox Virtual Environment',
 
@@ -26,6 +21,14 @@ Ext.define('PVE.Workspace', {
        me.loginData = loginData;
        PVE.CSRFPreventionToken = loginData.CSRFPreventionToken;
        PVE.UserName = loginData.username;
+
+       if (loginData.cap) {
+           Ext.state.Manager.set('GuiCap', loginData.cap);
+       }
+
+       // creates a session cookie (expire = null) 
+       // that way the cookie gets deleted after browser window close
+       Ext.util.Cookies.set('PVEAuthCookie', loginData.ticket, null, '/', null, true);
        me.onLogin(loginData);
     },
 
@@ -42,6 +45,7 @@ Ext.define('PVE.Workspace', {
                handler: function(data) {
                    me.login = null;
                    me.updateLoginData(data);
+                   PVE.Utils.checked_command(function() {}); // display subscription status
                }
            });
        }
@@ -61,8 +65,6 @@ Ext.define('PVE.Workspace', {
            }
        });
 
-       document.title = me.title;
-
        me.callParent();
 
         if (!PVE.Utils.authOK()) {
@@ -88,7 +90,6 @@ Ext.define('PVE.Workspace', {
                    url: '/api2/json/access/ticket',
                    method: 'POST',
                    success: function(response, opts) {
-                       // cookie is automatically updated
                        var obj = Ext.decode(response.responseText);
                        me.updateLoginData(obj.data);
                    }
@@ -102,13 +103,10 @@ Ext.define('PVE.Workspace', {
 
 Ext.define('PVE.ConsoleWorkspace', {
     extend: 'PVE.Workspace',
-    requires: [          
-       'PVE.KVMConsole'
-    ],
 
     alias: ['widget.pveConsoleWorkspace'],
 
-    title: 'Proxmox Console',
+    title: gettext('Console'),
 
     initComponent : function() {
        var me = this;
@@ -116,27 +114,57 @@ Ext.define('PVE.ConsoleWorkspace', {
        var param = Ext.Object.fromQueryString(window.location.search);
        var consoleType = me.consoleType || param.console;
 
+       param.novnc = (param.novnc === '1') ? true : false;
+
        var content;
        if (consoleType === 'kvm') {
            me.title = "VM " + param.vmid;
+           if (param.vmname) {
+               me.title += " ('" + param.vmname + "')";
+           }
            content = {
                xtype: 'pveKVMConsole',
+               novnc: param.novnc,
                vmid: param.vmid,
                nodename: param.node,
+               vmname: param.vmname,
+               toplevel: true
+           };
+       } else if (consoleType === 'lxc') {
+           me.title = "CT " + param.vmid;
+           if (param.vmname) {
+               me.title += " ('" + param.vmname + "')";
+           }
+           content = {
+               xtype: 'pveLxcConsole',
+               novnc: param.novnc,
+               vmid: param.vmid,
+               nodename: param.node,
+               vmname: param.vmname,
                toplevel: true
            };
        } else if (consoleType === 'shell') {
-           me.title = "node " + param.node + " - Proxmox Shell";
+           me.title = "node '" + param.node + "'";
+           content = {
+               xtype: 'pveShell',
+               novnc: param.novnc,
+               nodename: param.node,
+               toplevel: true
+           };
+       } else if (consoleType === 'upgrade') {
+           me.title = Ext.String.format(gettext('System upgrade on node {0}'), "'" + param.node + "'");
            content = {
                xtype: 'pveShell',
+               novnc: param.novnc,
                nodename: param.node,
+               ugradeSystem: true,
                toplevel: true
            };
        } else {
            content = {
                border: false,
                bodyPadding: 10,
-               html: 'Error: No such console type' 
+               html: gettext('Error') + ': No such console type'
            };
        }
 
@@ -152,34 +180,29 @@ Ext.define('PVE.ConsoleWorkspace', {
 
 Ext.define('PVE.StdWorkspace', {
     extend: 'PVE.Workspace',
-    requires: [          
-       'Ext.History',
-       'Ext.state.*',
-       'Ext.selection.*',
-       'PVE.form.ViewSelector', 
-       'PVE.data.ResourceStore',
-       'PVE.tree.ResourceTree'
-    ],
 
     alias: ['widget.pveStdWorkspace'],
 
     // private
-    defaultContent: {
-       title: 'Nothing selected',
-       region: 'center'
-    },
-
     setContent: function(comp) {
        var me = this;
        
-       if (!comp) { 
-           comp = me.defaultContent;
-       }
-
        var cont = me.child('#content');
        cont.removeAll(true);
-       cont.add(comp);
-       cont.doLayout();
+
+       if (comp) {
+           PVE.Utils.setErrorMask(cont, false);
+           comp.border = false;
+           cont.add(comp);
+           cont.doLayout();
+       } 
+       // else {
+           // TODO: display something useful
+
+           // Note:: error mask has wrong zindex, so we do not
+           // use that - see bug 114
+           // PVE.Utils.setErrorMask(cont, 'nothing selected');
+       //}
     },
 
     selectById: function(nodeid) {
@@ -188,6 +211,12 @@ Ext.define('PVE.StdWorkspace', {
        tree.selectById(nodeid);
     },
 
+    checkVmMigration: function(record) {
+       var me = this;
+       var tree = me.down('pveResourceTree');
+       tree.checkVmMigration(record);
+    },
+
     onLogin: function(loginData) {
        var me = this;
 
@@ -195,6 +224,15 @@ Ext.define('PVE.StdWorkspace', {
 
        if (loginData) {
            PVE.data.ResourceStore.startUpdate();
+
+           PVE.Utils.API2Request({
+               url: '/version',
+               method: 'GET',
+               success: function(response) {
+                   PVE.VersionInfo = response.result.data;
+                   me.updateVersionInfo();
+               }
+           });
        }
     },
 
@@ -204,39 +242,42 @@ Ext.define('PVE.StdWorkspace', {
        var ui = me.query('#userinfo')[0];
 
        if (PVE.UserName) {
-           ui.update('<div class="x-unselectable" style="white-space:nowrap;">You are logged in as "' + PVE.UserName + '"</div>');
+           var msg =  Ext.String.format(gettext("You are logged in as {0}"), "'" + PVE.UserName + "'");
+           ui.update('<div class="x-unselectable" style="white-space:nowrap;">' + msg + '</div>');
        } else {
            ui.update('');
        }
        ui.doLayout();
     },
 
+    updateVersionInfo: function() {
+       var me = this;
+
+       var ui = me.query('#versioninfo')[0];
+
+       if (PVE.VersionInfo) {
+           var version = PVE.VersionInfo.version + '-' + PVE.VersionInfo.release + '/' +
+               PVE.VersionInfo.repoid;
+           ui.update('<span class="x-panel-header-text">Proxmox Virtual Environment<br>' + gettext('Version') + ': ' + version + "</span>");
+       } else {
+           ui.update('<span class="x-panel-header-text">Proxmox Virtual Environment</span>');
+       }
+       ui.doLayout();
+    },
+
     initComponent : function() {
        var me = this;
 
        Ext.History.init();
-       Ext.state.Manager.setProvider(Ext.create('PVE.StateProvider'));
 
-       //document.title = ;
+       var sprovider = Ext.create('PVE.StateProvider');
+       Ext.state.Manager.setProvider(sprovider);
 
-       var selview = new PVE.form.ViewSelector({
-           listeners: {
-               select: function(combo, records) { 
-                   if (records && records.length) {
-                       var view = combo.getViewFilter();
-                       combo.up('pveResourceTree').setViewFilter(view);
-                   }
-               }
-           }
-       });
+       var selview = new PVE.form.ViewSelector({});
 
        var rtree = Ext.createWidget('pveResourceTree', {
-           width: 200,
-           region: 'west',
-           margins: '0 0 0 5',
-           split: true,
            viewFilter: selview.getViewFilter(),
-           tbar: [ ' ', selview ],
+           flex: 1,
            selModel: new Ext.selection.TreeModel({
                listeners: {
                    selectionchange: function(sm, selected) {
@@ -245,20 +286,24 @@ Ext.define('PVE.StdWorkspace', {
                            root: 'PVE.dc.Config',
                            node: 'PVE.node.Config',
                            qemu: 'PVE.qemu.Config',
-                           storage: 'PVE.storage.Browser'
+                           lxc: 'PVE.lxc.Config',
+                           storage: 'PVE.storage.Browser',
+                           pool: 'pvePoolConfig'
                        };
                        
                        if (selected.length > 0) {
                            var n = selected[0];
-                           comp = { 
+                           comp = {
                                xtype: tlckup[n.data.type || 'root'] || 
-                                   'PVE.panel.Config',
+                                   'pvePanelConfig',
                                layout: { type: 'fit' },
                                showSearch: (n.data.id === 'root') ||
                                    Ext.isDefined(n.data.groupbyid),
                                pveSelNode: n,
+                               workspace: me,
                                viewFilter: selview.getViewFilter()
                            };
+                           PVE.curSelectedNode = n;
                        }
 
                        me.setContent(comp);
@@ -267,6 +312,47 @@ Ext.define('PVE.StdWorkspace', {
            })
        });
 
+       selview.on('select', function(combo, records) { 
+           if (records && records.length) {
+               var view = combo.getViewFilter();
+               rtree.setViewFilter(view);
+           }
+       });
+
+       var caps = sprovider.get('GuiCap');
+
+       var createVM = Ext.createWidget('button', {
+           pack: 'end',
+           margins: '3 5 0 0',
+           baseCls: 'x-btn',
+           text: gettext("Create VM"),
+           disabled: !caps.vms['VM.Allocate'],
+           handler: function() {
+               var wiz = Ext.create('PVE.qemu.CreateWizard', {});
+               wiz.show();
+           } 
+       });
+
+       var createCT = Ext.createWidget('button', {
+           pack: 'end',
+           margins: '3 5 0 0',
+           baseCls: 'x-btn',
+           text: gettext("Create CT"),
+           disabled: !caps.vms['VM.Allocate'],
+           handler: function() {
+               var wiz = Ext.create('PVE.lxc.CreateWizard', {});
+               wiz.show();
+           } 
+       });
+
+       sprovider.on('statechange', function(sp, key, value) {
+           if (key === 'GuiCap' && value) {
+               caps = value;
+               createVM.setDisabled(!caps.vms['VM.Allocate']);
+               createCT.setDisabled(!caps.vms['VM.Allocate']);
+           }
+       });
+
        Ext.apply(me, {
            layout: { type: 'border' },
            border: false,
@@ -293,7 +379,8 @@ Ext.define('PVE.StdWorkspace', {
                        {
                            minWidth: 200,
                            flex: 1,
-                           html: '<span class="x-panel-header-text">Proxmox Virtual Environment<br>Version ' + PVE.GUIVersion + "</span>"
+                           id: 'versioninfo',
+                           html: '<span class="x-panel-header-text">Proxmox Virtual Environment</span>'
                        },
                        {
                            pack: 'end',
@@ -306,7 +393,7 @@ Ext.define('PVE.StdWorkspace', {
                            margins: '3 5 0 0',
                            xtype: 'button',
                            baseCls: 'x-btn',
-                           text: "Logout",
+                           text: gettext("Logout"),
                            handler: function() { 
                                PVE.data.ResourceStore.stopUpdate();
                                me.showLogin(); 
@@ -314,48 +401,36 @@ Ext.define('PVE.StdWorkspace', {
                                var rt = me.down('pveResourceTree');
                                rt.clearTree();
                            }
-                       },
-                       {
-                           pack: 'end',
-                           margins: '3 5 0 0',
-                           xtype: 'button',
-                           baseCls: 'x-btn',
-                           text: "Create VM",
-                           handler: function() {
-                               var wiz = Ext.create('PVE.qemu.CreateWizard', {});
-                               wiz.show();
-                           } 
-                       },
-                       {
-                           pack: 'end',
-                           margins: '3 5 0 0',
-                           xtype: 'button',
-                           baseCls: 'x-btn',
-                           text: "Create CT",
-                           handler: function() {
-                               var wiz = Ext.create('PVE.openvz.CreateWizard', {});
-                               wiz.show();
-                           } 
-                       }
+                       }, 
+                       createVM, 
+                       createCT
                    ]
                },
                {
                    region: 'center',
                    id: 'content',
-                   xtype: 'panel',
+                   xtype: 'container',
                    layout: { type: 'fit' },
                    border: false,
                    stateful: false,
-                   margins:'0 5 0 0',
-                   items: [ me.defaultContent ]
+                   margins: '0 5 0 0',
+                   items: []
+               },
+               {
+                   region: 'west',
+                   xtype: 'container',
+                   border: false,
+                   layout: { type: 'vbox', align: 'stretch' },
+                   margins: '0 0 0 5',
+                   split: true,
+                   width: 200,
+                   items: [ selview, rtree ]
                },
-               rtree,
                {
                    xtype: 'pveStatusPanel',
                    region: 'south',
                    margins:'0 5 5 5',
                    height: 200,       
-                   collapsible: true,
                    split:true
                }
            ]