]>
Commit | Line | Data |
---|---|---|
96feba89 DM |
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 | order: 'DESC' | |
23 | } | |
24 | }); | |
25 | ||
26 | var reload = function() { | |
27 | store.load(); | |
28 | }; | |
29 | ||
30 | me.selModel = Ext.create('Ext.selection.RowModel', {}); | |
31 | ||
b357057e | 32 | var remove_btn = Ext.createWidget('proxmoxStdRemoveButton', { |
96feba89 | 33 | selModel: me.selModel, |
b357057e DM |
34 | baseurl: '/config/mynetworks', |
35 | callback: reload, | |
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, | |
47 | method: 'PUT', | |
48 | subject: gettext("Trusted Network"), | |
49 | items: [ | |
50 | { | |
51 | xtype: 'displayfield', | |
52 | name: 'cidr', | |
53 | fieldLabel: 'CIDR' | |
54 | }, | |
55 | { | |
56 | xtype: 'textfield', | |
57 | name: 'comment', | |
58 | fieldLabel: gettext("Comment") | |
59 | } | |
60 | ] | |
61 | }; | |
62 | ||
63 | var win = Ext.createWidget('proxmoxWindowEdit', config); | |
64 | ||
65 | win.load(); | |
66 | win.on('destroy', reload); | |
67 | win.show(); | |
68 | }; | |
69 | ||
70 | var tbar = [ | |
71 | { | |
72 | xtype: 'proxmoxButton', | |
73 | text: gettext('Edit'), | |
74 | disabled: true, | |
75 | selModel: me.selModel, | |
76 | handler: run_editor | |
77 | }, | |
78 | { | |
79 | text: gettext('Create'), | |
80 | handler: function() { | |
81 | var config = { | |
82 | method: 'POST', | |
83 | url: "/api2/extjs/config/mynetworks", | |
84 | create: true, | |
85 | subject: gettext("Trusted Network"), | |
86 | items: [ | |
87 | { | |
88 | xtype: 'proxmoxtextfield', | |
89 | name: 'cidr', | |
90 | fieldLabel: 'CIDR' | |
91 | }, | |
92 | { | |
93 | xtype: 'proxmoxtextfield', | |
94 | name: 'comment', | |
95 | fieldLabel: gettext("Comment") | |
96 | } | |
97 | ] | |
98 | }; | |
99 | ||
100 | var win = Ext.createWidget('proxmoxWindowEdit', config); | |
101 | ||
102 | win.on('destroy', reload); | |
103 | win.show(); | |
104 | } | |
105 | }, | |
106 | remove_btn | |
107 | ]; | |
108 | ||
2f8fe1a3 | 109 | Proxmox.Utils.monStoreErrors(me, store, true); |
96feba89 DM |
110 | |
111 | Ext.apply(me, { | |
112 | store: store, | |
113 | tbar: tbar, | |
114 | viewConfig: { | |
115 | trackOver: false | |
116 | }, | |
117 | columns: [ | |
118 | { | |
1000bed1 | 119 | header: gettext('Trusted Network'), |
96feba89 DM |
120 | width: 200, |
121 | sortable: true, | |
122 | dataIndex: 'cidr' | |
123 | }, | |
124 | { | |
125 | header: gettext('Comment'), | |
126 | sortable: false, | |
127 | renderer: Ext.String.htmlEncode, | |
128 | dataIndex: 'comment', | |
129 | flex: 1 | |
130 | } | |
131 | ], | |
132 | listeners: { | |
133 | itemdblclick: run_editor, | |
134 | activate: reload | |
135 | } | |
136 | }); | |
137 | ||
138 | me.callParent(); | |
139 | } | |
140 | }); |