]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/lxc/Config.js
1 Ext
.define('PVE.lxc.Config', {
2 extend
: 'PVE.panel.Config',
3 alias
: 'widget.PVE.lxc.Config',
5 initComponent: function() {
8 var nodename
= me
.pveSelNode
.data
.node
;
10 throw "no node name specified";
13 var vmid
= me
.pveSelNode
.data
.vmid
;
15 throw "no VM ID specified";
18 var template
= me
.pveSelNode
.data
.template
;
20 var caps
= Ext
.state
.Manager
.get('GuiCap');
22 var base_url
= '/nodes/' + nodename
+ '/lxc/' + vmid
;
24 me
.statusStore
= Ext
.create('PVE.data.ObjectStore', {
25 url
: '/api2/json' + base_url
+ '/status/current',
29 var vm_command = function(cmd
, params
) {
30 PVE
.Utils
.API2Request({
32 url
: base_url
+ "/status/" + cmd
,
35 failure: function(response
, opts
) {
36 Ext
.Msg
.alert('Error', response
.htmlStatus
);
41 var startBtn
= Ext
.create('Ext.Button', {
42 text
: gettext('Start'),
43 disabled
: !caps
.vms
['VM.PowerMgmt'],
50 var umountBtn
= Ext
.create('Ext.Button', {
51 text
: gettext('Unmount'),
59 var stopBtn
= Ext
.create('Ext.menu.Item',{
60 text
: gettext('Stop'),
61 disabled
: !caps
.vms
['VM.PowerMgmt'],
62 confirmMsg
: PVE
.Utils
.format_task_description('vzstop', vmid
),
70 var shutdownBtn
= Ext
.create('PVE.button.Split', {
71 text
: gettext('Shutdown'),
72 disabled
: !caps
.vms
['VM.PowerMgmt'],
73 confirmMsg
: PVE
.Utils
.format_task_description('vzshutdown', vmid
),
75 vm_command('shutdown');
80 iconCls
: 'fa fa-power-off'
83 var migrateBtn
= Ext
.create('Ext.Button', {
84 text
: gettext('Migrate'),
85 disabled
: !caps
.vms
['VM.Migrate'],
87 var win
= Ext
.create('PVE.window.Migrate', {
94 iconCls
: 'fa fa-send-o'
97 var removeBtn
= Ext
.create('PVE.button.Button', {
98 text
: gettext('Remove'),
99 disabled
: !caps
.vms
['VM.Allocate'],
100 handler: function() {
101 Ext
.create('PVE.window.SafeDestroy', {
103 item
: { type
: 'CT', id
: vmid
}
106 iconCls
: 'fa fa-trash-o'
109 var vmname
= me
.pveSelNode
.data
.name
;
111 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
112 disabled
: !caps
.vms
['VM.Console'],
117 iconCls
: 'fa fa-terminal'
120 var descr
= vmid
+ " (" + (vmname
? "'" + vmname
+ "' " : "'CT " + vmid
+ "'") + ")";
123 title
: Ext
.String
.format(gettext("Container {0} on node {1}"), descr
, "'" + nodename
+ "'"),
125 tbar
: [ startBtn
, shutdownBtn
, umountBtn
, removeBtn
,
126 migrateBtn
, consoleBtn
],
127 defaults
: { statusStore
: me
.statusStore
},
130 title
: gettext('Summary'),
131 xtype
: 'pveLxcSummary',
135 title
: gettext('Resources'),
141 xtype
: 'pveLxcRessourceView',
142 pveSelNode
: me
.pveSelNode
147 title
: gettext('Network'),
149 xtype
: 'pveLxcNetworkView'
152 title
: gettext('DNS'),
157 title
: gettext('Options'),
159 xtype
: 'pveLxcOptions'
162 title
: gettext('Task History'),
164 xtype
: 'pveNodeTasks',
170 if (caps
.vms
['VM.Backup']) {
172 title
: gettext('Backup'),
173 xtype
: 'pveBackupView',
178 if (caps
.vms
['VM.Console']) {
180 title
: gettext('Console'),
182 xtype
: 'pveNoVncConsole',
189 if (caps
.vms
['VM.Snapshot']) {
191 title
: gettext('Snapshots'),
192 xtype
: 'pveLxcSnapshotTree',
197 if (caps
.vms
['VM.Console']) {
200 xtype
: 'pveFirewallPanel',
201 title
: gettext('Firewall'),
202 base_url
: base_url
+ '/firewall',
204 phstateid
: me
.hstateid
,
210 if (caps
.vms
['Permissions.Modify']) {
213 title
: gettext('Permissions'),
214 itemId
: 'permissions',
221 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
224 me
.workspace
.checkVmMigration(me
.pveSelNode
);
227 var rec
= s
.data
.get('status');
228 status
= rec
? rec
.data
.value
: 'unknown';
229 rec
= s
.data
.get('template');
230 template
= rec
.data
.value
|| false;
232 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
233 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
234 stopBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'stopped');
235 removeBtn
.setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
236 consoleBtn
.setDisabled(template
);
238 if (status
=== 'mounted') {
239 umountBtn
.setDisabled(false);
240 umountBtn
.setVisible(true);
241 stopBtn
.setDisabled(true);
243 umountBtn
.setDisabled(true);
244 umountBtn
.setVisible(false);
245 stopBtn
.setDisabled(false);
249 me
.on('afterrender', function() {
250 me
.statusStore
.startUpdate();
253 me
.on('destroy', function() {
254 me
.statusStore
.stopUpdate();