2024-01-12 10:57:58 +01:00
|
|
|
{% extends 'layouts/main.html' %}
|
|
|
|
|
|
|
|
|
|
{% block content %}
|
2024-01-19 11:13:01 +01:00
|
|
|
<h1>{{ title }}</h1>
|
2024-01-12 10:57:58 +01:00
|
|
|
<h3>{{ utc_dt }}</h3>
|
|
|
|
|
|
|
|
|
|
|
2024-01-23 11:17:24 +01:00
|
|
|
<style>
|
|
|
|
|
#heatmap {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(7, 0fr); /* 7 Tage in einer Woche */
|
|
|
|
|
gap: 5px;
|
2024-01-16 11:16:21 +01:00
|
|
|
}
|
|
|
|
|
|
2024-01-23 11:17:24 +01:00
|
|
|
.day {
|
|
|
|
|
width: 50px; /* Ändere die Breite nach Bedarf */
|
|
|
|
|
height: 50px; /* Ändere die Höhe nach Bedarf */
|
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
2024-01-19 10:27:08 +01:00
|
|
|
|
2024-01-23 11:17:24 +01:00
|
|
|
<div class="row">
|
2024-01-19 11:13:01 +01:00
|
|
|
|
2024-01-26 10:01:02 +01:00
|
|
|
<div class="col-sm-12 col-md-5 col-12" id="heatmap"></div>
|
2024-01-23 11:17:24 +01:00
|
|
|
<script>
|
|
|
|
|
// Funktion zur Rückgabe des Montagsdatums
|
|
|
|
|
function getMonday(date) {
|
|
|
|
|
const day = date.getDay();
|
|
|
|
|
const diff = date.getDate() - day + (day === 0 ? -6 : 1); // Anpassung für Sonntag
|
|
|
|
|
return new Date(date.setDate(diff));
|
|
|
|
|
}
|
2024-01-19 11:13:01 +01:00
|
|
|
|
2024-01-23 11:17:24 +01:00
|
|
|
// Simulierte Aktivitätsdaten (ersetze dies durch deine echten Daten)
|
2024-01-26 09:13:33 +01:00
|
|
|
const activityData = [9, 5, 11, 39, 24, 2, 10, 47, 32, 45, 9, 5, 11, 39, 24, 2, 10, 47, 32, 45];
|
2024-01-23 11:17:24 +01:00
|
|
|
|
|
|
|
|
// Funktion zum Erstellen der Heatmap
|
|
|
|
|
function createHeatmap(data) {
|
|
|
|
|
const heatmapContainer = document.getElementById('heatmap');
|
|
|
|
|
|
|
|
|
|
// Aktuelles Datum des Montags
|
2024-01-26 09:13:33 +01:00
|
|
|
const days = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So']
|
2024-01-23 11:17:24 +01:00
|
|
|
|
|
|
|
|
for (let i = 0; i < 7; i++) {
|
|
|
|
|
const dayElement = document.createElement('div');
|
|
|
|
|
dayElement.classList.add('day');
|
2024-01-26 09:13:33 +01:00
|
|
|
dayElement.textContent = days[i];
|
2024-01-23 11:17:24 +01:00
|
|
|
heatmapContainer.appendChild(dayElement);
|
2024-01-26 09:13:33 +01:00
|
|
|
// currentDate.setDate(currentDate.getDate() + 1);
|
2024-01-23 11:17:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Aktuelles Datum des Montags in der neuen linken Spalte
|
|
|
|
|
for (let i = 0; i < 7; i++) {
|
2024-01-26 09:13:33 +01:00
|
|
|
for (let j = 0; j < 7; j++) {
|
|
|
|
|
console.log(i * 7 + j, data[i * 7 + j], Math.max(...data));
|
2024-01-23 11:17:24 +01:00
|
|
|
const opacity = data[i * 7 + j] / Math.max(...data); // Berechne die Opazität basierend auf Aktivitätsanzahl
|
2024-01-26 09:13:33 +01:00
|
|
|
|
|
|
|
|
if (data[i * 7 + j]) {
|
|
|
|
|
const dayElement = document.createElement('div');
|
|
|
|
|
dayElement.classList.add('day');
|
|
|
|
|
dayElement.style.backgroundColor = `rgba(0, 255, 0, ${opacity})`;
|
|
|
|
|
heatmapContainer.appendChild(dayElement);
|
|
|
|
|
} else {
|
|
|
|
|
const dayElement = document.createElement('div');
|
|
|
|
|
// dayElement.classList.add('day');
|
|
|
|
|
// dayElement.style.backgroundColor = `rgba(0, 255, 0, ${opacity})`;
|
|
|
|
|
heatmapContainer.appendChild(dayElement);
|
|
|
|
|
}
|
2024-01-23 11:17:24 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-01-19 11:13:01 +01:00
|
|
|
|
2024-01-23 11:17:24 +01:00
|
|
|
// Erstelle die Heatmap mit den simulierten Daten
|
|
|
|
|
createHeatmap(activityData);
|
|
|
|
|
</script>
|
2024-01-16 11:16:21 +01:00
|
|
|
|
2024-01-26 10:01:02 +01:00
|
|
|
<div class="col-sm-12 col-md-7 col-12">
|
2024-01-23 11:17:24 +01:00
|
|
|
<div class="row">
|
|
|
|
|
<h2 class="col-10">Task List</h2>
|
|
|
|
|
<a class="col-2 btn btn-primary" role="button" href="/habit">
|
|
|
|
|
Task erstellen
|
|
|
|
|
</a>
|
2024-01-19 10:27:08 +01:00
|
|
|
</div>
|
|
|
|
|
|
2024-01-23 11:17:24 +01:00
|
|
|
<ul class="task-list row">
|
|
|
|
|
{% for habit in habits %}
|
|
|
|
|
<li class="row col-md-4">
|
|
|
|
|
<div class="col-auto">
|
2024-01-26 10:01:02 +01:00
|
|
|
<input {% if habit.checked %} checked {% endif %} type="checkbox" class="task-checkbox" id="{{habit.id}}" onclick="sendPostRequest('{{habit.id}}')">
|
2024-01-23 11:17:24 +01:00
|
|
|
</div>
|
2024-01-19 10:27:08 +01:00
|
|
|
|
2024-01-23 11:17:24 +01:00
|
|
|
<div class="col" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
|
|
|
|
|
{{ habit.name }}
|
|
|
|
|
</div>
|
2024-01-19 10:27:08 +01:00
|
|
|
|
2024-01-23 11:17:24 +01:00
|
|
|
</li>
|
2024-01-19 10:27:08 +01:00
|
|
|
|
2024-01-23 11:17:24 +01:00
|
|
|
<div class="col-md-8" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
|
|
|
|
|
{{ habit.note }}
|
|
|
|
|
</div>
|
2024-01-17 11:17:35 +01:00
|
|
|
|
2024-01-23 11:17:24 +01:00
|
|
|
{% endfor %}
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
2024-01-26 08:27:44 +01:00
|
|
|
<script>
|
|
|
|
|
function sendPostRequest(checkboxId) {
|
|
|
|
|
// Get the checkbox element using the provided ID
|
|
|
|
|
var checkbox = document.getElementById(checkboxId);
|
2024-01-26 10:01:02 +01:00
|
|
|
// console.log(checkbox);
|
|
|
|
|
|
|
|
|
|
// Get the habit id from the checkbox id attribute
|
|
|
|
|
var habitId = checkboxId;
|
|
|
|
|
|
|
|
|
|
// Make a POST request to /check with the habit id
|
|
|
|
|
axios.post('/check', { habitId: habitId }, {
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
|
}
|
|
|
|
|
}).then(function (response) {
|
|
|
|
|
// Handle the success response if needed
|
|
|
|
|
console.log(response.data);
|
|
|
|
|
}).catch(function (error) {
|
|
|
|
|
// Handle the error if needed
|
|
|
|
|
console.error('Error:', error);
|
|
|
|
|
});
|
2024-01-26 08:27:44 +01:00
|
|
|
}
|
|
|
|
|
</script>
|
2024-01-23 11:17:24 +01:00
|
|
|
</div>
|
2024-01-16 11:16:21 +01:00
|
|
|
|
2024-01-12 10:57:58 +01:00
|
|
|
{% endblock %}
|