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