From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id CB11C6323C for ; Mon, 24 Jan 2022 16:39:07 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C187E249F3 for ; Mon, 24 Jan 2022 16:39:07 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 1BC8D249E4 for ; Mon, 24 Jan 2022 16:39:07 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E45A346139 for ; Mon, 24 Jan 2022 16:39:06 +0100 (CET) Message-ID: <8e3db760-b373-fb75-f091-4be9ec9940c5@proxmox.com> Date: Mon, 24 Jan 2022 16:39:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Thunderbird/97.0 Content-Language: en-US From: Thomas Lamprecht To: Proxmox VE development discussion , Aaron Lauterer Reply-To: Proxmox VE development discussion References: <20220121145115.1374455-1-a.lauterer@proxmox.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.058 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH manager] fix #3451 ui: ceph create osd: show custom device classes X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Jan 2022 15:39:07 -0000 On 24.01.22 16:32, Thomas Lamprecht wrote: > On 21.01.22 15:51, Aaron Lauterer wrote: >> + success: function(response, opts) { >> + let data = response.result.data; >> + >> + let classes = new Set(); >> + for (const match of data.matchAll(/^device\s[0-9]*\sosd\.[0-9]*\sclass\s(.*)$/gim)) { >> + classes.add(match[1]); >> + } >> + for (const v of ['hdd', 'ssd', 'nvme']) { >> + classes.delete(v); >> + } >> + for (const v of classes) { >> + deviceClasses.push([v, v]); >> + } >> + me.down('field[name=crush-device-class]').setComboItems(deviceClasses); > > Something like the following would be a bit more concise while also only changing > the field if required, I did not test this at all besides verifying that eslint > eats it though ^^ > > success: function({ result: { data } }) { > let classes = data.matchAll(/^device\s[0-9]*\sosd\.[0-9]*\sclass\s(.*)$/gim) > .filter(v => !['hdd', 'ssd', 'nvme'].includes(v)) > .map(v => [v, v]); Oh, forget to filter repeated clases here, so that would actually be something along the lines of: let classes = [...new Set( data.matchAll(/^device\s[0-9]*\sosd\.[0-9]*\sclass\s(.*)$/gim) .filter(v => !['hdd', 'ssd', 'nvme'].includes(v)) )].map(v => [v, v]); > > if (classes.length) { > let kvField = me.down('field[name=crush-device-class]').setComboItems(classes); > classes.unshift(kvField.comboItems); > > kvField.setComboItems(classes); > } > },