This repository has been archived on 2024-10-30. You can view files and clone it, but cannot push or open issues or pull requests.
swb6-it-sec/Lab01/app/templates/tasks.tmpl

50 lines
1.8 KiB
Cheetah
Raw Normal View History

2022-04-04 11:40:34 +02:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ .title }}</title>
{{template "head" .}}
</head>
<body>
{{template "navbar" .}}
2022-04-06 14:24:01 +02:00
<div class="container">
<div class="fs-3 text-center mt-5">{{ .title }}</div>
2022-04-04 11:40:34 +02:00
<hr>
2022-04-06 14:12:15 +02:00
<div id="tasks"></div>
2022-04-04 11:40:34 +02:00
</div>
{{template "scripts" .}}
<script>
2022-04-04 12:26:36 +02:00
userLoggedIn().then((loggedIn) => !loggedIn ? redirect("/view/login") : getAllTasks());
2022-04-06 14:12:15 +02:00
const tasksEl = document.getElementById("tasks");
2022-04-04 12:26:36 +02:00
2022-04-06 14:12:15 +02:00
function getAllTasks() {
axios.get("/tasks", axiosConfig).then((response) => {
2022-04-06 14:24:01 +02:00
const taskHeader = document.createElement("div");
taskHeader.classList.add('row', 'g-0', 'align-items-center', 'mb-1');
taskHeader.innerHTML = `
<div class="col-2 overflow-ellipsis text-end pe-4">ID</div>
<div class="col-6 overflow-ellipsis">Description</div>
<div class="col-2 overflow-ellipsis text-end">Done</div>
<hr class="mt-3 mb-2">
`;
tasksEl.appendChild(taskHeader);
2022-04-06 14:12:15 +02:00
const tasks = response.data.tasks;
[...tasks]
.forEach((task) => {
const newTask = document.createElement('div');
newTask.classList.add('row', 'g-0', 'align-items-center', 'mb-1');
newTask.innerHTML = `
<div class="col-2 overflow-ellipsis text-end pe-4">${task.ID}</div>
<div class="col-6 overflow-ellipsis">${task.Description}</div>
2022-04-06 14:24:01 +02:00
<div class="col-2 overflow-ellipsis text-end"><i class="bi ${task.Done ? "bi-check-circle" : "bi-circle"}"></i></div>
2022-04-06 14:12:15 +02:00
`;
tasksEl.appendChild(newTask);
});
});
2022-04-04 12:26:36 +02:00
}
2022-04-04 11:40:34 +02:00
</script>
</body>
</html>