2022-04-12 05:26:01 +00:00
|
|
|
Ext.define('PBS.form.maintenanceType', {
|
|
|
|
extend: 'Proxmox.form.KVComboBox',
|
|
|
|
alias: 'widget.pbsMaintenanceType',
|
|
|
|
|
|
|
|
comboItems: [
|
|
|
|
['__default__', gettext('None')],
|
|
|
|
['read-only', gettext('Read only')],
|
|
|
|
['offline', gettext('Offline')],
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
Ext.define('PBS.window.MaintenanceOptions', {
|
|
|
|
extend: 'Proxmox.window.Edit',
|
|
|
|
xtype: 'pbsMaintenanceOptionEdit',
|
|
|
|
mixins: ['Proxmox.Mixin.CBind'],
|
|
|
|
|
2022-05-17 12:03:00 +00:00
|
|
|
onlineHelp: 'maintenance-mode',
|
|
|
|
|
2022-04-12 05:26:01 +00:00
|
|
|
subject: gettext('Maintenance mode'),
|
|
|
|
|
|
|
|
width: 450,
|
|
|
|
fieldDefaults: {
|
|
|
|
labelWidth: 120,
|
|
|
|
},
|
|
|
|
|
2022-05-14 12:38:58 +00:00
|
|
|
apiCallDone: function(success, response, options) {
|
|
|
|
if (success) {
|
|
|
|
let datastoreStore = Ext.data.StoreManager.lookup('pbs-datastore-list');
|
|
|
|
if (datastoreStore) {
|
|
|
|
// delay a bit to allow the window to close and maintenance mode to take effect
|
|
|
|
setTimeout(() => datastoreStore.load(), 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-04-12 05:26:01 +00:00
|
|
|
items: {
|
2022-04-12 14:52:14 +00:00
|
|
|
xtype: 'inputpanel',
|
2022-04-12 05:26:01 +00:00
|
|
|
onGetValues: function(values) {
|
|
|
|
if (values.delete === 'maintenance-type') {
|
|
|
|
values.delete = 'maintenance-mode';
|
|
|
|
} else if (values['maintenance-type']) {
|
2022-05-14 12:51:57 +00:00
|
|
|
const message = (values['maintenance-msg'] ?? '')
|
2022-04-12 05:26:01 +00:00
|
|
|
.replaceAll('\\', '')
|
|
|
|
.replaceAll('"', '\\"');
|
2022-05-14 12:51:57 +00:00
|
|
|
const maybe_message = values['maintenance-msg'] ? `,message="${message}"` : '';
|
2022-04-12 05:26:01 +00:00
|
|
|
values['maintenance-mode'] = `type=${values['maintenance-type']}${maybe_message}`;
|
|
|
|
}
|
|
|
|
delete values['maintenance-type'];
|
|
|
|
delete values['maintenance-msg'];
|
|
|
|
return values;
|
|
|
|
},
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
xtype: 'pbsMaintenanceType',
|
|
|
|
name: 'maintenance-type',
|
|
|
|
fieldLabel: gettext('Maintenance Type'),
|
|
|
|
value: '__default__',
|
|
|
|
deleteEmpty: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxtextfield',
|
|
|
|
name: 'maintenance-msg',
|
|
|
|
fieldLabel: gettext('Description'),
|
2022-04-12 14:52:14 +00:00
|
|
|
// FIXME: disable if maintenance type is none
|
2022-04-12 05:26:01 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
setValues: function(values) {
|
|
|
|
let me = this;
|
|
|
|
|
|
|
|
let options = {
|
|
|
|
'maintenance-type': '__default__',
|
|
|
|
'maintenance-msg': '',
|
|
|
|
};
|
|
|
|
if (values['maintenance-mode']) {
|
2022-04-26 06:23:34 +00:00
|
|
|
const [type, message] = PBS.Utils.parseMaintenanceMode(values['maintenance-mode']);
|
2022-04-12 05:26:01 +00:00
|
|
|
options = {
|
|
|
|
'maintenance-type': type,
|
2022-04-26 06:23:34 +00:00
|
|
|
'maintenance-msg': message ?? '',
|
2022-04-12 05:26:01 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
me.callParent([options]);
|
|
|
|
},
|
|
|
|
});
|