Compare commits

..

No commits in common. "ce0a6b588b5029c1d27d439721f030a5462ec1d9" and "454ce33846414b6604c63bc619c1dd1372edd685" have entirely different histories.

4 changed files with 199 additions and 208 deletions

1
app.py
View File

@ -136,7 +136,6 @@ def index():
title=name, title=name,
utc_dt=datetime.datetime.now().strftime("%d.%m.%Y %H:%M %A"), utc_dt=datetime.datetime.now().strftime("%d.%m.%Y %H:%M %A"),
habit_lists=habit_lists, habit_lists=habit_lists,
heatmap_values=current_user.get_heatmap(),
errors={}, errors={},
) )

View File

@ -80,9 +80,6 @@ class Habit:
count = 0 count = 0
self.checked = False self.checked = False
for tracking in self.get_habitTrackings(): for tracking in self.get_habitTrackings():
if tracking.created_at.date() == datetime.today().date():
self.checked = True
# day # day
if self.unit == 0: if self.unit == 0:
if tracking.created_at.date() == datetime.today().date(): if tracking.created_at.date() == datetime.today().date():

View File

@ -1,8 +1,8 @@
from datetime import datetime from datetime import datetime
from flask_login import UserMixin from flask_login import UserMixin
from db.SQLiteClient import create_user, get_user, get_user_by_email, delete_user, update_user, \ from db.SQLiteClient import create_user, get_user, get_user_by_email, get_habits, delete_user, update_user, \
get_habitLists, get_heatmap_value get_habitLists
class User(UserMixin): class User(UserMixin):
@ -43,10 +43,3 @@ class User(UserMixin):
habitLists.append(habitList) habitLists.append(habitList)
return habitLists return habitLists
def get_heatmap(self):
heatmap = []
for day in range(0, 28):
value = get_heatmap_value(self.id, day)
heatmap.append(value)
return heatmap

View File

@ -21,10 +21,9 @@
justify-content: center; justify-content: center;
} }
</style> </style>
<div class="row">
<div class="d-flex flex-column gap-5"> <div class="col-md-4 col-12 card bg-light mb-6">
<div class="d-flex gap-3">
<div class="flex-fill col-5 card bg-light mb-6">
<div class="card-body"> <div class="card-body">
<h5 class="card-title">Heatmap</h5> <h5 class="card-title">Heatmap</h5>
<div id="heatmap"></div> <div id="heatmap"></div>
@ -32,9 +31,15 @@
</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 = {{heatmap_values}}; const activityData = [5, 3, 10, 5, 24, 2, 10, 47, 32, 45, 9, 5, 11, 39, 24, 2, 10, 47, 32, 45];
// Funktion zum Erstellen der Heatmap // Funktion zum Erstellen der Heatmap
function createHeatmap(data) { function createHeatmap(data) {
@ -53,9 +58,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 < 4; j++) { for (let j = 0; j < 7; 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) <= 0 ? 1 : Math.max(...data)); // Berechne die Opazität basierend auf Aktivitätsanzahl const opacity = data[i * 7 + j] / 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');
@ -64,14 +69,12 @@
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
@ -80,7 +83,7 @@
</script> </script>
<div class="flex-fill col-7 card bg-light p-6 mb-6"> <div class="col-md-7 col-12 card gap-3 bg-light p-6 offset-md-1 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 p" 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>
@ -110,8 +113,8 @@
{{ habit.name }} {{ habit.name }}
</div> </div>
<div class="col-5 text-black text-opacity-50" <div class="col-5 text-black text-opacity-50" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
{{ habit.note }} {{ habit.note }}
</div> </div>
@ -241,7 +244,6 @@
} }
</script> </script>
</div> </div>
</div>
<script> <script>
document.addEventListener('DOMContentLoaded', (event) => { document.addEventListener('DOMContentLoaded', (event) => {