Update to mailstats panel
This commit is contained in:
parent
7fcdfccfa6
commit
a58191f667
@ -13,6 +13,8 @@ use esmith::AccountsDB;
|
|||||||
use esmith::NetworksDB;
|
use esmith::NetworksDB;
|
||||||
use esmith::DomainsDB;
|
use esmith::DomainsDB;
|
||||||
|
|
||||||
|
use POSIX 'strftime';
|
||||||
|
|
||||||
use constant FALSE => 0;
|
use constant FALSE => 0;
|
||||||
use constant TRUE => 1;
|
use constant TRUE => 1;
|
||||||
|
|
||||||
@ -291,4 +293,29 @@ sub get_URIBL_list{
|
|||||||
"white.uribl.com" # Verified safe URI list
|
"white.uribl.com" # Verified safe URI list
|
||||||
);}
|
);}
|
||||||
|
|
||||||
|
sub get_mailstat_dates {
|
||||||
|
my ($directory) = '/opt/mailstats/html';
|
||||||
|
my @date_pairs;
|
||||||
|
|
||||||
|
# Find all matching files in directory
|
||||||
|
opendir(my $dh, $directory) or die "Can't open directory: $!";
|
||||||
|
|
||||||
|
while (my $file = readdir($dh)) {
|
||||||
|
next unless $file =~ /mailstats_for_(\d{4}-\d{2}-\d{2})\.html$/;
|
||||||
|
my $date = $1;
|
||||||
|
|
||||||
|
if ($date =~ /^(\d{4})-(\d{2})-(\d{2})$/) {
|
||||||
|
my $formatted_date = strftime("%B %-d %Y", 0, 0, 0, $3, $2-1, $1-1900);
|
||||||
|
push @date_pairs, [$formatted_date, $date];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir($dh);
|
||||||
|
|
||||||
|
# Sort dates chronologically
|
||||||
|
@date_pairs = sort { $a->[1] cmp $b->[1] } @date_pairs;
|
||||||
|
|
||||||
|
return \@date_pairs;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
@ -37,4 +37,30 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
// Add change listener to multiselect
|
// Add change listener to multiselect
|
||||||
document.getElementById('CountrySelect_select')
|
document.getElementById('CountrySelect_select')
|
||||||
.addEventListener('click', updateTextInput);
|
.addEventListener('click', updateTextInput);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Initialize select with current object content
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const objectElement = document.getElementById('mailstats_object');
|
||||||
|
const selectElement = document.getElementById('StatsDate_select');
|
||||||
|
|
||||||
|
// Extract current date from object's data URL
|
||||||
|
const currentDate = objectElement.data.match(/mailstats_for_(\d{4}-\d{2}-\d{2})\.html/)?.[1];
|
||||||
|
|
||||||
|
if (currentDate) {
|
||||||
|
selectElement.value = currentDate;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update object content when selection changes
|
||||||
|
document.getElementById('StatsDate_select').addEventListener('change', function() {
|
||||||
|
const selectedDate = this.value;
|
||||||
|
const objectElement = document.getElementById('mailstats_object');
|
||||||
|
|
||||||
|
// Update object's data source
|
||||||
|
objectElement.data = `mailstats_for_${selectedDate}.html`;
|
||||||
|
|
||||||
|
// Force refresh using clone method (cross-browser workaround)
|
||||||
|
const clone = objectElement.cloneNode(true);
|
||||||
|
objectElement.replaceWith(clone);
|
||||||
});
|
});
|
@ -39,12 +39,12 @@
|
|||||||
<p><span class=label>
|
<p><span class=label>
|
||||||
%=l('mst_Date_for_Stats_display')
|
%=l('mst_Date_for_Stats_display')
|
||||||
</span><span class=data>
|
</span><span class=data>
|
||||||
% my @StatsDate_options = [['$c->get_StatsDate()' => '$c->get_StatsDate()']];
|
% my @StatsDate_options = $c->get_mailstat_dates();
|
||||||
% param 'StatsDate' => $mst_data->{StatsDate} unless param 'StatsDate';
|
% param 'StatsDate' => $mst_data->{StatsDate} unless param 'StatsDate';
|
||||||
%= select_field 'StatsDate' => @StatsDate_options, class => 'input', id => 'StatsDate_select'
|
%= select_field 'StatsDate' => @StatsDate_options, class => 'input', id => 'StatsDate_select'
|
||||||
<br></span> </p>
|
<br></span> </p>
|
||||||
|
|
||||||
<object data="<%='mailstats/$c->stash("url")' %>" title="<%= $c->stash('title') %>" type="text/html" ><%= $c->stash('title') %> not found</object>
|
<object id = 'mailstats_object' data="<%='mailstats/$c->stash("url")' %>" title="<%= $c->stash('title') %>" type="text/html" ><%= $c->stash('title') %> not found</object>
|
||||||
|
|
||||||
|
|
||||||
%# Probably finally by a submit.
|
%# Probably finally by a submit.
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
Summary: Daily mail statistics for SME Server
|
Summary: Daily mail statistics for SME Server
|
||||||
%define name smeserver-mailstats
|
%define name smeserver-mailstats
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
%define version 1.1
|
%define version 11.1
|
||||||
%define release 19
|
%define release 2
|
||||||
Version: %{version}
|
Version: %{version}
|
||||||
Release: %{release}%{?dist}
|
Release: %{release}%{?dist}
|
||||||
License: GPL
|
License: GPL
|
||||||
@ -32,7 +32,10 @@ A script that via cron.d e-mails mail statistics to admin on a daily basis.
|
|||||||
See http://www.contribs.org/bugzilla/show_bug.cgi?id=819
|
See http://www.contribs.org/bugzilla/show_bug.cgi?id=819
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Mon Dec 30 2024 Brian Read <brianr@koozali.org> 1.1-19.sme
|
* Sun Apr 06 2025 Brian Read <brianr@koozali.org> 11.2-2.sme
|
||||||
|
- Add in SM2 panel [SME: ]
|
||||||
|
|
||||||
|
* Mon Dec 30 2024 Brian Read <brianr@koozali.org> 11.2-1.sme
|
||||||
- Update mailstats.pl to accomodate change in log format for SME11 [SME: 12841]
|
- Update mailstats.pl to accomodate change in log format for SME11 [SME: 12841]
|
||||||
|
|
||||||
* Fri Jun 07 2024 Brian Read <brianr@koozali.org> 1.1-18.sme
|
* Fri Jun 07 2024 Brian Read <brianr@koozali.org> 1.1-18.sme
|
||||||
|
Loading…
x
Reference in New Issue
Block a user