]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/window/Snapshot.js
ui: follow up style fixes, don't cram expressions into one line
[pve-manager.git] / www / manager6 / window / Snapshot.js
1 Ext.define('PVE.window.Snapshot', {
2 extend: 'Proxmox.window.Edit',
3
4 onGetValues: function(values) {
5 let me = this;
6
7 if (me.type === 'lxc') {
8 delete values.vmstate;
9 }
10
11 return values;
12 },
13
14 initComponent : function() {
15 var me = this;
16
17 if (!me.nodename) {
18 throw "no node name specified";
19 }
20
21 if (!me.vmid) {
22 throw "no VM ID specified";
23 }
24
25 if (!me.type) {
26 throw "no VM ID specified";
27 }
28
29 me.items = [
30 {
31 xtype: me.snapname ? 'displayfield' : 'textfield',
32 name: 'snapname',
33 value: me.snapname,
34 fieldLabel: gettext('Name'),
35 vtype: 'ConfigId',
36 allowBlank: false
37 },
38 {
39 xtype: 'displayfield',
40 hidden: !me.snapname,
41 disabled: !me.snapname,
42 name: 'snaptime',
43 renderer: PVE.Utils.render_timestamp_human_readable,
44 fieldLabel: gettext('Timestamp')
45 },
46 {
47 xtype: 'proxmoxcheckbox',
48 hidden: me.type !== 'qemu' || me.snapname,
49 disabled: me.type !== 'qemu' || me.snapname,
50 name: 'vmstate',
51 uncheckedValue: 0,
52 defaultValue: 0,
53 checked: 1,
54 fieldLabel: gettext('Include RAM')
55 },
56 {
57 xtype: 'textareafield',
58 grow: true,
59 editable: !me.viewonly,
60 name: 'description',
61 fieldLabel: gettext('Description')
62 },
63 {
64 title: gettext('Settings'),
65 hidden: !me.snapname,
66 xtype: 'grid',
67 itemId: 'summary',
68 border: true,
69 height: 200,
70 store: {
71 model: 'KeyValue',
72 sorters: [
73 {
74 property : 'key',
75 direction: 'ASC'
76 }
77 ]
78 },
79 columns: [
80 {
81 header: gettext('Key'),
82 width: 150,
83 dataIndex: 'key',
84 },
85 {
86 header: gettext('Value'),
87 flex: 1,
88 dataIndex: 'value',
89 }
90 ]
91 }
92 ];
93
94 me.url = `/nodes/${me.nodename}/${me.type}/${me.vmid}/snapshot`;
95
96 let subject;
97 if (me.snapname) {
98 subject = gettext('Snapshot') + ` ${me.snapname}`;
99 me.url += `/${me.snapname}/config`;
100 } else {
101 subject = (me.type === 'qemu' ? 'VM' : 'CT') + me.vmid + ' ' + gettext('Snapshot');
102 me.method = 'POST';
103 me.showProgress = true;
104 }
105
106 Ext.apply(me, {
107 subject: subject,
108 width: me.snapname ? 620 : 450,
109 height: me.snapname ? 420 : undefined,
110 });
111
112 me.callParent();
113
114 if (!me.snapname) {
115 return;
116 }
117
118 me.load({
119 success: function(response) {
120 let kvarray = [];
121 Ext.Object.each(response.result.data, function(key, value) {
122 if (key === 'description' || key === 'snaptime') {
123 return;
124 }
125 kvarray.push({ key: key, value: value });
126 });
127
128 let summarystore = me.down('#summary').getStore();
129 summarystore.suspendEvents();
130 summarystore.add(kvarray);
131 summarystore.sort();
132 summarystore.resumeEvents();
133 summarystore.fireEvent('refresh', summarystore);
134
135 me.setValues(response.result.data);
136 }
137 });
138 }
139 });