Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorporate pending PR int one commit and add youtube song links #85

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BirdNET-Pi/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions birdcage_backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions birdcage_frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
CMD ["./start_app.sh"]
2 changes: 1 addition & 1 deletion birdcage_frontend/templates/annual_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ <h3 id="report-summary">Total Detections: 0 | Unique Species: 0</h3>
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;
}
}
Expand Down
5 changes: 3 additions & 2 deletions birdcage_frontend/templates/detection_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<button id="back-btn" class="btn btn-secondary">Go Back</button>
</div>
<div class="col-8 text-center">
<h1 class="my-4 d-inline-block mx-auto"><span id="detection-common-name"></span></h1>
<h1 class="my-4 d-inline-block mx-auto"><a target="_blank" id="detection-common-name" href=""></a></h1>
</div>
<div class="col-2"></div>
</div>
Expand Down Expand Up @@ -60,6 +60,7 @@ <h1 class="my-4 d-inline-block mx-auto"><span id="detection-common-name"></span>
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;

Expand Down Expand Up @@ -98,4 +99,4 @@ <h1 class="my-4 d-inline-block mx-auto"><span id="detection-common-name"></span>
updateDetectionDetails();

</script>
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion birdcage_frontend/templates/detections_by_name.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{% block content %}
<div class="row">
<div class="col-12 text-center">
<h1 class="my-4">Detections for {{ common_name }}, {{ date }}{% if end_date %} to {{ end_date }}{% endif %}</h1>
<h1 class="my-4">Detections for <a target="_blank" href="https://www.youtube.com/results?search_query={{ common_name }} call">{{ common_name }}</a>, {{ date }}{% if end_date %} to {{ end_date }}{% endif %}</h1>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion birdcage_frontend/templates/monthly_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ <h3 id="report-summary">Total Detections: 0 | Unique Species: 0</h3>
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;
}
}
Expand Down
21 changes: 15 additions & 6 deletions birdcage_frontend/templates/weekly_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h3 id="report-summary">Total Detections: 0 | Unique Species: 0</h3>
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)
Expand Down Expand Up @@ -157,11 +157,17 @@ <h3 id="report-summary">Total Detections: 0 | Unique Species: 0</h3>
});
}

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 () {
Expand All @@ -172,7 +178,7 @@ <h3 id="report-summary">Total Detections: 0 | Unique Species: 0</h3>
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}`;
Expand All @@ -185,7 +191,10 @@ <h3 id="report-summary">Total Detections: 0 | Unique Species: 0</h3>
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;
}

Expand Down
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -58,6 +60,7 @@ services:
- birdcage_net

birdcage_frontend:
restart: unless-stopped
image: "mmcc73/birdcage_frontend:latest"
ports:
- "7008:7008"
Expand All @@ -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"
Expand Down