[pve-devel] [PATCH widget-toolkit v2 1/1] add node/HostsView
Dominik Csapak
d.csapak at proxmox.com
Wed Sep 5 10:54:48 CEST 2018
to show/edit /etc/hosts
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes from v1:
* correct if(!succes || records.length) condition, not && records.length
Makefile | 1 +
node/HostsView.js | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 96 insertions(+)
create mode 100644 node/HostsView.js
diff --git a/Makefile b/Makefile
index ad820a2..20dba60 100644
--- a/Makefile
+++ b/Makefile
@@ -45,6 +45,7 @@ JSSRC= \
node/NetworkEdit.js \
node/NetworkView.js \
node/DNSEdit.js \
+ node/HostsView.js \
node/DNSView.js \
node/Tasks.js \
node/ServiceView.js \
diff --git a/node/HostsView.js b/node/HostsView.js
new file mode 100644
index 0000000..2978324
--- /dev/null
+++ b/node/HostsView.js
@@ -0,0 +1,95 @@
+Ext.define('Proxmox.node.HostsView', {
+ extend: 'Ext.panel.Panel',
+ xtype: 'proxmoxNodeHostsView',
+
+ reload: function() {
+ var me = this;
+ me.store.load();
+ },
+
+ tbar: [
+ {
+ text: gettext('Save'),
+ disabled: true,
+ itemId: 'savebtn',
+ handler: function() {
+ var me = this.up('panel');
+ Proxmox.Utils.API2Request({
+ params: {
+ digest: me.digest,
+ data: me.down('#hostsfield').getValue()
+ },
+ method: 'POST',
+ url: '/nodes/' + me.nodename + '/hosts',
+ waitMsgTarget: me,
+ success: function(response, opts) {
+ me.reload();
+ },
+ failure: function(response, opts) {
+ Ext.Msg.alert('Error', response.htmlStatus);
+ }
+ });
+ }
+ },
+ {
+ text: gettext('Revert'),
+ disabled: true,
+ itemId: 'resetbtn',
+ handler: function() {
+ var me = this.up('panel');
+ me.down('#hostsfield').reset();
+ }
+ }
+ ],
+
+ layout: 'fit',
+
+ items: [
+ {
+ xtype: 'textarea',
+ itemId: 'hostsfield',
+ fieldStyle: {
+ 'font-family': 'monospace',
+ 'white-space': 'pre'
+ },
+ listeners: {
+ dirtychange: function(ta, dirty) {
+ var me = this.up('panel');
+ me.down('#savebtn').setDisabled(!dirty);
+ me.down('#resetbtn').setDisabled(!dirty);
+ }
+ }
+ }
+ ],
+
+ initComponent : function() {
+ var me = this;
+
+ if (!me.nodename) {
+ throw "no node name specified";
+ }
+
+ me.store = Ext.create('Ext.data.Store', {
+ proxy: {
+ type: 'proxmox',
+ url: "/api2/json/nodes/" + me.nodename + "/hosts",
+ }
+ });
+
+ me.callParent();
+
+ Proxmox.Utils.monStoreErrors(me, me.store);
+
+ me.mon(me.store, 'load', function(store, records, success) {
+ if (!success || records.length < 1) {
+ return;
+ }
+ me.digest = records[0].data.digest;
+ var data = records[0].data.data;
+ me.down('#hostsfield').setValue(data);
+ me.down('#hostsfield').resetOriginalValue();
+ });
+
+ me.reload();
+ }
+});
--
2.11.0
More information about the pve-devel
mailing list