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