From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id C57BB1FF164 for <inbox@lore.proxmox.com>; Fri, 28 Mar 2025 11:20:10 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E3BD236852; Fri, 28 Mar 2025 11:19:56 +0100 (CET) From: Lukas Wagner <l.wagner@proxmox.com> To: pve-devel@lists.proxmox.com Date: Fri, 28 Mar 2025 11:19:12 +0100 Message-Id: <20250328101915.73951-4-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250328101915.73951-1-l.wagner@proxmox.com> References: <20250328101915.73951-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.487 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% CONTENT_AFTER_HTML 1 More content after HTML close tag + other spam signs DMARC_MISSING 0.1 Missing DMARC policy 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 pve-manager v2 2/4] notifications: apt: clean up notification template X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> Clean up the notification templates to prepare for user-customizable templates - Change some of the template variable names to improve clarity - Generate the table for available updates in the template itself, not via the 'table' helper. This makes it possible for users to change the style/structure of the table. Signed-off-by: Lukas Wagner <l.wagner@proxmox.com> --- PVE/API2/APT.pm | 27 ++++++++----------- .../default/package-updates-body.html.hbs | 15 ++++++++++- .../default/package-updates-body.txt.hbs | 2 +- .../default/package-updates-subject.txt.hbs | 2 +- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/PVE/API2/APT.pm b/PVE/API2/APT.pm index 47c50961..99c2e152 100644 --- a/PVE/API2/APT.pm +++ b/PVE/API2/APT.pm @@ -306,43 +306,38 @@ __PACKAGE__->register_method({ schema => { columns => [ { - label => "Package", - id => "package", + label => "Package Name", + id => "package-name", }, { - label => "Old Version", - id => "old-version", + label => "Installed Version", + id => "installed-version", }, { - label => "New Version", - id => "new-version", + label => "Available Version", + id => "available-version", } ] }, data => [] }; - my $hostname = `hostname -f` || PVE::INotify::nodename(); - chomp $hostname; - my $count = 0; foreach my $p (sort {$a->{Package} cmp $b->{Package} } @$pkglist) { next if $p->{NotifyStatus} && $p->{NotifyStatus} eq $p->{Version}; $count++; push @{$updates_table->{data}}, { - "package" => $p->{Package}, - "old-version" => $p->{OldVersion}, - "new-version" => $p->{Version} + "package-name" => $p->{Package}, + "installed-version" => $p->{OldVersion}, + "available-version" => $p->{Version} }; } return if !$count; - my $template_data = { - updates => $updates_table, - hostname => $hostname, - }; + my $template_data = PVE::Notify::common_template_data(); + $template_data->{"available-updates"} = $updates_table; # Additional metadata fields that can be used in notification # matchers. diff --git a/templates/default/package-updates-body.html.hbs b/templates/default/package-updates-body.html.hbs index d058e114..ad29a941 100644 --- a/templates/default/package-updates-body.html.hbs +++ b/templates/default/package-updates-body.html.hbs @@ -1,6 +1,19 @@ <html> <body> The following updates are available: - {{table updates}} + <table style="border: 1px solid;border-collapse=collapse;margin-top: 5px;"> + <tr> + <th style="border: 1px solid;border-collapse=collapse;">Package Name</th> + <th style="border: 1px solid;border-collapse=collapse;">Installed Version</th> + <th style="border: 1px solid;border-collapse=collapse;">Available Version</th> + </tr> + {{#each available-updates.data}} + <tr> + <td style="border: 1px solid;border-collapse=collapse;">{{this.package-name}}</th> + <td style="border: 1px solid;border-collapse=collapse;">{{this.installed-version}}</th> + <td style="border: 1px solid;border-collapse=collapse;">{{this.available-version}}</th> + </tr> + {{/each}} + </table> </body> </html> diff --git a/templates/default/package-updates-body.txt.hbs b/templates/default/package-updates-body.txt.hbs index 14bdbf9e..74969433 100644 --- a/templates/default/package-updates-body.txt.hbs +++ b/templates/default/package-updates-body.txt.hbs @@ -1,3 +1,3 @@ The following updates are available: -{{table updates}} +{{table available-updates}} diff --git a/templates/default/package-updates-subject.txt.hbs b/templates/default/package-updates-subject.txt.hbs index 556a67b8..b73fdefd 100644 --- a/templates/default/package-updates-subject.txt.hbs +++ b/templates/default/package-updates-subject.txt.hbs @@ -1 +1 @@ -New software packages available ({{hostname}}) +New software packages available ({{fqdn}}) -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel