1 Ext
.define('PVE.window.Snapshot', {
2 extend
: 'Ext.window.Window',
6 // needed for finding the reference to submitbutton
7 // because we do not have a controller
9 defaultButton
: 'submitbutton',
10 defaultFocus
: 'field',
12 take_snapshot: function(snapname
, descr
, vmstate
) {
14 var params
= { snapname
: snapname
, vmstate
: vmstate
? 1 : 0 };
16 params
.description
= descr
;
19 Proxmox
.Utils
.API2Request({
21 url
: '/nodes/' + me
.nodename
+ '/qemu/' + me
.vmid
+ "/snapshot",
24 failure: function(response
, opts
) {
25 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
27 success: function(response
, options
) {
28 var upid
= response
.result
.data
;
29 var win
= Ext
.create('PVE.window.TaskProgress', { upid
: upid
});
36 update_snapshot: function(snapname
, descr
) {
38 Proxmox
.Utils
.API2Request({
39 params
: { description
: descr
},
40 url
: '/nodes/' + me
.nodename
+ '/qemu/' + me
.vmid
+ "/snapshot/" +
44 failure: function(response
, opts
) {
45 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
47 success: function(response
, options
) {
53 initComponent : function() {
57 throw "no node name specified";
61 throw "no VM ID specified";
64 var summarystore
= Ext
.create('Ext.data.Store', {
76 xtype
: me
.snapname
? 'displayfield' : 'textfield',
79 fieldLabel
: gettext('Name'),
87 xtype
: 'displayfield',
89 renderer
: PVE
.Utils
.render_timestamp_human_readable
,
90 fieldLabel
: gettext('Timestamp')
99 fieldLabel
: gettext('Include RAM')
104 xtype
: 'textareafield',
107 fieldLabel
: gettext('Description')
112 title
: gettext('Settings'),
117 {header
: gettext('Key'), width
: 150, dataIndex
: 'key'},
118 {header
: gettext('Value'), flex
: 1, dataIndex
: 'value'}
123 me
.formPanel
= Ext
.create('Ext.form.Panel', {
133 var form
= me
.formPanel
.getForm();
138 me
.title
= gettext('Edit') + ': ' + gettext('Snapshot');
139 submitBtn
= Ext
.create('Ext.Button', {
140 text
: gettext('Update'),
141 handler: function() {
142 if (form
.isValid()) {
143 var values
= form
.getValues();
144 me
.update_snapshot(me
.snapname
, values
.description
);
149 me
.title
="VM " + me
.vmid
+ ': ' + gettext('Take Snapshot');
150 submitBtn
= Ext
.create('Ext.Button', {
151 text
: gettext('Take Snapshot'),
152 reference
: 'submitbutton',
153 handler: function() {
154 if (form
.isValid()) {
155 var values
= form
.getValues();
156 me
.take_snapshot(values
.snapname
, values
.description
, values
.vmstate
);
167 buttons
: [ submitBtn
],
168 items
: [ me
.formPanel
]
185 Proxmox
.Utils
.API2Request({
186 url
: '/nodes/' + me
.nodename
+ '/qemu/' + me
.vmid
+ "/snapshot/" +
187 me
.snapname
+ '/config',
190 failure: function(response
, opts
) {
191 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
194 success: function(response
, options
) {
195 var data
= response
.result
.data
;
197 Ext
.Object
.each(data
, function(key
, value
) {
198 if (key
=== 'description' || key
=== 'snaptime') {
201 kvarray
.push({ key
: key
, value
: value
});
204 summarystore
.suspendEvents();
205 summarystore
.add(kvarray
);
207 summarystore
.resumeEvents();
208 summarystore
.fireEvent('refresh', summarystore
);
210 form
.findField('snaptime').setValue(data
.snaptime
);
211 form
.findField('description').setValue(data
.description
);