load stats on deman via ajax

This commit is contained in:
Andrew Bauer 2020-09-13 07:32:49 -05:00
parent 56aa906dd8
commit 1599bc4c14
3 changed files with 33 additions and 14 deletions

24
web/ajax/stats.php Normal file
View File

@ -0,0 +1,24 @@
<?php
if ( empty($_REQUEST['eid']) ) ajaxError('Event Id Not Provided');
if ( empty($_REQUEST['fid']) ) ajaxError('Frame Id Not Provided');
$eid = $_REQUEST['eid'];
$fid = $_REQUEST['fid'];
$row = ( isset($_REQUEST['row']) ) ? $_REQUEST['row'] : '';
$data = array();
// Not sure if this is required
if ( ZM_OPT_USE_AUTH && (ZM_AUTH_RELAY == 'hashed') ) {
$auth_hash = generateAuthHash(ZM_AUTH_HASH_IPS);
if ( isset($_REQUEST['auth']) and ($_REQUEST['auth'] != $auth_hash) ) {
$data['auth'] = $auth_hash;
}
}
$data['html'] = getStatsTableHTML($eid, $fid, $row);
$data['id'] = '#contentStatsTable' .$row;
ajaxResponse($data);
return;
?>

View File

@ -206,15 +206,4 @@ if ( count($frames) ) {
</table>
</div>
</div>
<!-- Load the statistics for each frame -->
<!-- This content gets hidden on init and only revailed on detail view -->
<?php
$row = 0;
if ( count($frames) ) foreach ( $frames as $frame ) {
$eid = $frame['EventId'];
$fid = $frame['FrameId'];
echo getStatsTableHTML($eid, $fid, $row);
$row++;
}
?>
<?php xhtmlFooter() ?>

View File

@ -25,10 +25,16 @@ function processClicks(event, field, value, row, $element) {
}
}
function detailFormatter(index, row, element) {
return $j(element).html($j('#contentStatsTable'+index).clone(true).show());
// This function handles when the user clicks a "+" link to retrieve stats for a frame
function detailFormatter(index, row, $detail) {
$detail.html('Please wait. Loading from ajax request...');
$j.get(thisUrl + '?request=stats&eid=' + row.EventId + '&fid=' + row.FrameId + '&row=' + index)
.done(function(data){ $detail.html(data.html) })
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
}
function initPage() {
var backBtn = $j('#backBtn');
var table = $j('#framesTable');