mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-10-04 09:46:01 +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 => {
|
schema => {
|
||||||
columns => [
|
columns => [
|
||||||
{
|
{
|
||||||
label => "Package",
|
label => "Package Name",
|
||||||
id => "package",
|
id => "package-name",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label => "Old Version",
|
label => "Installed Version",
|
||||||
id => "old-version",
|
id => "installed-version",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label => "New Version",
|
label => "Available Version",
|
||||||
id => "new-version",
|
id => "available-version",
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
data => []
|
data => []
|
||||||
};
|
};
|
||||||
|
|
||||||
my $hostname = `hostname -f` || PVE::INotify::nodename();
|
|
||||||
chomp $hostname;
|
|
||||||
|
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
foreach my $p (sort {$a->{Package} cmp $b->{Package} } @$pkglist) {
|
foreach my $p (sort {$a->{Package} cmp $b->{Package} } @$pkglist) {
|
||||||
next if $p->{NotifyStatus} && $p->{NotifyStatus} eq $p->{Version};
|
next if $p->{NotifyStatus} && $p->{NotifyStatus} eq $p->{Version};
|
||||||
$count++;
|
$count++;
|
||||||
|
|
||||||
push @{$updates_table->{data}}, {
|
push @{$updates_table->{data}}, {
|
||||||
"package" => $p->{Package},
|
"package-name" => $p->{Package},
|
||||||
"old-version" => $p->{OldVersion},
|
"installed-version" => $p->{OldVersion},
|
||||||
"new-version" => $p->{Version}
|
"available-version" => $p->{Version}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return if !$count;
|
return if !$count;
|
||||||
|
|
||||||
my $template_data = {
|
my $template_data = PVE::Notify::common_template_data();
|
||||||
updates => $updates_table,
|
$template_data->{"available-updates"} = $updates_table;
|
||||||
hostname => $hostname,
|
|
||||||
};
|
|
||||||
|
|
||||||
# Additional metadata fields that can be used in notification
|
# Additional metadata fields that can be used in notification
|
||||||
# matchers.
|
# matchers.
|
||||||
|
@ -1,6 +1,19 @@
|
|||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
The following updates are available:
|
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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
The following updates are available:
|
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