From 8fb03a36fbef3682aec47fe324c5d52f66e8c896 Mon Sep 17 00:00:00 2001 From: Alek Pinchuk Date: Sun, 5 May 2024 14:48:12 -0400 Subject: [PATCH 1/2] added upstream PRs --- BirdNET-Pi/server.py | 1 + birdcage_backend/Dockerfile | 4 ++-- birdcage_frontend/Dockerfile | 4 ++-- .../templates/annual_report.html | 2 +- .../templates/monthly_report.html | 2 +- .../templates/weekly_report.html | 21 +++++++++++++------ docker-compose.yml | 6 ++++-- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/BirdNET-Pi/server.py b/BirdNET-Pi/server.py index b3a46f8..c4d1807 100644 --- a/BirdNET-Pi/server.py +++ b/BirdNET-Pi/server.py @@ -292,6 +292,7 @@ def handle_client(conn, addr): settings_dict = config_to_settings(userDir + '/BirdNET-Pi/scripts/thisrun.txt') sendAppriseNotifications(species2, str(score), + str(round(score * 100)), File_Name, Date, Time, diff --git a/birdcage_backend/Dockerfile b/birdcage_backend/Dockerfile index cf74733..10ce54e 100644 --- a/birdcage_backend/Dockerfile +++ b/birdcage_backend/Dockerfile @@ -17,11 +17,11 @@ COPY app /app ENV DATABASE_FILE=/db/birdcage.db \ API_SERVER_PORT=7007 \ TEMP_DIR_NAME=tmp \ - ANALYZE_SERVER=192.168.1.75 \ + ANALYZE_SERVER=127.0.0.1 \ ANALYZE_PORT=7667 \ DETECTION_DIR_NAME=detections \ CORS_ORIGINS=http://192.168.1.75:7008 \ - REDIS_SERVER=192.168.1.75 \ + REDIS_SERVER=127.0.0.1 \ REDIS_PORT=6379 # Grant execution permission to start_app.sh diff --git a/birdcage_frontend/Dockerfile b/birdcage_frontend/Dockerfile index b47be3d..465592c 100644 --- a/birdcage_frontend/Dockerfile +++ b/birdcage_frontend/Dockerfile @@ -11,11 +11,11 @@ COPY webui.py / COPY static /static COPY templates /templates -ENV API_SERVER_URL=http://192.168.1.75 \ +ENV API_SERVER_URL=http://127.0.0.1 \ WEBUI_PORT=7008 # Grant execution permission to start_app.sh RUN chmod +x start_app.sh # Start the app -CMD ["./start_app.sh"] \ No newline at end of file +CMD ["./start_app.sh"] diff --git a/birdcage_frontend/templates/annual_report.html b/birdcage_frontend/templates/annual_report.html index e4b6ffd..c0fca21 100644 --- a/birdcage_frontend/templates/annual_report.html +++ b/birdcage_frontend/templates/annual_report.html @@ -185,7 +185,7 @@

Total Detections: 0 | Unique Species: 0

defaultDate: "{{ year }}", onChange: function (selectedDates, dateStr, instance) { if (selectedDates.length > 0) { - const newUrl = `/annual_report/${dateStr}`; + const newUrl = `{{ script_name }}/annual_report/${dateStr}`; window.location.href = newUrl; } } diff --git a/birdcage_frontend/templates/monthly_report.html b/birdcage_frontend/templates/monthly_report.html index f81cafc..2e92de5 100644 --- a/birdcage_frontend/templates/monthly_report.html +++ b/birdcage_frontend/templates/monthly_report.html @@ -167,7 +167,7 @@

Total Detections: 0 | Unique Species: 0

defaultDate: "{{ month }}", onChange: function (selectedDates, dateStr, instance) { if (selectedDates.length > 0) { - const newUrl = `/monthly_report/${dateStr}`; + const newUrl = `{{ script_name }}/monthly_report/${dateStr}`; window.location.href = newUrl; } } diff --git a/birdcage_frontend/templates/weekly_report.html b/birdcage_frontend/templates/weekly_report.html index 7dae2a2..988d87a 100644 --- a/birdcage_frontend/templates/weekly_report.html +++ b/birdcage_frontend/templates/weekly_report.html @@ -77,7 +77,7 @@

Total Detections: 0 | Unique Species: 0

const [year, week] = weekString.split('-W'); // Calculate the start of the week (Monday) - const start = new Date(year, 0, (week) * 7 + 1); + const start = getMondayOfWeek(weekString); start.setDate(start.getDate() - (start.getDay() + 6) % 7); // Calculate the end of the week (Sunday) @@ -157,11 +157,17 @@

Total Detections: 0 | Unique Species: 0

}); } + function getWeekYear(date) { + const thursday = new Date(date); + thursday.setDate(thursday.getDate() + 3 - (thursday.getDay() + 6) % 7); + return thursday.getFullYear(); + } function getWeekNumber(date) { - const firstDayOfYear = new Date(date.getFullYear(), 0, 1); - const dayOfYear = (date - firstDayOfYear + (86400000 /* ms per day */ * (firstDayOfYear.getDay() + 1))) / 86400000; - return Math.ceil(dayOfYear / 7); + const thursday = new Date(date); + thursday.setDate(thursday.getDate() + 3 - (thursday.getDay() + 6) % 7); + const firstWeek = new Date(thursday.getFullYear(), 0, 4); + return 1 + Math.round(((thursday.getTime() - firstWeek.getTime()) / 86400000 - 3 + (firstWeek.getDay() + 6) % 7) / 7); } document.addEventListener('DOMContentLoaded', function () { @@ -172,7 +178,7 @@

Total Detections: 0 | Unique Species: 0

onChange: function (selectedDates, dateStr, instance) { if (selectedDates.length > 0) { const selectedDate = selectedDates[0]; - const selectedWeek = selectedDate.getFullYear() + "-W" + getWeekNumber(selectedDate); + const selectedWeek = getWeekYear(selectedDate) + "-W" + getWeekNumber(selectedDate); instance.input.value = selectedWeek; // Redirect to the new URL for the selected week const newUrl = `{{ script_name }}/weekly_report/${selectedWeek}`; @@ -185,7 +191,10 @@

Total Detections: 0 | Unique Species: 0

function getMondayOfWeek(weekString) { const [year, week] = weekString.split('-W'); const date = new Date(year, 0, (week) * 7 + 1); - date.setDate(date.getDate() - (date.getDay() + 6) % 7); + if (date.getDay() <= 4) { + date.setDate(date.getDate() - 7); + } + date.setDate(date.getDate() - date.getDay() + 1); return date; } diff --git a/docker-compose.yml b/docker-compose.yml index bd2411c..9c819df 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,12 +14,14 @@ services: - "7667:8080" redis: + restart: unless-stopped image: "redis:latest" #the redis server doesn't need to be exposed outside the virtual network, so no "ports" #mapping is needed networks: - birdcage_net birdcage_backend: + restart: unless-stopped image: "mmcc73/birdcage_backend:latest" ports: - "7007:7007" @@ -43,7 +45,7 @@ services: #to be fancy you can use a device on a remote machine and put its address here. See the wiki #SCRIPT_NAME: /birdcage # Uncomment this if you want to reverse proxy to BirdCAGE at a subfolder like /birdcage/ tmpfs: - - /tmp:size=16M #you might want to increase this size if you are recording a bunch of streams, if your + - /tmp:size=64M #you might want to increase this size if you are recording a bunch of streams, if your # streams are particularly hi-res, or if your analyzer might be periodically unavailable #volumes_from: #uncomment for HA addon # - container:addon_local_birdcage #uncomment for HA addon @@ -58,6 +60,7 @@ services: - birdcage_net birdcage_frontend: + restart: unless-stopped image: "mmcc73/birdcage_frontend:latest" ports: - "7008:7008" @@ -67,7 +70,6 @@ services: #SCRIPT_NAME: /birdcage # Uncomment this if you want to reverse proxy to BirdCAGE at a subfolder like /birdcage/ #TITLE_TEXT: Your Title Here #TITLE_LINK: http://yourlinkhere - #TITLE_TEXT: Your Title Here #Include the above variables if you want to put some text, and optionally a link, in the nav bar volumes: - "/etc/localtime:/etc/localtime:ro" From 60fa38cdfe884bcb3ad20910cb7e952e4932f5a7 Mon Sep 17 00:00:00 2001 From: Alek Pinchuk Date: Sun, 5 May 2024 16:17:14 -0400 Subject: [PATCH 2/2] added youtube bird call search links --- birdcage_frontend/templates/detection_details.html | 5 +++-- birdcage_frontend/templates/detections_by_name.html | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/birdcage_frontend/templates/detection_details.html b/birdcage_frontend/templates/detection_details.html index edb4177..5914930 100644 --- a/birdcage_frontend/templates/detection_details.html +++ b/birdcage_frontend/templates/detection_details.html @@ -10,7 +10,7 @@
-

+

@@ -60,6 +60,7 @@

document.querySelector('#detection-streamname').textContent = detection.streamname; document.querySelector('#detection-scientific-name').textContent = detection.scientific_name; document.querySelector('#detection-common-name').textContent = detection.common_name; + document.querySelector('#detection-common-name').href = "https://www.youtube.com/results?search_query=" + detection.common_name + " call"; document.querySelector('#detection-confidence').textContent = detection.confidence; document.querySelector('#detection-filename').textContent = detection.filename; @@ -98,4 +99,4 @@

updateDetectionDetails(); -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/birdcage_frontend/templates/detections_by_name.html b/birdcage_frontend/templates/detections_by_name.html index b1937f5..699e5e0 100644 --- a/birdcage_frontend/templates/detections_by_name.html +++ b/birdcage_frontend/templates/detections_by_name.html @@ -13,7 +13,7 @@ {% block content %}
-

Detections for {{ common_name }}, {{ date }}{% if end_date %} to {{ end_date }}{% endif %}

+

Detections for {{ common_name }}, {{ date }}{% if end_date %} to {{ end_date }}{% endif %}