also the keys to display from the lxc config where updated as some from OpenVZ times where used.
Signed-off-by: Thomas Lamprecht <t.lampre...@proxmox.com> --- www/mobile/LXCSummary.js | 179 ++-------------------------------------------- www/mobile/QemuSummary.js | 175 ++------------------------------------------ 2 files changed, 12 insertions(+), 342 deletions(-) diff --git a/www/mobile/LXCSummary.js b/www/mobile/LXCSummary.js index 15f8005..a73f350 100644 --- a/www/mobile/LXCSummary.js +++ b/www/mobile/LXCSummary.js @@ -1,5 +1,5 @@ Ext.define('PVE.LXCSummary', { - extend: 'PVE.Page', + extend: 'PVE.VMSummaryBase', alias: 'widget.pveLXCSummary', statics: { @@ -8,123 +8,12 @@ Ext.define('PVE.LXCSummary', { } }, - nodename: undefined, - vmid: undefined, + vmtype: 'lxc', - vm_command: function(cmd, params) { - var me = this; - - PVE.Utils.API2Request({ - params: params, - url: '/nodes/' + me.nodename + '/lxc/' + me.vmid + '/status/' + cmd, - method: 'POST', - success: function(response, opts) { - var upid = response.result.data; - var page = 'nodes/' + me.nodename + '/tasks/' + upid; - PVE.Workspace.gotoPage(page); - }, - failure: function(response, opts) { - Ext.Msg.alert('Error', response.htmlStatus); - } - }); - }, - - config: { - items: [ - { - xtype: 'pveTitleBar' - }, - { - xtype: 'component', - itemId: 'ctstatus', - styleHtmlContent: true, - style: 'background-color:white;', - tpl: [ - '<table style="margin-bottom:0px;">', - - '<tr><td>Status:</td><td>{status}</td></tr>', - '<tr><td>Memory:</td><td>{[this.meminfo(values)]}</td></tr>', - '<tr><td>CPU:</td><td>{[this.cpuinfo(values)]}</td></tr>', - '<tr><td>Uptime:</td><td>{[PVE.Utils.format_duration_long'+ - '(values.uptime)]}</td></tr>', - - '</table>', - { - meminfo: function(values) { - if (!Ext.isDefined(values.mem)) { - return '-'; - } - return PVE.Utils.format_size(values.mem || 0) + " of " + - PVE.Utils.format_size(values.maxmem); - }, - cpuinfo: function(values) { - if (!Ext.isDefined(values.cpu)) { - return '-'; - } - var per = values.cpu * 100; - return per.toFixed(2) + "% (" + values.cpus + " CPUs)"; - } - } - ] - }, - { - xtype: 'component', - padding: 5, - html: gettext('Configuration') - }, - { - xtype: 'container', - scrollable: 'both', - flex: 1, - styleHtmlContent: true, - itemId: 'ctconfig', - style: 'background-color:white;white-space:pre;', - tpl: [ - '<table style="margin-bottom:0px;">', - '<tpl for=".">', - '<tr><td>{key}</td><td>{value}</td></tr>', - '</tpl>', - '</table>' - ] - } - ] - }, - - reload: function() { - var me = this; - - var cti = me.down('#ctstatus'); - - var error_handler = function(response) { - me.setMasked({ xtype: 'loadmask', message: response.htmlStatus} ); - }; - - PVE.Utils.API2Request({ - url: '/nodes/' + me.nodename + '/lxc/' + me.vmid + '/status/current', - method: 'GET', - success: function(response) { - var d = response.result.data; - cti.setData(d); - }, - failure: error_handler - }); - - var ctc = me.down('#ctconfig'); - - PVE.Utils.API2Request({ - url: '/nodes/' + me.nodename + '/lxc/' + me.vmid + '/config', - method: 'GET', - success: function(response) { - var d = response.result.data; - var names = ['hostname', 'memory', 'swap', 'cpus', 'ostemplate', - 'ip_address', 'nameserver', 'searchdomain', - 'netif']; - var kv = PVE.Workspace.obj_to_kv(d, names); - ctc.setData(kv); - }, - failure: error_handler - }); - }, + config_keys: [ + 'hostname','ostype', , 'memory', 'swap', 'cpulimit', 'cpuunits', + /^net\d+/, 'rootfs', /^mp\d+/, 'nameserver', 'searchdomain','description' + ], initialize: function() { var me = this; @@ -139,62 +28,6 @@ Ext.define('PVE.LXCSummary', { me.down('titlebar').setTitle('CT: ' + me.vmid); - me.down('pveMenuButton').setMenuItems([ - { - text: gettext('Start'), - handler: function() { - me.vm_command("start", {}); - } - }, - { - text: gettext('Suspend'), - handler: function() { - me.vm_command("suspend", {}); - } - }, - { - text: gettext('Resume'), - handler: function() { - me.vm_command("resume", {}); - } - }, - { - text: gettext('Shutdown'), - handler: function() { - me.vm_command("shutdown", {}); - } - }, - { - text: gettext('Stop'), - handler: function() { - me.vm_command("stop", {}); - } - }, - { - text: gettext('Migrate'), - handler: function() { - PVE.Workspace.gotoPage('nodes/' + me.nodename + '/lxc/' - + me.vmid + '/migrate'); - } - }, - { - text: gettext('Console'), - handler: function() { - PVE.Utils.openConsoleWindow('html5', 'lxc', me.vmid, - me.nodename); - } - }, - { - text: gettext('Spice'), - handler: function() { - PVE.Utils.openConsoleWindow('vv', 'lxc', me.vmid, - me.nodename); - } - } - ]); - - me.reload(); - this.callParent(); } }); diff --git a/www/mobile/QemuSummary.js b/www/mobile/QemuSummary.js index ad72460..6cbaba1 100644 --- a/www/mobile/QemuSummary.js +++ b/www/mobile/QemuSummary.js @@ -1,5 +1,5 @@ Ext.define('PVE.QemuSummary', { - extend: 'PVE.Page', + extend: 'PVE.VMSummaryBase', alias: 'widget.pveQemuSummary', statics: { @@ -8,122 +8,12 @@ Ext.define('PVE.QemuSummary', { } }, - nodename: undefined, - vmid: undefined, + vmtype: 'qemu', - vm_command: function(cmd, params) { - var me = this; - - PVE.Utils.API2Request({ - params: params, - url: '/nodes/' + me.nodename + '/qemu/' + me.vmid + '/status/' + cmd, - method: 'POST', - success: function(response, opts) { - var upid = response.result.data; - var page = 'nodes/' + me.nodename + '/tasks/' + upid; - PVE.Workspace.gotoPage(page); - }, - failure: function(response, opts) { - Ext.Msg.alert('Error', response.htmlStatus); - } - }); - }, - - config: { - items: [ - { - xtype: 'pveTitleBar' - }, - { - xtype: 'component', - itemId: 'vmstatus', - styleHtmlContent: true, - style: 'background-color:white;', - tpl: [ - '<table style="margin-bottom:0px;">', - '<tr><td>Status:</td><td>{qmpstatus}</td></tr>', - '<tr><td>Memory:</td><td>{[this.meminfo(values)]}</td></tr>', - '<tr><td>CPU:</td><td>{[this.cpuinfo(values)]}</td></tr>', - '<tr><td>Uptime:</td><td>{[PVE.Utils.format_duration_long(values.uptime)]}</td></tr>', - '</table>', - { - meminfo: function(values) { - if (!Ext.isDefined(values.mem)) { - return '-'; - } - return PVE.Utils.format_size(values.mem || 0) + " of " + - PVE.Utils.format_size(values.maxmem); - }, - cpuinfo: function(values) { - if (!Ext.isDefined(values.cpu)) { - return '-'; - } - var per = values.cpu * 100; - return per.toFixed(2) + "% (" + values.cpus + " CPUs)"; - } - } - ] - }, - { - xtype: 'component', - cls: 'dark', - padding: 5, - html: gettext('Configuration') - }, - { - xtype: 'container', - scrollable: 'both', - flex: 1, - styleHtmlContent: true, - itemId: 'vmconfig', - style: 'background-color:white;white-space:pre', - tpl: [ - '<table style="margin-bottom:0px;">', - '<tpl for=".">', - '<tr><td>{key}</td><td>{value}</td></tr>', - '</tpl>', - '</table>' - ] - } - ] - }, - - reload: function() { - var me = this; - - var vmi = me.down('#vmstatus'); - - var error_handler = function(response) { - me.setMasked({ xtype: 'loadmask', message: response.htmlStatus} ); - }; - - PVE.Utils.API2Request({ - url: '/nodes/' + me.nodename + '/qemu/' + me.vmid + '/status/current', - method: 'GET', - success: function(response) { - var d = response.result.data; - vmi.setData(d); - }, - failure: error_handler - }); - - var vmc = me.down('#vmconfig'); - - PVE.Utils.API2Request({ - url: '/nodes/' + me.nodename + '/qemu/' + me.vmid + '/config', - method: 'GET', - success: function(response) { - var d = response.result.data; - var names = ['name', 'memory', 'sockets', 'cores', 'ostype', - 'bootdisk', /^net\d+/, - /^ide\d+/, /^virtio\d+/, /^sata\d+/, - /^scsi\d+/, /^unused\d+/ ]; - var kv = PVE.Workspace.obj_to_kv(d, names); - vmc.setData(kv); - }, - failure: error_handler - }); - }, + config_keys: [ + 'name', 'memory', 'sockets', 'cores', 'ostype', 'bootdisk', /^net\d+/, + /^ide\d+/, /^virtio\d+/, /^sata\d+/, /^scsi\d+/, /^unused\d+/ + ], initialize: function() { var me = this; @@ -138,59 +28,6 @@ Ext.define('PVE.QemuSummary', { me.down('titlebar').setTitle('VM: ' + me.vmid); - me.down('pveMenuButton').setMenuItems([ - { - text: gettext('Start'), - handler: function() { - me.vm_command("start", {}); - } - }, - { - text: gettext('Suspend'), - handler: function() { - me.vm_command("suspend", {}); - } - }, - { - text: gettext('Resume'), - handler: function() { - me.vm_command("resume", {}); - } - }, - { - text: gettext('Shutdown'), - handler: function() { - me.vm_command("shutdown", {}); - } - }, - { - text: gettext('Stop'), - handler: function() { - me.vm_command("stop", {}); - } - }, - { - text: gettext('Migrate'), - handler: function() { - PVE.Workspace.gotoPage('nodes/' + me.nodename + '/qemu/' + me.vmid + '/migrate'); - } - }, - { - text: gettext('Console'), - handler: function() { - PVE.Utils.openConsoleWindow('html5', 'kvm', me.vmid, me.nodename); - } - }, - { - text: gettext('Spice'), - handler: function() { - PVE.Utils.openConsoleWindow('vv', 'kvm', me.vmid, me.nodename); - } - } - ]); - - me.reload(); - this.callParent(); } }); -- 2.1.4 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel