Compare commits
2 Commits
a74e8b0cf1
...
92b099b112
| Author | SHA1 | Date | |
|---|---|---|---|
| 92b099b112 | |||
| d3013a5982 |
@ -1,43 +1,43 @@
|
|||||||
{% extends 'layouts/main.html' %}
|
{% extends 'layouts/main.html' %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{{ title }}</h1>
|
<h1>{{ title }}</h1>
|
||||||
<h3>{{ utc_dt }}</h3>
|
<h3>{{ utc_dt }}</h3>
|
||||||
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
#heatmap {
|
#heatmap {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(7, 0fr); /* 7 Tage in einer Woche */
|
grid-template-columns: repeat(7, 0fr); /* 7 Tage in einer Woche */
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
}
|
width: 100%;
|
||||||
|
table-layout: fixed;
|
||||||
|
}
|
||||||
|
|
||||||
.day {
|
.day {
|
||||||
width: 50px;
|
width: 50px;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
table-layout: fixed;
|
||||||
</style>
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<div class="row">
|
<div class="d-flex flex-column gap-5">
|
||||||
|
<div class="d-flex gap-3">
|
||||||
<div class="col-md-5 col-12">
|
<div class="flex-md-fill col-md-4 col-12 card bg-light mb-6">
|
||||||
<div id="heatmap"></div>
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Heatmap</h5>
|
||||||
|
<div id="heatmap"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<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));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Simulierte Aktivitätsdaten (ersetze dies durch deine echten Daten)
|
// Simulierte Aktivitätsdaten (ersetze dies durch deine echten Daten)
|
||||||
const activityData = [5, 3, 10, 5, 24, 2, 10, 47, 32, 45, 9, 5, 11, 39, 24, 2, 10, 47, 32, 45];
|
const activityData = {{ heatmap_values }};
|
||||||
|
|
||||||
// Funktion zum Erstellen der Heatmap
|
// Funktion zum Erstellen der Heatmap
|
||||||
function createHeatmap(data) {
|
function createHeatmap(data) {
|
||||||
@ -56,9 +56,9 @@
|
|||||||
|
|
||||||
// Aktuelles Datum des Montags in der neuen linken Spalte
|
// Aktuelles Datum des Montags in der neuen linken Spalte
|
||||||
for (let i = 0; i < 7; i++) {
|
for (let i = 0; i < 7; i++) {
|
||||||
for (let j = 0; j < 7; j++) {
|
for (let j = 0; j < 4; j++) {
|
||||||
// console.log(i * 7 + j, data[i * 7 + j], Math.max(...data));
|
// console.log(i * 7 + j, data[i * 7 + j], Math.max(...data));
|
||||||
const opacity = data[i * 7 + j] / Math.max(...data); // Berechne die Opazität basierend auf Aktivitätsanzahl
|
const opacity = data[i * 7 + j] / (Math.max(...data) <= 0 ? 1 : Math.max(...data)); // Berechne die Opazität basierend auf Aktivitätsanzahl
|
||||||
|
|
||||||
if (data[i * 7 + j]) {
|
if (data[i * 7 + j]) {
|
||||||
const dayElement = document.createElement('div');
|
const dayElement = document.createElement('div');
|
||||||
@ -67,77 +67,110 @@
|
|||||||
heatmapContainer.appendChild(dayElement);
|
heatmapContainer.appendChild(dayElement);
|
||||||
} else {
|
} else {
|
||||||
const dayElement = document.createElement('div');
|
const dayElement = document.createElement('div');
|
||||||
// dayElement.classList.add('day');
|
dayElement.classList.add('day');
|
||||||
// dayElement.style.backgroundColor = `rgba(0, 255, 0, ${opacity})`;
|
dayElement.style.backgroundColor = `rgba(0, 255, 0, ${opacity})`;
|
||||||
heatmapContainer.appendChild(dayElement);
|
heatmapContainer.appendChild(dayElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var left = 7 - (new Date()).getDay();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Erstelle die Heatmap mit den simulierten Daten
|
// Erstelle die Heatmap mit den simulierten Daten
|
||||||
createHeatmap(activityData);
|
createHeatmap(activityData);
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="col-md-7 col-12">
|
|
||||||
|
<div class="flex-fill col-md-8 col-12 card bg-light p-6 mb-6">
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<h2 class="col-9">Gewohnheiten</h2>
|
<h2 class="col-9">Gewohnheiten</h2>
|
||||||
<a class="col-3 btn btn-primary" role="button" href="/habit-list">Neue Liste erstellen</a>
|
<a class="col-3 btn btn-primary p" role="button" href="/habit-list">Neue Liste erstellen</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="card-header">
|
||||||
|
<ul class="nav nav-tabs card-header-tabs">
|
||||||
|
|
||||||
|
{% for habit_list in habit_lists %}
|
||||||
|
<li class="nav-item">
|
||||||
|
{% if habit_list == habit_lists[0] %}
|
||||||
|
<a class="nav-link active" aria-current="true">{{ habit_list.name }}</a>
|
||||||
|
{% else %}
|
||||||
|
<a class="nav-link">{{ habit_list.name }}</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-body text-center">
|
||||||
|
<h5 class="card-title">Special title treatment</h5>
|
||||||
|
<p class="card-text">
|
||||||
|
With supporting text below as a natural lead-in to additional content.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% for habit_list in habit_lists %}
|
{% for habit_list in habit_lists %}
|
||||||
|
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<h2 class="col-9">{{ habit_list.name }}</h2>
|
<h2 class="col-9">{{ habit_list.name }}</h2>
|
||||||
<a class="col-3 btn btn-primary" role="button" href="/habit?list={{ habit_list.id }}">Gewohnheit erstellen</a>
|
<a class="col-3 btn btn-primary" role="button" href="/habit?list={{ habit_list.id }}">Gewohnheit
|
||||||
</div>
|
erstellen</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<ul class="task-list row">
|
<ul class="task-list row">
|
||||||
{% for habit in habit_list.habits %}
|
{% for habit in habit_list.habits %}
|
||||||
<li class="row d-flex align-items-center mb-2" id="habit-{{ habit.id }}">
|
<li class="row d-flex align-items-center mb-2" id="habit-{{ habit.id }}">
|
||||||
<div class="col-auto drag-handle" style="cursor: grab;">
|
<div class="col-auto drag-handle" style="cursor: grab;">
|
||||||
<i class="bi bi-grip-vertical"></i>
|
<i class="bi bi-grip-vertical"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<input {% if habit.checked %} checked {% endif %} type="checkbox" class="task-checkbox"
|
<input {% if habit.checked %} checked {% endif %} type="checkbox" class="task-checkbox"
|
||||||
id="{{ habit.id }}"
|
id="{{ habit.id }}"
|
||||||
onclick="sendPostRequest('{{ habit.id }}')">
|
onclick="sendPostRequest('{{ habit.id }}')">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
|
<div class="col" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
|
||||||
{{ habit.name }}
|
{{ habit.name }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-6" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
|
<div class="col-5 text-black text-opacity-50"
|
||||||
{{ habit.note }}
|
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
|
||||||
</div>
|
{{ habit.note }}
|
||||||
|
|
||||||
<div class="col-2" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
|
</div>
|
||||||
{% if habit %}
|
|
||||||
5 🔥
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</div>
|
<div class="col-2" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
|
||||||
|
{% if habit %}
|
||||||
|
|
||||||
<button type="button" class="btn btn-xs btn-danger rounded-circle" data-bs-toggle="modal"
|
{% else %}
|
||||||
data-bs-target="#exampleModal" style="width: 40px; height: 40px"
|
5 🔥
|
||||||
onclick="setSelectedHabitId({{ habit.id }})">
|
{% endif %}
|
||||||
<i class="bi bi-trash3"></i>
|
|
||||||
</button>
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="progress" style="height: 2px; width: 90%">
|
|
||||||
<div class="progress-bar" id="progress-bar-{{ habit.id }}" role="progressbar"
|
|
||||||
style="width: {{ habit.percentage }}%; background-color: {% if habit.percentage >= 100 %} green {% else %} primary {% endif %}"
|
|
||||||
aria-valuenow="{{ habit.percentage }}" aria-valuemin="0"
|
|
||||||
aria-valuemax="100"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{% endfor %}
|
</div>
|
||||||
</ul>
|
|
||||||
|
<button type="button" class="btn btn-xs btn-danger rounded-circle" data-bs-toggle="modal"
|
||||||
|
data-bs-target="#exampleModal" style="width: 40px; height: 40px"
|
||||||
|
onclick="setSelectedHabitId({{ habit.id }})">
|
||||||
|
<i class="bi bi-trash3"></i>
|
||||||
|
</button>
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="progress" style="height: 2px; width: 90%">
|
||||||
|
<div class="progress-bar" id="progress-bar-{{ habit.id }}" role="progressbar"
|
||||||
|
style="width: {{ habit.percentage }}%; background-color: {% if habit.percentage >= 100 %} green {% else %} primary {% endif %}"
|
||||||
|
aria-valuenow="{{ habit.percentage }}" aria-valuemin="0"
|
||||||
|
aria-valuemax="100"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
@ -177,14 +210,11 @@
|
|||||||
var habitBlock = document.getElementById("habit-" + habitId);
|
var habitBlock = document.getElementById("habit-" + habitId);
|
||||||
|
|
||||||
if (percentage == 100) {
|
if (percentage == 100) {
|
||||||
|
progressBar.style.backgroundColor = "green";
|
||||||
habitBlock.classList.add("animate-bounce");
|
habitBlock.classList.add("animate-bounce");
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
habitBlock.classList.remove("animate-bounce");
|
habitBlock.classList.remove("animate-bounce");
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
|
||||||
|
|
||||||
if (percentage >= 100) {
|
|
||||||
progressBar.style.backgroundColor = "green";
|
|
||||||
} else {
|
} else {
|
||||||
progressBar.style.backgroundColor = "";
|
progressBar.style.backgroundColor = "";
|
||||||
habitBlock.classList.remove("animate-bounce");
|
habitBlock.classList.remove("animate-bounce");
|
||||||
@ -212,9 +242,7 @@
|
|||||||
var percentage = response.data.percentage;
|
var percentage = response.data.percentage;
|
||||||
var progressBar = document.getElementById("progress-bar-" + habitId);
|
var progressBar = document.getElementById("progress-bar-" + habitId);
|
||||||
progressBar.style.width = percentage + "%";
|
progressBar.style.width = percentage + "%";
|
||||||
if (response.data.unchecked) {
|
checkCompletionAndAnimate(habitId, percentage);
|
||||||
checkCompletionAndAnimate(habitId, percentage);
|
|
||||||
}
|
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
// Handle the error if needed
|
// Handle the error if needed
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
@ -242,30 +270,33 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', (event) => {
|
document.addEventListener('DOMContentLoaded', (event) => {
|
||||||
var el = document.querySelector('.task-list');
|
var el = document.querySelector('.task-list');
|
||||||
Sortable.create(el, {
|
Sortable.create(el, {
|
||||||
handle: '.drag-handle',
|
handle: '.drag-handle',
|
||||||
animation: 150,
|
animation: 150,
|
||||||
onEnd: function (evt) {
|
onEnd: function (evt) {
|
||||||
var habitId = el.children[evt.newIndex].id.split('-')[1];
|
var habitId = el.children[evt.newIndex].id.split('-')[1];
|
||||||
var oldIndex = evt.oldIndex;
|
var oldIndex = evt.oldIndex;
|
||||||
var newIndex = evt.newIndex;
|
var newIndex = evt.newIndex;
|
||||||
|
|
||||||
axios.post('/reorder', {habitId: habitId, oldIndex: oldIndex, newIndex: newIndex}, {
|
axios.post('/reorder', {habitId: habitId, oldIndex: oldIndex, newIndex: newIndex}, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
}).then(function (response) {
|
}).then(function (response) {
|
||||||
// Handle the success response if needed
|
// Handle the success response if needed
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
// Handle the error if needed
|
// Handle the error if needed
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
});
|
||||||
</script>
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Loading…
x
Reference in New Issue
Block a user