More changes to responsive tables and make top liks depend on email or web
This commit is contained in:
parent
52c1bfba48
commit
389175c392
@ -8,6 +8,7 @@ $event = 'smeserver-mailstats-update';
|
|||||||
foreach my $file (qw(
|
foreach my $file (qw(
|
||||||
/etc/systemd/system-preset/49-koozali.preset
|
/etc/systemd/system-preset/49-koozali.preset
|
||||||
/etc/e-smith/sql/init/99smeserver-mailstats.sql
|
/etc/e-smith/sql/init/99smeserver-mailstats.sql
|
||||||
|
/etc/httpd/conf/httpd.conf
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
templates2events( $file, $event );
|
templates2events( $file, $event );
|
||||||
@ -18,7 +19,7 @@ event_link('systemd-reload', $event, '50');
|
|||||||
#action specific to this package
|
#action specific to this package
|
||||||
#event_link('action', $event, '30');
|
#event_link('action', $event, '30');
|
||||||
#services we need to restart
|
#services we need to restart
|
||||||
#safe_symlink('restart', 'root/etc/e-smith/events/$event/services2adjust/<service>)
|
safe_symlink('restart', "root/etc/e-smith/events/$event/services2adjust/httpd-e-smith");
|
||||||
#and Server Mmanager panel link
|
#and Server Mmanager panel link
|
||||||
#panel_link('somefunction', 'manager');
|
#panel_link('somefunction', 'manager');
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<!-- 1. Take out style for table for email
|
<!-- 1. Take out style for table for email
|
||||||
2. Switch "see in Browser" to "index" in web version
|
2. Switch "see in Browser" to "index" in web version
|
||||||
>
|
-->
|
||||||
<html><head>
|
<html><head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>SMEServer Mailstats</title>
|
<title>SMEServer Mailstats</title>
|
||||||
@ -39,28 +39,27 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div style="width:100%;overflow-x:auto;font-size:1cqw">
|
||||||
<!---Navigation here-->
|
<!---Navigation here-->
|
||||||
<br />
|
<br />
|
||||||
<h2>${title}</h2>
|
<h2>${title}</h2>
|
||||||
<br />
|
<br />
|
||||||
<div style="width:100%;overflow-x:auto;font-size:1.35cqw">
|
<table border="1">
|
||||||
<table border="1">
|
<thead>
|
||||||
<thead>
|
<tr>
|
||||||
<tr>
|
<th>Date/Time</th>
|
||||||
<th>Date/Time</th>
|
<th tal:repeat="header column_headers" tal:content="header">Header</th>
|
||||||
<th tal:repeat="header column_headers" tal:content="header">Header</th>
|
</tr>
|
||||||
</tr>
|
</thead>
|
||||||
</thead>
|
<tbody>
|
||||||
<tbody>
|
<tr tal:repeat="row array_2d">
|
||||||
<tr tal:repeat="row array_2d">
|
<td tal:condition="repeat.row.index == 24" tal:content="'TOTALS'">Totals</td>
|
||||||
<td tal:condition="repeat.row.index == 24" tal:content="'TOTALS'">Totals</td>
|
<td tal:condition="repeat.row.index == 25" tal:content="'PERCENT'">Percent</td>
|
||||||
<td tal:condition="repeat.row.index == 25" tal:content="'PERCENT'">Percent</td>
|
<td tal:condition="repeat.row.index < 24" tal:content="string:${reporting_date}, ${repeat.row.index}">Hour</td>
|
||||||
<td tal:condition="repeat.row.index < 24" tal:content="string:${reporting_date}, ${repeat.row.index}">Hour</td>
|
<td tal:repeat="cell row" tal:content="cell">Cell</td>
|
||||||
<td tal:repeat="cell row" tal:content="cell">Cell</td>
|
</tr>
|
||||||
</tr>
|
</tbody>
|
||||||
</tbody>
|
</table>
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<!---Add in sub tables here -->
|
<!---Add in sub tables here -->
|
||||||
<br />
|
<br />
|
||||||
<footer>${version}</footer>
|
<footer>${version}</footer>
|
||||||
@ -78,6 +77,6 @@
|
|||||||
src="http://www.w3.org/Icons/valid-xhtml10"
|
src="http://www.w3.org/Icons/valid-xhtml10"
|
||||||
alt="Valid XHTML 1.0!" height="31" width="88" /></a>
|
alt="Valid XHTML 1.0!" height="31" width="88" /></a>
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -589,6 +589,13 @@ def send_email(subject, from_email, to_email, smtp_server, smtp_port, HTML_conte
|
|||||||
server.login(smtp_user, smtp_password) # Authenticate only if credentials are provided
|
server.login(smtp_user, smtp_password) # Authenticate only if credentials are provided
|
||||||
server.sendmail(from_email, to_email, msg.as_string())
|
server.sendmail(from_email, to_email, msg.as_string())
|
||||||
|
|
||||||
|
def replace_between(text, start, end, replacement):
|
||||||
|
# Escaping start and end in case they contain special regex characters
|
||||||
|
pattern = re.escape(start) + '.*?' + re.escape(end)
|
||||||
|
# Using re.DOTALL to match any character including newline
|
||||||
|
replaced_text = re.sub(pattern, replacement, text, flags=re.DOTALL)
|
||||||
|
return replaced_text
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
chameleon_version = pkg_resources.get_distribution("Chameleon").version
|
chameleon_version = pkg_resources.get_distribution("Chameleon").version
|
||||||
@ -897,7 +904,7 @@ if __name__ == "__main__":
|
|||||||
previous_date_str = previous_date.strftime(day_format)
|
previous_date_str = previous_date.strftime(day_format)
|
||||||
navigation_str_html = "<div class='linksattop'>\
|
navigation_str_html = "<div class='linksattop'>\
|
||||||
<a class='prevlink' href='http://${DomainName}/mailstats/mailstats_for_${PreviousDate}.html'>Previous</a>\
|
<a class='prevlink' href='http://${DomainName}/mailstats/mailstats_for_${PreviousDate}.html'>Previous</a>\
|
||||||
<div class='divseeinbrowser'><a class='seeinbrowser' href='http://${DomainName}/mailstats/mailstats_for_${TodayDate}.html'>See in browser</a></div>\
|
<div class='divshowindex'><a class='showindex' href='http://${DomainName}/mailstats/'>Index of files</a></div>\
|
||||||
<a class='nextlink' href='http://${DomainName}/mailstats/mailstats_for_${NextDate}.html'>Next</a>\
|
<a class='nextlink' href='http://${DomainName}/mailstats/mailstats_for_${NextDate}.html'>Next</a>\
|
||||||
</div>"
|
</div>"
|
||||||
template = PageTemplate(navigation_str_html)
|
template = PageTemplate(navigation_str_html)
|
||||||
@ -923,6 +930,9 @@ if __name__ == "__main__":
|
|||||||
# Send html email (default))
|
# Send html email (default))
|
||||||
filepath = html_page_dir+"mailstats_for_"+formatted_yesterday+".html"
|
filepath = html_page_dir+"mailstats_for_"+formatted_yesterday+".html"
|
||||||
html_content = read_html_from_file(filepath)
|
html_content = read_html_from_file(filepath)
|
||||||
|
# Replace the Navigation by a "See in browser" prompt
|
||||||
|
replace_str = f"<div class='divseeinbrowser' style='text-align:center;'><a class='seeinbrowser' href='http://{DomainName}/mailstats/mailstats_for_{formatted_yesterday}.html'>See in browser</a></div>"
|
||||||
|
html_content = replace_between(html_content, "<div class='linksattop'>", ">Next</a></div>", replace_str)
|
||||||
if EmailTextOrHTML == "Text" or EmailTextOrHTML == "Both":
|
if EmailTextOrHTML == "Text" or EmailTextOrHTML == "Both":
|
||||||
filepath = html_page_dir+"mailstats_for_"+formatted_yesterday+".txt"
|
filepath = html_page_dir+"mailstats_for_"+formatted_yesterday+".txt"
|
||||||
text_content = read_text_from_file(filepath)
|
text_content = read_text_from_file(filepath)
|
||||||
|
Loading…
Reference in New Issue
Block a user