]>
Commit | Line | Data |
---|---|---|
96feba89 DM |
1 | Ext.define('pmg-mynetworks', { |
2 | extend: 'Ext.data.Model', | |
c87d46fb | 3 | fields: ['cidr', 'comment'], |
96feba89 DM |
4 | proxy: { |
5 | type: 'proxmox', | |
c87d46fb | 6 | url: "/api2/json/config/mynetworks", |
96feba89 | 7 | }, |
c87d46fb | 8 | idProperty: 'cidr', |
96feba89 DM |
9 | }); |
10 | ||
11 | Ext.define('PMG.MyNetworks', { | |
12 | extend: 'Ext.grid.GridPanel', | |
13 | alias: ['widget.pmgMyNetworks'], | |
14 | ||
c87d46fb | 15 | initComponent: function() { |
96feba89 DM |
16 | var me = this; |
17 | ||
18 | var store = new Ext.data.Store({ | |
19 | model: 'pmg-mynetworks', | |
20 | sorters: { | |
21 | property: 'cidr', | |
18722987 | 22 | direction: 'ASC', |
c87d46fb | 23 | }, |
96feba89 DM |
24 | }); |
25 | ||
26 | var reload = function() { | |
27 | store.load(); | |
28 | }; | |
29 | ||
30 | me.selModel = Ext.create('Ext.selection.RowModel', {}); | |
31 | ||
c87d46fb | 32 | var remove_btn = Ext.createWidget('proxmoxStdRemoveButton', { |
96feba89 | 33 | selModel: me.selModel, |
b357057e DM |
34 | baseurl: '/config/mynetworks', |
35 | callback: reload, | |
c87d46fb | 36 | waitMsgTarget: me, |
96feba89 DM |
37 | }); |
38 | ||
39 | var run_editor = function() { | |
40 | var rec = me.selModel.getSelection()[0]; | |
41 | if (!rec) { | |
42 | return; | |
43 | } | |
44 | ||
45 | var config = { | |
46 | url: "/api2/extjs/config/mynetworks/" + rec.data.cidr, | |
573a6e8b | 47 | onlineHelp: 'pmgconfig_mailproxy_networks', |
96feba89 DM |
48 | method: 'PUT', |
49 | subject: gettext("Trusted Network"), | |
50 | items: [ | |
51 | { | |
52 | xtype: 'displayfield', | |
53 | name: 'cidr', | |
d2d9df1a | 54 | fieldLabel: gettext('CIDR'), |
96feba89 DM |
55 | }, |
56 | { | |
57 | xtype: 'textfield', | |
58 | name: 'comment', | |
c87d46fb TL |
59 | fieldLabel: gettext("Comment"), |
60 | }, | |
61 | ], | |
96feba89 DM |
62 | }; |
63 | ||
64 | var win = Ext.createWidget('proxmoxWindowEdit', config); | |
65 | ||
66 | win.load(); | |
67 | win.on('destroy', reload); | |
68 | win.show(); | |
69 | }; | |
70 | ||
71 | var tbar = [ | |
72 | { | |
73 | xtype: 'proxmoxButton', | |
74 | text: gettext('Edit'), | |
75 | disabled: true, | |
76 | selModel: me.selModel, | |
c87d46fb | 77 | handler: run_editor, |
96feba89 DM |
78 | }, |
79 | { | |
80 | text: gettext('Create'), | |
81 | handler: function() { | |
82 | var config = { | |
83 | method: 'POST', | |
84 | url: "/api2/extjs/config/mynetworks", | |
573a6e8b | 85 | onlineHelp: 'pmgconfig_mailproxy_networks', |
18b5b6ad | 86 | isCreate: true, |
96feba89 DM |
87 | subject: gettext("Trusted Network"), |
88 | items: [ | |
89 | { | |
90 | xtype: 'proxmoxtextfield', | |
91 | name: 'cidr', | |
d2d9df1a | 92 | fieldLabel: gettext('CIDR'), |
96feba89 DM |
93 | }, |
94 | { | |
95 | xtype: 'proxmoxtextfield', | |
96 | name: 'comment', | |
c87d46fb TL |
97 | fieldLabel: gettext("Comment"), |
98 | }, | |
99 | ], | |
96feba89 DM |
100 | }; |
101 | ||
102 | var win = Ext.createWidget('proxmoxWindowEdit', config); | |
103 | ||
104 | win.on('destroy', reload); | |
105 | win.show(); | |
c87d46fb | 106 | }, |
96feba89 | 107 | }, |
c87d46fb | 108 | remove_btn, |
4703989a DC |
109 | '->', |
110 | { | |
111 | xtype: 'pmgFilterField', | |
112 | filteredFields: ['cidr', 'comment'], | |
113 | }, | |
96feba89 DM |
114 | ]; |
115 | ||
2f8fe1a3 | 116 | Proxmox.Utils.monStoreErrors(me, store, true); |
96feba89 DM |
117 | |
118 | Ext.apply(me, { | |
119 | store: store, | |
120 | tbar: tbar, | |
01e0e5e5 | 121 | run_editor: run_editor, |
96feba89 | 122 | viewConfig: { |
c87d46fb | 123 | trackOver: false, |
96feba89 DM |
124 | }, |
125 | columns: [ | |
126 | { | |
1000bed1 | 127 | header: gettext('Trusted Network'), |
96feba89 DM |
128 | width: 200, |
129 | sortable: true, | |
c87d46fb | 130 | dataIndex: 'cidr', |
96feba89 DM |
131 | }, |
132 | { | |
133 | header: gettext('Comment'), | |
134 | sortable: false, | |
135 | renderer: Ext.String.htmlEncode, | |
136 | dataIndex: 'comment', | |
c87d46fb TL |
137 | flex: 1, |
138 | }, | |
96feba89 DM |
139 | ], |
140 | listeners: { | |
141 | itemdblclick: run_editor, | |
c87d46fb TL |
142 | activate: reload, |
143 | }, | |
96feba89 DM |
144 | }); |
145 | ||
146 | me.callParent(); | |
c87d46fb | 147 | }, |
96feba89 | 148 | }); |