-
Notifications
You must be signed in to change notification settings - Fork 0
/
Index.html
209 lines (185 loc) · 7.22 KB
/
Index.html
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
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<!-- Linked Scripts -->
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.23/js/dataTables.bootstrap4.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.23/css/dataTables.bootstrap4.min.css">
<script>
google.script.run.withSuccessHandler(viewData).getData();
// Automatically assigns label to task based on task type and task deadline
function getLabel(taskName, type, deadline) {
var label = "";
let totalDays="";
let today = new Date();
let d = new Date(deadline);
let difference = d-today;
let daysBetween = difference / (1000 * 60 * 60 * 24);
let numDays = Math.floor(daysBetween);
const LABELS = {
p1: "URGENT",
p2: "POSTPONABLE",
p3: "NOT IMPORTANT",
p4: "UNLABELED"
}
console.log("Start Label: " + label);
switch (type) {
case "Work":
var label = LABELS.p4
if (numDays <= 1) {
label = LABELS.p1
console.log("Label 1: " + label);
} else if ((numDays <= 30) && (taskName.includes("PLO") || taskName.includes("GJL"))){
label = LABELS.p2
console.log("Label 2: " + label);
} else if ((numDays <= 7) &&((taskName.includes("PLO") || taskName.includes("GJL"))==false)) {
label = LABELS.p2
console.log("Label 3: " + label);
} else {
label = LABELS.p3
console.log("Label 4: " + label);
}
console.log("Label: " + label);
return label;
break;
case "Personal":
var label = LABELS.p4
if (numDays <= 7) {
label = LABELS.p2
} else {
label = LABELS.p3
}
console.log("Label: " + label);
return label;
break;
case "Health":
if ((numDays <= 3) && (taskName.includes("Treatment")==false)) {
label = LABELS.p1
console.log("Label 1: " + label);
} else if ((numDays <= 3) && (taskName.includes("Treatment"))) {
label = LABELS.p2
console.log("Label 2: " + label);
} else if (numDays<=7) {
label = LABELS.p2
console.log("Label 3: " + label);
} else {
label = LABELS.p3
console.log("Label 4: " + label);
}
console.log("Label: " + label);
return label;
break;
default:
if (numDays <= 7) {
label = LABELS.p2
// Assumed 6-7 days are ok in postponable category.
// Unspecified in requirements.
} else if ((numDays >= 8) || (numDays == NULL)) {
label = LABELS.p3
}
console.log("Label: " + label);
return label;
break;
}
}
// Resets form values
function clearForm() {
document.getElementById("taskname").value = '';
document.getElementById("taskdescription").value = '';
document.getElementById("tasktype").value = '';
document.getElementById("taskduedate").value = '';
}
// Pushes the form fields to the google sheet
function submitForm() {
// Get values from form fields
taskName = document.getElementById("taskname").value;
taskDescription = document.getElementById("taskdescription").value;
taskType = document.getElementById("tasktype").value;
taskDueDate = document.getElementById("taskduedate").value;
taskLabel = getLabel(taskName, taskType, taskDueDate);
// Adds data as row in google sheet
console.log("Task: " + taskName + ", " + taskDescription + ", " + taskType + ", " + taskDueDate + ", " + taskLabel);
google.script.run.addRecord(taskName, taskDescription, taskType, taskDueDate, taskLabel);
// Resets the form fields
clearForm();
};
// Populates the task table
function viewData(dataArray){
$(document).ready(function(){
$('#datatable').DataTable({
data: dataArray,
columns: [
{"title":"Name"},
{"title":"Description"},
{"title":"Type"},
{"title":"Due Date"},
{"title":"Label"}
]
});
});
}
</script>
</head>
<body>
<form>
<!-- Task Input Form -->
<label for="taskname">Name:</label><br>
<input type = "text" id="taskname" /><br>
<label for="taskdescription">Description:</label><br>
<input type = "text" id="taskdescription" /><br>
<label for="tasktype">Type:</label><br>
<select name="tasktype" id="tasktype">
<option value="Work">Work</option>
<option value="Personal">Personal</option>
<option value="Health">Health</option>
<option value="Other">Other</option>
</select><br>
<label for="taskduedate">Due Date:</label><br>
<input type = "date" id="taskduedate" name="taskduedate" value="" min="1900-01-01" max="2100-12-31"/><br>
<!-- <label for="tasklabel">Label:</label><br> -->
<input type = "button" value = "Add" onclick="submitForm()"/><br>
</form>
<br>
Current Tasks:<br>
<!-- Table View of Data -->
<div class="container">
<br>
<div class="row">
<table id="datatable" class="table table-striped table-sm table-hover table-bordered">
</table>
</div>
</div>
<br><br><br>
<header>
<h1>Setup & Instructions:</h>
</header>
<p>
Thank you for viewing!
</p>
<ul>
<li>Clone the public <a href="https://github.com/NankeyDev/TechnicalAssessment230906.git">GitHub Repository</a></li>
<li>Load project into <a href="https://script.google.com/home">Apps Script</a></li>
<li>Enable Google Sheets API (Apps Script main project window, Services > Add a Service > Google Sheets API)</li>
<li>Deploy the Web Application (Deploy > New Deployment)</li>
</ul>
<ul>
<li>The link to the sheet utilized in web application can be found in the following link: <i><a href="https://docs.google.com/spreadsheets/d/1LvLY5RBwm3nUqr-GBK5C0Q8ylX8uOSaTUzJG7jAXsDc/edit?usp=sharing">Sheet used in Application</a></i></li>
</ul>
<h2>Future Improvements:</h2>
<ul>
<li>Manual override of assigned label</li>
<li>Delete task functionality</li>
<li>Addition of MySQL Backend for Persistent Storage</li>
<li>Input Validation</li>
<li>Testing</li>
<li>Improved UI & UX</li>
<li>Auditing & Metadata</li>
<li>Improved Label Logic</li>
<li>Improved Processing Efficiency (label validation logic)</li>
<li>Improved Setup Instructions</li>
</ul>
</body>
</html>