]>
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() { | |
13 | var me = this.up('menu'); | |
14 | var wiz = Ext.create('PVE.qemu.CreateWizard', { | |
f6710aac | 15 | nodename: me.nodename, |
c11ab8cb DC |
16 | }); |
17 | wiz.show(); | |
f6710aac | 18 | }, |
c11ab8cb DC |
19 | }, |
20 | { | |
21 | text: gettext('Create CT'), | |
22 | itemId: 'createct', | |
23 | iconCls: 'fa fa-cube', | |
24 | handler: function() { | |
25 | var me = this.up('menu'); | |
26 | var wiz = Ext.create('PVE.lxc.CreateWizard', { | |
f6710aac | 27 | nodename: me.nodename, |
c11ab8cb DC |
28 | }); |
29 | wiz.show(); | |
f6710aac | 30 | }, |
c11ab8cb DC |
31 | }, |
32 | { xtype: 'menuseparator' }, | |
33 | { | |
34 | text: gettext('Bulk Start'), | |
35 | itemId: 'bulkstart', | |
36 | iconCls: 'fa fa-fw fa-play', | |
37 | handler: function() { | |
38 | var me = this.up('menu'); | |
39 | var win = Ext.create('PVE.window.BulkAction', { | |
40 | nodename: me.nodename, | |
41 | title: gettext('Bulk Start'), | |
42 | btnText: gettext('Start'), | |
f6710aac | 43 | action: 'startall', |
c11ab8cb DC |
44 | }); |
45 | win.show(); | |
f6710aac | 46 | }, |
c11ab8cb DC |
47 | }, |
48 | { | |
49 | text: gettext('Bulk Stop'), | |
50 | itemId: 'bulkstop', | |
51 | iconCls: 'fa fa-fw fa-stop', | |
52 | handler: function() { | |
53 | var me = this.up('menu'); | |
54 | var win = Ext.create('PVE.window.BulkAction', { | |
55 | nodename: me.nodename, | |
56 | title: gettext('Bulk Stop'), | |
57 | btnText: gettext('Stop'), | |
f6710aac | 58 | action: 'stopall', |
c11ab8cb DC |
59 | }); |
60 | win.show(); | |
f6710aac | 61 | }, |
c11ab8cb DC |
62 | }, |
63 | { | |
64 | text: gettext('Bulk Migrate'), | |
65 | itemId: 'bulkmigrate', | |
66 | iconCls: 'fa fa-fw fa-send-o', | |
67 | handler: function() { | |
68 | var me = this.up('menu'); | |
69 | var win = Ext.create('PVE.window.BulkAction', { | |
70 | nodename: me.nodename, | |
71 | title: gettext('Bulk Migrate'), | |
72 | btnText: gettext('Migrate'), | |
f6710aac | 73 | action: 'migrateall', |
c11ab8cb DC |
74 | }); |
75 | win.show(); | |
f6710aac | 76 | }, |
c11ab8cb DC |
77 | }, |
78 | { xtype: 'menuseparator' }, | |
79 | { | |
80 | text: gettext('Shell'), | |
81 | itemId: 'shell', | |
82 | iconCls: 'fa fa-fw fa-terminal', | |
83 | handler: function() { | |
84 | var me = this.up('menu'); | |
85 | PVE.Utils.openDefaultConsoleWindow(true, 'shell', undefined, me.nodename, undefined); | |
f6710aac | 86 | }, |
06406206 CE |
87 | }, |
88 | { xtype: 'menuseparator' }, | |
89 | { | |
90 | text: gettext('Wake-on-LAN'), | |
91 | itemId: 'wakeonlan', | |
92 | iconCls: 'fa fa-fw fa-power-off', | |
93 | handler: function() { | |
94 | var me = this.up('menu'); | |
95 | Proxmox.Utils.API2Request({ | |
96 | param: {}, | |
97 | url: '/nodes/' + me.nodename + '/wakeonlan', | |
98 | method: 'POST', | |
99 | failure: function(response, opts) { | |
100 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
101 | }, | |
102 | success: function(response, opts) { | |
103 | Ext.Msg.show({ | |
104 | title: 'Success', | |
105 | icon: Ext.Msg.INFO, | |
f6710aac | 106 | msg: Ext.String.format(gettext("Wake on LAN packet send for '{0}': '{1}'"), me.nodename, response.result.data), |
06406206 | 107 | }); |
f6710aac | 108 | }, |
06406206 | 109 | }); |
f6710aac TL |
110 | }, |
111 | }, | |
c11ab8cb DC |
112 | ], |
113 | ||
114 | initComponent: function() { | |
115 | var me = this; | |
116 | ||
117 | if (!me.nodename) { | |
118 | throw 'no nodename specified'; | |
119 | } | |
120 | ||
121 | me.title = gettext('Node') + " '" + me.nodename + "'"; | |
122 | me.callParent(); | |
123 | ||
124 | var caps = Ext.state.Manager.get('GuiCap'); | |
125 | // disable not allowed options | |
126 | if (!caps.vms['VM.Allocate']) { | |
127 | me.getComponent('createct').setDisabled(true); | |
128 | me.getComponent('createvm').setDisabled(true); | |
129 | } | |
130 | ||
131 | if (!caps.nodes['Sys.PowerMgmt']) { | |
132 | me.getComponent('bulkstart').setDisabled(true); | |
133 | me.getComponent('bulkstop').setDisabled(true); | |
134 | me.getComponent('bulkmigrate').setDisabled(true); | |
06406206 | 135 | me.getComponent('wakeonlan').setDisabled(true); |
c11ab8cb DC |
136 | } |
137 | ||
138 | if (!caps.nodes['Sys.Console']) { | |
139 | me.getComponent('shell').setDisabled(true); | |
140 | } | |
06406206 CE |
141 | |
142 | if (me.pveSelNode.data.running) { | |
143 | me.getComponent('wakeonlan').setDisabled(true); | |
144 | } | |
f6710aac | 145 | }, |
c11ab8cb | 146 | }); |