]> git.proxmox.com Git - proxmox-widget-toolkit.git/blame - node/HostsView.js
use eslint and execute as check target
[proxmox-widget-toolkit.git] / node / HostsView.js
CommitLineData
3cf341e9
DC
1Ext.define('Proxmox.node.HostsView', {
2 extend: 'Ext.panel.Panel',
3 xtype: 'proxmoxNodeHostsView',
4
5 reload: function() {
05a977a2 6 let me = this;
3cf341e9
DC
7 me.store.load();
8 },
9
10 tbar: [
11 {
12 text: gettext('Save'),
13 disabled: true,
14 itemId: 'savebtn',
15 handler: function() {
05a977a2 16 let view = this.up('panel');
3cf341e9
DC
17 Proxmox.Utils.API2Request({
18 params: {
05a977a2
TL
19 digest: view.digest,
20 data: view.down('#hostsfield').getValue(),
3cf341e9
DC
21 },
22 method: 'POST',
05a977a2
TL
23 url: '/nodes/' + view.nodename + '/hosts',
24 waitMsgTarget: view,
3cf341e9 25 success: function(response, opts) {
05a977a2 26 view.reload();
3cf341e9
DC
27 },
28 failure: function(response, opts) {
29 Ext.Msg.alert('Error', response.htmlStatus);
01031528 30 },
3cf341e9 31 });
01031528 32 },
3cf341e9
DC
33 },
34 {
35 text: gettext('Revert'),
36 disabled: true,
37 itemId: 'resetbtn',
38 handler: function() {
05a977a2
TL
39 let view = this.up('panel');
40 view.down('#hostsfield').reset();
01031528
TL
41 },
42 },
3cf341e9
DC
43 ],
44
45 layout: 'fit',
46
47 items: [
48 {
49 xtype: 'textarea',
50 itemId: 'hostsfield',
51 fieldStyle: {
52 'font-family': 'monospace',
01031528 53 'white-space': 'pre',
3cf341e9
DC
54 },
55 listeners: {
56 dirtychange: function(ta, dirty) {
05a977a2
TL
57 let view = this.up('panel');
58 view.down('#savebtn').setDisabled(!dirty);
59 view.down('#resetbtn').setDisabled(!dirty);
01031528
TL
60 },
61 },
62 },
3cf341e9
DC
63 ],
64
01031528 65 initComponent: function() {
05a977a2 66 let me = this;
3cf341e9
DC
67
68 if (!me.nodename) {
69 throw "no node name specified";
70 }
71
72 me.store = Ext.create('Ext.data.Store', {
73 proxy: {
74 type: 'proxmox',
75 url: "/api2/json/nodes/" + me.nodename + "/hosts",
01031528 76 },
3cf341e9
DC
77 });
78
79 me.callParent();
80
81 Proxmox.Utils.monStoreErrors(me, me.store);
82
83 me.mon(me.store, 'load', function(store, records, success) {
84 if (!success || records.length < 1) {
85 return;
86 }
87 me.digest = records[0].data.digest;
05a977a2 88 let data = records[0].data.data;
3cf341e9
DC
89 me.down('#hostsfield').setValue(data);
90 me.down('#hostsfield').resetOriginalValue();
91 });
92
93 me.reload();
01031528 94 },
3cf341e9 95});