Commit 7446d82b authored by Jeremy Fischer's avatar Jeremy Fischer
Browse files

Update Dashboard Presence

parent 942aad87
......@@ -46,21 +46,7 @@
<th>Load</th>
</thead>
<tbody id="teamTableBody">
<tr onclick="details_show(); return true;">
<td> Jeremy Fischer </td>
<td> Now </td>
<td> 2 Tasks </td>
</tr>
<tr onclick="details_show(); return true;">
<td> Sebastian Schleier </td>
<td> 2 Hours Ago </td>
<td class="amber-text"> 3 Task </td>
</tr>
<tr onclick="details_show(); return true;">
<td> Andreas Machbar </td>
<td> 6 Weeks Ago </td>
<td class="red-text"> 1 Task </td>
</tr>
</tbody>
</table>
</div>
......
......@@ -190,14 +190,51 @@ if (declare_load("appclient") !== TRUE)
}
function update_dashboard() {
if(current_view!="dashboard") return;
//TODO: Fix this mess
var tableContents = "";
var row_template = '<tr onclick="details_show(); return true;"><td>$state</td><td>$name</td><td>$activeTime</td><td>$tasks</td></tr>';
for (member in teamData["members"]) {
var cm = teamData["members"][member];
var hours = Math.floor((((Date.now() / 1000) - cm["timeOut"] ) % 216000) / 3600);
var minutes = Math.floor(((Date.now() / 1000) - cm["timeOut"] ) % 3600) / 60;
tableContents += row_template.replace("$name", cm["Name"]).replace("$activeTime", hours + ":" + minutes);
var tp = getUserTP(cm["FullID"],false) - getUserTP(cm["FullID"],true);
var time = "";
if(cm["timeOut"] != undefined){
var seconds = Math.floor(Date.now()/1000 - cm["timeOut"]);
console.log(seconds);
var minutes = Math.floor(seconds/60);
seconds = seconds % 60;
var hours = Math.floor(minutes/60);
minutes = minutes % 60;
var days = Math.floor(hours/24);
hours = hours % 24;
var weeks = days / 7;
days = days % 7;
if(weeks > 0 ){
time = weeks+" Weeks";
}else if(days > 0 ){
time = days+" Days";
}else if(hours > 0 ){
time = hours+" Hours";
}else if(minutes > 0 ){
time = minutes+" Minutes";
}else {
time = "Unknown";
}
}else{
time = "Unknown";
}
var online = ((Date.now() / 1000) - cm["timeOut"] < 0);
if(online){
online = '<i class="material-icons">person</i>';
time = "Now";
}else{
online = '<i class="material-icons">person_outline</i>';
}
tableContents += row_template.replace("$name", cm["Name"]).replace("$tasks",tp).replace("$state",online).replace("$activeTime", time);
}
document.getElementById("teamTableBody").innerHTML = tableContents;
}
......@@ -1441,6 +1478,7 @@ if (declare_load("appclient") !== TRUE)
setInterval(updateTeamData, 120000);
setTimeout(updates_check, 50000);
setInterval(sessionKeepAlive, 20000);
setInterval(update_dashboard, 5000);
setInterval(validateSession, 50000);
setInterval(updateNotificationBadge, 10000);
setTimeout(overview_init(),10);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment