]>
Commit | Line | Data |
---|---|---|
658bfdff WB |
1 | Ext.define('Proxmox.panel.ACMEPluginView', { |
2 | extend: 'Ext.grid.Panel', | |
3 | alias: 'widget.pmxACMEPluginView', | |
4 | ||
5 | title: gettext('Challenge Plugins'), | |
6 | acmeUrl: undefined, | |
7 | ||
8 | controller: { | |
9 | xclass: 'Ext.app.ViewController', | |
10 | ||
11 | addPlugin: function() { | |
12 | let me = this; | |
13 | let view = me.getView(); | |
14 | Ext.create('Proxmox.window.ACMEPluginEdit', { | |
15 | acmeUrl: view.acmeUrl, | |
16 | url: `${view.acmeUrl}/plugins`, | |
17 | isCreate: true, | |
18 | apiCallDone: function() { | |
19 | me.reload(); | |
20 | }, | |
21 | }).show(); | |
22 | }, | |
23 | ||
24 | editPlugin: function() { | |
25 | let me = this; | |
26 | let view = me.getView(); | |
27 | let selection = view.getSelection(); | |
28 | if (selection.length < 1) return; | |
29 | let plugin = selection[0].data.plugin; | |
30 | Ext.create('Proxmox.window.ACMEPluginEdit', { | |
31 | acmeUrl: view.acmeUrl, | |
32 | url: `${view.acmeUrl}/plugins/${plugin}`, | |
33 | apiCallDone: function() { | |
34 | me.reload(); | |
35 | }, | |
36 | }).show(); | |
37 | }, | |
38 | ||
39 | reload: function() { | |
40 | let me = this; | |
41 | let view = me.getView(); | |
42 | view.getStore().rstore.load(); | |
43 | }, | |
44 | }, | |
45 | ||
46 | minHeight: 150, | |
47 | emptyText: gettext('No Plugins configured'), | |
48 | ||
49 | columns: [ | |
50 | { | |
51 | dataIndex: 'plugin', | |
52 | text: gettext('Plugin'), | |
53 | renderer: Ext.String.htmlEncode, | |
54 | flex: 1, | |
55 | }, | |
56 | { | |
57 | dataIndex: 'api', | |
58 | text: 'API', | |
59 | renderer: Ext.String.htmlEncode, | |
60 | flex: 1, | |
61 | }, | |
62 | ], | |
63 | ||
64 | listeners: { | |
65 | itemdblclick: 'editPlugin', | |
66 | }, | |
67 | ||
68 | store: { | |
69 | type: 'diff', | |
70 | autoDestroy: true, | |
71 | autoDestroyRstore: true, | |
72 | rstore: { | |
73 | type: 'update', | |
74 | storeid: 'proxmox-acme-plugins', | |
75 | model: 'proxmox-acme-plugins', | |
76 | autoStart: true, | |
77 | filters: item => !!item.data.api, | |
78 | }, | |
79 | sorters: 'plugin', | |
80 | }, | |
81 | ||
82 | initComponent: function() { | |
83 | let me = this; | |
84 | ||
85 | if (!me.acmeUrl) { | |
86 | throw "no acmeUrl given"; | |
87 | } | |
88 | me.url = `${me.acmeUrl}/plugins`; | |
89 | ||
90 | Ext.apply(me, { | |
91 | tbar: [ | |
92 | { | |
93 | xtype: 'proxmoxButton', | |
94 | text: gettext('Add'), | |
95 | handler: 'addPlugin', | |
96 | selModel: false, | |
97 | }, | |
98 | { | |
99 | xtype: 'proxmoxButton', | |
100 | text: gettext('Edit'), | |
101 | handler: 'editPlugin', | |
102 | disabled: true, | |
103 | }, | |
104 | { | |
105 | xtype: 'proxmoxStdRemoveButton', | |
106 | callback: 'reload', | |
107 | baseurl: `${me.acmeUrl}/plugins`, | |
108 | }, | |
109 | ], | |
110 | }); | |
111 | ||
112 | me.callParent(); | |
113 | ||
114 | me.store.rstore.proxy.setUrl(`/api2/json/${me.acmeUrl}/plugins`); | |
115 | }, | |
116 | }); |