]> git.proxmox.com Git - pmg-gui.git/blob - js/BackupRestore.js
BackupRestore.js - add anchor to download backup files
[pmg-gui.git] / js / BackupRestore.js
1 /*global Proxmox*/
2 Ext.define('pmg-backup-list', {
3 extend: 'Ext.data.Model',
4 fields: [
5 'filename',
6 { type: 'integer', name: 'size' }
7 ],
8 proxy: {
9 type: 'proxmox',
10 url: "/api2/json/nodes/" + Proxmox.NodeName + "/backup"
11 },
12 idProperty: 'filename'
13 });
14
15 Ext.define('PMG.BackupRestore', {
16 extend: 'Ext.grid.GridPanel',
17 xtype: 'pmgBackupRestore',
18
19 title: gettext('Backup') + '/' + gettext('Restore'),
20
21 controller: {
22 xclass: 'Ext.app.ViewController',
23
24 createBackup: function() {
25 var me = this.getView();
26 Proxmox.Utils.API2Request({
27 url: "/nodes/" + Proxmox.NodeName + "/backup",
28 method: 'POST',
29 waitMsgTarget: me,
30 failure: function (response, opts) {
31 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
32 },
33 success: function(response, opts) {
34 var upid = response.result.data;
35
36 var win = Ext.create('Proxmox.window.TaskViewer', {
37 upid: upid
38 });
39 win.show();
40 me.mon(win, 'close', function() { me.store.load(); });
41 }
42 });
43 },
44
45 onAfterRemove: function(btn, res) {
46 var me = this.getView();
47 me.store.load();
48 },
49
50 onFactoryDefaults: function() {
51 var me = this.getView();
52
53 Ext.Msg.confirm(
54 gettext('Confirm'),
55 gettext('Reset rule database to factory defaults?'),
56 function(button) {
57 if (button !== 'yes') {
58 return;
59 }
60 var url = '/config/ruledb';
61 Proxmox.Utils.API2Request({
62 url: '/config/ruledb',
63 method: 'POST',
64 waitMsgTarget: me,
65 failure: function (response, opts) {
66 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
67 }
68 });
69 }
70 );
71 }
72 },
73
74 tbar: [
75 {
76 text: gettext('Backup'),
77 handler: 'createBackup'
78 },
79 {
80 xtype: 'proxmoxStdRemoveButton',
81 baseurl: '/nodes/' + Proxmox.NodeName + '/backup',
82 reference: 'removeBtn',
83 callback: 'onAfterRemove',
84 waitMsgTarget: true
85 },
86 {
87 text: gettext('Factory Defaults'),
88 handler: 'onFactoryDefaults'
89 }
90 ],
91
92 store: {
93 autoLoad: true,
94 model: 'pmg-backup-list'
95 },
96
97 columns: [
98 {
99 header: gettext('Filename'),
100 width: 300,
101 sortable: true,
102 renderer: function(filename) {
103 return "<a href='" +
104 "/api2/json/nodes/" + Proxmox.NodeName + "/backup/" + encodeURIComponent(filename) +
105 "'>" + Ext.htmlEncode(filename) + "</a>";
106 },
107 dataIndex: 'filename'
108 },
109 {
110 header: gettext('Size'),
111 width: 100,
112 sortable: true,
113 dataIndex: 'size'
114 }
115 ]
116 });