]> git.proxmox.com Git - pve-manager.git/blame - www/manager/qemu/Config.js
start i18n support
[pve-manager.git] / www / manager / qemu / Config.js
CommitLineData
aff192e6
DM
1Ext.define('PVE.qemu.Config', {
2 extend: 'PVE.panel.Config',
3 alias: 'widget.PVE.qemu.Config',
4
5 initComponent: function() {
6 var me = this;
7
8 var nodename = me.pveSelNode.data.node;
9 if (!nodename) {
10 throw "no node name specified";
11 }
12
13 var vmid = me.pveSelNode.data.vmid;
14 if (!vmid) {
15 throw "no VM ID specified";
16 }
17
3732a665
DM
18 me.statusStore = Ext.create('PVE.data.ObjectStore', {
19 url: "/api2/json/nodes/" + nodename + "/qemu/" + vmid + "/status/current",
20 interval: 1000
21 });
22
23 var vm_command = function(cmd, params) {
24 PVE.Utils.API2Request({
25 params: params,
26 url: '/nodes/' + nodename + '/qemu/' + vmid + "/status/" + cmd,
27 waitMsgTarget: me,
28 method: 'POST',
29 failure: function(response, opts) {
30 Ext.Msg.alert('Error', response.htmlStatus);
31 }
32 });
33 };
34
35 var startBtn = Ext.create('Ext.Button', {
36 text: 'Start',
37 handler: function() {
38 vm_command('start');
39 }
40 });
41
42 var stopBtn = Ext.create('PVE.button.Button', {
43 text: 'Stop',
44 confirmMsg: "Do you really want to stop the VM?",
45 handler: function() {
46 vm_command("stop", { timeout: 30 });
47 }
48 });
49
50 var migrateBtn = Ext.create('Ext.Button', {
51 text: 'Migrate',
52 handler: function() {
7e79e293
DM
53 var win = Ext.create('PVE.window.Migrate', {
54 vmtype: 'qemu',
55 nodename: nodename,
56 vmid: vmid
3732a665
DM
57 });
58 win.show();
59 }
60 });
61
62 var resetBtn = Ext.create('PVE.button.Button', {
63 text: 'Reset',
64 confirmMsg: "Do you really want to reset the VM?",
65 handler: function() {
66 vm_command("reset");
67 }
68 });
69
70 var shutdownBtn = Ext.create('PVE.button.Button', {
2198a479 71 text: gettext('Shutdown'),
3732a665
DM
72 confirmMsg: "Do you really want to shutdown the VM?",
73 handler: function() {
74 vm_command('shutdown', { timeout: 30 });
75 }
76 });
77
78 var removeBtn = Ext.create('PVE.button.Button', {
79 text: 'Remove',
80 confirmMsg: 'Are you sure you want to remove VM ' +
81 vmid + '? This will permanently erase all VM data.',
82 handler: function() {
83 PVE.Utils.API2Request({
84 url: '/nodes/' + nodename + '/qemu/' + vmid,
85 method: 'DELETE',
86 waitMsgTarget: me,
87 failure: function(response, opts) {
88 Ext.Msg.alert('Error', response.htmlStatus);
89 }
90 });
91 }
92 });
93
94 var consoleBtn = Ext.create('Ext.Button', {
95 text: 'Console',
96 handler: function() {
176eee4f 97 PVE.Utils.openConoleWindow('kvm', vmid, nodename);
3732a665
DM
98 }
99 });
100
aff192e6
DM
101 var vmname = me.pveSelNode.data.name;
102 var descr = vmname ? "'" + vmname + "' " : '';
103 Ext.apply(me, {
104 title: "Virtual machine " + descr + "'KVM " + vmid +
105 "' on node '" + nodename + "'",
106 hstateid: 'kvmtab',
7e79e293
DM
107 tbar: [ startBtn, stopBtn, resetBtn, shutdownBtn,
108 migrateBtn, removeBtn, consoleBtn ],
3732a665 109 defaults: { statusStore: me.statusStore },
aff192e6
DM
110 items: [
111 {
112 title: 'Summary',
113 xtype: 'pveQemuSummary',
114 itemId: 'summary'
115 },
116 {
117 title: 'Hardware',
118 itemId: 'hardware',
119 xtype: 'PVE.qemu.HardwareView'
120 },
121 {
122 title: 'Options',
123 itemId: 'options',
124 xtype: 'PVE.qemu.Options'
125 },
956d1b6e
DM
126 {
127 title: 'Monitor',
128 itemId: 'monitor',
129 xtype: 'pveQemuMonitor'
130 },
aff192e6 131 {
c5125d5a 132 xtype: 'pveBackupView',
aff192e6 133 title: 'Backup',
30edfad9 134 itemId: 'backup'
aff192e6
DM
135 },
136 {
137 title: 'Permissions',
138 itemId: 'permissions',
139 html: 'permissions ' + vmid
140 }
141
142 ]
143 });
144
145 me.callParent();
3732a665
DM
146
147 me.statusStore.on('load', function(s, records, success) {
148 var status;
149 if (!success) {
150 me.workspace.checkVmMigration(me.pveSelNode);
151 status = 'unknown';
152 } else {
153 var rec = s.data.get('status');
154 status = rec ? rec.data.value : 'unknown';
155 }
156
157 startBtn.setDisabled(status === 'running');
158 resetBtn.setDisabled(status !== 'running');
159 shutdownBtn.setDisabled(status !== 'running');
160 stopBtn.setDisabled(status === 'stopped');
3732a665
DM
161 removeBtn.setDisabled(status !== 'stopped');
162 });
163
164 me.on('afterrender', function() {
165 me.statusStore.startUpdate();
166 });
167
168 me.on('destroy', function() {
169 me.statusStore.stopUpdate();
170 });
aff192e6
DM
171 }
172});