From 9baa96806ab932de731330d7c012d9c7d79244cb Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 13 Jun 2013 12:53:51 +0200 Subject: [PATCH] popup dialog to remind user about subscriptions --- www/manager/Utils.js | 33 +++++++++++++++++++++++++++++++++ www/manager/dc/Support.js | 2 +- www/manager/node/APT.js | 4 ++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/www/manager/Utils.js b/www/manager/Utils.js index d5de2e2e..509b6294 100644 --- a/www/manager/Utils.js +++ b/www/manager/Utils.js @@ -107,6 +107,8 @@ Ext.define('PVE.Utils', { statics: { 'p': gettext('Premium') }, + noSubKeyHtml: 'You do not have a valid subscription for this server. Please visit www.proxmox.com to get a list of available options.', + kvm_ostypes: { other: gettext('Other OS types'), wxp: 'Microsoft Windows XP/2003', @@ -429,6 +431,37 @@ Ext.define('PVE.Utils', { statics: { } }, + checked_command: function(orig_cmd) { + PVE.Utils.API2Request({ + url: '/nodes/localhost/subscription', + method: 'GET', + //waitMsgTarget: me, + failure: function(response, opts) { + Ext.Msg.alert('Error', response.htmlStatus); + }, + success: function(response, opts) { + var data = response.result.data; + + if (data.status !== 'Active') { + Ext.Msg.show({ + title: 'No valid subscription', + icon: Ext.Msg.WARNING, + msg: PVE.Utils.noSubKeyHtml, + buttons: Ext.Msg.OK, + callback: function(btn) { + if (btn !== 'ok') { + return; + } + orig_cmd(); + } + }); + } else { + orig_cmd(); + } + } + }); + }, + task_desc_table: { vncproxy: [ 'VM/CT', gettext('Console') ], vncshell: [ '', gettext('Shell') ], diff --git a/www/manager/dc/Support.js b/www/manager/dc/Support.js index c54cb3d6..bcdae79b 100644 --- a/www/manager/dc/Support.js +++ b/www/manager/dc/Support.js @@ -2,7 +2,7 @@ Ext.define('PVE.dc.Support', { extend: 'Ext.panel.Panel', alias: 'widget.pveDcSupport', - invalidHtml: '

No valid subscription

You do not have a valid subscription for this server. Please visit www.proxmox.com to get a list of available options.', + invalidHtml: '

No valid subscription

' + PVE.Utils.noSubKeyHtml, communityHtml: 'Please use the public community forum for any questions.', diff --git a/www/manager/node/APT.js b/www/manager/node/APT.js index bcf604bc..ea16a073 100644 --- a/www/manager/node/APT.js +++ b/www/manager/node/APT.js @@ -73,7 +73,7 @@ Ext.define('PVE.node.APT', { var update_btn = new Ext.Button({ text: gettext('Update'), handler: function(){ - apt_command('update'); + PVE.Utils.checked_command(function() { apt_command('update'); }); } }); @@ -84,7 +84,7 @@ Ext.define('PVE.node.APT', { return gettext('Are you sure you want to upgrade this node?'); }, handler: function(){ - apt_command('upgrade'); + PVE.Utils.checked_command(function() { apt_command('upgrade'); }); } }); -- 2.39.2