WIP: Add pagination to frames.php in classic (#2618)
* add pagination to the frames.php results * remove commented code, fix view all paging * removing debugging logging statements * default frames paging to on
This commit is contained in:
parent
98bf7800b0
commit
1336c03f97
|
@ -1077,13 +1077,28 @@ function parseSort( $saveToSession=false, $querySep='&' ) {
|
|||
case 'MaxScore' :
|
||||
$sortColumn = 'E.MaxScore';
|
||||
break;
|
||||
case 'FramesFrameId' :
|
||||
$sortColumn = 'F.FrameId';
|
||||
break;
|
||||
case 'FramesType' :
|
||||
$sortColumn = 'F.Type';
|
||||
break;
|
||||
case 'FramesTimeStamp' :
|
||||
$sortColumn = 'F.TimeStamp';
|
||||
break;
|
||||
case 'FramesDelta' :
|
||||
$sortColumn = 'F.Delta';
|
||||
break;
|
||||
case 'FramesScore' :
|
||||
$sortColumn = 'F.Score';
|
||||
break;
|
||||
default:
|
||||
$sortColumn = 'E.StartTime';
|
||||
break;
|
||||
}
|
||||
$sortOrder = $_REQUEST['sort_asc']?'asc':'desc';
|
||||
if ( !$_REQUEST['sort_asc'] )
|
||||
$_REQUEST['sort_asc'] = 0;
|
||||
$sortOrder = $_REQUEST['sort_asc']?'asc':'desc';
|
||||
$sortQuery = $querySep.'sort_field='.validHtmlStr($_REQUEST['sort_field']).$querySep.'sort_asc='.validHtmlStr($_REQUEST['sort_asc']);
|
||||
if ( !isset($_REQUEST['limit']) )
|
||||
$_REQUEST['limit'] = '';
|
||||
|
@ -1168,6 +1183,9 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') {
|
|||
case 'StartDateTime':
|
||||
$filter['sql'] .= 'E.StartTime';
|
||||
break;
|
||||
case 'FramesEventId':
|
||||
$filter['sql'] .= 'F.EventId';
|
||||
break;
|
||||
case 'StartDate':
|
||||
$filter['sql'] .= 'to_days( E.StartTime )';
|
||||
break;
|
||||
|
|
|
@ -22,8 +22,44 @@ if ( !canView('Events') ) {
|
|||
$view = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
require_once('includes/Frame.php');
|
||||
$Event = new ZM\Event($_REQUEST['eid']);
|
||||
|
||||
$countSql = 'SELECT COUNT(*) AS FrameCount FROM Frames AS F WHERE 1 ';
|
||||
$frameSql = 'SELECT *, unix_timestamp( TimeStamp ) AS UnixTimeStamp FROM Frames AS F WHERE 1 ';
|
||||
|
||||
$eid = $_REQUEST['eid'];
|
||||
|
||||
// override the sort_field handling in parseSort for frames
|
||||
if ( empty($_REQUEST['sort_field']) )
|
||||
$_REQUEST['sort_field'] = 'FramesTimeStamp';
|
||||
|
||||
if ( !isset($_REQUEST['sort_asc']) )
|
||||
$_REQUEST['sort_asc'] = true;
|
||||
|
||||
if( ! isset($_REQUEST['filter'])){
|
||||
// generate a dummy filter from the eid for pagination
|
||||
$_REQUEST['filter'] = array('Query' => array( 'terms' => array( ) ) );
|
||||
$_REQUEST['filter'] = addFilterTerm(
|
||||
$_REQUEST['filter'],
|
||||
0,
|
||||
array( 'cnj' => 'and', 'attr' => 'FramesEventId', 'op' => '=', 'val' => $eid )
|
||||
);
|
||||
}
|
||||
|
||||
parseSort();
|
||||
parseFilter($_REQUEST['filter']);
|
||||
$filterQuery = $_REQUEST['filter']['query'];
|
||||
|
||||
|
||||
if ( $_REQUEST['filter']['sql'] ) {
|
||||
$countSql .= $_REQUEST['filter']['sql'];
|
||||
$frameSql .= $_REQUEST['filter']['sql'];
|
||||
}
|
||||
|
||||
$frameSql .= " ORDER BY $sortColumn $sortOrder,Id $sortOrder";
|
||||
|
||||
$Event = new ZM\Event($eid);
|
||||
$Monitor = $Event->Monitor();
|
||||
|
||||
if ( isset( $_REQUEST['scale'] ) ) {
|
||||
|
@ -35,8 +71,40 @@ if ( isset( $_REQUEST['scale'] ) ) {
|
|||
} else {
|
||||
$scale = max(reScale(SCALE_BASE, $Monitor->DefaultScale(), ZM_WEB_DEFAULT_SCALE), SCALE_BASE);
|
||||
}
|
||||
$sql = 'SELECT *, unix_timestamp(TimeStamp) AS UnixTimeStamp FROM Frames WHERE EventID = ? ORDER BY FrameId';
|
||||
$frames = dbFetchAll($sql, NULL, array($_REQUEST['eid']));
|
||||
|
||||
$page = isset($_REQUEST['page']) ? validInt($_REQUEST['page']) : 1;
|
||||
$limit = isset($_REQUEST['limit']) ? validInt($_REQUEST['limit']) : 0;
|
||||
|
||||
$nEvents = dbFetchOne($countSql, 'FrameCount' );
|
||||
|
||||
if ( !empty($limit) && $nEvents > $limit ) {
|
||||
$nEvents = $limit;
|
||||
}
|
||||
|
||||
$pages = (int)ceil($nEvents/ZM_WEB_EVENTS_PER_PAGE);
|
||||
|
||||
if ( !empty($page) ) {
|
||||
if ( $page < 0 )
|
||||
$page = 1;
|
||||
else if ( $pages and ( $page > $pages ) )
|
||||
$page = $pages;
|
||||
|
||||
$limitStart = (($page-1)*ZM_WEB_EVENTS_PER_PAGE);
|
||||
if ( empty( $limit ) ) {
|
||||
$limitAmount = ZM_WEB_EVENTS_PER_PAGE;
|
||||
} else {
|
||||
$limitLeft = $limit - $limitStart;
|
||||
$limitAmount = ($limitLeft>ZM_WEB_EVENTS_PER_PAGE)?ZM_WEB_EVENTS_PER_PAGE:$limitLeft;
|
||||
}
|
||||
$frameSql .= " limit $limitStart, $limitAmount";
|
||||
} elseif ( !empty($limit) ) {
|
||||
$frameSql .= ' limit 0, '.$limit;
|
||||
}
|
||||
|
||||
$maxShortcuts = 5;
|
||||
$pagination = getPagination($pages, $page, $maxShortcuts, $sortQuery.'&eid='.$eid.$limitQuery.$filterQuery);
|
||||
|
||||
$frames = dbFetchAll( $frameSql );
|
||||
|
||||
$focusWindow = true;
|
||||
|
||||
|
@ -47,18 +115,48 @@ xhtmlHeaders(__FILE__, translate('Frames').' - '.$Event->Id());
|
|||
<div id="header">
|
||||
<div id="headerButtons"><a href="#" data-on-click="closeWindow"><?php echo translate('Close') ?></a></div>
|
||||
<h2><?php echo translate('Frames') ?> - <?php echo $Event->Id() ?></h2>
|
||||
<div id="pagination">
|
||||
<?php
|
||||
if ( $pagination ) {
|
||||
?>
|
||||
<h2 class="pagination"><?php echo $pagination ?></h2>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if ( $pages > 1 ) {
|
||||
if ( !empty($page) ) {
|
||||
?>
|
||||
<a href="?view=<?php echo $view ?>&page=0<?php echo $filterQuery ?><?php echo $sortQuery.$limitQuery ?>"><?php echo translate('ViewAll') ?></a>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<a href="?view=<?php echo $view ?>&page=1<?php echo $filterQuery ?><?php echo $sortQuery.$limitQuery ?>"><?php echo translate('ViewPaged') ?></a>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div id="content">
|
||||
<form name="contentForm" id="contentForm" method="get" action="?">
|
||||
<input type="hidden" name="view" value="none"/>
|
||||
<table id="contentTable" class="major" cellspacing="0">
|
||||
<input type="hidden" name="view" value="<?php echo $view ?>"/>
|
||||
<input type="hidden" name="action" value=""/>
|
||||
<input type="hidden" name="page" value="<?php echo $page ?>"/>
|
||||
<input type="hidden" name="eid" value="<?php echo $eid ?>"/>
|
||||
<?php echo $_REQUEST['filter']['fields'] ?>
|
||||
<input type="hidden" name="sort_field" value="<?php echo validHtmlStr($_REQUEST['sort_field']) ?>"/>
|
||||
<input type="hidden" name="sort_asc" value="<?php echo validHtmlStr($_REQUEST['sort_asc']) ?>"/>
|
||||
<input type="hidden" name="limit" value="<?php echo $limit ?>"/>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="colId"><?php echo translate('FrameId') ?></th>
|
||||
<th class="colType"><?php echo translate('Type') ?></th>
|
||||
<th class="colTimeStamp"><?php echo translate('TimeStamp') ?></th>
|
||||
<th class="colTimeDelta"><?php echo translate('TimeDelta') ?></th>
|
||||
<th class="colScore"><?php echo translate('Score') ?></th>
|
||||
<th class="colId"><a href="<?php echo sortHeader('FramesFrameId') ?>"><?php echo translate('Frame Id') ?><?php echo sortTag('FramesFrameId') ?></a></th>
|
||||
<th class="colType"><a href="<?php echo sortHeader('FramesType') ?>"><?php echo translate('Type') ?><?php echo sortTag('FramesType') ?></a></th>
|
||||
<th class="colTimeStamp"><a href="<?php echo sortHeader('FramesTimeStamp') ?>"><?php echo translate('TimeStamp') ?><?php echo sortTag('FramesTimeStamp') ?></a></th>
|
||||
<th class="colTimeDelta"><a href="<?php echo sortHeader('FramesDelta') ?>"><?php echo translate('TimeDelta') ?><?php echo sortTag('FramesDelta') ?></a></th>
|
||||
<th class="colScore"><a href="<?php echo sortHeader('FramesScore') ?>"><?php echo translate('Score') ?><?php echo sortTag('FramesScore') ?></a></th>
|
||||
<?php
|
||||
if ( ZM_WEB_LIST_THUMBS ) {
|
||||
?>
|
||||
|
@ -122,6 +220,15 @@ if ( count($frames) ) {
|
|||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
if ( $pagination ) {
|
||||
?>
|
||||
<h3 class="pagination"><?php echo $pagination ?></h3>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="contentButtons">
|
||||
</div>
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue