fix login and show tasks
This commit is contained in:
parent
6ad423ae5c
commit
9b4eb8f7aa
2 changed files with 25 additions and 11 deletions
|
@ -11,18 +11,30 @@
|
|||
<div class="position-absolute top-50 start-50 translate-middle">
|
||||
<div class="fs-3">{{ .title }}</div>
|
||||
<hr>
|
||||
<div id="tasks"></div>
|
||||
</div>
|
||||
|
||||
{{template "scripts" .}}
|
||||
<script>
|
||||
userLoggedIn().then((loggedIn) => !loggedIn ? redirect("/view/login") : getAllTasks());
|
||||
const tasksEl = document.getElementById("tasks");
|
||||
|
||||
async function getAllTasks() {
|
||||
const response = await fetch("/tasks", {method: 'GET', headers: myHeaders});
|
||||
const json = await response.json();
|
||||
console.log(json);
|
||||
function getAllTasks() {
|
||||
axios.get("/tasks", axiosConfig).then((response) => {
|
||||
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">${task.Done}</div>
|
||||
`;
|
||||
tasksEl.appendChild(newTask);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Reference in a new issue