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', {
}
});
var backup_btn = new Ext.Button({
var sm = Ext.create('Ext.selection.RowModel', {});
var backup_btn = Ext.create('Ext.button.Button', {
text: 'Backup now',
handler: function() {
var win = Ext.create('PVE.window.Backup', {
......@@ -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',
disabled: true,
handler: function(){
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
if (!rec) {
return;
}
var volid = rec.data.volid;
msg = 'Are you sure you want to restore from "' + volid + '"? ' +
selModel: sm,
confirmMsg: function(rec) {
return 'Are you sure you want to restore from "' + rec.data.volid + '"? ' +
'This will permanently erase current VM data.';
Ext.Msg.confirm('Restore Confirmation', msg, function(btn) {
if (btn !== 'yes') {
return;
}
},
enableFn: function(rec) {
return !!rec;
},
handler: function(b, e, rec) {
var volid = rec.data.volid;
var url;
var params = {
......@@ -126,34 +123,27 @@ Ext.define('PVE.grid.BackupView', {
win.show();
}
});
});
}
});
var delete_btn = new Ext.Button({
var delete_btn = Ext.create('PVE.button.Button', {
text: 'Delete',
disabled: true,
handler: function(){
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
if (!rec) {
return;
}
selModel: sm,
confirmMsg: function(rec) {
return 'Are you sure you want to delete "' + rec.data.volid + '"? ' +
'This will permanently erase all data.';
},
enableFn: function(rec) {
return !!rec;
},
handler: function(b, e, rec){
var storage = storagesel.getValue();
if (!storage) {
return;
}
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({
url: "/nodes/" + nodename + "/storage/" + storage + "/content/" + volid,
method: 'DELETE',
......@@ -165,20 +155,12 @@ Ext.define('PVE.grid.BackupView', {
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, {
stateful: false,
selModel: sm,
tbar: [ backup_btn, restore_btn, delete_btn, '->', storagesel ],
columns: [
{
......@@ -201,8 +183,7 @@ Ext.define('PVE.grid.BackupView', {
}
],
listeners: {
show: reload,
selectionchange: set_button_status
show: reload
}
});
......
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