]>
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 DC |
82 | /*jslint confusion: true*/ |
83 | /* create is function and bool */ | |
96feba89 DM |
84 | var config = { |
85 | method: 'POST', | |
86 | url: "/api2/extjs/config/mynetworks", | |
87 | create: true, | |
88 | subject: gettext("Trusted Network"), | |
89 | items: [ | |
90 | { | |
91 | xtype: 'proxmoxtextfield', | |
92 | name: 'cidr', | |
93 | fieldLabel: 'CIDR' | |
94 | }, | |
95 | { | |
96 | xtype: 'proxmoxtextfield', | |
97 | name: 'comment', | |
98 | fieldLabel: gettext("Comment") | |
99 | } | |
100 | ] | |
101 | }; | |
de0ebd99 | 102 | /*jslint confusion: false*/ |
96feba89 DM |
103 | |
104 | var win = Ext.createWidget('proxmoxWindowEdit', config); | |
105 | ||
106 | win.on('destroy', reload); | |
107 | win.show(); | |
108 | } | |
109 | }, | |
110 | remove_btn | |
111 | ]; | |
112 | ||
2f8fe1a3 | 113 | Proxmox.Utils.monStoreErrors(me, store, true); |
96feba89 DM |
114 | |
115 | Ext.apply(me, { | |
116 | store: store, | |
117 | tbar: tbar, | |
118 | viewConfig: { | |
119 | trackOver: false | |
120 | }, | |
121 | columns: [ | |
122 | { | |
1000bed1 | 123 | header: gettext('Trusted Network'), |
96feba89 DM |
124 | width: 200, |
125 | sortable: true, | |
126 | dataIndex: 'cidr' | |
127 | }, | |
128 | { | |
129 | header: gettext('Comment'), | |
130 | sortable: false, | |
131 | renderer: Ext.String.htmlEncode, | |
132 | dataIndex: 'comment', | |
133 | flex: 1 | |
134 | } | |
135 | ], | |
136 | listeners: { | |
137 | itemdblclick: run_editor, | |
138 | activate: reload | |
139 | } | |
140 | }); | |
141 | ||
142 | me.callParent(); | |
143 | } | |
144 | }); |