]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/qemu/BootOrderEdit.js
1 Ext
.define('PVE.qemu.BootOrderPanel', {
2 extend
: 'Proxmox.panel.InputPanel',
3 alias
: 'widget.pveQemuBootOrderPanel',
4 vmconfig
: {}, // store loaded vm config
11 isBootDisk: function(value
) {
12 return PVE
.Utils
.bus_match
.test(value
);
15 setVMConfig: function(vmconfig
) {
17 me
.vmconfig
= vmconfig
;
18 var order
= me
.vmconfig
.boot
|| 'cdn';
19 me
.bootdisk
= me
.vmconfig
.bootdisk
|| undefined;
21 // get the first 3 characters
22 // ignore the rest (there should never be more than 3)
23 me
.selection
= order
.split('').slice(0,3);
27 Ext
.Object
.each(me
.vmconfig
, function(key
, value
) {
28 if (me
.isBootDisk(key
) &&
29 !(/media=cdrom/).test(value
)) {
30 me
.list
.push([key
, "Disk '" + key
+ "'"]);
34 me
.list
.push(['d', 'CD-ROM']);
35 me
.list
.push(['n', gettext('Network')]);
36 me
.list
.push(['__none__', Proxmox
.Utils
.noneText
]);
40 me
.comboboxes
.forEach(function(box
) {
41 box
.resetOriginalValue();
45 onGetValues: function(values
) {
47 var order
= me
.selection
.join('');
48 var res
= { boot
: order
};
50 if (me
.bootdisk
&& order
.indexOf('c') !== -1) {
51 res
.bootdisk
= me
.bootdisk
;
53 res
['delete'] = 'bootdisk';
59 recomputeSelection: function(combobox
, newVal
, oldVal
) {
60 var me
= this.up('#inputpanel');
62 me
.comboboxes
.forEach(function(item
) {
63 var val
= item
.getValue();
65 // when selecting an already selected item,
67 if ((val
=== newVal
|| (me
.isBootDisk(val
) && me
.isBootDisk(newVal
))) &&
68 item
.name
!== combobox
.name
&&
69 newVal
!== '__none__') {
74 // push 'c','d' or 'n' in the array
75 if (me
.isBootDisk(val
)) {
76 me
.selection
.push('c');
78 } else if (val
=== 'd' ||
80 me
.selection
.push(val
);
87 recomputeList: function(){
89 // set the correct values in the kvcomboboxes
91 me
.comboboxes
.forEach(function(item
) {
93 // never show 'none' on first combobox
94 item
.store
.loadData(me
.list
.slice(0, me
.list
.length
-1));
96 item
.store
.loadData(me
.list
);
98 item
.suspendEvent('change');
99 if (cnt
< me
.selection
.length
) {
100 item
.setValue((me
.selection
[cnt
] !== 'c')?me
.selection
[cnt
]:me
.bootdisk
);
101 } else if (cnt
=== 0){
104 item
.setValue('__none__');
107 item
.resumeEvent('change');
112 initComponent : function() {
115 // this has to be done here, because of
116 // the way our inputPanel class handles items
118 Ext
.createWidget('proxmoxKVComboBox', {
119 fieldLabel
: gettext('Boot device') + " 1",
124 change
: me
.recomputeSelection
127 Ext
.createWidget('proxmoxKVComboBox', {
128 fieldLabel
: gettext('Boot device') + " 2",
133 change
: me
.recomputeSelection
136 Ext
.createWidget('proxmoxKVComboBox', {
137 fieldLabel
: gettext('Boot device') + " 3",
142 change
: me
.recomputeSelection
146 Ext
.apply(me
, { items
: me
.comboboxes
});
151 Ext
.define('PVE.qemu.BootOrderEdit', {
152 extend
: 'Proxmox.window.Edit',
155 xtype
: 'pveQemuBootOrderPanel',
159 subject
: gettext('Boot Order'),
161 initComponent : function() {
165 success: function(response
, options
) {
166 me
.down('#inputpanel').setVMConfig(response
.result
.data
);