]>
Commit | Line | Data |
---|---|---|
1 | /*global Proxmox*/ | |
2 | Ext.define('pmg-backup-list', { | |
3 | extend: 'Ext.data.Model', | |
4 | fields: [ | |
5 | 'filename', | |
6 | { type: 'integer', name: 'size' }, | |
7 | { type: 'date', dateFormat: 'timestamp', name: 'timestamp' } | |
8 | ||
9 | ], | |
10 | proxy: { | |
11 | type: 'proxmox', | |
12 | url: "/api2/json/nodes/" + Proxmox.NodeName + "/backup" | |
13 | }, | |
14 | idProperty: 'filename' | |
15 | }); | |
16 | ||
17 | Ext.define('PMG.RestoreWindow', { | |
18 | extend: 'Proxmox.window.Edit', | |
19 | xtype: 'pmgRestoreWindow', | |
20 | ||
21 | showProgress: true, | |
22 | title: gettext('Restore'), | |
23 | isCreate: true, | |
24 | method: 'POST', | |
25 | submitText: gettext('Restore'), | |
26 | fieldDefaults: { | |
27 | labelWidth: 150 | |
28 | }, | |
29 | items: [ | |
30 | { | |
31 | xtype: 'proxmoxcheckbox', | |
32 | name: 'config', | |
33 | fieldLabel: gettext('System Configuration') | |
34 | }, | |
35 | { | |
36 | xtype: 'proxmoxcheckbox', | |
37 | name: 'database', | |
38 | value: 1, | |
39 | uncheckedValue: 0, | |
40 | fieldLabel: gettext('Rule Database'), | |
41 | listeners: { | |
42 | change: function(cb, value) { | |
43 | var me = this; | |
44 | me.up().down('field[name=statistic]').setDisabled(!value); | |
45 | } | |
46 | } | |
47 | }, | |
48 | { | |
49 | xtype: 'proxmoxcheckbox', | |
50 | name: 'statistic', | |
51 | fieldLabel: gettext('Statistic') | |
52 | } | |
53 | ], | |
54 | ||
55 | initComponent: function() { | |
56 | var me = this; | |
57 | ||
58 | if (!me.filename) { | |
59 | throw "no filename given"; | |
60 | } | |
61 | ||
62 | me.url = "/nodes/" + Proxmox.NodeName + "/backup/" + encodeURIComponent(me.filename); | |
63 | ||
64 | me.callParent(); | |
65 | } | |
66 | }); | |
67 | ||
68 | Ext.define('PMG.BackupRestore', { | |
69 | extend: 'Ext.grid.GridPanel', | |
70 | xtype: 'pmgBackupRestore', | |
71 | ||
72 | title: gettext('Backup') + '/' + gettext('Restore'), | |
73 | ||
74 | controller: { | |
75 | xclass: 'Ext.app.ViewController', | |
76 | ||
77 | createBackup: function() { | |
78 | var me = this.getView(); | |
79 | Proxmox.Utils.API2Request({ | |
80 | url: "/nodes/" + Proxmox.NodeName + "/backup", | |
81 | method: 'POST', | |
82 | waitMsgTarget: me, | |
83 | failure: function (response, opts) { | |
84 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
85 | }, | |
86 | success: function(response, opts) { | |
87 | var upid = response.result.data; | |
88 | ||
89 | var win = Ext.create('Proxmox.window.TaskViewer', { | |
90 | upid: upid | |
91 | }); | |
92 | win.show(); | |
93 | me.mon(win, 'close', function() { me.store.load(); }); | |
94 | } | |
95 | }); | |
96 | }, | |
97 | ||
98 | onRestore: function() { | |
99 | var me = this.getView(); | |
100 | var rec = me.getSelection()[0]; | |
101 | ||
102 | if (!(rec && rec.data && rec.data.filename)) { | |
103 | return; | |
104 | } | |
105 | ||
106 | Ext.create('PMG.RestoreWindow', { | |
107 | filename: rec.data.filename | |
108 | }).show(); | |
109 | }, | |
110 | ||
111 | onAfterRemove: function(btn, res) { | |
112 | var me = this.getView(); | |
113 | me.store.load(); | |
114 | } | |
115 | }, | |
116 | ||
117 | tbar: [ | |
118 | { | |
119 | text: gettext('Backup'), | |
120 | handler: 'createBackup' | |
121 | }, | |
122 | '-', | |
123 | { | |
124 | xtype: 'proxmoxButton', | |
125 | text: gettext('Restore'), | |
126 | handler: 'onRestore', | |
127 | disabled: true | |
128 | }, | |
129 | { | |
130 | xtype: 'proxmoxStdRemoveButton', | |
131 | baseurl: '/nodes/' + Proxmox.NodeName + '/backup', | |
132 | reference: 'removeBtn', | |
133 | callback: 'onAfterRemove', | |
134 | waitMsgTarget: true | |
135 | } | |
136 | ], | |
137 | ||
138 | store: { | |
139 | autoLoad: true, | |
140 | model: 'pmg-backup-list', | |
141 | sorters: [ | |
142 | { | |
143 | property: 'timestamp', | |
144 | direction: 'DESC' | |
145 | } | |
146 | ] | |
147 | }, | |
148 | ||
149 | columns: [ | |
150 | { | |
151 | header: gettext('Filename'), | |
152 | width: 300, | |
153 | sortable: true, | |
154 | renderer: Ext.htmlEncode, | |
155 | dataIndex: 'filename' | |
156 | }, | |
157 | { | |
158 | xtype: 'datecolumn', | |
159 | header: gettext('Time'), | |
160 | width: 150, | |
161 | format: 'Y-m-d H:i', | |
162 | sortable: true, | |
163 | dataIndex: 'timestamp' | |
164 | }, | |
165 | { | |
166 | header: gettext('Size'), | |
167 | width: 100, | |
168 | sortable: true, | |
169 | renderer: Proxmox.Utils.format_size, | |
170 | dataIndex: 'size' | |
171 | }, | |
172 | { | |
173 | header: gettext('Download'), | |
174 | renderer: function(filename) { | |
175 | return "<a class='download' href='" + | |
176 | "/api2/json/nodes/" + Proxmox.NodeName + "/backup/" + encodeURIComponent(filename) + | |
177 | "'><i class='fa fa-fw fa-download'</i></a>"; | |
178 | }, | |
179 | dataIndex: 'filename' | |
180 | } | |
181 | ] | |
182 | }); |