From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH cluster 1/1] datacenter config: add options for sorting the gui tree
Date: Wed, 1 Feb 2023 16:49:14 +0100 [thread overview]
Message-ID: <20230201154917.1632212-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20230201154917.1632212-1-d.csapak@proxmox.com>
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 <d.csapak@proxmox.com>
---
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 => "<tag>[;<tag>...]",
},
+ '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
next prev parent reply other threads:[~2023-02-01 15:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-01 15:49 [pve-devel] [PATCH cluster/manager] fix #1408: ui: make tree sorting configurable Dominik Csapak
2023-02-01 15:49 ` Dominik Csapak [this message]
2023-02-01 15:49 ` [pve-devel] [PATCH manager 1/3] ui: Utils: refactor refreshing the the resource store/tree Dominik Csapak
2023-02-02 10:22 ` Thomas Lamprecht
2023-02-01 15:49 ` [pve-devel] [PATCH manager 2/3] ui: add TreeSortingEdit window Dominik Csapak
2023-02-02 10:56 ` Thomas Lamprecht
2023-02-02 12:16 ` Dominik Csapak
2023-02-01 15:49 ` [pve-devel] [PATCH manager 3/3] fix #1408: ui: ResourceTree: sort the tree according to tree-sorting options Dominik Csapak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230201154917.1632212-2-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox