mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-10-04 05:57:13 +00:00
notifications: apt: clean up notification template
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>
This commit is contained in:
parent
5577f9da2d
commit
82fc0f6cdf
@ -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.
|
||||
|
@ -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>
|
||||
|
@ -1,3 +1,3 @@
|
||||
The following updates are available:
|
||||
|
||||
{{table updates}}
|
||||
{{table available-updates}}
|
||||
|
@ -1 +1 @@
|
||||
New software packages available ({{hostname}})
|
||||
New software packages available ({{fqdn}})
|
||||
|
Loading…
Reference in New Issue
Block a user