]> git.proxmox.com Git - pve-manager.git/commitdiff
gui: refactor {lxc, qemu}/Summary to panel/GuestSummary
authorDominik Csapak <d.csapak@proxmox.com>
Wed, 4 Dec 2019 12:41:33 +0000 (13:41 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 9 Dec 2019 13:20:37 +0000 (14:20 +0100)
they are both similar enough to have it only once

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
www/manager6/Makefile
www/manager6/lxc/Config.js
www/manager6/lxc/Summary.js [deleted file]
www/manager6/panel/GuestSummary.js [new file with mode: 0644]
www/manager6/qemu/Config.js
www/manager6/qemu/Summary.js [deleted file]

index a027e66bd0d12e4b189c416ec959188bc73a163c..a6926b5bbece63019e22ae9ac763c86a5b936eb2 100644 (file)
@@ -78,6 +78,7 @@ JSSRC=                                                        \
        panel/InfoWidget.js                             \
        panel/TemplateStatusView.js                     \
        panel/HealthWidget.js                           \
+       panel/GuestSummary.js                           \
        window/LoginWindow.js                           \
        window/Wizard.js                                \
        window/NotesEdit.js                             \
@@ -127,7 +128,6 @@ JSSRC=                                                      \
        window/BulkAction.js                            \
        window/Clone.js                                 \
        qemu/Monitor.js                                 \
-       qemu/Summary.js                                 \
        qemu/OSTypeEdit.js                              \
        qemu/OSDefaults.js                              \
        qemu/ProcessorEdit.js                           \
@@ -160,7 +160,6 @@ JSSRC=                                                      \
        qemu/IPConfigEdit.js                            \
        qemu/SystemEdit.js                              \
        qemu/AudioEdit.js                               \
-       lxc/Summary.js                                  \
        lxc/Network.js                                  \
        lxc/Resources.js                                \
        lxc/FeaturesEdit.js                             \
index a250b7cebc41866e1aacd0b45bd309dcd4ebef01..1b9ab048a0b34c29c492c975d006962610677a6d 100644 (file)
@@ -190,7 +190,7 @@ Ext.define('PVE.lxc.Config', {
            items: [
                {
                    title: gettext('Summary'),
-                   xtype: 'pveLxcSummary',
+                   xtype: 'pveGuestSummary',
                    iconCls: 'fa fa-book',
                    itemId: 'summary'
                }
diff --git a/www/manager6/lxc/Summary.js b/www/manager6/lxc/Summary.js
deleted file mode 100644 (file)
index 3eb0689..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-Ext.define('PVE.lxc.Summary', {
-    extend: 'Ext.panel.Panel',
-    alias: 'widget.pveLxcSummary',
-
-    scrollable: true,
-    bodyPadding: 5,
-
-    initComponent: function() {
-        var me = this;
-
-       var nodename = me.pveSelNode.data.node;
-       if (!nodename) {
-           throw "no node name specified";
-       }
-
-       var vmid = me.pveSelNode.data.vmid;
-       if (!vmid) {
-           throw "no VM ID specified";
-       }
-
-       if (!me.workspace) {
-           throw "no workspace specified";
-       }
-
-       if (!me.statusStore) {
-           throw "no status storage specified";
-       }
-
-       var template = !!me.pveSelNode.data.template;
-       var rstore = me.statusStore;
-
-       var width = template ? 1 : 0.5;
-       var items = [
-           {
-               xtype: template ? 'pveTemplateStatusView' : 'pveGuestStatusView',
-               responsiveConfig: {
-                   'width < 1900': {
-                       columnWidth: width
-                   },
-                   'width >= 1900': {
-                       columnWidth: width / 2
-                   }
-               },
-               itemId: 'gueststatus',
-               pveSelNode: me.pveSelNode,
-               rstore: rstore
-           },
-           {
-               xtype: 'pveNotesView',
-               maxHeight: 320,
-               itemId: 'notesview',
-               pveSelNode: me.pveSelNode,
-               responsiveConfig: {
-                   'width < 1900': {
-                       columnWidth: width
-                   },
-                   'width >= 1900': {
-                       columnWidth: width / 2
-                   }
-               }
-           }
-       ];
-
-       var rrdstore;
-       if (!template) {
-
-           rrdstore = Ext.create('Proxmox.data.RRDStore', {
-               rrdurl: "/api2/json/nodes/" + nodename + "/lxc/" + vmid + "/rrddata",
-               model: 'pve-rrd-guest'
-           });
-
-           items.push(
-               {
-                   xtype: 'proxmoxRRDChart',
-                   title: gettext('CPU usage'),
-                   pveSelNode: me.pveSelNode,
-                   fields: ['cpu'],
-                   fieldTitles: [gettext('CPU usage')],
-                   store: rrdstore
-               },
-               {
-                   xtype: 'proxmoxRRDChart',
-                   title: gettext('Memory usage'),
-                   pveSelNode: me.pveSelNode,
-                   fields: ['maxmem', 'mem'],
-                   fieldTitles: [gettext('Total'), gettext('RAM usage')],
-                   store: rrdstore
-               },
-               {
-                   xtype: 'proxmoxRRDChart',
-                   title: gettext('Network traffic'),
-                   pveSelNode: me.pveSelNode,
-                   fields: ['netin','netout'],
-                   store: rrdstore
-               },
-               {
-                   xtype: 'proxmoxRRDChart',
-                   title: gettext('Disk IO'),
-                   pveSelNode: me.pveSelNode,
-                   fields: ['diskread','diskwrite'],
-                   store: rrdstore
-               }
-           );
-
-       }
-
-       Ext.apply(me, {
-           tbar: [ '->', { xtype: 'proxmoxRRDTypeSelector' } ],
-           items: [
-               {
-                   xtype: 'container',
-                   layout: {
-                       type: 'column'
-                   },
-                   defaults: {
-                       minHeight: 320,
-                       padding: 5,
-                       plugins: 'responsive',
-                       responsiveConfig: {
-                           'width < 1900': {
-                               columnWidth: 1
-                           },
-                           'width >= 1900': {
-                               columnWidth: 0.5
-                           }
-                       }
-                   },
-                   items: items
-               }
-           ]
-       });
-
-       me.callParent();
-       if (!template) {
-           rrdstore.startUpdate();
-           me.on('destroy', rrdstore.stopUpdate);
-       }
-    }
-});
diff --git a/www/manager6/panel/GuestSummary.js b/www/manager6/panel/GuestSummary.js
new file mode 100644 (file)
index 0000000..e863386
--- /dev/null
@@ -0,0 +1,140 @@
+Ext.define('PVE.qemu.Summary', {
+    extend: 'Ext.panel.Panel',
+    xtype: 'pveGuestSummary',
+
+    scrollable: true,
+    bodyPadding: 5,
+
+    initComponent: function() {
+        var me = this;
+
+       var nodename = me.pveSelNode.data.node;
+       if (!nodename) {
+           throw "no node name specified";
+       }
+
+       var vmid = me.pveSelNode.data.vmid;
+       if (!vmid) {
+           throw "no VM ID specified";
+       }
+
+       if (!me.workspace) {
+           throw "no workspace specified";
+       }
+
+       if (!me.statusStore) {
+           throw "no status storage specified";
+       }
+
+       var type = me.pveSelNode.data.type;
+       var template = !!me.pveSelNode.data.template;
+       var rstore = me.statusStore;
+
+       var width = template ? 1 : 0.5;
+       var items = [
+           {
+               xtype: template ? 'pveTemplateStatusView' : 'pveGuestStatusView',
+               responsiveConfig: {
+                   'width < 1900': {
+                       columnWidth: width
+                   },
+                   'width >= 1900': {
+                       columnWidth: width / 2
+                   }
+               },
+               itemId: 'gueststatus',
+               pveSelNode: me.pveSelNode,
+               rstore: rstore
+           },
+           {
+               xtype: 'pveNotesView',
+               maxHeight: 330,
+               itemId: 'notesview',
+               pveSelNode: me.pveSelNode,
+               responsiveConfig: {
+                   'width < 1900': {
+                       columnWidth: width
+                   },
+                   'width >= 1900': {
+                       columnWidth: width / 2
+                   }
+               }
+           }
+       ];
+
+       var rrdstore;
+       if (!template) {
+
+           rrdstore = Ext.create('Proxmox.data.RRDStore', {
+               rrdurl: `/api2/json/nodes/${nodename}/${type}/${vmid}/rrddata`,
+               model: 'pve-rrd-guest'
+           });
+
+           items.push(
+               {
+                   xtype: 'proxmoxRRDChart',
+                   title: gettext('CPU usage'),
+                   pveSelNode: me.pveSelNode,
+                   fields: ['cpu'],
+                   fieldTitles: [gettext('CPU usage')],
+                   store: rrdstore
+               },
+               {
+                   xtype: 'proxmoxRRDChart',
+                   title: gettext('Memory usage'),
+                   pveSelNode: me.pveSelNode,
+                   fields: ['maxmem', 'mem'],
+                   fieldTitles: [gettext('Total'), gettext('RAM usage')],
+                   store: rrdstore
+               },
+               {
+                   xtype: 'proxmoxRRDChart',
+                   title: gettext('Network traffic'),
+                   pveSelNode: me.pveSelNode,
+                   fields: ['netin','netout'],
+                   store: rrdstore
+               },
+               {
+                   xtype: 'proxmoxRRDChart',
+                   title: gettext('Disk IO'),
+                   pveSelNode: me.pveSelNode,
+                   fields: ['diskread','diskwrite'],
+                   store: rrdstore
+               }
+           );
+
+       }
+
+       Ext.apply(me, {
+           tbar: [ '->', { xtype: 'proxmoxRRDTypeSelector' } ],
+           items: [
+               {
+                   xtype: 'container',
+                   layout: {
+                       type: 'column'
+                   },
+                   defaults: {
+                       minHeight: 330,
+                       padding: 5,
+                       plugins: 'responsive',
+                       responsiveConfig: {
+                           'width < 1900': {
+                               columnWidth: 1
+                           },
+                           'width >= 1900': {
+                               columnWidth: 0.5
+                           }
+                       }
+                   },
+                   items: items
+               }
+           ]
+       });
+
+       me.callParent();
+       if (!template) {
+           rrdstore.startUpdate();
+           me.on('destroy', rrdstore.stopUpdate);
+       }
+    }
+});
index ccf30a9b6901d414d7bc7f787a62f62b6af50e8f..439dd0b3c7d5a0db2ffe28bfe199c04524442d7f 100644 (file)
@@ -223,7 +223,7 @@ Ext.define('PVE.qemu.Config', {
            items: [
                {
                    title: gettext('Summary'),
-                   xtype: 'pveQemuSummary',
+                   xtype: 'pveGuestSummary',
                    iconCls: 'fa fa-book',
                    itemId: 'summary'
                }
diff --git a/www/manager6/qemu/Summary.js b/www/manager6/qemu/Summary.js
deleted file mode 100644 (file)
index 7810af0..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-Ext.define('PVE.qemu.Summary', {
-    extend: 'Ext.panel.Panel',
-    alias: 'widget.pveQemuSummary',
-
-    scrollable: true,
-    bodyPadding: 5,
-
-    initComponent: function() {
-        var me = this;
-
-       var nodename = me.pveSelNode.data.node;
-       if (!nodename) {
-           throw "no node name specified";
-       }
-
-       var vmid = me.pveSelNode.data.vmid;
-       if (!vmid) {
-           throw "no VM ID specified";
-       }
-
-       if (!me.workspace) {
-           throw "no workspace specified";
-       }
-
-       if (!me.statusStore) {
-           throw "no status storage specified";
-       }
-
-       var template = !!me.pveSelNode.data.template;
-       var rstore = me.statusStore;
-
-       var width = template ? 1 : 0.5;
-       var items = [
-           {
-               xtype: template ? 'pveTemplateStatusView' : 'pveGuestStatusView',
-               responsiveConfig: {
-                   'width < 1900': {
-                       columnWidth: width
-                   },
-                   'width >= 1900': {
-                       columnWidth: width / 2
-                   }
-               },
-               itemId: 'gueststatus',
-               pveSelNode: me.pveSelNode,
-               rstore: rstore
-           },
-           {
-               xtype: 'pveNotesView',
-               maxHeight: 330,
-               itemId: 'notesview',
-               pveSelNode: me.pveSelNode,
-               responsiveConfig: {
-                   'width < 1900': {
-                       columnWidth: width
-                   },
-                   'width >= 1900': {
-                       columnWidth: width / 2
-                   }
-               }
-           }
-       ];
-
-       var rrdstore;
-       if (!template) {
-
-           rrdstore = Ext.create('Proxmox.data.RRDStore', {
-               rrdurl: "/api2/json/nodes/" + nodename + "/qemu/" + vmid + "/rrddata",
-               model: 'pve-rrd-guest'
-           });
-
-           items.push(
-               {
-                   xtype: 'proxmoxRRDChart',
-                   title: gettext('CPU usage'),
-                   pveSelNode: me.pveSelNode,
-                   fields: ['cpu'],
-                   fieldTitles: [gettext('CPU usage')],
-                   store: rrdstore
-               },
-               {
-                   xtype: 'proxmoxRRDChart',
-                   title: gettext('Memory usage'),
-                   pveSelNode: me.pveSelNode,
-                   fields: ['maxmem', 'mem'],
-                   fieldTitles: [gettext('Total'), gettext('RAM usage')],
-                   store: rrdstore
-               },
-               {
-                   xtype: 'proxmoxRRDChart',
-                   title: gettext('Network traffic'),
-                   pveSelNode: me.pveSelNode,
-                   fields: ['netin','netout'],
-                   store: rrdstore
-               },
-               {
-                   xtype: 'proxmoxRRDChart',
-                   title: gettext('Disk IO'),
-                   pveSelNode: me.pveSelNode,
-                   fields: ['diskread','diskwrite'],
-                   store: rrdstore
-               }
-           );
-
-       }
-
-       Ext.apply(me, {
-           tbar: [ '->', { xtype: 'proxmoxRRDTypeSelector' } ],
-           items: [
-               {
-                   xtype: 'container',
-                   layout: {
-                       type: 'column'
-                   },
-                   defaults: {
-                       minHeight: 330,
-                       padding: 5,
-                       plugins: 'responsive',
-                       responsiveConfig: {
-                           'width < 1900': {
-                               columnWidth: 1
-                           },
-                           'width >= 1900': {
-                               columnWidth: 0.5
-                           }
-                       }
-                   },
-                   items: items
-               }
-           ]
-       });
-
-       me.callParent();
-       if (!template) {
-           rrdstore.startUpdate();
-           me.on('destroy', rrdstore.stopUpdate);
-       }
-    }
-});