[pve-devel] [PATCH manager 4/5 v2] dc options: Add apt notifications GUI checkbox
Dominic Jäger
d.jaeger at proxmox.com
Wed Jul 14 12:09:32 CEST 2021
Default value like pveupdate: Assume users with subscriptions want
notifications
Signed-off-by: Dominic Jäger <d.jaeger at proxmox.com>
---
v2: default depends on subscription status
www/manager6/dc/OptionView.js | 37 +++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/www/manager6/dc/OptionView.js b/www/manager6/dc/OptionView.js
index edae97ea..ec6ff1a3 100644
--- a/www/manager6/dc/OptionView.js
+++ b/www/manager6/dc/OptionView.js
@@ -90,6 +90,43 @@ Ext.define('PVE.dc.OptionView', {
vtype: 'proxmoxMail',
defaultValue: 'root@$hostname',
});
+ me.add_inputpanel_row('notify', gettext('Notification settings'), {
+ renderer: PVE.Utils.render_dc_ha_opts,
+ labelWidth: 120,
+ url: "/api2/extjs/cluster/options",
+ items: [
+ {
+ xtype: 'checkbox',
+ name: 'package_updates',
+ fieldLabel: gettext('Package updates'),
+ inputValue: 1,
+ uncheckedValue: 0, // behavior for undefined is different
+ listeners: {
+ added: function(checkbox) {
+ Proxmox.Utils.API2Request({
+ url: '/nodes/localhost/subscription',
+ method: 'GET',
+ failure: function(response) {
+ console.warn('Unable to load subscription status: '
+ + response.htmlStatus);
+ },
+ success: function(response) {
+ const data = response.result.data;
+ // This happens after the row is clicked and the edit window
+ // opens but before the setValue from add_inputpanel_row sets
+ // the value that is (potentially) saved in datacenter.cfg. If
+ // no value is in datacenter.cfg then the setValue from
+ // add_inputpanel_row does nothing. Then this setValue uses the
+ // subscription status as default like pveupdate.
+ checkbox.setValue(data.status ==='Active');
+ },
+ });
+ },
+ },
+ },
+ ],
+ });
+
me.add_text_row('mac_prefix', gettext('MAC address prefix'), {
deleteEmpty: true,
vtype: 'MacPrefix',
--
2.30.2
More information about the pve-devel
mailing list