ui: add spice enhancements form component

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
This commit is contained in:
Aaron Lauterer 2019-10-07 15:23:51 +02:00 committed by Thomas Lamprecht
parent b6b80da79c
commit c1025d7e31
2 changed files with 61 additions and 0 deletions

View File

@ -66,6 +66,7 @@ JSSRC= \
form/CalendarEvent.js \
form/CephPoolSelector.js \
form/PermPathSelector.js \
form/SpiceEnhancementSelector.js \
dc/Tasks.js \
dc/Log.js \
panel/StatusPanel.js \

View File

@ -0,0 +1,60 @@
Ext.define('PVE.form.SpiceEnhancementSelector', {
extend: 'Proxmox.panel.InputPanel',
alias: 'widget.pveSpiceEnhancementSelector',
items: [
{
xtype: 'proxmoxcheckbox',
itemId: 'foldersharing',
name: 'foldersharing',
fieldLabel: 'Folder Sharing',
uncheckedValue: 0,
},
{
xtype: 'proxmoxKVComboBox',
itemId: 'videostreaming',
name: 'videostreaming',
value: 'off',
fieldLabel: 'Video Streaming',
comboItems: [
['off', 'off'],
['all', 'all'],
['filter', 'filter'],
],
},
{
xtype: 'displayfield',
itemId: 'spicehint',
userCls: 'pve-hint',
value: gettext('To use these features set the display to SPICE in the hardware settings of the VM.'),
hidden: true,
}
],
onGetValues: function(values) {
var ret = {};
if (values.videostreaming !== "off") {
ret.videostreaming = values.videostreaming;
}
if (values.foldersharing) {
ret.foldersharing = 1;
}
if (Ext.Object.isEmpty(ret)) {
return { 'delete': 'spice_enhancements' };
}
var enhancements = PVE.Parser.printPropertyString(ret);
return { spice_enhancements: enhancements };
},
setValues: function(values) {
var vga = PVE.Parser.parsePropertyString(values.vga, 'type');
if (!/^qxl\d?$/.test(vga.type)) {
this.down('#spicehint').setVisible(true);
}
if (values.spice_enhancements) {
var enhancements = PVE.Parser.parsePropertyString(values.spice_enhancements);
enhancements['foldersharing'] = PVE.Parser.parseBoolean(enhancements['foldersharing'], 0);
this.callParent([enhancements]);
}
},
});