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 17042915A2 for ; Wed, 1 Feb 2023 16:49:20 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 00C0A2CAC for ; Wed, 1 Feb 2023 16:49:20 +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 for ; Wed, 1 Feb 2023 16:49:18 +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 6F9AB45A6F for ; Wed, 1 Feb 2023 16:49:18 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Wed, 1 Feb 2023 16:49:14 +0100 Message-Id: <20230201154917.1632212-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201154917.1632212-1-d.csapak@proxmox.com> References: <20230201154917.1632212-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.062 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH cluster 1/1] datacenter config: add options for sorting the gui tree 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: Wed, 01 Feb 2023 15:49:20 -0000 namely the 'sort-field' (either vmid or name), 'group-templates' (if the guest templates should be grouped seperately) and 'group-guest-types' (if the guest types should be grouped or not) Signed-off-by: Dominik Csapak --- data/PVE/DataCenterConfig.pm | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/data/PVE/DataCenterConfig.pm b/data/PVE/DataCenterConfig.pm index 7a24870..36e0ea6 100644 --- a/data/PVE/DataCenterConfig.pm +++ b/data/PVE/DataCenterConfig.pm @@ -219,6 +219,28 @@ my $user_tag_privs_format = { }, }; +my $tree_sorting_format = { + 'sort-field' => { + optional => 1, + type => 'string', + enum => ['vmid', 'name'], + default => 'vmid', + description => "Controls the field to use as sort order and primary display.", + }, + 'group-templates' => { + optional => 1, + type => 'boolean', + default => 1, + description => "If enabled, groups the guest templates seperately from regular guests.", + }, + 'group-guest-types' => { + optional => 1, + type => 'boolean', + default => 1, + description => "If enabled, groups the guests by type.", + }, +}; + my $datacenter_schema = { type => "object", additionalProperties => 0, @@ -374,6 +396,12 @@ my $datacenter_schema = { pattern => "(?:${PVE::JSONSchema::PVE_TAG_RE};)*${PVE::JSONSchema::PVE_TAG_RE}", typetext => "[;...]", }, + 'tree-sorting' => { + optional => 1, + type => 'string', + description => "Tree sorting and grouping options", + format => $tree_sorting_format, + }, }, }; @@ -442,6 +470,10 @@ sub parse_datacenter_config { $res->{'registered-tags'} = [split(';', $admin_tags)]; } + if (my $tree_sorting = $res->{'tree-sorting'}) { + $res->{'tree-sorting'} = parse_property_string($tree_sorting_format, $tree_sorting); + } + # for backwards compatibility only, new migration property has precedence if (defined($res->{migration_unsecure})) { if (defined($res->{migration}->{type})) { @@ -524,6 +556,11 @@ sub write_datacenter_config { $cfg->{'registered-tags'} = join(';', sort $admin_tags->@*); } + if (ref(my $tree_sorting = $cfg->{'tree-sorting'})) { + $cfg->{'tree-sorting'} = + PVE::JSONSchema::print_property_string($tree_sorting, $tree_sorting_format); + } + my $comment = ''; # add description as comment to top of file my $description = $cfg->{description} || ''; -- 2.30.2