]>
Commit | Line | Data |
---|---|---|
1 | Ext.define('pmg-mynetworks', { | |
2 | extend: 'Ext.data.Model', | |
3 | fields: ['cidr', 'comment'], | |
4 | proxy: { | |
5 | type: 'proxmox', | |
6 | url: "/api2/json/config/mynetworks", | |
7 | }, | |
8 | idProperty: 'cidr', | |
9 | }); | |
10 | ||
11 | Ext.define('PMG.MyNetworks', { | |
12 | extend: 'Ext.grid.GridPanel', | |
13 | alias: ['widget.pmgMyNetworks'], | |
14 | ||
15 | initComponent: function() { | |
16 | var me = this; | |
17 | ||
18 | var store = new Ext.data.Store({ | |
19 | model: 'pmg-mynetworks', | |
20 | sorters: { | |
21 | property: 'cidr', | |
22 | direction: 'ASC', | |
23 | }, | |
24 | }); | |
25 | ||
26 | var reload = function() { | |
27 | store.load(); | |
28 | }; | |
29 | ||
30 | me.selModel = Ext.create('Ext.selection.RowModel', {}); | |
31 | ||
32 | var remove_btn = Ext.createWidget('proxmoxStdRemoveButton', { | |
33 | selModel: me.selModel, | |
34 | baseurl: '/config/mynetworks', | |
35 | callback: reload, | |
36 | waitMsgTarget: me, | |
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, | |
47 | onlineHelp: 'pmgconfig_mailproxy_networks', | |
48 | method: 'PUT', | |
49 | subject: gettext("Trusted Network"), | |
50 | items: [ | |
51 | { | |
52 | xtype: 'displayfield', | |
53 | name: 'cidr', | |
54 | fieldLabel: 'CIDR', | |
55 | }, | |
56 | { | |
57 | xtype: 'textfield', | |
58 | name: 'comment', | |
59 | fieldLabel: gettext("Comment"), | |
60 | }, | |
61 | ], | |
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, | |
77 | handler: run_editor, | |
78 | }, | |
79 | { | |
80 | text: gettext('Create'), | |
81 | handler: function() { | |
82 | var config = { | |
83 | method: 'POST', | |
84 | url: "/api2/extjs/config/mynetworks", | |
85 | onlineHelp: 'pmgconfig_mailproxy_networks', | |
86 | isCreate: true, | |
87 | subject: gettext("Trusted Network"), | |
88 | items: [ | |
89 | { | |
90 | xtype: 'proxmoxtextfield', | |
91 | name: 'cidr', | |
92 | fieldLabel: 'CIDR', | |
93 | }, | |
94 | { | |
95 | xtype: 'proxmoxtextfield', | |
96 | name: 'comment', | |
97 | fieldLabel: gettext("Comment"), | |
98 | }, | |
99 | ], | |
100 | }; | |
101 | ||
102 | var win = Ext.createWidget('proxmoxWindowEdit', config); | |
103 | ||
104 | win.on('destroy', reload); | |
105 | win.show(); | |
106 | }, | |
107 | }, | |
108 | remove_btn, | |
109 | ]; | |
110 | ||
111 | Proxmox.Utils.monStoreErrors(me, store, true); | |
112 | ||
113 | Ext.apply(me, { | |
114 | store: store, | |
115 | tbar: tbar, | |
116 | run_editor: run_editor, | |
117 | viewConfig: { | |
118 | trackOver: false, | |
119 | }, | |
120 | columns: [ | |
121 | { | |
122 | header: gettext('Trusted Network'), | |
123 | width: 200, | |
124 | sortable: true, | |
125 | dataIndex: 'cidr', | |
126 | }, | |
127 | { | |
128 | header: gettext('Comment'), | |
129 | sortable: false, | |
130 | renderer: Ext.String.htmlEncode, | |
131 | dataIndex: 'comment', | |
132 | flex: 1, | |
133 | }, | |
134 | ], | |
135 | listeners: { | |
136 | itemdblclick: run_editor, | |
137 | activate: reload, | |
138 | }, | |
139 | }); | |
140 | ||
141 | me.callParent(); | |
142 | }, | |
143 | }); |