From a10c81d94d11de4e6e5d3dc0cdb65b4d1b9cd1e1 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 27 Sep 2017 12:55:54 +0200 Subject: [PATCH] add Subscription panel --- js/Makefile | 1 + js/NavigationTree.js | 8 ++-- js/Subscription.js | 110 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+), 4 deletions(-) create mode 100644 js/Subscription.js diff --git a/js/Makefile b/js/Makefile index 329f8fc..b69c4ac 100644 --- a/js/Makefile +++ b/js/Makefile @@ -29,6 +29,7 @@ JSSRC= \ NavigationTree.js \ RuleConfiguration.js \ SystemOptions.js \ + Subscription.js \ SystemConfiguration.js \ MailProxyRelaying.js \ MailProxyPorts.js \ diff --git a/js/NavigationTree.js b/js/NavigationTree.js index e3a0440..90a78d8 100644 --- a/js/NavigationTree.js +++ b/js/NavigationTree.js @@ -81,10 +81,10 @@ Ext.define('PMG.store.NavigationStore', { leaf: true, }, { - text: gettext('License'), - iconCls: 'fa fa-ticket', - path: 'pmgLicense', - leaf: true, + text: gettext('Subscription'), + iconCls: 'fa fa-support', + path: 'pmgSubscription', + leaf: true } ] }, diff --git a/js/Subscription.js b/js/Subscription.js new file mode 100644 index 0000000..b2e9aae --- /dev/null +++ b/js/Subscription.js @@ -0,0 +1,110 @@ +/*global Blob*/ +Ext.define('PMG.SubscriptionKeyEdit', { + extend: 'Proxmox.window.Edit', + + title: gettext('Upload Subscription Key'), + width: 300, + autoLoad: true, + + items: { + xtype: 'textfield', + name: 'key', + value: '', + fieldLabel: gettext('Subscription Key') + } +}); + +Ext.define('PMG.Subscription', { + extend: 'Proxmox.grid.ObjectGrid', + xtype: 'pmgSubscription', + + //o//nlineHelp: 'getting_help', + + features: [ {ftype: 'selectable'}], + + initComponent : function() { + var me = this; + + var reload = function() { + me.rstore.load(); + }; + + var baseurl = '/nodes/' + Proxmox.NodeName + '/subscription'; + + var render_status = function(value) { + + var message = me.getObjectValue('message'); + + if (message) { + return value + ": " + message; + } + return value; + }; + + var rows = { + productname: { + header: gettext('Type') + }, + key: { + header: gettext('Subscription Key') + }, + status: { + header: gettext('Status'), + renderer: render_status + }, + message: { + visible: false + }, + serverid: { + header: gettext('Server ID') + }, + sockets: { + header: gettext('Sockets') + }, + checktime: { + header: gettext('Last checked'), + renderer: Proxmox.Utils.render_timestamp + }, + nextduedate: { + header: gettext('Next due date') + } + }; + + Ext.apply(me, { + url: '/api2/json' + baseurl, + cwidth1: 170, + tbar: [ + { + text: gettext('Upload Subscription Key'), + handler: function() { + var win = Ext.create('PMG.SubscriptionKeyEdit', { + url: '/api2/extjs/' + baseurl + }); + win.show(); + win.on('destroy', reload); + } + }, + { + text: gettext('Check'), + handler: function() { + Proxmox.Utils.API2Request({ + params: { force: 1 }, + url: baseurl, + method: 'POST', + waitMsgTarget: me, + failure: function(response, opts) { + Ext.Msg.alert(gettext('Error'), response.htmlStatus); + }, + callback: reload + }); + } + } + ], + rows: rows + }); + + me.callParent(); + + reload(); + } +});