Cleanup
This commit is contained in:
parent
fdc90fe118
commit
03e1f22a87
20
app.py
20
app.py
@ -432,7 +432,7 @@ def delete_habit():
|
|||||||
habit.delete()
|
habit.delete()
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@app.route('/reorder', methods=['POST'])
|
@app.route('/reorder-habit', methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def reorder_habits():
|
def reorder_habits():
|
||||||
new_index = request.get_json()["newIndex"] + 1
|
new_index = request.get_json()["newIndex"] + 1
|
||||||
@ -699,6 +699,24 @@ def deny_list():
|
|||||||
|
|
||||||
habit_list.remove_user(current_user.id)
|
habit_list.remove_user(current_user.id)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
@app.route('/reorder-list', methods=['POST'])
|
||||||
|
@login_required
|
||||||
|
def reorder_habit_list():
|
||||||
|
new_index = request.get_json()["newIndex"] + 1
|
||||||
|
habitList = HabitList.get(request.get_json()["habitListId"])
|
||||||
|
|
||||||
|
if habitList is None:
|
||||||
|
return {"error": "HabitList not found"}
|
||||||
|
|
||||||
|
# Check if habit belongs to user
|
||||||
|
users = habitList.get_users()
|
||||||
|
if current_user not in users:
|
||||||
|
return {"error": "HabitList does not belong to user"}
|
||||||
|
|
||||||
|
habitList.update_slot(new_index)
|
||||||
|
|
||||||
|
return {}
|
||||||
###########################################################
|
###########################################################
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
// Funktion zum Erstellen der Heatmap
|
// Erstellen der Heatmap
|
||||||
function createHeatmap(data, day) {
|
function createHeatmap(data, day) {
|
||||||
const heatmapContainer = document.getElementById('heatmap');
|
const heatmapContainer = document.getElementById('heatmap');
|
||||||
|
|
||||||
@ -29,6 +29,7 @@ function createHeatmap(data, day) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Löschen der Heatmap
|
||||||
function deleteHeatmap() {
|
function deleteHeatmap() {
|
||||||
const heatmapContainer = document.getElementById('heatmap');
|
const heatmapContainer = document.getElementById('heatmap');
|
||||||
const dayElements = heatmapContainer.getElementsByClassName('day');
|
const dayElements = heatmapContainer.getElementsByClassName('day');
|
||||||
@ -39,6 +40,7 @@ function deleteHeatmap() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Animation der Progressbar
|
||||||
function checkCompletionAndAnimate(habitId, percentage) {
|
function checkCompletionAndAnimate(habitId, percentage) {
|
||||||
const progressBar = document.getElementById("progress-bar-" + habitId);
|
const progressBar = document.getElementById("progress-bar-" + habitId);
|
||||||
const habitBlock = document.getElementById("habit-" + habitId);
|
const habitBlock = document.getElementById("habit-" + habitId);
|
||||||
@ -55,6 +57,7 @@ function checkCompletionAndAnimate(habitId, percentage) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Senden einer Post-Request, sobald ein Habit abgehackt wird
|
||||||
function sendPostRequest(checkboxId) {
|
function sendPostRequest(checkboxId) {
|
||||||
// Get the habit id from the checkbox id attribute
|
// Get the habit id from the checkbox id attribute
|
||||||
const habitId = checkboxId;
|
const habitId = checkboxId;
|
||||||
@ -88,6 +91,7 @@ function sendPostRequest(checkboxId) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Senden einer Post-Request, sobald ein Habit gelöscht wird
|
||||||
function deleteHabit(habitId) {
|
function deleteHabit(habitId) {
|
||||||
// Make a POST request to /delete with the habit id
|
// Make a POST request to /delete with the habit id
|
||||||
|
|
||||||
@ -108,6 +112,7 @@ function deleteHabit(habitId) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Senden einer Post-Request, sobald eine HabitList gelöscht wird
|
||||||
function deleteList(listId) {
|
function deleteList(listId) {
|
||||||
// Make a POST request to /delete with the habit id
|
// Make a POST request to /delete with the habit id
|
||||||
|
|
||||||
@ -130,6 +135,7 @@ function deleteList(listId) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const elements = document.querySelectorAll('.task-list').values()
|
const elements = document.querySelectorAll('.task-list').values()
|
||||||
|
|
||||||
@ -139,11 +145,11 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
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];
|
const habitId = el.children[evt.newIndex].id.split('-')[1];
|
||||||
var oldIndex = evt.oldIndex;
|
const oldIndex = evt.oldIndex;
|
||||||
var newIndex = evt.newIndex;
|
const newIndex = evt.newIndex;
|
||||||
|
|
||||||
axios.post('/reorder', {habitId: habitId, oldIndex: oldIndex, newIndex: newIndex}, {
|
axios.post('/reorder-habit', {habitId: habitId, oldIndex: oldIndex, newIndex: newIndex}, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
@ -162,7 +168,7 @@ $(function () {
|
|||||||
$('[data-toggle="tooltip"]').tooltip()
|
$('[data-toggle="tooltip"]').tooltip()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Function to update the current time
|
// Aktualisieren der Uhrzeit
|
||||||
function updateCurrentTime() {
|
function updateCurrentTime() {
|
||||||
const currentTimeElement = document.getElementById('current-time');
|
const currentTimeElement = document.getElementById('current-time');
|
||||||
const currentDate = new Date();
|
const currentDate = new Date();
|
||||||
@ -171,11 +177,8 @@ function updateCurrentTime() {
|
|||||||
currentTimeElement.innerText = currentDateTime.replace(',', ',') + ' ' + currentDate.toLocaleString('de-DE', { weekday: 'long' });
|
currentTimeElement.innerText = currentDateTime.replace(',', ',') + ' ' + currentDate.toLocaleString('de-DE', { weekday: 'long' });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Erstelle die Heatmap mit den simulierten Daten
|
// Erstellt die Heatmap mit den simulierten Daten
|
||||||
createHeatmap(activityData, day, color);
|
createHeatmap(activityData, day, color);
|
||||||
|
|
||||||
// Update the time immediately
|
|
||||||
updateCurrentTime();
|
updateCurrentTime();
|
||||||
|
|
||||||
// Update the time every second
|
|
||||||
setInterval(updateCurrentTime, 1000);
|
setInterval(updateCurrentTime, 1000);
|
||||||
|
|||||||
@ -2,13 +2,8 @@
|
|||||||
|
|
||||||
<!-- Listen erstellen -->
|
<!-- Listen erstellen -->
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<h5 class="col-9">
|
<h5 class="col-9">📋 Gewohnheiten</h5>
|
||||||
📋 Gewohnheiten
|
<a class="col-3 btn btn-primary p" role="button" href="/habit-list">Neue Liste erstellen</a>
|
||||||
</h5>
|
|
||||||
|
|
||||||
<a class="col-3 btn btn-primary p" role="button" href="/habit-list">
|
|
||||||
Neue Liste erstellen
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Tabs zur Auswahl -->
|
<!-- Tabs zur Auswahl -->
|
||||||
@ -25,6 +20,7 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
// Select all the tab links
|
// Select all the tab links
|
||||||
@ -207,7 +203,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -222,5 +218,4 @@
|
|||||||
function setSelectedListId(listId) {
|
function setSelectedListId(listId) {
|
||||||
selectedlistId = listId;
|
selectedlistId = listId;
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -40,17 +40,16 @@
|
|||||||
<option value="Jahr">Jahr</option>
|
<option value="Jahr">Jahr</option>
|
||||||
</select>
|
</select>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', (event) => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
let selectedElement = document.getElementById('unit');
|
let selectedElement = document.getElementById('unit');
|
||||||
|
|
||||||
for (let option of selectedElement.options) {
|
for (let option of selectedElement.options) {
|
||||||
if (option.value == '{{ unit }}') {
|
if (option.value === '{{ unit }}') {
|
||||||
option.selected = true;
|
option.selected = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<div class="invalid-feedback">
|
<div class="invalid-feedback">
|
||||||
{{ errors.get('unit', '') }}
|
{{ errors.get('unit', '') }}
|
||||||
@ -65,13 +64,13 @@
|
|||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
// Extracting the list-query from the URL
|
// Extracting the list-query from the URL
|
||||||
var listQuery = new URLSearchParams(window.location.search).get('habit');
|
let listQuery = new URLSearchParams(window.location.search).get('habit');
|
||||||
|
|
||||||
if ("{{ habit }}" != "") {
|
if ("{{ habit }}" !== "") {
|
||||||
listQuery = "{{ habit }}";
|
listQuery = "{{ habit }}";
|
||||||
|
|
||||||
// Add the list_id to the URL
|
// Add the list_id to the URL
|
||||||
var url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
url.searchParams.set('habit', listQuery);
|
url.searchParams.set('habit', listQuery);
|
||||||
// window.history.pushState({}, '', url);
|
// window.history.pushState({}, '', url);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,11 +37,11 @@
|
|||||||
<option value="Jahr">Jahr</option>
|
<option value="Jahr">Jahr</option>
|
||||||
</select>
|
</select>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', (event) => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
let selectedElement = document.getElementById('unit');
|
let selectedElement = document.getElementById('unit');
|
||||||
|
|
||||||
for (let option of selectedElement.options) {
|
for (let option of selectedElement.options) {
|
||||||
if (option.value == '{{ unit }}') {
|
if (option.value === '{{ unit }}') {
|
||||||
option.selected = true;
|
option.selected = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -61,13 +61,13 @@
|
|||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
// Extracting the list-query from the URL
|
// Extracting the list-query from the URL
|
||||||
var listQuery = new URLSearchParams(window.location.search).get('list');
|
let listQuery = new URLSearchParams(window.location.search).get('list');
|
||||||
|
|
||||||
if ("{{ list_id }}" != "") {
|
if ("{{ list_id }}" !== "") {
|
||||||
listQuery = "{{ list_id }}";
|
listQuery = "{{ list_id }}";
|
||||||
|
|
||||||
// Add the list_id to the URL
|
// Add the list_id to the URL
|
||||||
var url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
url.searchParams.set('list', listQuery);
|
url.searchParams.set('list', listQuery);
|
||||||
// window.history.pushState({}, '', url);
|
// window.history.pushState({}, '', url);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
<form action="/user-delete" class="row" method="POST">
|
<form action="/user-delete" class="row" method="POST">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<img src="{{ user.profile_image }}" class="avatar"/>
|
<img src="{{ user.profile_image }}" class="avatar" alt=""/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
{{ user.name }}
|
{{ user.name }}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user