]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/qemu/CmdMenu.js
add font-awesome
[pve-manager.git] / www / manager6 / qemu / CmdMenu.js
CommitLineData
dc56cd13
DM
1Ext.define('PVE.qemu.CmdMenu', {
2 extend: 'Ext.menu.Menu',
3
4 initComponent: function() {
5 var me = this;
6
7 var nodename = me.pveSelNode.data.node;
8 if (!nodename) {
9 throw "no node name specified";
10 }
11
12 var vmid = me.pveSelNode.data.vmid;
13 if (!vmid) {
14 throw "no VM ID specified";
15 }
16
17 var vmname = me.pveSelNode.data.name;
18
19 var vm_command = function(cmd, params) {
20 PVE.Utils.API2Request({
21 params: params,
22 url: '/nodes/' + nodename + '/qemu/' + vmid + "/status/" + cmd,
23 method: 'POST',
24 failure: function(response, opts) {
25 Ext.Msg.alert('Error', response.htmlStatus);
26 }
27 });
28 };
29
30 me.title = "VM " + vmid;
31
32 me.items = [
33 {
34 text: gettext('Start'),
35 icon: '/pve2/images/start.png',
36 handler: function() {
37 vm_command('start');
38 }
39 },
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 },
52 {
53 text: gettext('Suspend'),
54 icon: '/pve2/images/forward.png',
55 handler: function() {
16152937 56 var msg = PVE.Utils.format_task_description('qmsuspend', vmid);
dc56cd13
DM
57 Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
58 if (btn !== 'yes') {
59 return;
60 }
61 vm_command('suspend');
62 });
63 }
64 },
65 {
66 text: gettext('Resume'),
67 icon: '/pve2/images/forward.png',
68 handler: function() {
69 vm_command('resume');
70 }
71 },
72 {
73 text: gettext('Shutdown'),
74 icon: '/pve2/images/stop.png',
75 handler: function() {
16152937 76 var msg = PVE.Utils.format_task_description('qmshutdown', vmid);
dc56cd13
DM
77 Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
78 if (btn !== 'yes') {
79 return;
80 }
81
82 vm_command('shutdown');
83 });
84 }
85 },
86 {
87 text: gettext('Stop'),
88 icon: '/pve2/images/gtk-stop.png',
89 handler: function() {
16152937 90 var msg = PVE.Utils.format_task_description('qmstop', vmid);
dc56cd13
DM
91 Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
92 if (btn !== 'yes') {
93 return;
94 }
95
96 vm_command("stop");
97 });
98 }
99 },
100 {
101 text: gettext('Clone'),
102 icon: '/pve2/images/forward.png',
103 handler: function() {
104 var win = Ext.create('PVE.window.Clone', {
105 nodename: nodename,
106 vmid: vmid
107 });
108 win.show();
109 }
110 },
111 {
112 text: gettext('Convert to template'),
113 icon: '/pve2/images/forward.png',
114 handler: function() {
16152937 115 var msg = PVE.Utils.format_task_description('qmtemplate', vmid);
dc56cd13
DM
116 Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
117 if (btn !== 'yes') {
118 return;
119 }
120
121 PVE.Utils.API2Request({
122 url: '/nodes/' + nodename + '/qemu/' + vmid + '/template',
123 method: 'POST',
124 failure: function(response, opts) {
125 Ext.Msg.alert('Error', response.htmlStatus);
126 }
127 });
128 });
129 }
130 },
131 {
132 text: gettext('Console'),
133 icon: '/pve2/images/display.png',
134 handler: function() {
135 PVE.Utils.API2Request({
136 url: '/nodes/' + nodename + '/qemu/' + vmid + '/status/current',
137 failure: function(response, opts) {
138 Ext.Msg.alert('Error', response.htmlStatus);
139 },
140 success: function(response, opts) {
141 var allowSpice = response.result.data.spice;
142 PVE.Utils.openDefaultConsoleWindow(allowSpice, 'kvm', vmid, nodename, vmname);
143 }
144 });
145 }
146 }
147 ];
148
149 me.callParent();
150 }
151});