Compare commits
No commits in common. "d340a1e19fefc14960ecaf784a7ec4756d678d29" and "11104fe96b1aaf3b0b880f9d05c9e1ad183bfd1a" have entirely different histories.
d340a1e19f
...
11104fe96b
10
app.py
10
app.py
@ -131,7 +131,7 @@ def index():
|
||||
if current_user.is_authenticated:
|
||||
habit_lists = current_user.get_habitLists()
|
||||
name = "Hallo " + current_user.name
|
||||
heatmap_values, day = current_user.get_heatmap()
|
||||
heatmap_values = current_user.get_heatmap()
|
||||
else:
|
||||
habit_lists = []
|
||||
name = "Bitte melde dich an."
|
||||
@ -152,8 +152,7 @@ def index():
|
||||
utc_dt=date,
|
||||
habit_lists=habit_lists,
|
||||
heatmap_values=heatmap_values,
|
||||
day=day,
|
||||
errors={}
|
||||
errors={},
|
||||
)
|
||||
|
||||
|
||||
@ -564,15 +563,14 @@ def check_habit():
|
||||
habit.reset_statistics()
|
||||
|
||||
habit.load_statistics()
|
||||
heatmap_values, day = current_user.get_heatmap()
|
||||
heatmap_values = current_user.get_heatmap()
|
||||
|
||||
return {
|
||||
"habitId": habit_id,
|
||||
"unchecked": not delete_tracking,
|
||||
"percentage": habit.percentage,
|
||||
"streak": habit.streak,
|
||||
"heatmap": heatmap_values,
|
||||
"day": day
|
||||
"heatmap": heatmap_values
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ class User(UserMixin):
|
||||
|
||||
|
||||
# Returns all heatmap-values from the last 28 days
|
||||
def get_heatmap(self) -> tuple:
|
||||
def get_heatmap(self) -> list:
|
||||
# get current day of week as integer. monday is 0 and sunday is 6
|
||||
weekday = datetime.today().weekday()
|
||||
heatmap = [100]
|
||||
@ -75,5 +75,4 @@ class User(UserMixin):
|
||||
value = get_heatmap_value(self.id, day)
|
||||
heatmap.append(value)
|
||||
heatmap.reverse()
|
||||
day = 27-weekday
|
||||
return heatmap, day
|
||||
return heatmap
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
// Funktion zum Erstellen der Heatmap
|
||||
function createHeatmap(data, day) {
|
||||
function createHeatmap(data) {
|
||||
const heatmapContainer = document.getElementById('heatmap');
|
||||
|
||||
const days = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So']
|
||||
@ -22,19 +22,11 @@ function createHeatmap(data, day) {
|
||||
const dayElement = document.createElement('div');
|
||||
dayElement.classList.add('day');
|
||||
dayElement.style.backgroundColor = `rgba(0, 255, 0, ${opacity})`;
|
||||
if (day == i * 7 + j){
|
||||
dayElement.style.borderColor = `rgba(255, 0, 0)`;
|
||||
dayElement.style.borderWidth = "2px";
|
||||
}
|
||||
heatmapContainer.appendChild(dayElement);
|
||||
} else {
|
||||
const dayElement = document.createElement('div');
|
||||
dayElement.classList.add('day');
|
||||
dayElement.style.backgroundColor = `rgba(0, 255, 0, ${opacity})`;
|
||||
if (day == i * 7 + j){
|
||||
dayElement.style.borderColor = `rgba(255, 0, 0)`;
|
||||
dayElement.style.borderWidth = "2px";
|
||||
}
|
||||
heatmapContainer.appendChild(dayElement);
|
||||
}
|
||||
}
|
||||
@ -92,7 +84,7 @@ function sendPostRequest(checkboxId) {
|
||||
|
||||
const heatmapValues = response.data.heatmap;
|
||||
deleteHeatmap()
|
||||
createHeatmap(heatmapValues, day)
|
||||
createHeatmap(heatmapValues)
|
||||
|
||||
}).catch(function (error) {
|
||||
// Handle the error if needed
|
||||
@ -173,8 +165,7 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||
$(function () {
|
||||
$('[data-toggle="tooltip"]').tooltip()
|
||||
|
||||
})
|
||||
console.log(activityData, day)
|
||||
// Erstelle die Heatmap mit den simulierten Daten
|
||||
createHeatmap(activityData, day);
|
||||
createHeatmap(activityData);
|
||||
|
||||
})
|
||||
@ -92,7 +92,7 @@
|
||||
{% for user in habit_list.get_users() %}
|
||||
{% if current_user.id != user.id %}
|
||||
<img class="avatar" src="/{{user.profile_image}}" data-toggle="tooltip" data-placement="top"
|
||||
title="{{user.name}}"/>
|
||||
title="{{user.name}}" alt=""/>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
@ -101,10 +101,11 @@
|
||||
|
||||
<!-- Knopf für das Hinzufügen einer Person zur gemeinsamen Liste -->
|
||||
<div class="col">
|
||||
<a href="/users?habit_list={{habit_list.id}}" style="width: 40px; height: 40px; min-height: 3em;"
|
||||
<a href="/users?habit_list={{habit_list.id}}" style="min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center;"
|
||||
data-toggle="tooltip" data-placement="top" title="Benutzer einladen">
|
||||
<i class="bi bi-person-fill-add" style="font-size: 24px;"></i>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="col"></div>
|
||||
@ -129,9 +130,9 @@
|
||||
|
||||
<!-- Checkbox -->
|
||||
<div class="col-auto">
|
||||
<label for="{{ habit.id }}"></label>
|
||||
<input {% if habit.checked %} checked {% endif %} type="checkbox" class="task-checkbox"
|
||||
id="{{ habit.id }}"
|
||||
onclick="sendPostRequest('{{ habit.id }}')">
|
||||
id="{{ habit.id }}" onclick="sendPostRequest('{{ habit.id }}')">
|
||||
</div>
|
||||
|
||||
<!-- Name -->
|
||||
@ -187,13 +188,13 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var selectedHabitId = null;
|
||||
let selectedHabitId = null;
|
||||
|
||||
function setSelectedHabitId(habitId) {
|
||||
selectedHabitId = habitId;
|
||||
}
|
||||
|
||||
var selectedListId = null;
|
||||
let selectedListId = null;
|
||||
|
||||
function setSelectedListId(listId) {
|
||||
selectedlistId = listId;
|
||||
|
||||
@ -9,5 +9,4 @@
|
||||
<script>
|
||||
// Generates activity based on the Values given by the Backend
|
||||
const activityData = {{ heatmap_values }};
|
||||
const day = {{ day }};
|
||||
</script>
|
||||
Loading…
x
Reference in New Issue
Block a user