]> git.proxmox.com Git - proxmox-backup.git/blob - www/Subscription.js
ui: system config: fix leading whitespace in translation
[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: 320,
6 autoLoad: true,
7
8 onlineHelp: 'get_help',
9
10 items: {
11 xtype: 'textfield',
12 labelWidth: 120,
13 name: 'key',
14 value: '',
15 fieldLabel: gettext('Subscription Key'),
16 },
17 });
18
19 Ext.define('PBS.Subscription', {
20 extend: 'Proxmox.grid.ObjectGrid',
21 xtype: 'pbsSubscription',
22
23 title: gettext('Subscription'),
24 border: true,
25
26 onlineHelp: 'get_help',
27 tools: [PBS.Utils.get_help_tool("get_help")],
28
29 viewConfig: {
30 enableTextSelection: true,
31 },
32
33 showReport: function() {
34 var me = this;
35
36 var getReportFileName = function() {
37 var now = Ext.Date.format(new Date(), 'D-d-F-Y-G-i');
38 return `${me.nodename}-pbs-report-${now}.txt`;
39 };
40
41 var view = Ext.createWidget('component', {
42 itemId: 'system-report-view',
43 scrollable: true,
44 style: {
45 'white-space': 'pre',
46 'font-family': 'monospace',
47 padding: '5px',
48 },
49 });
50
51 let reportWindow;
52 reportWindow = Ext.create('Ext.window.Window', {
53 title: gettext('System Report'),
54 width: 1024,
55 height: 600,
56 layout: 'fit',
57 modal: true,
58 buttons: [
59 '->',
60 {
61 text: gettext('Download'),
62 handler: function() {
63 let fileContent = Ext.htmlDecode(reportWindow.getComponent('system-report-view').html);
64 let fileName = getReportFileName();
65
66 let dataUrl = `data:text/plain;charset=utf-8,${encodeURIComponent(fileContent)}`;
67
68 Proxmox.Utils.downloadAsFile(dataUrl, fileName);
69 },
70 },
71 ],
72 items: view,
73 });
74
75 Proxmox.Utils.API2Request({
76 url: '/api2/extjs/nodes/' + me.nodename + '/report',
77 method: 'GET',
78 waitMsgTarget: me,
79 success: function(response) {
80 var report = Ext.htmlEncode(response.result.data);
81 reportWindow.show();
82 view.update(report);
83 },
84 });
85 },
86
87 initComponent: function() {
88 let me = this;
89
90 let reload = () => me.rstore.load();
91 let baseurl = '/nodes/localhost/subscription';
92
93 let rows = {
94 productname: {
95 header: gettext('Type'),
96 },
97 key: {
98 header: gettext('Subscription Key'),
99 },
100 status: {
101 header: gettext('Status'),
102 renderer: (value) => {
103 value = Ext.String.capitalize(value);
104 let message = me.getObjectValue('message');
105 if (message) {
106 return value + ": " + message;
107 }
108 return value;
109 },
110 },
111 message: {
112 visible: false,
113 },
114 serverid: {
115 header: gettext('Server ID'),
116 },
117 checktime: {
118 header: gettext('Last checked'),
119 renderer: Proxmox.Utils.render_timestamp,
120 },
121 nextduedate: {
122 header: gettext('Next due date'),
123 },
124 signature: {
125 header: gettext('Signed/Offline'),
126 renderer: (value) => {
127 if (value) {
128 return gettext('Yes');
129 } else {
130 return gettext('No');
131 }
132 },
133 },
134 };
135
136 Ext.apply(me, {
137 url: `/api2/json${baseurl}`,
138 cwidth1: 170,
139 tbar: [
140 {
141 text: gettext('Upload Subscription Key'),
142 iconCls: 'fa fa-ticket',
143 handler: function() {
144 Ext.create('PBS.SubscriptionKeyEdit', {
145 url: '/api2/extjs/' + baseurl,
146 autoShow: true,
147 listeners: {
148 destroy: () => reload(),
149 },
150 });
151 },
152 },
153 {
154 text: gettext('Check'),
155 iconCls: 'fa fa-check-square-o',
156 handler: function() {
157 Proxmox.Utils.API2Request({
158 params: { force: 1 },
159 url: baseurl,
160 method: 'POST',
161 waitMsgTarget: me,
162 callback: reload,
163 });
164 },
165 },
166 {
167 text: gettext('Remove Subscription'),
168 xtype: 'proxmoxStdRemoveButton',
169 confirmMsg: gettext('Are you sure you want to remove the subscription key?'),
170 baseurl: baseurl,
171 dangerous: true,
172 selModel: false,
173 callback: reload,
174 iconCls: 'fa fa-trash-o',
175 },
176 '-',
177 {
178 text: gettext('System Report'),
179 iconCls: 'fa fa-stethoscope',
180 handler: function() {
181 Proxmox.Utils.checked_command(function() { me.showReport(); });
182 },
183 },
184 ],
185 rows: rows,
186 });
187
188 me.callParent();
189
190 reload();
191 },
192 });