2022-04-12 05:26:01 +00:00
|
|
|
|
2020-11-06 16:51:52 +00:00
|
|
|
Ext.define('PBS.Datastore.Options', {
|
|
|
|
extend: 'Proxmox.grid.ObjectGrid',
|
|
|
|
xtype: 'pbsDatastoreOptionView',
|
|
|
|
mixins: ['Proxmox.Mixin.CBind'],
|
|
|
|
|
|
|
|
cbindData: function(initial) {
|
|
|
|
let me = this;
|
|
|
|
|
2022-04-12 05:26:01 +00:00
|
|
|
me.maintenanceActiveTasks = {
|
|
|
|
read: 0,
|
|
|
|
write: 0,
|
|
|
|
};
|
2020-11-06 16:51:52 +00:00
|
|
|
me.datastore = encodeURIComponent(me.datastore);
|
|
|
|
me.url = `/api2/json/config/datastore/${me.datastore}`;
|
|
|
|
me.editorConfig = {
|
|
|
|
url: `/api2/extjs/config/datastore/${me.datastore}`,
|
|
|
|
datastore: me.datastore,
|
|
|
|
};
|
|
|
|
return {};
|
|
|
|
},
|
|
|
|
|
|
|
|
controller: {
|
|
|
|
xclass: 'Ext.app.ViewController',
|
|
|
|
|
2022-04-12 05:26:01 +00:00
|
|
|
init: function(view) {
|
|
|
|
let me = this;
|
|
|
|
|
|
|
|
me.activeOperationsRstore = Ext.create('Proxmox.data.ObjectStore', {
|
|
|
|
url: `/api2/json/admin/datastore/${view.datastore}/active-operations`,
|
|
|
|
interval: 3000,
|
|
|
|
});
|
|
|
|
me.activeOperationsRstore.startUpdate();
|
|
|
|
|
|
|
|
view.mon(me.activeOperationsRstore, 'load', (store, data, success) => {
|
2022-04-12 14:52:14 +00:00
|
|
|
let activeTasks = me.getView().maintenanceActiveTasks;
|
2022-05-27 08:59:25 +00:00
|
|
|
activeTasks.read = data?.[0]?.data.value ?? 0;
|
|
|
|
activeTasks.write = data?.[1]?.data.value ?? 0;
|
2022-04-12 05:26:01 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-11-06 16:51:52 +00:00
|
|
|
edit: function() {
|
|
|
|
this.getView().run_editor();
|
|
|
|
},
|
2021-06-02 11:27:04 +00:00
|
|
|
|
|
|
|
removeDatastore: function() {
|
|
|
|
let me = this;
|
|
|
|
let datastore = me.getView().datastore;
|
|
|
|
Ext.create('Proxmox.window.SafeDestroy', {
|
|
|
|
url: `/config/datastore/${datastore}`,
|
|
|
|
item: {
|
|
|
|
id: datastore,
|
|
|
|
},
|
|
|
|
note: gettext('Configuration change only, no data will be deleted.'),
|
|
|
|
autoShow: true,
|
|
|
|
taskName: 'delete-datastore',
|
2021-06-04 09:44:06 +00:00
|
|
|
apiCallDone: (success) => {
|
|
|
|
let navtree = Ext.ComponentQuery.query('navigationtree')[0];
|
|
|
|
navtree.rstore.load();
|
|
|
|
let mainview = me.getView().up('mainview');
|
|
|
|
mainview.getController().redirectTo('pbsDataStores');
|
2021-06-02 11:27:04 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
2022-04-12 14:18:43 +00:00
|
|
|
|
|
|
|
stopUpdates: function() {
|
2022-04-12 14:21:38 +00:00
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
|
2022-04-12 14:18:43 +00:00
|
|
|
view.rstore.stopUpdate();
|
2022-04-12 14:21:38 +00:00
|
|
|
me.activeOperationsRstore.stopUpdate();
|
2022-04-12 14:18:43 +00:00
|
|
|
},
|
|
|
|
startUpdates: function() {
|
2022-04-12 14:21:38 +00:00
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
|
2022-04-12 14:18:43 +00:00
|
|
|
view.rstore.startUpdate();
|
2022-04-12 14:21:38 +00:00
|
|
|
me.activeOperationsRstore.startUpdate();
|
2022-04-12 14:18:43 +00:00
|
|
|
},
|
2020-11-06 16:51:52 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
tbar: [
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
text: gettext('Edit'),
|
|
|
|
disabled: true,
|
|
|
|
handler: 'edit',
|
|
|
|
},
|
2021-06-02 11:27:04 +00:00
|
|
|
'->',
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
selModel: null,
|
|
|
|
iconCls: 'fa fa-trash-o',
|
|
|
|
text: gettext('Remove Datastore'),
|
|
|
|
handler: 'removeDatastore',
|
|
|
|
},
|
2020-11-06 16:51:52 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
listeners: {
|
2022-04-12 14:18:43 +00:00
|
|
|
activate: 'startUpdates',
|
|
|
|
beforedestroy: 'stopUpdates',
|
|
|
|
deactivate: 'stopUpdates',
|
2020-11-06 16:51:52 +00:00
|
|
|
itemdblclick: 'edit',
|
|
|
|
},
|
|
|
|
|
|
|
|
rows: {
|
|
|
|
"notify": {
|
|
|
|
required: true,
|
2021-03-10 13:04:02 +00:00
|
|
|
header: gettext('Notify'),
|
2020-11-06 16:51:52 +00:00
|
|
|
renderer: (value) => {
|
|
|
|
let notify = PBS.Utils.parsePropertyString(value);
|
|
|
|
let res = [];
|
|
|
|
for (const k of ['Verify', 'Sync', 'GC']) {
|
|
|
|
let v = Ext.String.capitalize(notify[k.toLowerCase()]) || 'Always';
|
|
|
|
res.push(`${k}=${v}`);
|
|
|
|
}
|
|
|
|
return res.join(', ');
|
|
|
|
},
|
|
|
|
editor: {
|
|
|
|
xtype: 'pbsNotifyOptionEdit',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"notify-user": {
|
|
|
|
required: true,
|
|
|
|
defaultValue: 'root@pam',
|
2021-03-10 13:04:02 +00:00
|
|
|
header: gettext('Notify User'),
|
2020-11-06 16:51:52 +00:00
|
|
|
editor: {
|
|
|
|
xtype: 'pbsNotifyOptionEdit',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"verify-new": {
|
|
|
|
required: true,
|
|
|
|
header: gettext('Verify New Snapshots'),
|
|
|
|
defaultValue: false,
|
|
|
|
renderer: Proxmox.Utils.format_boolean,
|
|
|
|
editor: {
|
|
|
|
xtype: 'proxmoxWindowEdit',
|
|
|
|
title: gettext('Verify New'),
|
|
|
|
width: 350,
|
|
|
|
items: {
|
|
|
|
xtype: 'proxmoxcheckbox',
|
|
|
|
name: 'verify-new',
|
|
|
|
boxLabel: gettext("Verify new backups immediately after completion"),
|
|
|
|
defaultValue: false,
|
|
|
|
deleteDefaultValue: true,
|
|
|
|
deleteEmpty: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-04-12 05:26:01 +00:00
|
|
|
"maintenance-mode": {
|
|
|
|
required: true,
|
|
|
|
header: gettext('Maintenance mode'),
|
2022-04-12 14:52:14 +00:00
|
|
|
renderer: function(v) {
|
|
|
|
return PBS.Utils.renderMaintenance(v, this.maintenanceActiveTasks);
|
|
|
|
},
|
2022-04-12 05:26:01 +00:00
|
|
|
editor: {
|
|
|
|
xtype: 'pbsMaintenanceOptionEdit',
|
|
|
|
},
|
|
|
|
},
|
2020-11-06 16:51:52 +00:00
|
|
|
},
|
|
|
|
});
|