ui: datastore options: maintenance mode related refactorings

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-04-12 16:52:14 +02:00
parent 3c8f240712
commit 9c3b29bd8f
2 changed files with 8 additions and 6 deletions

View File

@ -25,9 +25,6 @@ Ext.define('PBS.Datastore.Options', {
init: function(view) { init: function(view) {
let me = this; let me = this;
me.callParent();
view.rows['maintenance-mode'].renderer =
(value) => PBS.Utils.renderMaintenance(value, view.maintenanceActiveTasks);
me.activeOperationsRstore = Ext.create('Proxmox.data.ObjectStore', { me.activeOperationsRstore = Ext.create('Proxmox.data.ObjectStore', {
url: `/api2/json/admin/datastore/${view.datastore}/active-operations`, url: `/api2/json/admin/datastore/${view.datastore}/active-operations`,
@ -36,8 +33,9 @@ Ext.define('PBS.Datastore.Options', {
me.activeOperationsRstore.startUpdate(); me.activeOperationsRstore.startUpdate();
view.mon(me.activeOperationsRstore, 'load', (store, data, success) => { view.mon(me.activeOperationsRstore, 'load', (store, data, success) => {
me.view.maintenanceActiveTasks.read = data[0].data.value; let activeTasks = me.getView().maintenanceActiveTasks;
me.view.maintenanceActiveTasks.write = data[1].data.value; activeTasks.read = data[0].data.value;
activeTasks.write = data[1].data.value;
}); });
}, },
@ -152,6 +150,9 @@ Ext.define('PBS.Datastore.Options', {
"maintenance-mode": { "maintenance-mode": {
required: true, required: true,
header: gettext('Maintenance mode'), header: gettext('Maintenance mode'),
renderer: function(v) {
return PBS.Utils.renderMaintenance(v, this.maintenanceActiveTasks);
},
editor: { editor: {
xtype: 'pbsMaintenanceOptionEdit', xtype: 'pbsMaintenanceOptionEdit',
}, },

View File

@ -22,6 +22,7 @@ Ext.define('PBS.window.MaintenanceOptions', {
}, },
items: { items: {
xtype: 'inputpanel',
onGetValues: function(values) { onGetValues: function(values) {
if (values.delete === 'maintenance-type') { if (values.delete === 'maintenance-type') {
values.delete = 'maintenance-mode'; values.delete = 'maintenance-mode';
@ -37,7 +38,6 @@ Ext.define('PBS.window.MaintenanceOptions', {
delete values['maintenance-msg']; delete values['maintenance-msg'];
return values; return values;
}, },
xtype: 'inputpanel',
items: [ items: [
{ {
xtype: 'pbsMaintenanceType', xtype: 'pbsMaintenanceType',
@ -50,6 +50,7 @@ Ext.define('PBS.window.MaintenanceOptions', {
xtype: 'proxmoxtextfield', xtype: 'proxmoxtextfield',
name: 'maintenance-msg', name: 'maintenance-msg',
fieldLabel: gettext('Description'), fieldLabel: gettext('Description'),
// FIXME: disable if maintenance type is none
}, },
], ],
}, },