]> git.proxmox.com Git - pmg-gui.git/blame - js/FetchmailView.js
user management: separate add/create and edit/remove buttons
[pmg-gui.git] / js / FetchmailView.js
CommitLineData
6a2f908e
DM
1Ext.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
16Ext.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 73 },
eb0a1118 74 '-',
30a27efa
DM
75 {
76 xtype: 'proxmoxButton',
77 text: gettext('Edit'),
78 disabled: true,
c87d46fb 79 handler: 'onEdit',
30a27efa 80 },
a989cf62
DM
81 {
82 xtype: 'proxmoxStdRemoveButton',
83 baseurl: '/config/fetchmail',
84 reference: 'removeBtn',
85 callback: 'onAfterRemove',
c87d46fb
TL
86 waitMsgTarget: true,
87 },
a989cf62
DM
88 ],
89
6a2f908e
DM
90 listeners: {
91 //scope: 'controller',
c87d46fb 92 itemdblclick: 'onEdit',
6a2f908e
DM
93 },
94
c37614f5 95 columns: [
6a2f908e
DM
96 {
97 header: gettext('Server'),
98 flex: 1,
99 renderer: Ext.String.htmlEncode,
c87d46fb 100 dataIndex: 'server',
6a2f908e 101 },
30a27efa
DM
102 {
103 header: gettext('Protocol'),
c87d46fb 104 dataIndex: 'protocol',
30a27efa 105 },
6a2f908e
DM
106 {
107 header: gettext('User name'),
108 flex: 1,
109 renderer: Ext.String.htmlEncode,
c87d46fb 110 dataIndex: 'user',
6a2f908e
DM
111 },
112 {
113 header: gettext('Deliver to'),
114 flex: 1,
115 renderer: Ext.String.htmlEncode,
c87d46fb 116 dataIndex: 'target',
6a2f908e
DM
117 },
118 {
119 header: gettext('Enabled'),
120 sortable: true,
121 renderer: Proxmox.Utils.format_boolean,
c87d46fb 122 dataIndex: 'enable',
6a2f908e
DM
123 },
124 {
125 header: gettext('Interval'),
c87d46fb
TL
126 dataIndex: 'interval',
127 },
128 ],
6a2f908e 129});