]>
Commit | Line | Data |
---|---|---|
b82d8626 DM |
1 | Ext.define('PVE.qemu.CmdMenu', { |
2 | extend: 'Ext.menu.Menu', | |
3 | ||
4 | initComponent: function() { | |
5 | var me = this; | |
6 | ||
47b80718 DM |
7 | var nodename = me.pveSelNode.data.node; |
8 | if (!nodename) { | |
b82d8626 DM |
9 | throw "no node name specified"; |
10 | } | |
11 | ||
47b80718 DM |
12 | var vmid = me.pveSelNode.data.vmid; |
13 | if (!vmid) { | |
b82d8626 DM |
14 | throw "no VM ID specified"; |
15 | } | |
16 | ||
47b80718 DM |
17 | var vmname = me.pveSelNode.data.name; |
18 | ||
b82d8626 DM |
19 | var vm_command = function(cmd, params) { |
20 | PVE.Utils.API2Request({ | |
21 | params: params, | |
47b80718 | 22 | url: '/nodes/' + nodename + '/qemu/' + vmid + "/status/" + cmd, |
b82d8626 DM |
23 | method: 'POST', |
24 | failure: function(response, opts) { | |
25 | Ext.Msg.alert('Error', response.htmlStatus); | |
26 | } | |
27 | }); | |
28 | }; | |
29 | ||
47b80718 | 30 | me.title = "VM " + vmid; |
b82d8626 DM |
31 | |
32 | me.items = [ | |
33 | { | |
50c1c8a5 | 34 | text: gettext('Start'), |
b82d8626 DM |
35 | icon: '/pve2/images/start.png', |
36 | handler: function() { | |
37 | vm_command('start'); | |
38 | } | |
39 | }, | |
fbf2ad18 DM |
40 | { |
41 | text: gettext('Migrate'), | |
42 | icon: '/pve2/images/forward.png', | |
43 | handler: function() { | |
44 | var win = Ext.create('PVE.window.Migrate', { | |
45 | vmtype: 'qemu', | |
46 | nodename: nodename, | |
47 | vmid: vmid | |
48 | }); | |
49 | win.show(); | |
50 | } | |
51 | }, | |
b82d8626 | 52 | { |
50c1c8a5 | 53 | text: gettext('Shutdown'), |
b82d8626 DM |
54 | icon: '/pve2/images/stop.png', |
55 | handler: function() { | |
47b80718 | 56 | var msg = Ext.String.format(gettext("Do you really want to shutdown VM {0}?"), vmid); |
50c1c8a5 | 57 | Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) { |
b82d8626 DM |
58 | if (btn !== 'yes') { |
59 | return; | |
60 | } | |
61 | ||
bed57d31 | 62 | vm_command('shutdown'); |
b82d8626 DM |
63 | }); |
64 | } | |
65 | }, | |
fbf2ad18 DM |
66 | { |
67 | text: gettext('Stop'), | |
68 | icon: '/pve2/images/gtk-stop.png', | |
69 | handler: function() { | |
70 | var msg = Ext.String.format(gettext("Do you really want to stop VM {0}?"), vmid); | |
71 | Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) { | |
72 | if (btn !== 'yes') { | |
73 | return; | |
74 | } | |
75 | ||
5706408b | 76 | vm_command("stop"); |
fbf2ad18 DM |
77 | }); |
78 | } | |
79 | }, | |
1a6c1876 | 80 | { |
c5e35117 | 81 | text: gettext('Clone'), |
1a6c1876 AD |
82 | icon: '/pve2/images/forward.png', |
83 | handler: function() { | |
84 | var win = Ext.create('PVE.window.Clone', { | |
1a6c1876 | 85 | nodename: nodename, |
156c9ed6 | 86 | vmid: vmid |
1a6c1876 AD |
87 | }); |
88 | win.show(); | |
89 | } | |
90 | }, | |
231d98f9 | 91 | { |
085f9d9b | 92 | text: gettext('Convert to template'), |
231d98f9 AD |
93 | icon: '/pve2/images/forward.png', |
94 | handler: function() { | |
95 | var msg = Ext.String.format(gettext("Do you really want convert VM {0} to template (You'll can use the VM anymore)?"), vmid); | |
96 | Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) { | |
97 | if (btn !== 'yes') { | |
98 | return; | |
99 | } | |
100 | ||
101 | PVE.Utils.API2Request({ | |
102 | url: '/nodes/' + nodename + '/qemu/' + vmid + '/template', | |
103 | method: 'POST', | |
104 | failure: function(response, opts) { | |
105 | Ext.Msg.alert('Error', response.htmlStatus); | |
106 | } | |
107 | }); | |
108 | }); | |
109 | } | |
110 | }, | |
b82d8626 | 111 | { |
50c1c8a5 | 112 | text: gettext('Console'), |
b82d8626 DM |
113 | icon: '/pve2/images/display.png', |
114 | handler: function() { | |
47b80718 | 115 | PVE.Utils.openConoleWindow('kvm', vmid, nodename, vmname); |
b82d8626 DM |
116 | } |
117 | } | |
118 | ]; | |
119 | ||
120 | me.callParent(); | |
121 | } | |
122 | }); |