Commit 9822bddd authored by Dietmar Maurer's avatar Dietmar Maurer

use new button class

parent 5838b3ba
...@@ -61,7 +61,9 @@ Ext.define('PVE.grid.BackupView', { ...@@ -61,7 +61,9 @@ Ext.define('PVE.grid.BackupView', {
} }
}); });
var backup_btn = new Ext.Button({ var sm = Ext.create('Ext.selection.RowModel', {});
var backup_btn = Ext.create('Ext.button.Button', {
text: 'Backup now', text: 'Backup now',
handler: function() { handler: function() {
var win = Ext.create('PVE.window.Backup', { var win = Ext.create('PVE.window.Backup', {
...@@ -74,24 +76,19 @@ Ext.define('PVE.grid.BackupView', { ...@@ -74,24 +76,19 @@ Ext.define('PVE.grid.BackupView', {
} }
}); });
var restore_btn = new Ext.Button({ var restore_btn = Ext.create('PVE.button.Button', {
text: 'Restore', text: 'Restore',
disabled: true, disabled: true,
handler: function(){ selModel: sm,
var sm = me.getSelectionModel(); confirmMsg: function(rec) {
var rec = sm.getSelection()[0]; return 'Are you sure you want to restore from "' + rec.data.volid + '"? ' +
if (!rec) {
return;
}
var volid = rec.data.volid;
msg = 'Are you sure you want to restore from "' + volid + '"? ' +
'This will permanently erase current VM data.'; 'This will permanently erase current VM data.';
Ext.Msg.confirm('Restore Confirmation', msg, function(btn) { },
if (btn !== 'yes') { enableFn: function(rec) {
return; return !!rec;
} },
handler: function(b, e, rec) {
var volid = rec.data.volid;
var url; var url;
var params = { var params = {
...@@ -126,34 +123,27 @@ Ext.define('PVE.grid.BackupView', { ...@@ -126,34 +123,27 @@ Ext.define('PVE.grid.BackupView', {
win.show(); win.show();
} }
}); });
});
} }
}); });
var delete_btn = new Ext.Button({ var delete_btn = Ext.create('PVE.button.Button', {
text: 'Delete', text: 'Delete',
disabled: true, disabled: true,
handler: function(){ selModel: sm,
var sm = me.getSelectionModel(); confirmMsg: function(rec) {
var rec = sm.getSelection()[0]; return 'Are you sure you want to delete "' + rec.data.volid + '"? ' +
if (!rec) { 'This will permanently erase all data.';
return; },
} enableFn: function(rec) {
return !!rec;
},
handler: function(b, e, rec){
var storage = storagesel.getValue(); var storage = storagesel.getValue();
if (!storage) { if (!storage) {
return; return;
} }
var volid = rec.data.volid; var volid = rec.data.volid;
msg = 'Are you sure you want to delete "' + volid + '"? ' +
'This will permanently erase all data.';
Ext.Msg.confirm('Delete Confirmation', msg, function(btn) {
if (btn !== 'yes') {
return;
}
PVE.Utils.API2Request({ PVE.Utils.API2Request({
url: "/nodes/" + nodename + "/storage/" + storage + "/content/" + volid, url: "/nodes/" + nodename + "/storage/" + storage + "/content/" + volid,
method: 'DELETE', method: 'DELETE',
...@@ -165,20 +155,12 @@ Ext.define('PVE.grid.BackupView', { ...@@ -165,20 +155,12 @@ Ext.define('PVE.grid.BackupView', {
reload(); reload();
} }
}); });
});
} }
}); });
var set_button_status = function() {
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
restore_btn.setDisabled(!(rec && rec.data.volid));
delete_btn.setDisabled(!(rec && rec.data.volid));
}
Ext.apply(me, { Ext.apply(me, {
stateful: false, stateful: false,
selModel: sm,
tbar: [ backup_btn, restore_btn, delete_btn, '->', storagesel ], tbar: [ backup_btn, restore_btn, delete_btn, '->', storagesel ],
columns: [ columns: [
{ {
...@@ -201,8 +183,7 @@ Ext.define('PVE.grid.BackupView', { ...@@ -201,8 +183,7 @@ Ext.define('PVE.grid.BackupView', {
} }
], ],
listeners: { listeners: {
show: reload, show: reload
selectionchange: set_button_status
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment