]>
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(); | |
74 | }, | |
75 | ||
76 | onFactoryDefaults: function() { | |
77 | var me = this.getView(); | |
78 | ||
79 | Ext.Msg.confirm( | |
80 | gettext('Confirm'), | |
81 | gettext('Reset rule database to factory defaults?'), | |
82 | function(button) { | |
83 | if (button !== 'yes') { | |
84 | return; | |
85 | } | |
86 | var url = '/config/ruledb'; | |
87 | Proxmox.Utils.API2Request({ | |
88 | url: '/config/ruledb', | |
89 | method: 'POST', | |
90 | waitMsgTarget: me, | |
91 | failure: function (response, opts) { | |
92 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
93 | } | |
94 | }); | |
95 | } | |
96 | ); | |
97 | } | |
98 | }, | |
99 | ||
100 | tbar: [ | |
101 | { | |
102 | text: gettext('Backup'), | |
103 | handler: 'createBackup' | |
104 | }, | |
7cd5155c DM |
105 | { |
106 | xtype: 'proxmoxButton', | |
107 | text: gettext('Restore'), | |
108 | handler: 'onRestore', | |
109 | disabled: true | |
110 | }, | |
7f261b55 DM |
111 | { |
112 | xtype: 'proxmoxStdRemoveButton', | |
113 | baseurl: '/nodes/' + Proxmox.NodeName + '/backup', | |
114 | reference: 'removeBtn', | |
115 | callback: 'onAfterRemove', | |
116 | waitMsgTarget: true | |
117 | }, | |
118 | { | |
119 | text: gettext('Factory Defaults'), | |
120 | handler: 'onFactoryDefaults' | |
121 | } | |
122 | ], | |
123 | ||
124 | store: { | |
125 | autoLoad: true, | |
0b33a628 DM |
126 | model: 'pmg-backup-list', |
127 | sorters: [ | |
128 | { | |
129 | property: 'timestamp', | |
130 | direction: 'DESC' | |
131 | } | |
132 | ] | |
7f261b55 DM |
133 | }, |
134 | ||
135 | columns: [ | |
136 | { | |
137 | header: gettext('Filename'), | |
138 | width: 300, | |
139 | sortable: true, | |
560360fb DM |
140 | renderer: function(filename) { |
141 | return "<a href='" + | |
142 | "/api2/json/nodes/" + Proxmox.NodeName + "/backup/" + encodeURIComponent(filename) + | |
143 | "'>" + Ext.htmlEncode(filename) + "</a>"; | |
144 | }, | |
7f261b55 DM |
145 | dataIndex: 'filename' |
146 | }, | |
0b33a628 DM |
147 | { |
148 | xtype: 'datecolumn', | |
149 | header: gettext('Time'), | |
150 | width: 150, | |
151 | format: 'Y-m-d H:i', | |
152 | sortable: true, | |
153 | dataIndex: 'timestamp' | |
154 | }, | |
7f261b55 DM |
155 | { |
156 | header: gettext('Size'), | |
157 | width: 100, | |
158 | sortable: true, | |
75a55308 | 159 | renderer: Proxmox.Utils.format_size, |
7f261b55 DM |
160 | dataIndex: 'size' |
161 | } | |
162 | ] | |
163 | }); |