]> git.proxmox.com Git - proxmox-backup.git/blob - www/Subscription.js
ui: code cleanup
[proxmox-backup.git] / www / Subscription.js
1 Ext.define('PBS.SubscriptionKeyEdit', {
2 extend: 'Proxmox.window.Edit',
3
4 title: gettext('Upload Subscription Key'),
5 width: 300,
6 autoLoad: true,
7
8 onlineHelp: 'getting_help',
9
10 items: {
11 xtype: 'textfield',
12 name: 'key',
13 value: '',
14 fieldLabel: gettext('Subscription Key'),
15 },
16 });
17
18 Ext.define('PBS.Subscription', {
19 extend: 'Proxmox.grid.ObjectGrid',
20 xtype: 'pbsSubscription',
21
22 title: gettext('Subscription'),
23 border: true,
24
25 onlineHelp: 'getting_help',
26
27 viewConfig: {
28 enableTextSelection: true,
29 },
30
31 initComponent: function() {
32 let me = this;
33
34 let reload = () => me.rstore.load();
35 let baseurl = '/nodes/localhost/subscription';
36
37 let rows = {
38 productname: {
39 header: gettext('Type'),
40 },
41 key: {
42 header: gettext('Subscription Key'),
43 },
44 status: {
45 header: gettext('Status'),
46 renderer: (value) => {
47 value = Ext.String.capitalize(value);
48 let message = me.getObjectValue('message');
49 if (message) {
50 return value + ": " + message;
51 }
52 return value;
53 },
54 },
55 message: {
56 visible: false,
57 },
58 serverid: {
59 header: gettext('Server ID'),
60 },
61 checktime: {
62 header: gettext('Last checked'),
63 renderer: Proxmox.Utils.render_timestamp,
64 },
65 nextduedate: {
66 header: gettext('Next due date'),
67 },
68 };
69
70 Ext.apply(me, {
71 url: `/api2/json${baseurl}`,
72 cwidth1: 170,
73 tbar: [
74 {
75 text: gettext('Upload Subscription Key'),
76 handler: function() {
77 let win = Ext.create('PBS.SubscriptionKeyEdit', {
78 url: '/api2/extjs/' + baseurl,
79 });
80 win.show();
81 win.on('destroy', reload);
82 },
83 },
84 {
85 text: gettext('Check'),
86 handler: function() {
87 Proxmox.Utils.API2Request({
88 params: { force: 1 },
89 url: baseurl,
90 method: 'POST',
91 waitMsgTarget: me,
92 failure: function(response, opts) {
93 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
94 },
95 callback: reload,
96 });
97 },
98 },
99 ],
100 rows: rows,
101 });
102
103 me.callParent();
104
105 reload();
106 },
107 });