]>
Commit | Line | Data |
---|---|---|
c11ab8cb DC |
1 | Ext.define('PVE.node.CmdMenu', { |
2 | extend: 'Ext.menu.Menu', | |
3 | xtype: 'nodeCmdMenu', | |
4 | ||
5 | showSeparator: false, | |
6 | ||
7 | items: [ | |
8 | { | |
9 | text: gettext('Create VM'), | |
10 | itemId: 'createvm', | |
11 | iconCls: 'fa fa-desktop', | |
12 | handler: function() { | |
ecbe890b TL |
13 | Ext.create('PVE.qemu.CreateWizard', { |
14 | nodename: this.up('menu').nodename, | |
15 | autoShow: true, | |
c11ab8cb | 16 | }); |
f6710aac | 17 | }, |
c11ab8cb DC |
18 | }, |
19 | { | |
20 | text: gettext('Create CT'), | |
21 | itemId: 'createct', | |
22 | iconCls: 'fa fa-cube', | |
23 | handler: function() { | |
ecbe890b TL |
24 | Ext.create('PVE.lxc.CreateWizard', { |
25 | nodename: this.up('menu').nodename, | |
26 | autoShow: true, | |
c11ab8cb | 27 | }); |
f6710aac | 28 | }, |
c11ab8cb DC |
29 | }, |
30 | { xtype: 'menuseparator' }, | |
31 | { | |
32 | text: gettext('Bulk Start'), | |
33 | itemId: 'bulkstart', | |
34 | iconCls: 'fa fa-fw fa-play', | |
35 | handler: function() { | |
ecbe890b TL |
36 | Ext.create('PVE.window.BulkAction', { |
37 | nodename: this.up('menu').nodename, | |
c11ab8cb DC |
38 | title: gettext('Bulk Start'), |
39 | btnText: gettext('Start'), | |
f6710aac | 40 | action: 'startall', |
ecbe890b | 41 | autoShow: true, |
c11ab8cb | 42 | }); |
f6710aac | 43 | }, |
c11ab8cb DC |
44 | }, |
45 | { | |
31fcdc1e | 46 | text: gettext('Bulk Shutdown'), |
c11ab8cb DC |
47 | itemId: 'bulkstop', |
48 | iconCls: 'fa fa-fw fa-stop', | |
49 | handler: function() { | |
ecbe890b TL |
50 | Ext.create('PVE.window.BulkAction', { |
51 | nodename: this.up('menu').nodename, | |
31fcdc1e TL |
52 | title: gettext('Bulk Shutdown'), |
53 | btnText: gettext('Shutdown'), | |
f6710aac | 54 | action: 'stopall', |
ecbe890b | 55 | autoShow: true, |
c11ab8cb | 56 | }); |
f6710aac | 57 | }, |
c11ab8cb | 58 | }, |
9ed1408b HL |
59 | { |
60 | text: gettext('Bulk Suspend'), | |
61 | itemId: 'bulksuspend', | |
62 | iconCls: 'fa fa-fw fa-download', | |
63 | handler: function() { | |
64 | Ext.create('PVE.window.BulkAction', { | |
65 | nodename: this.up('menu').nodename, | |
66 | title: gettext('Bulk Suspend'), | |
67 | btnText: gettext('Suspend'), | |
68 | action: 'suspendall', | |
69 | autoShow: true, | |
70 | }); | |
71 | }, | |
72 | }, | |
c11ab8cb DC |
73 | { |
74 | text: gettext('Bulk Migrate'), | |
75 | itemId: 'bulkmigrate', | |
76 | iconCls: 'fa fa-fw fa-send-o', | |
77 | handler: function() { | |
ecbe890b TL |
78 | Ext.create('PVE.window.BulkAction', { |
79 | nodename: this.up('menu').nodename, | |
c11ab8cb DC |
80 | title: gettext('Bulk Migrate'), |
81 | btnText: gettext('Migrate'), | |
f6710aac | 82 | action: 'migrateall', |
ecbe890b | 83 | autoShow: true, |
c11ab8cb | 84 | }); |
f6710aac | 85 | }, |
c11ab8cb DC |
86 | }, |
87 | { xtype: 'menuseparator' }, | |
88 | { | |
89 | text: gettext('Shell'), | |
90 | itemId: 'shell', | |
91 | iconCls: 'fa fa-fw fa-terminal', | |
92 | handler: function() { | |
ecbe890b TL |
93 | let nodename = this.up('menu').nodename; |
94 | PVE.Utils.openDefaultConsoleWindow(true, 'shell', undefined, nodename, undefined); | |
f6710aac | 95 | }, |
06406206 CE |
96 | }, |
97 | { xtype: 'menuseparator' }, | |
98 | { | |
99 | text: gettext('Wake-on-LAN'), | |
100 | itemId: 'wakeonlan', | |
101 | iconCls: 'fa fa-fw fa-power-off', | |
102 | handler: function() { | |
ecbe890b | 103 | let nodename = this.up('menu').nodename; |
06406206 | 104 | Proxmox.Utils.API2Request({ |
ecbe890b | 105 | url: `/nodes/${nodename}/wakeonlan`, |
06406206 | 106 | method: 'POST', |
ecbe890b | 107 | failure: (response, opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus), |
06406206 CE |
108 | success: function(response, opts) { |
109 | Ext.Msg.show({ | |
110 | title: 'Success', | |
111 | icon: Ext.Msg.INFO, | |
ecbe890b TL |
112 | msg: Ext.String.format( |
113 | gettext("Wake on LAN packet send for '{0}': '{1}'"), | |
114 | nodename, | |
115 | response.result.data, | |
116 | ), | |
06406206 | 117 | }); |
f6710aac | 118 | }, |
06406206 | 119 | }); |
f6710aac TL |
120 | }, |
121 | }, | |
c11ab8cb DC |
122 | ], |
123 | ||
124 | initComponent: function() { | |
ecbe890b | 125 | let me = this; |
c11ab8cb DC |
126 | |
127 | if (!me.nodename) { | |
128 | throw 'no nodename specified'; | |
129 | } | |
130 | ||
131 | me.title = gettext('Node') + " '" + me.nodename + "'"; | |
132 | me.callParent(); | |
133 | ||
ecbe890b TL |
134 | let caps = Ext.state.Manager.get('GuiCap'); |
135 | ||
c11ab8cb DC |
136 | if (!caps.vms['VM.Allocate']) { |
137 | me.getComponent('createct').setDisabled(true); | |
138 | me.getComponent('createvm').setDisabled(true); | |
139 | } | |
44705bf6 TL |
140 | if (!caps.vms['VM.Migrate']) { |
141 | me.getComponent('bulkmigrate').setDisabled(true); | |
142 | } | |
0d06378c | 143 | if (!caps.vms['VM.PowerMgmt']) { |
c11ab8cb DC |
144 | me.getComponent('bulkstart').setDisabled(true); |
145 | me.getComponent('bulkstop').setDisabled(true); | |
9ed1408b | 146 | me.getComponent('bulksuspend').setDisabled(true); |
0d06378c FE |
147 | } |
148 | if (!caps.nodes['Sys.PowerMgmt']) { | |
06406206 | 149 | me.getComponent('wakeonlan').setDisabled(true); |
c11ab8cb | 150 | } |
c11ab8cb DC |
151 | if (!caps.nodes['Sys.Console']) { |
152 | me.getComponent('shell').setDisabled(true); | |
153 | } | |
06406206 CE |
154 | if (me.pveSelNode.data.running) { |
155 | me.getComponent('wakeonlan').setDisabled(true); | |
156 | } | |
ed38c56b DC |
157 | |
158 | if (PVE.Utils.isStandaloneNode()) { | |
159 | me.getComponent('bulkmigrate').setVisible(false); | |
160 | } | |
f6710aac | 161 | }, |
c11ab8cb | 162 | }); |