Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #36

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Done #36

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 15 additions & 29 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<script type="module" src="./src/auth_required.js"></script>
<script type="module" src="./src/main.js"></script>
<style>
.hideme {
.hideme
{
display: none !important;
}
</style>
Expand Down Expand Up @@ -45,7 +46,7 @@
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img src="#" class="rounded-circle" id="avatar-image"><span class="todo-profile-name" id="profile-name">Loading ...</span></a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#" onclick="logout()">Logout</a>
<a class="dropdown-item" href="#" id="logoutButton">Logout</a>
</div>
</li>
</ul>
Expand All @@ -54,18 +55,26 @@
</nav>
<center>
<div class="input-group mb-3 todo-add-task">
<input type="text" class="form-control" placeholder="Enter Task">
<input type="text" class="form-control" placeholder="Enter Task" id="entervalue">
<div class="input-group-append">
<button type="button" class="btn btn-outline-success" onclick="addTask()">Add Task</button>
<button type="button" class="btn btn-outline-success" id="addTaskButton">Addd Task</button>
</div>
</div>

<div class="input-group mb-3 todo-add-task">
<input type="text" class="form-control" placeholder="Search Task" id="searchvalue">
<div class="input-group-append">
<button type="button" class="btn btn-outline-primary" id="searchTaskButton">Search Task</button>
</div>
</div>

<ul class="list-group todo-available-tasks">
<span class="badge badge-primary badge-pill todo-available-tasks-text">
Available Tasks
</span>


<li class="list-group-item d-flex justify-content-between align-items-center">
<!-- <li class="list-group-item d-flex justify-content-between align-items-center">
<input id="input-button-1" type="text" class="form-control todo-edit-task-input hideme" placeholder="Edit The Task">
<div id="done-button-1" class="input-group-append hideme">
<button class="btn btn-outline-secondary todo-update-task" type="button" onclick="updateTask(1)">Done</button>
Expand All @@ -85,30 +94,7 @@
width="18px" height="22px">
</button>
</span>
</li>


<li class="list-group-item d-flex justify-content-between align-items-center">
<input id="input-button-2" type="text" class="form-control todo-edit-task-input hideme" placeholder="Edit The Task">
<div id="done-button-2" class="input-group-append hideme">
<button class="btn btn-outline-secondary todo-update-task" type="button" onclick="updateTask(2)">Done</button>
</div>

<div id="task-2" class="todo-task">
Sample Task 2
</div>
<span id="task-actions-2">
<button style="margin-right:5px;" type="button" onclick="editTask(2)"
class="btn btn-outline-warning">
<img src="https://res.cloudinary.com/nishantwrp/image/upload/v1587486663/CSOC/edit.png"
width="18px" height="20px">
</button>
<button type="button" class="btn btn-outline-danger" onclick="deleteTask(2)">
<img src="https://res.cloudinary.com/nishantwrp/image/upload/v1587486661/CSOC/delete.svg"
width="18px" height="22px">
</button>
</span>
</li>
</li> -->


</ul>
Expand Down
6 changes: 3 additions & 3 deletions login/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
</div>
<div class="form-group">
<label>Username</label>
<input type="text" class="form-control" id="inputUsername">
<input type="text" class="form-control" id="inputUsername" required>
</div>
<div class="form-group">
<label>Password</label>
<input type="Password" class="form-control" id="inputPassword">
<input type="Password" class="form-control" id="inputPassword" required>
</div>
<button class="btn btn-outline-success my-2 my-sm-0" onclick="login()" type="submit">Log In</button>
<button class="btn btn-outline-success my-2 my-sm-0" id="loginButton" type="submit">Log In</button>
</div>
</body>

Expand Down
2 changes: 1 addition & 1 deletion register/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<label for="inputAddress2">Password</label>
<input type="Password" class="form-control" id="inputPassword">
</div>
<button class="btn btn-outline-success my-2 my-sm-0" onclick="register()" type="submit">Register</button>
<button class="btn btn-outline-success my-2 my-sm-0" id="registerButton" type="submit">Register</button>
</div>
</body>

Expand Down
4 changes: 4 additions & 0 deletions src/auth_required.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/***
* @todo Redirect the user to login page if token is not present.
*/
if(!localStorage.getItem("token"))
{
window.location.href = "/login/";
}
26 changes: 25 additions & 1 deletion src/init.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
import axios from 'axios';
import { createTask } from "./main";
const API_BASE_URL = 'https://todo-app-csoc.herokuapp.com/';

function getTasks() {
function getTasks()
{
/***
* @todo Fetch the tasks created by the user and display them in the dom.
*/
axios({
url:API_BASE_URL + "todo/",
method:"get",
headers:{
Authorization:"Token "+localStorage.getItem("token")
}

})
.then(function({data})
{
const list_group = document.querySelector('.list-group');
list_group.textContent = '';
data.forEach((element) => createTask(element));
})
.catch(function (err) {
iziToast.error({
title: 'Error',
message: "Cannot get it!"
});
});
}

axios({
Expand All @@ -18,3 +40,5 @@ axios({
document.getElementById('profile-name').innerHTML = data.name;
getTasks();
})

export { getTasks };
Loading