diff --git a/app.py b/app.py index 5419869..3f68c80 100644 --- a/app.py +++ b/app.py @@ -136,6 +136,7 @@ def index(): title=name, utc_dt=datetime.datetime.now().strftime("%d.%m.%Y %H:%M %A"), habit_lists=habit_lists, + heatmap_values=current_user.get_heatmap(), errors={}, ) diff --git a/models/User.py b/models/User.py index 13f9f72..317843b 100644 --- a/models/User.py +++ b/models/User.py @@ -46,7 +46,7 @@ class User(UserMixin): def get_heatmap(self): heatmap = [] - for day in range (0, 27): + for day in range(0, 28): value = get_heatmap_value(self.id, day) heatmap.append(value) return heatmap \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index e3a58d3..76ced99 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,43 +1,40 @@ {% extends 'layouts/main.html' %} {% block content %} -

{{ title }}

-

{{ utc_dt }}

+

{{ title }}

+

{{ utc_dt }}

- + .day { + width: 50px; + height: 50px; + border: 1px solid #ccc; + display: flex; + align-items: center; + justify-content: center; + } + -
- -
-
+
+
+
+
+
Heatmap
+
+
-
-
+ +
+ {% for habit_list in habit_lists %} -
-

{{ habit_list.name }}

- Gewohnheit erstellen -
+
+

{{ habit_list.name }}

+ Gewohnheit + erstellen +
-
    - {% for habit in habit_list.habits %} -
  • -
    - -
    -
    - -
    +
      + {% for habit in habit_list.habits %} +
    • +
      + +
      +
      + +
      -
      - {{ habit.name }} -
      +
      + {{ habit.name }} +
      -
      - {{ habit.note }} -
      +
      + {{ habit.note }} -
      - {% if habit %} - 5 🔥 - {% endif %} +
      -
      +
      + {% if habit %} - -
      -
      -
      -
      -
      -
    • + {% else %} + 5 🔥 + {% endif %} - {% endfor %} -
    +
+ + +
+
+
+
+
+ + + {% endfor %} + {% endfor %}
@@ -176,17 +180,17 @@ var progressBar = document.getElementById("progress-bar-" + habitId); var habitBlock = document.getElementById("habit-" + habitId); - if (percentage == 100) { - progressBar.style.backgroundColor = "green"; - habitBlock.classList.add("animate-bounce"); - setTimeout(function () { + if (percentage == 100) { + progressBar.style.backgroundColor = "green"; + habitBlock.classList.add("animate-bounce"); + setTimeout(function () { + habitBlock.classList.remove("animate-bounce"); + }, 2000); + } else { + progressBar.style.backgroundColor = ""; habitBlock.classList.remove("animate-bounce"); - }, 2000); - } else { - progressBar.style.backgroundColor = ""; - habitBlock.classList.remove("animate-bounce"); + } } - } function sendPostRequest(checkboxId) { // Get the checkbox element using the provided ID @@ -205,16 +209,16 @@ // Handle the success response if needed console.log(response.data); - // Set the percentage of the habit. percentage received as integer - var percentage = response.data.percentage; - var progressBar = document.getElementById("progress-bar-" + habitId); - progressBar.style.width = percentage + "%"; - checkCompletionAndAnimate(habitId, percentage); - }).catch(function (error) { - // Handle the error if needed - console.error('Error:', error); - }); - } + // Set the percentage of the habit. percentage received as integer + var percentage = response.data.percentage; + var progressBar = document.getElementById("progress-bar-" + habitId); + progressBar.style.width = percentage + "%"; + checkCompletionAndAnimate(habitId, percentage); + }).catch(function (error) { + // Handle the error if needed + console.error('Error:', error); + }); + } function deleteHabit(habitId) { // Make a POST request to /delete with the habit id @@ -237,30 +241,31 @@ }
+
- + }); + {% endblock %} \ No newline at end of file