]>
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 caps
= Ext
.state
.Manager
.get('GuiCap');
20 var base_url
= '/nodes/' + nodename
+ '/lxc/' + vmid
;
22 me
.statusStore
= Ext
.create('PVE.data.ObjectStore', {
23 url
: '/api2/json' + base_url
+ '/status/current',
27 var vm_command = function(cmd
, params
) {
28 PVE
.Utils
.API2Request({
30 url
: base_url
+ "/status/" + cmd
,
33 failure: function(response
, opts
) {
34 Ext
.Msg
.alert('Error', response
.htmlStatus
);
39 var startBtn
= Ext
.create('Ext.Button', {
40 text
: gettext('Start'),
41 disabled
: !caps
.vms
['VM.PowerMgmt'],
47 var umountBtn
= Ext
.create('Ext.Button', {
48 text
: gettext('Unmount'),
56 var stopBtn
= Ext
.create('PVE.button.Button', {
57 text
: gettext('Stop'),
58 disabled
: !caps
.vms
['VM.PowerMgmt'],
59 confirmMsg
: Ext
.String
.format(gettext("Do you really want to stop VM {0}?"), vmid
),
65 var shutdownBtn
= Ext
.create('PVE.button.Button', {
66 text
: gettext('Shutdown'),
67 disabled
: !caps
.vms
['VM.PowerMgmt'],
68 confirmMsg
: Ext
.String
.format(gettext("Do you really want to shutdown VM {0}?"), vmid
),
70 vm_command('shutdown');
74 var migrateBtn
= Ext
.create('Ext.Button', {
75 text
: gettext('Migrate'),
76 disabled
: !caps
.vms
['VM.Migrate'],
78 var win
= Ext
.create('PVE.window.Migrate', {
87 var removeBtn
= Ext
.create('PVE.button.Button', {
88 text
: gettext('Remove'),
89 disabled
: !caps
.vms
['VM.Allocate'],
91 confirmMsg
: Ext
.String
.format(gettext('Are you sure you want to remove VM {0}? This will permanently erase all VM data.'), vmid
),
93 PVE
.Utils
.API2Request({
97 failure: function(response
, opts
) {
98 Ext
.Msg
.alert('Error', response
.htmlStatus
);
104 var vmname
= me
.pveSelNode
.data
.name
;
106 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
107 disabled
: !caps
.vms
['VM.Console'],
114 var descr
= vmid
+ " (" + (vmname
? "'" + vmname
+ "' " : "'CT " + vmid
+ "'") + ")";
117 title
: Ext
.String
.format(gettext("Container {0} on node {1}"), descr
, "'" + nodename
+ "'"),
119 tbar
: [ startBtn
, shutdownBtn
, umountBtn
, stopBtn
, removeBtn
,
120 migrateBtn
, consoleBtn
],
121 defaults
: { statusStore
: me
.statusStore
},
124 title
: gettext('Summary'),
125 xtype
: 'pveLxcSummary',
129 title
: gettext('Resources'),
131 xtype
: 'pveLxcRessourceView'
134 title
: gettext('Network'),
136 xtype
: 'pveLxcNetworkView'
139 title
: gettext('DNS'),
144 title
: gettext('Options'),
146 xtype
: 'pveLxcOptions'
149 title
: gettext('Task History'),
151 xtype
: 'pveNodeTasks',
157 if (caps
.vms
['VM.Backup']) {
159 title
: gettext('Backup'),
160 xtype
: 'pveBackupView',
165 if (caps
.vms
['VM.Console']) {
167 title
: gettext('Console'),
169 xtype
: 'pveNoVncConsole',
176 if (caps
.vms
['VM.Snapshot']) {
178 title
: gettext('Snapshots'),
179 xtype
: 'pveLxcSnapshotTree',
184 if (caps
.vms
['VM.Console']) {
187 xtype
: 'pveFirewallPanel',
188 title
: gettext('Firewall'),
189 base_url
: base_url
+ '/firewall',
191 phstateid
: me
.hstateid
,
197 if (caps
.vms
['Permissions.Modify']) {
200 title
: gettext('Permissions'),
201 itemId
: 'permissions',
208 me
.statusStore
.on('load', function(s
, records
, success
) {
211 me
.workspace
.checkVmMigration(me
.pveSelNode
);
214 var rec
= s
.data
.get('status');
215 status
= rec
? rec
.data
.value
: 'unknown';
217 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running');
218 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
219 stopBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'stopped');
220 removeBtn
.setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
222 if (status
=== 'mounted') {
223 umountBtn
.setDisabled(false);
224 umountBtn
.setVisible(true);
225 stopBtn
.setVisible(false);
227 umountBtn
.setDisabled(true);
228 umountBtn
.setVisible(false);
229 stopBtn
.setVisible(true);
233 me
.on('afterrender', function() {
234 me
.statusStore
.startUpdate();
237 me
.on('destroy', function() {
238 me
.statusStore
.stopUpdate();