]>
Commit | Line | Data |
---|---|---|
ff735274 | 1 | /*global Proxmox*/ |
96feba89 DM |
2 | Ext.define('pmg-mynetworks', { |
3 | extend: 'Ext.data.Model', | |
4 | fields: [ 'cidr', 'comment' ], | |
5 | proxy: { | |
6 | type: 'proxmox', | |
7 | url: "/api2/json/config/mynetworks" | |
8 | }, | |
9 | idProperty: 'cidr' | |
10 | }); | |
11 | ||
12 | Ext.define('PMG.MyNetworks', { | |
13 | extend: 'Ext.grid.GridPanel', | |
14 | alias: ['widget.pmgMyNetworks'], | |
15 | ||
16 | initComponent : function() { | |
17 | var me = this; | |
18 | ||
19 | var store = new Ext.data.Store({ | |
20 | model: 'pmg-mynetworks', | |
21 | sorters: { | |
22 | property: 'cidr', | |
23 | order: 'DESC' | |
24 | } | |
25 | }); | |
26 | ||
27 | var reload = function() { | |
28 | store.load(); | |
29 | }; | |
30 | ||
31 | me.selModel = Ext.create('Ext.selection.RowModel', {}); | |
32 | ||
b357057e | 33 | var remove_btn = Ext.createWidget('proxmoxStdRemoveButton', { |
96feba89 | 34 | selModel: me.selModel, |
b357057e DM |
35 | baseurl: '/config/mynetworks', |
36 | callback: reload, | |
37 | waitMsgTarget: me | |
96feba89 DM |
38 | }); |
39 | ||
40 | var run_editor = function() { | |
41 | var rec = me.selModel.getSelection()[0]; | |
42 | if (!rec) { | |
43 | return; | |
44 | } | |
45 | ||
46 | var config = { | |
47 | url: "/api2/extjs/config/mynetworks/" + rec.data.cidr, | |
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() { | |
de0ebd99 | 82 | /*jslint confusion: true*/ |
96feba89 DM |
83 | var config = { |
84 | method: 'POST', | |
85 | url: "/api2/extjs/config/mynetworks", | |
18b5b6ad | 86 | isCreate: true, |
96feba89 DM |
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 | }; | |
de0ebd99 | 101 | /*jslint confusion: false*/ |
96feba89 DM |
102 | |
103 | var win = Ext.createWidget('proxmoxWindowEdit', config); | |
104 | ||
105 | win.on('destroy', reload); | |
106 | win.show(); | |
107 | } | |
108 | }, | |
109 | remove_btn | |
110 | ]; | |
111 | ||
2f8fe1a3 | 112 | Proxmox.Utils.monStoreErrors(me, store, true); |
96feba89 DM |
113 | |
114 | Ext.apply(me, { | |
115 | store: store, | |
116 | tbar: tbar, | |
117 | viewConfig: { | |
118 | trackOver: false | |
119 | }, | |
120 | columns: [ | |
121 | { | |
1000bed1 | 122 | header: gettext('Trusted Network'), |
96feba89 DM |
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 | }); |