From c3c1e9d9423b3c44126ea75f2694dd9028b8b0cb Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sun, 29 May 2022 11:07:44 -0400
Subject: [PATCH] 5 most recent detections on overview
---
homepage/style.css | 32 +++++++++++++++++++++++++++++++-
scripts/overview.php | 21 ++++++++++++++++++++-
scripts/todays_detections.php | 23 +++++++++++++++++++----
3 files changed, 70 insertions(+), 6 deletions(-)
diff --git a/homepage/style.css b/homepage/style.css
index 61b4109..32ec6f0 100644
--- a/homepage/style.css
+++ b/homepage/style.css
@@ -676,6 +676,18 @@ dialog::backdrop {
box-shadow:0px 2px 4px -1px rgb(0 0 0 / 20%), 0px 4px 5px 0px rgb(0 0 0 / 14%), 0px 1px 10px 0px rgb(0 0 0 / 12%);
}
+#birdimage {
+ transition:box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);
+ box-shadow:0px 3px 1px -2px rgb(0 0 0 / 20%), 0px 2px 2px 0px rgb(0 0 0 / 14%), 0px 1px 5px 0px rgb(0 0 0 / 12%);
+ cursor:pointer;
+ border-radius: 5px;
+}
+
+#birdimage:hover {
+ opacity:0.8;
+ box-shadow:0px 2px 4px -1px rgb(0 0 0 / 20%), 0px 4px 5px 0px rgb(0 0 0 / 14%), 0px 1px 10px 0px rgb(0 0 0 / 12%);
+}
+
.centered_image_container * {
font-size:19px !important;
}
@@ -711,4 +723,22 @@ dialog::backdrop {
form#views button .updatenumber {
position:initial;
margin-left:0px;
-}
\ No newline at end of file
+}
+
+#detections_table_overview table {
+ width:944px;
+}
+
+#recent_detection_middle_td{
+ width:33%;
+}
+@media screen and (max-width:500px) {
+ #recent_detection_middle_td{
+ width:66%;
+ }
+}
+#recent_detection_middle_td img{
+ width:unset !important;
+ height:75px;
+ float:left;
+}
diff --git a/scripts/overview.php b/scripts/overview.php
index fdc6d22..c77db38 100644
--- a/scripts/overview.php
+++ b/scripts/overview.php
@@ -251,6 +251,9 @@ if (file_exists('./Charts/'.$chart)) {
+
+5 Most Recent Detections
+Loading...
Currently Analyzing
0 && !this.responseText.includes("Database is busy")) {
document.getElementById("most_recent_detection").innerHTML = this.responseText;
- // only going to load left chart if there's a new detection
+ // only going to load left chart & 5 most recents if there's a new detection
loadLeftChart();
+ loadFiveMostRecentDetections();
}
}
xhttp.open("GET", "overview.php?ajax_detections=true&previous_detection_identifier="+previous_detection_identifier, true);
@@ -298,10 +302,25 @@ window.setInterval(function(){
loadDetectionIfNewExists();
}
}, *1000);
+
+function loadFiveMostRecentDetections() {
+ const xhttp = new XMLHttpRequest();
+ xhttp.onload = function() {
+ document.getElementById("detections_table").innerHTML= this.responseText;
+ }
+ if (window.innerWidth > 500) {
+ xhttp.open("GET", "todays_detections.php?ajax_detections=true&display_limit=undefined&hard_limit=5", true);
+ } else {
+ xhttp.open("GET", "todays_detections.php?ajax_detections=true&display_limit=undefined&hard_limit=5&mobile=true", true);
+ }
+ xhttp.send();
+}
window.addEventListener("load", function(){
+ loadFiveMostRecentDetections();
loadDetectionIfNewExists();
loadLeftChart();
});
+
// every $refresh seconds, this loop will run and refresh the spectrogram image
window.setInterval(function(){
document.getElementById("chart").src = "/Charts/?nocache="+Date.now();
diff --git a/scripts/todays_detections.php b/scripts/todays_detections.php
index f2af8cb..30ec20a 100644
--- a/scripts/todays_detections.php
+++ b/scripts/todays_detections.php
@@ -73,7 +73,12 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" ) {
$statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\', \'localtime\') '.$searchquery.' ORDER BY Time DESC LIMIT '.(intval($_GET['display_limit'])-40).',40');
} else {
// legacy mode
- $statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\', \'localtime\') '.$searchquery.' ORDER BY Time DESC');
+ if(isset($_GET['hard_limit']) && is_numeric($_GET['hard_limit'])) {
+ $statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\', \'localtime\') '.$searchquery.' ORDER BY Time DESC LIMIT '.$_GET['hard_limit']);
+ } else {
+ $statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\', \'localtime\') '.$searchquery.' ORDER BY Time DESC');
+ }
+
}
if($statement0 == False){
echo "Database is busy";
@@ -150,11 +155,21 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" ) {
-
|
-
-
|
+
|
+
+
+
+ 
+
+
+ |
+
Confidence:
|
+
|