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

Added all functionalities #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
64 changes: 15 additions & 49 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,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 id="logout-btn" class="dropdown-item" href="#">Logout</a>
</div>
</li>
</ul>
Expand All @@ -54,62 +54,28 @@
</nav>
<center>
<div class="input-group mb-3 todo-add-task">
<input type="text" class="form-control" placeholder="Enter Task">
<input id="new-task" type="text" class="form-control" placeholder="Enter Task">
<div class="input-group-append">
<button type="button" class="btn btn-outline-success" onclick="addTask()">Add Task</button>
<button id="add-task" type="button" class="btn btn-outline-success" >Add Task</button>
</div>
</div>
<ul class="list-group todo-available-tasks">
<div class="input-group mb-3 mt-0 todo-add-task">
<input id="search-input" type="text" class="form-control" placeholder="Search">
<div class="input-group-append">
<button id="search-btn" type="button" class="btn btn-outline-success fa fa-search" ></button>
</div>
<div class="input-group-append">
<button id="cancel-btn" type="button" class="btn btn-outline-success fa fa-close hideme" ></button>

</div>
</div>
<ul id="tasks" 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">
<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>
</div>
<div id="task-1" class="todo-task">
Sample Task 1
</div>

<span id="task-actions-1">
<button style="margin-right:5px;" type="button" onclick="editTask(1)"
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(1)">
<img src="https://res.cloudinary.com/nishantwrp/image/upload/v1587486661/CSOC/delete.svg"
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>



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

Expand Down
187 changes: 183 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 id="register-btn" class="btn btn-outline-success my-2 my-sm-0" type="submit">Register</button>
</div>
</body>

Expand Down
9 changes: 9 additions & 0 deletions src/auth_required.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/***
* @todo Redirect the user to login page if token is not present.
*/
function authRequired (){
const token = localStorage.getItem('token');
if(!token)
{
window.location.href = '/login/';
}
}

authRequired();
43 changes: 42 additions & 1 deletion src/init.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,51 @@
import axios from 'axios';
const API_BASE_URL = 'https://todo-app-csoc.herokuapp.com/';

function getTasks() {
export function getTasks() {
/***
* @todo Fetch the tasks created by the user and display them in the dom.
*/
const tasks = document.getElementById('tasks');

axios({
headers: {
Authorization: "Token " + localStorage.getItem("token"),
},
url: API_BASE_URL + "todo/",
})
.then(function ({ data, status }) {
tasks.innerHTML=` <span class="badge badge-primary badge-pill todo-available-tasks-text">
Available Tasks
</span>`;
for(var i=0;i<data.length;i++)
{
tasks.innerHTML+= `<li class="list-group-item d-flex justify-content-between align-items-center" id="taskItem-${data[i].id}">
<input id="input-button-${data[i].id}" type="text" class="form-control todo-edit-task-input hideme"
placeholder="Edit The Task">
<div id="done-button-${data[i].id}" class="input-group-append hideme">
<button class="btn btn-outline-secondary todo-update-task" type="button"
onclick="updateTask(${data[i].id})">Done</button>
</div>
<div id="task-${data[i].id}" class="todo-task">
${data[i].title}
</div>
<span id="task-actions-${data[i].id}">
<button style="margin-right:5px;" type="button" onclick="editTask(${data[i].id})"
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(${data[i].id})">
<img src="https://res.cloudinary.com/nishantwrp/image/upload/v1587486661/CSOC/delete.svg"
width="18px" height="22px">
</button>
</span>
</li>`;
}
})
.catch(function (err) {
displayErrorToast("Oops! Something went wrong!");
});
}

axios({
Expand Down
Loading