]>
Commit | Line | Data |
---|---|---|
7f261b55 DM |
1 | /*global Proxmox*/ |
2 | Ext.define('pmg-backup-list', { | |
3 | extend: 'Ext.data.Model', | |
4 | fields: [ | |
5 | 'filename', | |
0b33a628 DM |
6 | { type: 'integer', name: 'size' }, |
7 | { type: 'date', dateFormat: 'timestamp', name: 'timestamp' } | |
8 | ||
7f261b55 DM |
9 | ], |
10 | proxy: { | |
11 | type: 'proxmox', | |
12 | url: "/api2/json/nodes/" + Proxmox.NodeName + "/backup" | |
13 | }, | |
14 | idProperty: 'filename' | |
15 | }); | |
16 | ||
17 | Ext.define('PMG.BackupRestore', { | |
18 | extend: 'Ext.grid.GridPanel', | |
19 | xtype: 'pmgBackupRestore', | |
20 | ||
21 | title: gettext('Backup') + '/' + gettext('Restore'), | |
22 | ||
23 | controller: { | |
24 | xclass: 'Ext.app.ViewController', | |
25 | ||
26 | createBackup: function() { | |
27 | var me = this.getView(); | |
28 | Proxmox.Utils.API2Request({ | |
29 | url: "/nodes/" + Proxmox.NodeName + "/backup", | |
30 | method: 'POST', | |
31 | waitMsgTarget: me, | |
32 | failure: function (response, opts) { | |
33 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
34 | }, | |
35 | success: function(response, opts) { | |
36 | var upid = response.result.data; | |
37 | ||
38 | var win = Ext.create('Proxmox.window.TaskViewer', { | |
39 | upid: upid | |
40 | }); | |
41 | win.show(); | |
42 | me.mon(win, 'close', function() { me.store.load(); }); | |
43 | } | |
44 | }); | |
45 | }, | |
46 | ||
7cd5155c DM |
47 | onRestore: function() { |
48 | var me = this.getView(); | |
49 | var rec = me.getSelection()[0]; | |
50 | ||
51 | if (!(rec && rec.data && rec.data.filename)) return; | |
52 | ||
53 | Proxmox.Utils.API2Request({ | |
54 | url: "/nodes/" + Proxmox.NodeName + "/backup/" + encodeURIComponent(rec.data.filename), | |
55 | method: 'POST', | |
56 | waitMsgTarget: me, | |
57 | failure: function (response, opts) { | |
58 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
59 | }, | |
60 | success: function(response, opts) { | |
61 | var upid = response.result.data; | |
62 | ||
63 | var win = Ext.create('Proxmox.window.TaskViewer', { | |
64 | upid: upid | |
65 | }); | |
66 | win.show(); | |
7cd5155c DM |
67 | } |
68 | }); | |
69 | }, | |
70 | ||
7f261b55 DM |
71 | onAfterRemove: function(btn, res) { |
72 | var me = this.getView(); | |
73 | me.store.load(); | |
7f261b55 DM |
74 | } |
75 | }, | |
76 | ||
77 | tbar: [ | |
78 | { | |
79 | text: gettext('Backup'), | |
80 | handler: 'createBackup' | |
81 | }, | |
dd79f43a | 82 | '-', |
7cd5155c DM |
83 | { |
84 | xtype: 'proxmoxButton', | |
85 | text: gettext('Restore'), | |
86 | handler: 'onRestore', | |
87 | disabled: true | |
88 | }, | |
7f261b55 DM |
89 | { |
90 | xtype: 'proxmoxStdRemoveButton', | |
91 | baseurl: '/nodes/' + Proxmox.NodeName + '/backup', | |
92 | reference: 'removeBtn', | |
93 | callback: 'onAfterRemove', | |
94 | waitMsgTarget: true | |
7f261b55 DM |
95 | } |
96 | ], | |
97 | ||
98 | store: { | |
99 | autoLoad: true, | |
0b33a628 DM |
100 | model: 'pmg-backup-list', |
101 | sorters: [ | |
102 | { | |
103 | property: 'timestamp', | |
104 | direction: 'DESC' | |
105 | } | |
106 | ] | |
7f261b55 DM |
107 | }, |
108 | ||
109 | columns: [ | |
110 | { | |
111 | header: gettext('Filename'), | |
112 | width: 300, | |
113 | sortable: true, | |
bedf67ee | 114 | renderer: Ext.htmlEncode, |
7f261b55 DM |
115 | dataIndex: 'filename' |
116 | }, | |
0b33a628 DM |
117 | { |
118 | xtype: 'datecolumn', | |
119 | header: gettext('Time'), | |
120 | width: 150, | |
121 | format: 'Y-m-d H:i', | |
122 | sortable: true, | |
123 | dataIndex: 'timestamp' | |
124 | }, | |
7f261b55 DM |
125 | { |
126 | header: gettext('Size'), | |
127 | width: 100, | |
128 | sortable: true, | |
75a55308 | 129 | renderer: Proxmox.Utils.format_size, |
7f261b55 | 130 | dataIndex: 'size' |
bedf67ee DC |
131 | }, |
132 | { | |
133 | header: gettext('Download'), | |
134 | renderer: function(filename) { | |
135 | return "<a class='download' href='" + | |
136 | "/api2/json/nodes/" + Proxmox.NodeName + "/backup/" + encodeURIComponent(filename) + | |
137 | "'><i class='fa fa-fw fa-download'</i></a>"; | |
138 | }, | |
139 | dataIndex: 'filename' | |
7f261b55 DM |
140 | } |
141 | ] | |
142 | }); |