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