]> git.proxmox.com Git - pmg-gui.git/blame - js/RelayDomains.js
utils: anchor regex expression
[pmg-gui.git] / js / RelayDomains.js
CommitLineData
20c9b1f2
DM
1Ext.define('pmg-domains', {
2 extend: 'Ext.data.Model',
c87d46fb
TL
3 fields: ['domain', 'comment'],
4 idProperty: 'domain',
20c9b1f2
DM
5});
6
7Ext.define('PMG.RelayDomains', {
8 extend: 'Ext.grid.GridPanel',
9 alias: ['widget.pmgRelayDomains'],
10
e4b744c3
SI
11 baseurl: '/config/domains',
12 domain_desc: gettext('Relay Domain'),
13
14 onlineHelp: 'pmgconfig_mailproxy_relay_domains',
15
c87d46fb 16 initComponent: function() {
20c9b1f2
DM
17 var me = this;
18
19 var store = new Ext.data.Store({
20 model: 'pmg-domains',
21 sorters: {
22 property: 'domain',
18722987 23 direction: 'ASC',
e4b744c3
SI
24 },
25 proxy: {
26 type: 'proxmox',
c87d46fb 27 url: '/api2/json' + me.baseurl,
e4b744c3 28 },
20c9b1f2
DM
29 });
30
31 var reload = function() {
32 store.load();
33 };
34
d80ddaf7 35 me.selModel = Ext.create('Ext.selection.RowModel', {});
20c9b1f2 36
b357057e 37 var remove_btn = Ext.createWidget('proxmoxStdRemoveButton', {
d80ddaf7 38 selModel: me.selModel,
e4b744c3 39 baseurl: me.baseurl,
b357057e 40 callback: reload,
c87d46fb 41 waitMsgTarget: me,
20c9b1f2
DM
42 });
43
597c19d8
DM
44 var run_editor = function() {
45 var rec = me.selModel.getSelection()[0];
46 if (!rec) {
47 return;
48 }
49
50 var config = {
e4b744c3
SI
51 url: '/api2/extjs' + me.baseurl + '/' + rec.data.domain,
52 onlineHelp: me.onlineHelp,
597c19d8 53 method: 'PUT',
e4b744c3 54 subject: me.domain_desc,
597c19d8
DM
55 items: [
56 {
57 xtype: 'displayfield',
58 name: 'domain',
c87d46fb 59 fieldLabel: me.domain_desc,
597c19d8
DM
60 },
61 {
62 xtype: 'textfield',
63 name: 'comment',
c87d46fb
TL
64 fieldLabel: gettext("Comment"),
65 },
66 ],
597c19d8
DM
67 };
68
69 var win = Ext.createWidget('proxmoxWindowEdit', config);
70
71 win.load();
72 win.on('destroy', reload);
73 win.show();
74 };
75
20c9b1f2 76 var tbar = [
597c19d8
DM
77 {
78 xtype: 'proxmoxButton',
79 text: gettext('Edit'),
80 disabled: true,
81 selModel: me.selModel,
c87d46fb 82 handler: run_editor,
597c19d8 83 },
20c9b1f2
DM
84 {
85 text: gettext('Create'),
86 handler: function() {
87 var config = {
88 method: 'POST',
e4b744c3
SI
89 url: '/api2/extjs' + me.baseurl,
90 onlineHelp: me.onlineHelp,
18b5b6ad 91 isCreate: true,
20c9b1f2 92 subject: gettext("Relay Domain"),
597c19d8
DM
93 items: [
94 {
95 xtype: 'proxmoxtextfield',
96 name: 'domain',
c87d46fb 97 fieldLabel: me.domain_desc,
597c19d8
DM
98 },
99 {
100 xtype: 'proxmoxtextfield',
101 name: 'comment',
c87d46fb
TL
102 fieldLabel: gettext("Comment"),
103 },
104 ],
20c9b1f2
DM
105 };
106
107 var win = Ext.createWidget('proxmoxWindowEdit', config);
597c19d8 108
20c9b1f2
DM
109 win.on('destroy', reload);
110 win.show();
c87d46fb 111 },
20c9b1f2 112 },
c87d46fb 113 remove_btn,
4703989a
DC
114 '->',
115 {
116 xtype: 'pmgFilterField',
117 filteredFields: ['domain', 'comment'],
118 },
20c9b1f2
DM
119 ];
120
2f8fe1a3 121 Proxmox.Utils.monStoreErrors(me, store, true);
20c9b1f2
DM
122
123 Ext.apply(me, {
124 store: store,
20c9b1f2 125 tbar: tbar,
01e0e5e5 126 run_editor: run_editor,
20c9b1f2 127 viewConfig: {
c87d46fb 128 trackOver: false,
20c9b1f2
DM
129 },
130 columns: [
131 {
e4b744c3 132 header: me.domain_desc,
20c9b1f2
DM
133 width: 200,
134 sortable: true,
c87d46fb 135 dataIndex: 'domain',
20c9b1f2
DM
136 },
137 {
138 header: gettext('Comment'),
139 sortable: false,
140 renderer: Ext.String.htmlEncode,
141 dataIndex: 'comment',
c87d46fb
TL
142 flex: 1,
143 },
20c9b1f2
DM
144 ],
145 listeners: {
597c19d8 146 itemdblclick: run_editor,
c87d46fb
TL
147 activate: reload,
148 },
20c9b1f2
DM
149 });
150
151 me.callParent();
c87d46fb 152 },
20c9b1f2 153});