-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasksheduling.html
More file actions
239 lines (227 loc) · 7.77 KB
/
tasksheduling.html
File metadata and controls
239 lines (227 loc) · 7.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Task Shedule Page</title>
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css"
rel="stylesheet"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/js/bootstrap.bundle.min.js"></script>
<style>
body {
margin: 0;
position: relative;
}
.nav-space {
margin: 0 20px;
}
.nav-item:hover {
background-color: #96c7c1;
color: black;
}
.content {
margin: 10px 20px;
max-height: 100%;
max-width: 100%;
/* background-color: darkseagreen; */
}
button:hover {
border-color: darkblue;
color: darkblue;
}
.display {
border: 2px solid;
padding: 5px;
}
#userInfo {
position: absolute;
right: 5px;
margin: 10px;
width: auto;
font-size: 15px;
}
</style>
</head>
<body>
<nav
class="navbar navbar-expand-sm bg-dark container-fluid navbar-dark center"
>
<ul class="navbar-nav">
<li class="nav-item nav-space">
<a href="./taskhome.html" class="nav-link">Home</a>
</li>
<li class="nav-item nav-space">
<a href="./task.html" class="nav-link">Task</a>
</li>
<li class="nav-item nav-space">
<a href="#" class="nav-link">DasshBoard</a>
</li>
<li class="nav-item nav-space">
<a href="#" class="nav-link">Task Schedule</a>
</li>
<li class="nav-item nav-space">
<a href="./index.html" id="logout" class="nav-link">Logout</a>
</li>
</ul>
<span id="userInfo" class="navbar-brand"></span>
</nav>
<div class="container-fluid">
<table class="table" id="table">
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Type</th>
<th>Priority</th>
<th>Label</th>
<th>Due Date</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<script>
jQuery(document).ready(function () {
if (localStorage.getItem("accessToken") == null)
location.replace("./tasklogin.html");
let userName = localStorage.getItem("firstName");
let email = localStorage.getItem("email");
let userInfo = $("#userInfo");
userInfo.html(
"Hello" + " " + userName + " " + "(" + email + ")"
);
let logout = $("#logout");
let edtBtn = $("#edtBtn");
let delBtn = $("#delBtn");
logout.click(function () {
localStorage.removeItem("accessToken");
localStorage.removeItem("email");
localStorage.removeItem("firstName");
localStorage.removeItem("lastName");
localStorage.removeItem("userId");
});
$.ajax({
type: "GET",
url: "https://task-management-rest-app.herokuapp.com/api/tasks",
dataType: "json",
headers: { Authorization: localStorage.getItem("accessToken") },
contentType: "application/json",
success: function (data) {
console.log(data);
taskList(data);
},
});
});
function taskList(output) {
let table = document.getElementById("table");
for (j = 0; j < output.data.length; j++) {
let taskId = [];
taskId[j] = output.data[j]._id;
let rw = table.insertRow(-1);
let cell = [];
for (i = 0; i <= 8; i++) {
cell[i] = rw.insertCell(i);
}
cell[0].innerHTML = output.data[j].title;
cell[1].innerHTML = output.data[j].description;
for (k = 0; k < 3; k++) {
if (output.data[j].type == 1)
cell[2].innerHTML =
'<span class="display" style="border-color:#0092CA">Task</span>';
if (output.data[j].type == 2)
cell[2].innerHTML =
'<span class="display" style="border-color:#4C4C6D">Story</span>';
if (output.data[j].type == 3)
cell[2].innerHTML =
'<span class="display" style="border-color:#E01171">Bug</span>';
}
for (k = 0; k < 3; k++) {
if (output.data[j].priority == 1)
cell[3].innerHTML =
'<span class="display" style="border-color:#F90716">High</span>';
if (output.data[j].priority == 2)
cell[3].innerHTML =
'<span class="display" style="border-color:#C5D200">Medium</span>';
if (output.data[j].priority == 3)
cell[3].innerHTML =
'<span class="display" style="border-color:#424242">Low</span>';
}
for (k = 0; k < 4; k++) {
if (output.data[j].label[k] == 1) cell[4].innerHTML += " Feature";
if (output.data[j].label[k] == 2) cell[4].innerHTML += " Front-End";
if (output.data[j].label[k] == 3)
cell[4].innerHTML += " Change Request";
if (output.data[j].label[k] == 4) cell[4].innerHTML += " Back-End";
}
let dt = new Date(output.data[j].dueDate);
if (dt.getDate() < 10)
deadLine =
dt.getFullYear() +
"-" +
(dt.getMonth() + 1) +
"-" +
"0" +
(dt.getDate() + 1);
else
deadLine =
dt.getFullYear() +
"-" +
(dt.getMonth() + 1) +
"-" +
(dt.getDate() + 1);
let today = new Date();
if (dt.getTime() < today.getTime()) {
cell[5].innerHTML = `<span style="color:red;"> ${deadLine} *</span>`;
} else cell[5].innerHTML = deadLine;
cell[6].innerHTML = `<button class="btn" id="edtBtn" onclick="edt('${taskId[j]}');" data-id="${taskId[j]}" type="button">Edit</button>`;
cell[7].innerHTML = `<button class="btn" id="delBtn" onclick="dele('${taskId[j]}');" data-id="${taskId[j]}" type="button">Delete</button>`;
}
}
function lstore(elem) {
localStorage.setItem("title", elem.data.title);
localStorage.setItem("des", elem.data.description);
localStorage.setItem("due", elem.data.dueDate);
localStorage.setItem("type", elem.data.type);
localStorage.setItem("priority", elem.data.priority);
localStorage.setItem("label", elem.data.label);
localStorage.setItem("Id", elem.data._id);
location.replace("./task.html");
}
function dele(x) {
let deleId = x;
$.ajax({
type: "DELETE",
headers: { Authorization: localStorage.getItem("accessToken") },
url:
"https://task-management-rest-app.herokuapp.com/api/tasks/" +
deleId,
dataType: "json",
contentType: "application/json",
success: function () {
location.replace("./tasksheduling.html");
},
});
}
function edt(Id) {
let edtId = Id;
$.ajax({
type: "GET",
headers: { Authorization: localStorage.getItem("accessToken") },
dataType: "json",
contentType: "application/json",
url:
"https://task-management-rest-app.herokuapp.com/api/tasks/" + edtId,
success: function (data) {
lstore(data);
},
});
}
</script>
</body>
</html>