From: Dominik Csapak Date: Wed, 16 Nov 2022 15:47:57 +0000 (+0100) Subject: datacenter config: add tag-style property X-Git-Url: https://git.proxmox.com/?p=pve-cluster.git;a=commitdiff_plain;h=af234c4be985d445bd3583686ac32326c101c248 datacenter config: add tag-style property It's a property string containing 'tree-shape' and 'colors' the colors are formatted like this: :[:] Signed-off-by: Dominik Csapak Signed-off-by: Thomas Lamprecht --- diff --git a/data/PVE/DataCenterConfig.pm b/data/PVE/DataCenterConfig.pm index 6a2adee..532e5e5 100644 --- a/data/PVE/DataCenterConfig.pm +++ b/data/PVE/DataCenterConfig.pm @@ -131,6 +131,29 @@ sub pve_verify_mac_prefix { return $mac_prefix; } +my $COLOR_RE = '[0-9a-fA-F]{6}'; +my $TAG_COLOR_OVERRIDE_RE = "(?:${PVE::JSONSchema::PVE_TAG_RE}:${COLOR_RE}(?:\:${COLOR_RE})?)"; + +my $tag_style_format = { + 'shape' => { + optional => 1, + type => 'string', + enum => ['full', 'circle', 'dense', 'none'], + default => 'circle', + description => "Tag shape for the web ui tree. 'full' draws the full tag. " + ."'circle' draws only a circle with the background color. " + ."'dense' only draws a small rectancle (useful when many tags are assigned to each guest)." + ."'none' disables showing the tags.", + }, + 'color-map' => { + optional => 1, + type => 'string', + pattern => "${TAG_COLOR_OVERRIDE_RE}(?:\;$TAG_COLOR_OVERRIDE_RE)*", + typetext => ':[:][;=...]', + description => "Manual color mapping for tags (semicolon separated).", + }, +}; + my $datacenter_schema = { type => "object", additionalProperties => 0, @@ -256,6 +279,12 @@ my $datacenter_schema = { maxLength => 64 * 1024, optional => 1, }, + 'tag-style' => { + optional => 1, + type => 'string', + description => "Tag style options.", + format => $tag_style_format, + }, }, }; @@ -300,6 +329,10 @@ sub parse_datacenter_config { $res->{webauthn} = parse_property_string($webauthn_format, $webauthn); } + if (my $tag_style = $res->{'tag-style'}) { + $res->{'tag-style'} = parse_property_string($tag_style_format, $tag_style); + } + # for backwards compatibility only, new migration property has precedence if (defined($res->{migration_unsecure})) { if (defined($res->{migration}->{type})) { @@ -359,6 +392,10 @@ sub write_datacenter_config { $cfg->{webauthn} = PVE::JSONSchema::print_property_string($webauthn, $webauthn_format); } + if (ref(my $tag_style = $cfg->{'tag-style'})) { + $cfg->{'tag-style'} = PVE::JSONSchema::print_property_string($tag_style, $tag_style_format); + } + my $comment = ''; # add description as comment to top of file my $description = $cfg->{description} || '';