From 83737e59d30d46e80259f07dd8d528b06dd43858 Mon Sep 17 00:00:00 2001 From: Andrew DeFaria Date: Fri, 23 Jul 2021 14:56:48 -0700 Subject: [PATCH] Fixed quickstats Well not totally fixed. There are still some CSS issues. --- maps/css/MAPSStyle.css | 37 +++++++++++++++++++++---- maps/lib/MAPS.pm | 17 ++++++------ maps/lib/MAPSLog.pm | 3 +- maps/lib/MAPSWeb.pm | 24 ++++++++-------- maps/php/MAPS.php | 62 ++++++++++++++++++++++-------------------- 5 files changed, 87 insertions(+), 56 deletions(-) diff --git a/maps/css/MAPSStyle.css b/maps/css/MAPSStyle.css index 3945309..cc790d5 100644 --- a/maps/css/MAPSStyle.css +++ b/maps/css/MAPSStyle.css @@ -75,14 +75,44 @@ body { width: 125px; } +#quickwrap { + width: 130px; +} +#quickwrap table { + width: 100%; + table-layout: fixed; + border-collapse: collapse; + background: #579; +} +#quickwrap td.link a { + float: left; + width: 10px; + margin-left: -60px; + padding: 0 60px; + position: relative; + text-decoration: none; + color: white; + font-size: 12px; + font-weight: bold; +} +#quickwrap td.link a:hover { + background: #c1dffc; + color: steelblue; +} +table tr:hover td { + background: #c1dffc; + color: steelblue; +} + .quickstats { - font-size: 10px; + font-size: 12px; + font-weight: bold; line-height: 10px; margin: 2px; width: 125px; } .quickstats a:link { - color: white; + color: #c1dffc; text-decoration: none; } .quickstats a:visited { @@ -92,9 +122,6 @@ body { color: steelblue; background: white; } -.quickstats a:active { - color: Yellow; -} .toolbar a:hover { background: transparent; diff --git a/maps/lib/MAPS.pm b/maps/lib/MAPS.pm index 7bafc97..153c4bb 100644 --- a/maps/lib/MAPS.pm +++ b/maps/lib/MAPS.pm @@ -34,7 +34,7 @@ use base qw(Exporter); our $db; -our $Version = '2.0'; +our $VERSION = '2.0'; # Globals my $userid = $ENV{MAPS_USERNAME} ? $ENV{MAPS_USERNAME} : $ENV{USER}; @@ -155,6 +155,8 @@ sub OpenDB($$) { $db = MyDB->new($username, $password, $dbname, $dbserver); croak "Unable to instantiate MyDB ($username\@$dbserver:$dbname)" unless $db; + + return; } # OpenDB BEGIN { @@ -346,6 +348,7 @@ sub AddUserOptions(%) { } # for return ($err, $msg) if $err; + return; } # AddUserOptions sub Blacklist(%) { @@ -797,11 +800,7 @@ sub GetUser() { sub GetUserInfo($) { my ($userid) = @_; - my $userinfo = $db->getone('user', "userid='$userid'", ['name', 'email']); - return %{$db->getone('user', "userid='$userid'", ['name', 'email'])}; - - return %$userinfo; } # GetUserInfo sub GetUserOptions($) { @@ -1292,7 +1291,7 @@ sub SetContext($) { if (UserExists($to_user)) { $userid = $to_user; - return GetUserInfo $userid; + return GetUserOptions $userid; } else { return 0; } # if @@ -1327,11 +1326,11 @@ sub UpdateList(%) { my $table = 'list'; my $condition = "userid = '$rec{userid}' and type = '$rec{type}' and sequence = $rec{sequence}"; - if ($rec{pattern} =~ /\@/ and !$rec{domain}) { + if ($rec{pattern} =~ /\@/ && !$rec{domain}) { ($rec{pattern}, $rec{domain}) = split /\@/, $rec{pattern}; - } elsif (!$rec{pattern} and $rec{domain} =~ /\@/) { + } elsif (!$rec{pattern} && $rec{domain} =~ /\@/) { ($rec{pattern}, $rec{domain}) = split /\@/, $rec{domain}; - } elsif (!$rec{pattern} and !$rec{domain}) { + } elsif (!$rec{pattern} && !$rec{domain}) { return "Must specify either Username or Domain"; } # if diff --git a/maps/lib/MAPSLog.pm b/maps/lib/MAPSLog.pm index 433de2b..930dd17 100644 --- a/maps/lib/MAPSLog.pm +++ b/maps/lib/MAPSLog.pm @@ -24,6 +24,7 @@ use MAPS; use DateUtils; use Utils; +our @ISA = qw(Exporter); our @EXPORT = qw ( Debug Error @@ -34,12 +35,12 @@ our @EXPORT = qw ( ); our @Types = ( + 'nulllist', 'returned', 'whitelist', 'blacklist', 'registered', 'mailloop', - 'nulllist' ); sub nbr_msgs($) { diff --git a/maps/lib/MAPSWeb.pm b/maps/lib/MAPSWeb.pm index 3389c6a..5097b77 100644 --- a/maps/lib/MAPSWeb.pm +++ b/maps/lib/MAPSWeb.pm @@ -44,7 +44,7 @@ sub getquickstats(%) { my $date = $params{date}; - for (@MAPSLog::Types) { + for (@Types) { $dates{$date}{processed} += $dates{$date}{$_}; } # for @@ -69,11 +69,15 @@ sub displayquickstats($) { 'Today\'s Activity'; print p {-align => 'center'}, b ('as of ' . FormatTime($time)); + + print start_div {-id => 'quickwrap'}; + print start_table { - -align => 'center', - -border => 0, -cellspacing => 0, - -cellpadding => 2}; + -border => 0, + -align => 'center', + -cellpadding => 2, + }; print start_Tr {-align => 'right'}; print td {-class => 'smalllabel', @@ -89,9 +93,10 @@ sub displayquickstats($) { 'n/a'; print end_Tr; - for (@MAPSLog::Types) { + for (@Types) { print start_Tr {-align => 'right'}; + my $foo = $_; my $value = $dates{$date}{$_}; my $percent; @@ -105,13 +110,9 @@ sub displayquickstats($) { my $report = ucfirst $_; - if ($value) { - $report = a {-href => "detail.cgi?type=$_;date=$date"}, $report; - $value = a {-href => "detail.cgi?type=$_;date=$date"}, $value; - $percent = a {-href => "detail.cgi?type=$_;date=$date"}, $percent; - } # if + $report = a {-href => "detail.cgi?type=$_;date=$date"}, $report if $value; - print td {-class => 'smalllabel'}, $report, + print td {-class => 'link'}, $report, td {-class => 'smallnumber'}, $value, td {-class => 'smallnumber'}, $percent; @@ -120,6 +121,7 @@ sub displayquickstats($) { print end_table; print end_div; + print end_div; return; } # displayquickstats diff --git a/maps/php/MAPS.php b/maps/php/MAPS.php index 3816c00..6ccc76d 100755 --- a/maps/php/MAPS.php +++ b/maps/php/MAPS.php @@ -220,9 +220,9 @@ function displayquickstats() { $current_time = date("g:i:s a"); // Start quickstats - print "
"; - print "

Today's Activity

"; - print "

as of $current_time

"; + print "
"; + print "

Today's Activity

"; + print "

as of $current_time

"; $processed = $dates[$today]["processed"]; $returned = $dates[$today]["returned"]; @@ -240,20 +240,21 @@ function displayquickstats() { $nulllist_pct = $processed == 0 ? 0 : number_format ($nulllist / $processed * 100, 1, ".", ""); - $returned_link = $returned == 0 ? 0 : - "$returned"; - $whitelist_link = $whitelist == 0 ? 0 : - "$whitelist"; - $blacklist_link = $blacklist == 0 ? 0 : - "$blacklist"; - $registered_link = $registered == 0 ? 0 : - "$registered"; - $mailloop_link = $mailloop == 0 ? 0 : - "$mailloop"; - $nulllist_link = $nulllist == 0 ? 0 : - "$nulllist"; + $returned_link = $returned == 0 ? '' : + ""; + $whitelist_link = $whitelist == 0 ? '' : + ""; + $blacklist_link = $blacklist == 0 ? '' : + ""; + $registered_link = $registered == 0 ? '' : + ""; + $mailloop_link = $mailloop == 0 ? '' : + "\""; + $nulllist_link = $nulllist == 0 ? '' : + ""; print << @@ -261,37 +262,38 @@ print <<n/a - - + + + + + + - - + - - + - - + - - + - - - -
Processed
Returned$returned_link + $nulllist$nulllist_pct%
$returned $returned_pct%
Whitelist$whitelist_link + $whitelist $whitelist_pct%
Blacklist$blacklist_link + $blacklist $blacklist_pct%
Registered$registered_link + $registered n/a
Mailloop$mailloop_link + $mailloop n/a
Nulllist$nulllist_link - $nulllist_pct%
+
EOT; } // displayquickstats -- 2.17.1