Added duration to events. Backported a few API changes
This commit is contained in:
@@ -317,22 +317,37 @@ import { settings, elements, apiDelete, apiGet, apiPost, eventTitles, parseParam
|
||||
var eventDate = new Date(event.created + "Z");
|
||||
var curDate = new Date();
|
||||
jobInfo.innerHTML = "Entered: " + timeString(curDate - eventDate, true);
|
||||
if (event.percent_complete && event.percent_complete != 100)
|
||||
jobInfo.innerHTML += " - " + event.percent_complete + "%";
|
||||
if (event.time_remaining) {
|
||||
var times = event.time_remaining.split(":");
|
||||
var ms = 0;
|
||||
ms += parseInt(times[0]) * 3600000;
|
||||
ms += parseInt(times[1]) * 60000;
|
||||
ms += parseInt(times[2]) * 1000;
|
||||
jobInfo.innerHTML += " - " + timeString(ms, false) + " Remaining";
|
||||
}
|
||||
if (event.duration)
|
||||
jobInfo.innerHTML += " - Took: " + timeString(event.duration * 1000, false);
|
||||
else if (event.status != "notification")
|
||||
jobInfo.innerHTML += " - Waiting...";
|
||||
detailsCell.appendChild(jobType);
|
||||
detailsCell.appendChild(jobDetails);
|
||||
detailsCell.appendChild(br);
|
||||
detailsCell.appendChild(jobInfo);
|
||||
row.appendChild(detailsCell);
|
||||
|
||||
// Progress cell
|
||||
var progressCell = document.createElement("td");
|
||||
if (event.percent_complete && event.percent_complete != 100)
|
||||
progressCell.innerHTML = event.percent_complete + "%";
|
||||
if (event.time_remaining) {
|
||||
if (progressCell.innerHTML.length)
|
||||
progressCell.innerHTML += ", ";
|
||||
var times = event.time_remaining.split(":");
|
||||
var ms = 0;
|
||||
ms += parseInt(times[0]) * 3600000;
|
||||
ms += parseInt(times[1]) * 60000;
|
||||
ms += parseInt(times[2]) * 1000;
|
||||
progressCell.innerHTML += timeString(ms, false) + " to go";
|
||||
}
|
||||
if (event.rate) {
|
||||
if (progressCell.innerHTML.length)
|
||||
progressCell.innerHTML += ", ";
|
||||
progressCell.innerHTML += event.rate;
|
||||
}
|
||||
row.appendChild(progressCell);
|
||||
|
||||
return row;
|
||||
};
|
||||
|
||||
@@ -427,33 +442,6 @@ import { settings, elements, apiDelete, apiGet, apiPost, eventTitles, parseParam
|
||||
});
|
||||
};
|
||||
|
||||
// Callback for backups API call
|
||||
var displayBackups = function(response)
|
||||
{
|
||||
// Find time of most recent backup
|
||||
var mostRecent = new Date(0);
|
||||
for (var i = 0; i < response.automatic.length; i++) {
|
||||
if (response.automatic[i].status == "successful") {
|
||||
var time = new Date(response.automatic[i].finished + "Z");
|
||||
if (time > mostRecent)
|
||||
mostRecent = time;
|
||||
}
|
||||
}
|
||||
if (response.snapshot.current && response.snapshot.current.status == "successful") {
|
||||
var time = new Date(response.snapshot.current.finished + "Z");
|
||||
if (time > mostRecent)
|
||||
mostRecent = time;
|
||||
}
|
||||
|
||||
// 1970 means no backups happened
|
||||
if (mostRecent.getUTCFullYear() == 1970)
|
||||
return;
|
||||
|
||||
var curDate = new Date();
|
||||
ui.lastBackupTime.innerHTML = timeString(curDate - mostRecent, true);
|
||||
ui.lastBackup.style.display = "block";
|
||||
};
|
||||
|
||||
// Callback for config profile API call
|
||||
var displayConfigs = function(response)
|
||||
{
|
||||
@@ -516,6 +504,12 @@ import { settings, elements, apiDelete, apiGet, apiPost, eventTitles, parseParam
|
||||
if (data.linode.backups.enabled) {
|
||||
ui.backups.innerHTML = "Enabled!";
|
||||
ui.backups.className += " " + elements.backupsEnabled;
|
||||
if (data.linode.backups.last_successful) {
|
||||
var backupDate = new Date(data.linode.backups.last_successful + "Z");
|
||||
var now = new Date();
|
||||
ui.lastBackupTime.innerHTML = timeString(now - backupDate, true);
|
||||
ui.lastBackup.style.display = "block";
|
||||
}
|
||||
} else {
|
||||
ui.backups.innerHTML = "";
|
||||
var text = document.createElement("span");
|
||||
@@ -821,7 +815,6 @@ import { settings, elements, apiDelete, apiGet, apiPost, eventTitles, parseParam
|
||||
apiGet("/linode/instances/" + data.params.lid + "/disks", displayDisks, null);
|
||||
apiGet("/linode/instances/" + data.params.lid + "/volumes", displayVolumes, null);
|
||||
apiGet("/linode/instances/" + data.params.lid + "/transfer", displayTransfer, null);
|
||||
apiGet("/linode/instances/" + data.params.lid + "/backups", displayBackups, null);
|
||||
var filter = {
|
||||
"entity.type": "linode",
|
||||
"entity.id": parseInt(data.params.lid)
|
||||
|
||||
Reference in New Issue
Block a user