]>
Commit | Line | Data |
---|---|---|
6a2f908e DM |
1 | Ext.define('pmg-fetchmail-users', { |
2 | extend: 'Ext.data.Model', | |
3 | fields: [ | |
4 | 'id', 'protocol', 'port', 'server', 'user', 'pass', 'target', | |
5 | 'ssl', 'keep', | |
6 | { type: 'integer', name: 'interval' }, | |
c87d46fb | 7 | { type: 'boolean', name: 'enable' }, |
6a2f908e DM |
8 | ], |
9 | proxy: { | |
10 | type: 'proxmox', | |
c87d46fb | 11 | url: "/api2/json/config/fetchmail", |
6a2f908e | 12 | }, |
c87d46fb | 13 | idProperty: 'id', |
6a2f908e DM |
14 | }); |
15 | ||
16 | Ext.define('PMG.FetchmailView', { | |
17 | extend: 'Ext.grid.GridPanel', | |
18 | xtype: 'pmgFetchmailView', | |
19 | ||
c37614f5 DM |
20 | baseurl: '/api2/extjs/config/fetchmail', |
21 | ||
6a2f908e DM |
22 | store: { |
23 | autoDestroy: true, | |
24 | autoLoad: true, | |
c87d46fb | 25 | model: 'pmg-fetchmail-users', |
6a2f908e DM |
26 | }, |
27 | ||
28 | controller: { | |
29 | ||
30 | xclass: 'Ext.app.ViewController', | |
31 | ||
32 | init: function(view) { | |
33 | Proxmox.Utils.monStoreErrors(view, view.store, true); | |
c37614f5 DM |
34 | }, |
35 | ||
30a27efa DM |
36 | onAdd: function() { |
37 | var view = this.getView(); | |
38 | ||
39 | var win = Ext.create('PMG.FetchmailEdit', { | |
40 | url: view.baseurl, | |
c87d46fb | 41 | method: 'POST', |
30a27efa | 42 | }); |
131ba4f6 | 43 | win.on('destroy', function() { view.store.load(); }); |
30a27efa DM |
44 | win.show(); |
45 | }, | |
46 | ||
c37614f5 DM |
47 | onEdit: function() { |
48 | var view = this.getView(); | |
49 | ||
50 | var rec = view.selModel.getSelection()[0]; | |
51 | ||
52 | var win = Ext.create('PMG.FetchmailEdit', { | |
53 | userid: rec.data.id, | |
54 | url: view.baseurl + '/' + rec.data.id, | |
55 | method: 'PUT', | |
c87d46fb | 56 | autoLoad: true, |
c37614f5 DM |
57 | }); |
58 | win.on('destroy', function() { view.store.load(); }); | |
59 | win.show(); | |
a989cf62 DM |
60 | }, |
61 | ||
62 | onAfterRemove: function(btn, res) { | |
63 | var view = this.getView(); | |
64 | view.store.load(); | |
c87d46fb | 65 | }, |
6a2f908e DM |
66 | }, |
67 | ||
a989cf62 | 68 | tbar: [ |
30a27efa DM |
69 | { |
70 | text: gettext('Add'), | |
71 | reference: 'addBtn', | |
c87d46fb | 72 | handler: 'onAdd', |
30a27efa DM |
73 | }, |
74 | { | |
75 | xtype: 'proxmoxButton', | |
76 | text: gettext('Edit'), | |
77 | disabled: true, | |
c87d46fb | 78 | handler: 'onEdit', |
30a27efa | 79 | }, |
a989cf62 DM |
80 | { |
81 | xtype: 'proxmoxStdRemoveButton', | |
82 | baseurl: '/config/fetchmail', | |
83 | reference: 'removeBtn', | |
84 | callback: 'onAfterRemove', | |
c87d46fb TL |
85 | waitMsgTarget: true, |
86 | }, | |
a989cf62 DM |
87 | ], |
88 | ||
6a2f908e DM |
89 | listeners: { |
90 | //scope: 'controller', | |
c87d46fb | 91 | itemdblclick: 'onEdit', |
6a2f908e DM |
92 | }, |
93 | ||
c37614f5 | 94 | columns: [ |
6a2f908e DM |
95 | { |
96 | header: gettext('Server'), | |
97 | flex: 1, | |
98 | renderer: Ext.String.htmlEncode, | |
c87d46fb | 99 | dataIndex: 'server', |
6a2f908e | 100 | }, |
30a27efa DM |
101 | { |
102 | header: gettext('Protocol'), | |
c87d46fb | 103 | dataIndex: 'protocol', |
30a27efa | 104 | }, |
6a2f908e DM |
105 | { |
106 | header: gettext('User name'), | |
107 | flex: 1, | |
108 | renderer: Ext.String.htmlEncode, | |
c87d46fb | 109 | dataIndex: 'user', |
6a2f908e DM |
110 | }, |
111 | { | |
112 | header: gettext('Deliver to'), | |
113 | flex: 1, | |
114 | renderer: Ext.String.htmlEncode, | |
c87d46fb | 115 | dataIndex: 'target', |
6a2f908e DM |
116 | }, |
117 | { | |
118 | header: gettext('Enabled'), | |
119 | sortable: true, | |
120 | renderer: Proxmox.Utils.format_boolean, | |
c87d46fb | 121 | dataIndex: 'enable', |
6a2f908e DM |
122 | }, |
123 | { | |
124 | header: gettext('Interval'), | |
c87d46fb TL |
125 | dataIndex: 'interval', |
126 | }, | |
127 | ], | |
6a2f908e | 128 | }); |