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