in AzureCT/ServerSide/DisplayAvailability.js [36:224]
function PullJobDetails() {
// Get the selected Job ID from the drop down
headerJobID = document.getElementById("JobList").value;
currentStartTime = '';
currentEndTime = '';
currentTarget = '';
currentTimeoutSeconds = '';
currentCallCount = '';
currentSuccessRate = '';
currentJobMin = '';
currentJobMax = '';
currentJobMedian = '';
currentJobDuration = '';
currentJobDisplay = '';
// Define graph var
var data = [];
// Set Data Loading Message to visible
document.getElementById('MessageDiv').style.visibility = 'visible';
// Open the AvailabilityHeader.xml file
$.get('AvailabilityHeader.xml', {}, function (xml) {
// Run the function for each Job in xml file
$('Job', xml).each(function (i) {
jobID = $(this).find('ID').text();
// Pull Job Header info into variables
if (jobID == headerJobID) {
currentStartTime = $(this).find('StartTime').text();
currentEndTime = $(this).find('EndTime').text();
currentTarget = $(this).find('Target').text();
currentTimeoutSeconds = $(this).find('TimeoutSeconds').text();
currentCallCount = $(this).find('CallCount').text();
currentSuccessRate = $(this).find('SuccessRate').text();
currentJobMin = $(this).find('JobMin').text();
currentJobMax = $(this).find('JobMax').text();
currentJobMedian = $(this).find('JobMedian').text();
var t1 = new Date(currentStartTime);
var t2 = new Date(currentEndTime);
var dif = (t2 - t1) / 1000;
var runDays = Math.floor(dif / 86400);
var rem = dif - (runDays * 86400);
var runHours = Math.floor(rem / 3600);
var rem = rem - (runHours * 3600);
var runMinutes = Math.floor(rem / 60);
var runSeconds = rem - (runMinutes * 60);
if ((+runDays) == (+1)) { var unitDays = 'Day'; } else { var unitDays = 'Days'; };
currentJobDuration = runDays + ' ' + unitDays + ', ' + pad(runHours) + ':' + pad(runMinutes) + ':' + pad(runSeconds) + ' (hh:mm:ss)';
myHTMLOutput = '';
myHTMLOutput += '<table id="SummaryTable">';
myHTMLOutput += '<tr><td class="SumHead" colspan=6 style="text-align:left;">Job Details:</td></tr>';
myHTMLOutput += '<tr>';
myHTMLOutput += '<td>Start Time:</td>';
myHTMLOutput += '<td>' + dateString(t1, 'noMilli') + '</td>';
myHTMLOutput += '<td>End Time:</td>';
myHTMLOutput += '<td>' + dateString(t2, 'noMilli') + '</td>';
myHTMLOutput += '<td>Job Duration:</td>';
myHTMLOutput += '<td>' + currentJobDuration + '</td>';
myHTMLOutput += '</tr>';
myHTMLOutput += '<tr>';
myHTMLOutput += '<td>Target IP:</td>';
myHTMLOutput += '<td>' + currentTarget + '</td>';
myHTMLOutput += '<td>Calls Sent:</td>';
myHTMLOutput += '<td>' + currentCallCount + ' (' + currentSuccessRate + '%) Successful</td>';
myHTMLOutput += '<td>Timeout Value:</td>';
myHTMLOutput += '<td>' + currentTimeoutSeconds + ' Seconds</td>';
myHTMLOutput += '</tr>';
myHTMLOutput += '<tr><td class="SumHead" colspan="6" style="text-align:left;">Results Summary:</td></tr>';
myHTMLOutput += '<tr>';
myHTMLOutput += '<td>Min:</td>';
myHTMLOutput += '<td>' + currentJobMin + ' ms</td>';
myHTMLOutput += '<td>Max:</td>';
myHTMLOutput += '<td>' + currentJobMax + ' ms</td>';
myHTMLOutput += '<td>Median:</td>';
myHTMLOutput += '<td>' + currentJobMedian + ' ms</td>';
myHTMLOutput += '</tr>';
myHTMLOutput += '</table>';
$("#SummaryDiv").html(myHTMLOutput);
};
});
});
// Open the AvailabilityDetail.xml file
$.get('AvailabilityDetail.xml', {}, function (xml) {
// Define HTML string Var
myHTMLOutput = '';
myHTMLOutput += '<table id="ResultsTable"';
myHTMLOutput += '<thead>';
myHTMLOutput += '<th id=time>Time Stamp</th>'
myHTMLOutput += '<th id=display>Remarks</th>'
myHTMLOutput += '<th id=duration>Duration</th>'
myHTMLOutput += '<th id=trace>Trace</th>'
myHTMLOutput += '</thead>';
var t1 = new Date(currentStartTime);
var t2 = new Date(currentEndTime);
var chartWidth = document.getElementById("ResultsGraph").clientWidth - 100;
var totalDurationMS = (t2 - t1);
var timePerPixel = Math.round(totalDurationMS / chartWidth);
var iRunning = 0;
// Run the function for each Job in xml file
$('JobRecord', xml).each(function (i) {
jobID = $(this).find('JobID').text();
if (jobID == headerJobID) {
callTimeStamp = $(this).find('TimeStamp').text();
callID = $(this).find('CallID').text();
callReturn = $(this).find('Return').text();
callDisplay = $(this).find('Display').text();
callValid = $(this).find('Valid').text();
callDuration = $(this).find('Duration').text();
callTagged = $(this).find('Tag').text();
// Calculate X position
var thisTime = new Date(callTimeStamp);
if (callID == 1 || callID == '') {
dif = 1;
pos = 1;
lastTime = thisTime;
}
else {
dif = thisTime - lastTime;
pos += dif / timePerPixel;
lastTime = thisTime;
};
// Build Table Row for Results Table
myHTMLOutput += '<tr>';
myHTMLOutput += '<td>' + dateString(thisTime, 'withMilli') + '</td>';
myHTMLOutput += '<td>' + callDisplay + '</td>';
myHTMLOutput += '<td>' + Math.round(callDuration) + ' ms</td>';
if (callTagged == 'True') {
myHTMLOutput += "<td><a href=javascript:showTrace('" + jobID + "','" + callID + "')>View Trace</a></td>";
}
else {
myHTMLOutput += '<td> </td>';
};
myHTMLOutput += '</tr>';
// Build graph array
var myCallID = (+callID);
var datapoint = { x: pos, y: Math.round(callDuration), z: callValid };
data.push(datapoint);
};
});
myHTMLOutput += "</table>";
// Update the DIV called ResultsDiv with the HTML string
$("#ResultsDiv").html(myHTMLOutput);
var myTick;
if (currentCallCount < 15) { myTick = 1; } else { myTick = currentCallCount / 15; };
var myYMax;
if (currentJobMax > 500) { myYMax = currentJobMax; } else { myYMax = 500; };
// Instanitate the graph
ClearChart("ResultsGraph");
var myLineChart = new LineChart({
canvasId: "ResultsGraph",
minX: 0,
minY: 0,
maxX: currentCallCount,
maxY: myYMax,
unitsPerTickX: myTick,
unitsPerTickY: myYMax / 8
});
// Draw the chart
myLineChart.drawLine(data, "blue", 1);
});
// Set Data Loading Message to visible
document.getElementById('MessageDiv').style.visibility = 'hidden';
};