]>
Commit | Line | Data |
---|---|---|
7f261b55 DM |
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 | ||
7cd5155c DM |
45 | onRestore: function() { |
46 | var me = this.getView(); | |
47 | var rec = me.getSelection()[0]; | |
48 | ||
49 | if (!(rec && rec.data && rec.data.filename)) return; | |
50 | ||
51 | Proxmox.Utils.API2Request({ | |
52 | url: "/nodes/" + Proxmox.NodeName + "/backup/" + encodeURIComponent(rec.data.filename), | |
53 | method: 'POST', | |
54 | waitMsgTarget: me, | |
55 | failure: function (response, opts) { | |
56 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
57 | }, | |
58 | success: function(response, opts) { | |
59 | var upid = response.result.data; | |
60 | ||
61 | var win = Ext.create('Proxmox.window.TaskViewer', { | |
62 | upid: upid | |
63 | }); | |
64 | win.show(); | |
7cd5155c DM |
65 | } |
66 | }); | |
67 | }, | |
68 | ||
7f261b55 DM |
69 | onAfterRemove: function(btn, res) { |
70 | var me = this.getView(); | |
71 | me.store.load(); | |
72 | }, | |
73 | ||
74 | onFactoryDefaults: function() { | |
75 | var me = this.getView(); | |
76 | ||
77 | Ext.Msg.confirm( | |
78 | gettext('Confirm'), | |
79 | gettext('Reset rule database to factory defaults?'), | |
80 | function(button) { | |
81 | if (button !== 'yes') { | |
82 | return; | |
83 | } | |
84 | var url = '/config/ruledb'; | |
85 | Proxmox.Utils.API2Request({ | |
86 | url: '/config/ruledb', | |
87 | method: 'POST', | |
88 | waitMsgTarget: me, | |
89 | failure: function (response, opts) { | |
90 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
91 | } | |
92 | }); | |
93 | } | |
94 | ); | |
95 | } | |
96 | }, | |
97 | ||
98 | tbar: [ | |
99 | { | |
100 | text: gettext('Backup'), | |
101 | handler: 'createBackup' | |
102 | }, | |
7cd5155c DM |
103 | { |
104 | xtype: 'proxmoxButton', | |
105 | text: gettext('Restore'), | |
106 | handler: 'onRestore', | |
107 | disabled: true | |
108 | }, | |
7f261b55 DM |
109 | { |
110 | xtype: 'proxmoxStdRemoveButton', | |
111 | baseurl: '/nodes/' + Proxmox.NodeName + '/backup', | |
112 | reference: 'removeBtn', | |
113 | callback: 'onAfterRemove', | |
114 | waitMsgTarget: true | |
115 | }, | |
116 | { | |
117 | text: gettext('Factory Defaults'), | |
118 | handler: 'onFactoryDefaults' | |
119 | } | |
120 | ], | |
121 | ||
122 | store: { | |
123 | autoLoad: true, | |
124 | model: 'pmg-backup-list' | |
125 | }, | |
126 | ||
127 | columns: [ | |
128 | { | |
129 | header: gettext('Filename'), | |
130 | width: 300, | |
131 | sortable: true, | |
560360fb DM |
132 | renderer: function(filename) { |
133 | return "<a href='" + | |
134 | "/api2/json/nodes/" + Proxmox.NodeName + "/backup/" + encodeURIComponent(filename) + | |
135 | "'>" + Ext.htmlEncode(filename) + "</a>"; | |
136 | }, | |
7f261b55 DM |
137 | dataIndex: 'filename' |
138 | }, | |
139 | { | |
140 | header: gettext('Size'), | |
141 | width: 100, | |
142 | sortable: true, | |
75a55308 | 143 | renderer: Proxmox.Utils.format_size, |
7f261b55 DM |
144 | dataIndex: 'size' |
145 | } | |
146 | ] | |
147 | }); |