[pve-devel] [PATCH v3 manager 2/2] ui: lxc: add edit window for device passthrough
Fiona Ebner
f.ebner at proxmox.com
Mon Apr 15 14:12:57 CEST 2024
Am 31.01.24 um 16:03 schrieb Filip Schauer:
> diff --git a/www/manager6/lxc/DeviceEdit.js b/www/manager6/lxc/DeviceEdit.js
> new file mode 100644
> index 00000000..445f8607
> --- /dev/null
> +++ b/www/manager6/lxc/DeviceEdit.js
> @@ -0,0 +1,190 @@
> +Ext.define('PVE.lxc.DeviceInputPanel', {
> + extend: 'Proxmox.panel.InputPanel',
> +
> + autoComplete: false,
> +
> + controller: {
> + xclass: 'Ext.app.ViewController',
> + init: function(view) {
> + let me = this;
> + let vm = this.getViewModel();
> + vm.set('confid', view.confid);
Nit: Is the confid in the viewModel (and therefore the whole view model)
only used for the isCreate formula? That could also be directly passed
in and bound via cbind instead.
> + },
> + },
> +
> + viewModel: {
> + data: {
> + confid: '',
> + },
> +
> + formulas: {
> + isCreate: function(get) {
> + return !get('confid');
> + },
> + },
> + },
> +
> + setVMConfig: function(vmconfig) {
> + let me = this;
> + me.vmconfig = vmconfig;
> +
> + if (!me.confid) {
Nit: Should this be guarded by isCreate instead? If for whatever reason
setVMConfig() would be called a second time with a different config (not
currently happenening AFAICT), I suppose it would make sense to pick the
first free slot based on the new config again?
> + PVE.Utils.forEachLxcDev((i) => {
> + let name = "dev" + i.toString();
> + if (!Ext.isDefined(vmconfig[name])) {
> + me.confid = name;
> + me.down('field[name=devid]').setValue(i);
> + return false;
> + }
> + return undefined;
> + });
> + }
> + },
> +
(...)
> +
> + advancedColumn2: [
> + {
> + xtype: 'textfield',
> + name: 'mode',
> + editable: true,
> + fieldLabel: gettext('Access Mode'),
> + emptyText: '0660',
> + labelAlign: 'right',
> + validator: function(value) {
> + if (/^0[0-7]{3}$|^$/i.test(value)) {
Should we require the leading zero here? Many users will be familiar
with chown, where it is not required.
> + return true;
> + }
> +
> + return "Access mode has to be an octal number";
> + },
> + },
> + ],
> +});
> +
With that said:
Reviewed-by: Fiona Ebner <f.ebner at proxmox.com>
More information about the pve-devel
mailing list