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

49 lines
1.8 KiB
Cheetah

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ .title }}</title>
{{template "head" .}}
</head>
<body>
{{template "navbar" .}}
<div class="container">
<div class="fs-3 text-center mt-5">{{ .title }}</div>
<hr>
<div id="tasks"></div>
</div>
{{template "scripts" .}}
<script>
userLoggedIn().then((loggedIn) => !loggedIn ? redirect("/view/login") : getAllTasks());
const tasksEl = document.getElementById("tasks");
function getAllTasks() {
axios.get("/tasks", axiosConfig).then((response) => {
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);
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>
<div class="col-2 overflow-ellipsis text-end"><i class="bi ${task.Done ? "bi-check-circle" : "bi-circle"}"></i></div>
`;
tasksEl.appendChild(newTask);
});
});
}
</script>
</body>
</html>