]> git.proxmox.com Git - pmg-gui.git/blame - js/Subscription.js
dkim settings: improve label for signing domain source selection
[pmg-gui.git] / js / Subscription.js
CommitLineData
a10c81d9
DM
1Ext.define('PMG.SubscriptionKeyEdit', {
2 extend: 'Proxmox.window.Edit',
22b6f5db 3
a10c81d9
DM
4 title: gettext('Upload Subscription Key'),
5 width: 300,
6 autoLoad: true,
7
54fd9bd8
DM
8 onlineHelp: 'getting_help',
9
a10c81d9
DM
10 items: {
11 xtype: 'textfield',
12 name: 'key',
13 value: '',
c87d46fb
TL
14 fieldLabel: gettext('Subscription Key'),
15 },
a10c81d9
DM
16});
17
18Ext.define('PMG.Subscription', {
19 extend: 'Proxmox.grid.ObjectGrid',
20 xtype: 'pmgSubscription',
21
ad02dfe7
DC
22 title: gettext('Subscription'),
23
a151c079
DC
24 border: false,
25
28580cc2 26 onlineHelp: 'getting_help',
a10c81d9 27
562d589c 28 viewConfig: {
c87d46fb 29 enableTextSelection: true,
562d589c 30 },
a10c81d9 31
35241008 32 showReport: function() {
28eb60c0 33 let me = this;
35241008 34
28eb60c0
TL
35 const getReportFileName = function() {
36 let now = Ext.Date.format(new Date(), 'D-d-F-Y-G-i');
c87d46fb 37 return Proxmox.NodeName + '-report-' + now + '.txt';
35241008
DC
38 };
39
28eb60c0 40 let view = Ext.createWidget('component', {
35241008
DC
41 itemId: 'system-report-view',
42 scrollable: true,
43 style: {
35241008
DC
44 'white-space': 'pre',
45 'font-family': 'monospace',
c87d46fb
TL
46 padding: '5px',
47 },
35241008
DC
48 });
49
28eb60c0 50 let reportWindow = Ext.create('Ext.window.Window', {
35241008
DC
51 title: gettext('System Report'),
52 width: 1024,
53 height: 600,
54 layout: 'fit',
55 modal: true,
56 buttons: [
22b6f5db
TL
57 '->',
58 {
59 text: gettext('Download'),
60 handler: function() {
28eb60c0
TL
61 let fileContent = Ext.String.htmlDecode(reportWindow.getComponent('system-report-view').html);
62 let fileName = getReportFileName();
35241008 63
22b6f5db
TL
64 // Internet Explorer
65 if (window.navigator.msSaveOrOpenBlob) {
66 navigator.msSaveOrOpenBlob(new Blob([fileContent]), fileName);
67 } else {
28eb60c0 68 let element = document.createElement('a');
22b6f5db
TL
69 element.setAttribute('href', 'data:text/plain;charset=utf-8,'
70 + encodeURIComponent(fileContent));
71 element.setAttribute('download', fileName);
72 element.style.display = 'none';
73 document.body.appendChild(element);
74 element.click();
75 document.body.removeChild(element);
35241008 76 }
c87d46fb
TL
77 },
78 },
22b6f5db 79 ],
c87d46fb 80 items: view,
35241008
DC
81 });
82
83 Proxmox.Utils.API2Request({
84 url: '/api2/extjs/nodes/' + Proxmox.NodeName + '/report',
85 method: 'GET',
86 waitMsgTarget: me,
87 failure: function(response) {
88 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
89 },
90 success: function(response) {
28eb60c0 91 let report = Ext.htmlEncode(response.result.data);
35241008
DC
92 reportWindow.show();
93 view.update(report);
c87d46fb 94 },
35241008
DC
95 });
96 },
97
c87d46fb 98 initComponent: function() {
28eb60c0 99 let me = this;
a10c81d9 100
28eb60c0 101 const reload = function() {
a10c81d9
DM
102 me.rstore.load();
103 };
104
28eb60c0 105 let baseurl = `/nodes/${Proxmox.NodeName}/subscription`;
a10c81d9 106
28eb60c0
TL
107 let render_status = function(value) {
108 let message = me.getObjectValue('message');
a10c81d9
DM
109 if (message) {
110 return value + ": " + message;
111 }
112 return value;
113 };
114
28eb60c0 115 let rows = {
a10c81d9 116 productname: {
c87d46fb 117 header: gettext('Type'),
a10c81d9
DM
118 },
119 key: {
c87d46fb 120 header: gettext('Subscription Key'),
a10c81d9
DM
121 },
122 status: {
123 header: gettext('Status'),
c87d46fb 124 renderer: render_status,
a10c81d9
DM
125 },
126 message: {
c87d46fb 127 visible: false,
a10c81d9
DM
128 },
129 serverid: {
c87d46fb 130 header: gettext('Server ID'),
a10c81d9
DM
131 },
132 sockets: {
c87d46fb 133 header: gettext('Sockets'),
a10c81d9
DM
134 },
135 checktime: {
136 header: gettext('Last checked'),
c87d46fb 137 renderer: Proxmox.Utils.render_timestamp,
a10c81d9
DM
138 },
139 nextduedate: {
c87d46fb
TL
140 header: gettext('Next due date'),
141 },
a10c81d9
DM
142 };
143
144 Ext.apply(me, {
145 url: '/api2/json' + baseurl,
146 cwidth1: 170,
c87d46fb 147 tbar: [
a10c81d9
DM
148 {
149 text: gettext('Upload Subscription Key'),
150 handler: function() {
28eb60c0 151 let win = Ext.create('PMG.SubscriptionKeyEdit', {
c87d46fb 152 url: '/api2/extjs/' + baseurl,
28eb60c0 153 autoShow: true,
a10c81d9 154 });
a10c81d9 155 win.on('destroy', reload);
c87d46fb 156 },
a10c81d9 157 },
a5db7653
MA
158 {
159 text: gettext('Remove Subscription'),
160 xtype: 'proxmoxStdRemoveButton',
161 confirmMsg: gettext('Are you sure to remove the subscription key?'),
162 baseurl: baseurl,
163 dangerous: true,
164 selModel: false,
165 callback: reload,
166 },
a10c81d9
DM
167 {
168 text: gettext('Check'),
169 handler: function() {
170 Proxmox.Utils.API2Request({
171 params: { force: 1 },
172 url: baseurl,
173 method: 'POST',
174 waitMsgTarget: me,
175 failure: function(response, opts) {
176 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
177 },
c87d46fb 178 callback: reload,
a10c81d9 179 });
c87d46fb 180 },
35241008 181 },
51ef4bbe 182 '-',
35241008
DC
183 {
184 text: gettext('System Report'),
185 handler: function() {
c87d46fb
TL
186 Proxmox.Utils.checked_command(function() { me.showReport(); });
187 },
188 },
a10c81d9 189 ],
c87d46fb 190 rows: rows,
a10c81d9
DM
191 });
192
193 me.callParent();
194
195 reload();
c87d46fb 196 },
a10c81d9 197});