[pve-devel] r6015 - in pve-manager/pve2: lib/PVE/API2 www/new/node
svn-commits at proxmox.com
svn-commits at proxmox.com
Tue May 24 12:36:28 CEST 2011
Author: dietmar
Date: 2011-05-24 12:36:28 +0200 (Tue, 24 May 2011)
New Revision: 6015
Modified:
pve-manager/pve2/lib/PVE/API2/Nodes.pm
pve-manager/pve2/www/new/node/NetworkView.js
Log:
improve network view (view/revert changes)
Modified: pve-manager/pve2/lib/PVE/API2/Nodes.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Nodes.pm 2011-05-24 07:39:58 UTC (rev 6014)
+++ pve-manager/pve2/lib/PVE/API2/Nodes.pm 2011-05-24 10:36:28 UTC (rev 6015)
@@ -120,6 +120,32 @@
}});
__PACKAGE__->register_method({
+ name => 'revert_network_changes',
+ path => 'network_changes',
+ method => 'DELETE',
+ permissions => {
+ path => '/nodes/{node}',
+ privs => [ 'Sys.Modify' ],
+ },
+ protected => 1,
+ description => "Revert network configuration changes.",
+ proxyto => 'node',
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ },
+ },
+ returns => { type => "null" },
+ code => sub {
+ my ($param) = @_;
+
+ unlink "/etc/network/interfaces.new";
+
+ return undef;
+ }});
+
+__PACKAGE__->register_method({
name => 'status',
path => 'status',
method => 'GET',
Modified: pve-manager/pve2/www/new/node/NetworkView.js
===================================================================
--- pve-manager/pve2/www/new/node/NetworkView.js 2011-05-24 07:39:58 UTC (rev 6014)
+++ pve-manager/pve2/www/new/node/NetworkView.js 2011-05-24 10:36:28 UTC (rev 6015)
@@ -1,5 +1,5 @@
Ext.define('PVE.node.NetworkView', {
- extend: 'Ext.grid.GridPanel',
+ extend: 'Ext.panel.Panel',
alias: ['widget.pveNodeNetworkView'],
@@ -36,8 +36,31 @@
var store = Ext.create('PVE.data.DiffStore', { rstore: rstore });
+ var view_changes = function() {
+ var changeitem = me.down('#changes');
+ PVE.Utils.API2Request({
+ url: '/nodes/' + nodename + '/network_changes',
+ failure: function(response, opts) {
+ changeitem.update('Error: ' + response.htmlStatus);
+ },
+ success: function(response, opts) {
+ var result = Ext.decode(response.responseText);
+ var data = result.data;
+ if (data === '')
+ data = "no changes"
+ changeitem.update("<pre>" + Ext.htmlEncode(data) + "</pre>");
+ }
+ });
+ };
+
+ var reload = function() {
+ rstore.load();
+ view_changes();
+ };
+
var run_editor = function() {
- var sm = me.getSelectionModel();
+ var grid = me.down('gridpanel');
+ var sm = grid.getSelectionModel();
var rec = sm.getLastSelected();
if (!rec)
return;
@@ -48,6 +71,7 @@
iftype: rec.data.type
});
win.show();
+ win.on('destroy', reload)
};
var edit_btn = new Ext.Button({
@@ -60,7 +84,8 @@
text: 'Delete',
disabled: true,
handler: function(){
- var sm = me.getSelectionModel();
+ var grid = me.down('gridpanel');
+ var sm = grid.getSelectionModel();
var rec = sm.getLastSelected();
if (!rec)
return;
@@ -73,6 +98,7 @@
method: 'DELETE',
callback: function() {
me.setLoading(false);
+ reload();
},
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
@@ -82,7 +108,8 @@
});
var set_button_status = function() {
- var sm = me.getSelectionModel();
+ var grid = me.down('gridpanel');
+ var sm = grid.getSelectionModel();
var rec = sm.getLastSelected();
edit_btn.setDisabled(!rec);
@@ -106,8 +133,7 @@
};
Ext.apply(me, {
- store: store,
- stateful: false,
+ layout: 'border',
tbar: [
{
text: 'Create',
@@ -127,6 +153,7 @@
iftype: 'bridge',
iface_default: 'vmbr' + next
});
+ win.on('destroy', reload)
win.show();
}
},
@@ -143,69 +170,109 @@
iftype: 'bond',
iface_default: 'bond' + next
});
+ win.on('destroy', reload)
win.show();
}
}
]
})
}, ' ',
+ {
+ text: 'Revert changes',
+ handler: function() {
+ me.setLoading(true, true);
+ PVE.Utils.API2Request({
+ url: '/nodes/' + nodename + '/network_changes',
+ method: 'DELETE',
+ callback: function() {
+ me.setLoading(false);
+ reload();
+ },
+ failure: function(response, opts) {
+ Ext.Msg.alert('Error', response.htmlStatus);
+ }
+ });
+ }
+ },
edit_btn,
del_btn
],
- columns: [
+ items: [
{
- header: 'Interface Name',
- width: 100,
- sortable: true,
- dataIndex: 'iface'
+ xtype: 'gridpanel',
+ stateful: false,
+ store: store,
+ region: 'center',
+ border: false,
+ columns: [
+ {
+ header: 'Interface Name',
+ width: 100,
+ sortable: true,
+ dataIndex: 'iface'
+ },
+ {
+ xtype: 'booleancolumn',
+ header: 'Active',
+ width: 80,
+ sortable: true,
+ dataIndex: 'active',
+ trueText: 'Yes',
+ falseText: 'No',
+ undefinedText: 'No'
+ },
+ {
+ xtype: 'booleancolumn',
+ header: 'Autostart',
+ width: 80,
+ sortable: true,
+ dataIndex: 'autostart',
+ trueText: 'Yes',
+ falseText: 'No',
+ undefinedText: 'No'
+ },
+ {
+ header: 'Ports/Slaves',
+ dataIndex: 'type',
+ renderer: render_ports
+ },
+ {
+ header: 'IP address',
+ sortable: true,
+ dataIndex: 'address'
+ },
+ {
+ header: 'Subnet mask',
+ sortable: true,
+ dataIndex: 'netmask'
+ },
+ {
+ header: 'Gateway',
+ sortable: true,
+ dataIndex: 'gateway'
+ }
+ ],
+ listeners: {
+ selectionchange: set_button_status,
+ itemdblclick: run_editor
+ }
},
{
- xtype: 'booleancolumn',
- header: 'Active',
- width: 80,
- sortable: true,
- dataIndex: 'active',
- trueText: 'Yes',
- falseText: 'No',
- undefinedText: 'No'
- },
- {
- xtype: 'booleancolumn',
- header: 'Autostart',
- width: 80,
- sortable: true,
- dataIndex: 'autostart',
- trueText: 'Yes',
- falseText: 'No',
- undefinedText: 'No'
- },
- {
- header: 'Ports/Slaves',
- dataIndex: 'type',
- renderer: render_ports
- },
- {
- header: 'IP address',
- sortable: true,
- dataIndex: 'address'
- },
- {
- header: 'Subnet mask',
- sortable: true,
- dataIndex: 'netmask'
- },
- {
- header: 'Gateway',
- sortable: true,
- dataIndex: 'gateway'
+ border: false,
+ region: 'south',
+ autoScroll: true,
+ itemId: 'changes',
+ tbar: [
+ 'Pending changes (please reboot to activate changes)'
+ ],
+ split: true,
+ bodyPadding: 5,
+ flex: 0.6,
+ html: "no changes"
}
],
listeners: {
- selectionchange: set_button_status,
- itemdblclick: run_editor,
- show: rstore.startUpdate,
- hide: rstore.stopUpdate,
- destroy: rstore.stopUpdate,
+ show: reload
}
});
More information about the pve-devel
mailing list