render_as_property_string: v => !v ? Proxmox.Utils.defaultText : PVE.Parser.printPropertyString(v),
render_scsihw: function(value) {
- if (!value) {
+ if (!value || value === '__default__') {
return Proxmox.Utils.defaultText + ' (LSI 53C895A)';
} else if (value === 'lsi') {
return 'LSI 53C895A';
serial2: gettext('Serial terminal') + ' 2',
serial3: gettext('Serial terminal') + ' 3',
virtio: 'VirtIO-GPU',
+ 'virtio-gl': 'VirGL GPU',
none: Proxmox.Utils.noneText,
},
allowSpice = consoles.spice;
allowXtermjs = !!consoles.xtermjs;
}
- let dv = PVE.VersionInfo.console || (type === 'kvm' ? 'vv' : 'xtermjs');
+ let dv = PVE.UIOptions.console || (type === 'kvm' ? 'vv' : 'xtermjs');
if (dv === 'vv' && !allowSpice) {
dv = allowXtermjs ? 'xtermjs' : 'html5';
} else if (dv === 'xtermjs' && !allowXtermjs) {
}
},
- hardware_counts: { net: 32, usb: 5, hostpci: 16, audio: 1, efidisk: 1, serial: 4, rng: 1, tpmstate: 1 },
+ hardware_counts: {
+ net: 32,
+ usb: 14,
+ usb_old: 5,
+ hostpci: 16,
+ audio: 1,
+ efidisk: 1,
+ serial: 4,
+ rng: 1,
+ tpmstate: 1,
+ },
+
+ // we can have usb6 and up only for specific machine/ostypes
+ get_max_usb_count: function(ostype, machine) {
+ if (!ostype) {
+ return PVE.Utils.hardware_counts.usb_old;
+ }
+
+ let match = /-(\d+).(\d+)/.exec(machine ?? '');
+ if (!match || PVE.Utils.qemu_min_version([match[1], match[2]], [7, 1])) {
+ if (ostype === 'l26') {
+ return PVE.Utils.hardware_counts.usb;
+ }
+ let os_match = /^win(\d+)$/.exec(ostype);
+ if (os_match && os_match[1] > 7) {
+ return PVE.Utils.hardware_counts.usb;
+ }
+ }
+
+ return PVE.Utils.hardware_counts.usb_old;
+ },
+
+ // parameters are expected to be arrays, e.g. [7,1], [4,0,1]
+ // returns true if toCheck is equal or greater than minVersion
+ qemu_min_version: function(toCheck, minVersion) {
+ let i;
+ for (i = 0; i < toCheck.length && i < minVersion.length; i++) {
+ if (toCheck[i] < minVersion[i]) {
+ return false;
+ }
+ }
+
+ if (minVersion.length > toCheck.length) {
+ for (; i < minVersion.length; i++) {
+ if (minVersion[i] !== 0) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ },
cleanEmptyObjectKeys: function(obj) {
for (const propName of Object.keys(obj)) {
};
return value.replace(/(\\\\|\\n)/g, match => replace[match]);
},
+
+ notesTemplateVars: ['cluster', 'guestname', 'node', 'vmid'],
+
+ updateUIOptions: function() {
+ Proxmox.Utils.API2Request({
+ url: '/cluster/options',
+ method: 'GET',
+ success: function(response) {
+ PVE.UIOptions = {
+ 'allowed-tags': [],
+ };
+ for (const option of ['allowed-tags', 'console', 'tag-style']) {
+ PVE.UIOptions[option] = response?.result?.data?.[option];
+ }
+
+ PVE.Utils.updateTagList(PVE.UIOptions['allowed-tags']);
+ PVE.Utils.updateTagSettings(PVE.UIOptions?.['tag-style']);
+ },
+ });
+ },
+
+ tagList: [],
+
+ updateTagList: function(tags) {
+ PVE.Utils.tagList = [...new Set([...tags])].sort();
+ },
+
+ parseTagOverrides: function(overrides) {
+ let colors = {};
+ (overrides || "").split(';').forEach(color => {
+ if (!color) {
+ return;
+ }
+ let [tag, color_hex, font_hex] = color.split(':');
+ let r = parseInt(color_hex.slice(0, 2), 16);
+ let g = parseInt(color_hex.slice(2, 4), 16);
+ let b = parseInt(color_hex.slice(4, 6), 16);
+ colors[tag] = [r, g, b];
+ if (font_hex) {
+ colors[tag].push(parseInt(font_hex.slice(0, 2), 16));
+ colors[tag].push(parseInt(font_hex.slice(2, 4), 16));
+ colors[tag].push(parseInt(font_hex.slice(4, 6), 16));
+ }
+ });
+ return colors;
+ },
+
+ tagOverrides: {},
+
+ updateTagOverrides: function(colors) {
+ let sp = Ext.state.Manager.getProvider();
+ let color_state = sp.get('colors', '');
+ let browser_colors = PVE.Utils.parseTagOverrides(color_state);
+ PVE.Utils.tagOverrides = Ext.apply({}, browser_colors, colors);
+ },
+
+ updateTagSettings: function(style) {
+ let overrides = style?.['color-map'];
+ PVE.Utils.updateTagOverrides(PVE.Utils.parseTagOverrides(overrides ?? ""));
+
+ let shape = style?.shape ?? 'circle';
+ if (shape === '__default__') {
+ style = 'circle';
+ }
+
+ Ext.ComponentQuery.query('pveResourceTree')[0].setUserCls(`proxmox-tags-${shape}`);
+ PVE.data.ResourceStore.fireEvent('load');
+ Ext.GlobalEvents.fireEvent('loadedUiOptions');
+ },
+
+ tagTreeStyles: {
+ '__default__': `${Proxmox.Utils.defaultText} (${gettext('Cirlce')})`,
+ 'full': gettext('Full'),
+ 'circle': gettext('Circle'),
+ 'dense': gettext('Dense'),
+ 'none': Proxmox.Utils.NoneText,
+ },
+
+ tagOrderOptions: {
+ '__default__': `${Proxmox.Utils.defaultText} (${gettext('Alphabetical')})`,
+ 'config': gettext('Configuration'),
+ 'alphabetical': gettext('Alphabetical'),
+ },
+
+ renderTags: function(tagstext, overrides) {
+ let text = '';
+ if (tagstext) {
+ let tags = (tagstext.split(/[,; ]/) || []).filter(t => !!t);
+ if (PVE.Utils.shouldSortTags()) {
+ tags = tags.sort((a, b) => {
+ let alc = a.toLowerCase();
+ let blc = b.toLowerCase();
+ return alc < blc ? -1 : blc < alc ? 1 : a.localeCompare(b);
+ });
+ }
+ text += ' ';
+ tags.forEach((tag) => {
+ text += Proxmox.Utils.getTagElement(tag, overrides);
+ });
+ }
+ return text;
+ },
+
+ shouldSortTags: function() {
+ return !(PVE.UIOptions?.['tag-style']?.ordering === 'config');
+ },
+
+ tagCharRegex: /^[a-z0-9+_.-]+$/i,
},
singleton: true,