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 1809991597 for ; Mon, 14 Nov 2022 10:44:07 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0035C20F47 for ; Mon, 14 Nov 2022 10:44: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 for ; Mon, 14 Nov 2022 10:44:06 +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 D743C43D36 for ; Mon, 14 Nov 2022 10:44:05 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Mon, 14 Nov 2022 10:43:47 +0100 Message-Id: <20221114094404.1241050-4-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221114094404.1241050-1-d.csapak@proxmox.com> References: <20221114094404.1241050-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: =?UTF-8?Q?0=0A=09?=AWL 0.065 Adjusted score from AWL reputation of From: =?UTF-8?Q?address=0A=09?=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 =?UTF-8?Q?Alignment=0A=09?=SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF =?UTF-8?Q?Record=0A=09?=SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH cluster v9 3/4] datacenter.cfg: add option for tag-style 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, 14 Nov 2022 09:44:07 -0000 its a property string containing 'tree-shape' and 'colors' the colors are formatted like this: :[:] Signed-off-by: Dominik Csapak --- changes from v8: * renamed properties data/PVE/DataCenterConfig.pm | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) 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} || ''; -- 2.30.2