Commit fb3360b0 authored by Robert Lyon's avatar Robert Lyon

Bug 1515484: fixing pagination on webservices logs page

This was mostly right but the json bits were not hooked up
Also fixing layout of table to be more like a similar
table, User -> Search

behatnotneeded

Change-Id: I9b29c8cc780535efae5b74b4f1eedb60d2227625
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 117ab531
......@@ -9,12 +9,14 @@
<p class="no-results">{str tag=youhavenoblogs section=artefact.blog}</p>
{else}
<div class="rel view-container">
<div class="panel-items js-masonry" data-masonry-options='{ "itemSelector": ".panel" }'>
<div class="panel-items">
<div id="bloglist">
{$blogs->tablerows|safe}
</div>
<div class="panel-pagination">
{$blogs->pagination|safe}
</div>
</div>
{$blogs->pagination|safe}
</div>
{/if}
{include file="footer.tpl"}
......@@ -6,7 +6,8 @@
<div id="results" class="section panel panel-default">
<h2 class="panel-heading" id="resultsheading">{str tag="Results"}</h2>
{if $results}
<table id="searchresults" class="tablerenderer fullwidth listing">
<div class="table-responsive">
<table id="searchresults" class="table table-striped fullwidth listing">
<thead>
<tr>
{foreach from=$columns key=f item=c}
......@@ -14,7 +15,7 @@
{if $c.sort}
<a href="{$searchurl}&sortby={$f}&sortdir={if $f == $sortby && $sortdir == 'asc'}desc{else}asc{/if}">
{$c.name}
<span class="accessible-hidden">({str tag=sortby} {if $f == $sortby && $sortdir == 'asc'}{str tag=descending}{else}{str tag=ascending}{/if})</span>
<span class="accessible-hidden sr-only">({str tag=sortby} {if $f == $sortby && $sortdir == 'asc'}{str tag=descending}{else}{str tag=ascending}{/if})</span>
</a>
{else}
{$c.name}
......@@ -32,6 +33,12 @@
</tbody>
</table>
{$pagination|safe}
{if $pagination_js}
<script type="application/javascript">
{$pagination_js|safe}
</script>
{/if}
</div>
{else}
<div class="panel-body">
<p class="no-results">{str tag="noresultsfound"}</p>
......
......@@ -41,3 +41,8 @@
.pagination-xs {
@include pagination-size($padding-xs-vertical, $padding-xs-horizontal, $font-size-small, $border-radius-small);
}
.panel-pagination {
width: 100%;
clear: both;
}
......@@ -6,9 +6,11 @@
</p>
{/if}
{if $results}
<div id="friendslist" class="panel-items js-masonry" data-masonry-options='{ "itemSelector": ".panel" }'>
<div id="friendslist" class="panel-items">
{$results.tablerows|safe}
</div>
<div class="panel-pagination">
{$results.pagination|safe}
</div>
{/if}
{include file="footer.tpl"}
......@@ -47,7 +47,7 @@ while ($more && count($tmpitem) < $itemsperpage) {
$page++;
}
json_reply(array(
echo json_encode(array(
'more' => $more,
'results' => $tmpitem,
));
......
......@@ -27,18 +27,31 @@ if ($action == 'search') {
$params->institution_requested = param_alphanum('institution_requested', null);
$params->offset = param_integer('offset', 0);
$params->limit = param_integer('limit', 10);
$params->setlimit = param_integer('setlimit', false);
$params->onlyerrors = param_integer('onlyerrors', 0);
$params->sortby = param_alpha('sortby', 'timelogged');
$params->sortdir = param_alpha('sortdir', 'desc');
json_headers();
if (param_boolean('raw', false)) {
json_headers();
$data['error'] = false;
$data['message'] = null;
$data = get_log_search_results($params);
echo json_encode($data);
exit;
}
else {
$data['data'] = build_webservice_log_search_results($params);
list($html, $columns, $searchurl, $pagination) = build_webservice_log_search_results($params);
}
$data['error'] = false;
$data['message'] = null;
echo json_encode($data);
exit;
json_reply(false, array(
'message' => null,
'data' => array(
'tablerows' => $html,
'pagination' => $pagination['html'],
'pagination_js' => $pagination['javascript'],
'offset' => $params->offset,
'setlimit' => $params->setlimit,
)
));
}
......@@ -24,13 +24,17 @@ if (is_array($userquery)) {
}
$username = (!empty($userquery)) ? get_field('usr', 'username', 'id', $userquery) : '';
$functionquery = param_variable('functionquery', null);
if (is_array($functionquery)) {
$functionquery = $functionquery[0];
}
$functionname = (!empty($functionquery)) ? get_field('external_functions', 'name', 'id', $functionquery) : '';
$search = (object) array(
'userquery' => $username,
'functionquery' => $functionname,
'protocol' => trim(param_alphanumext('protocol', 'all')),
'authtype' => trim(param_alphanum('authtype', 'all')),
'onlyerrors' => ('on' == param_alphanum('onlyerrors', 'off') ? 1 : 0),
'onlyerrors' => (in_array(param_alphanum('onlyerrors', 0), array('on', '1'), true)),
'sortby' => param_alpha('sortby', 'timelogged'),
'sortdir' => param_alpha('sortdir', 'desc'),
'offset' => param_integer('offset', 0),
......@@ -137,7 +141,7 @@ $form = array(
);
unset($form['elements'][0]);
$form = pieform($form);
$smarty = smarty();
$smarty = smarty(array('paginator'));
setpageicon($smarty, 'icon-puzzle-piece');
safe_require('auth', 'webservice');
......@@ -149,6 +153,7 @@ $smarty->assign('protocols', array('REST', 'XML-RPC', 'SOAP'));
$smarty->assign('authtypes', array('TOKEN', 'USER', 'OAUTH'));
$smarty->assign('results', $html);
$smarty->assign('pagination', $pagination['html']);
$smarty->assign('pagination_js', $pagination['javascript']);
$smarty->assign('columns', $columns);
$smarty->assign('searchurl', $searchurl['url']);
$smarty->assign('sortby', $searchurl['sortby']);
......
......@@ -45,7 +45,7 @@ function build_webservice_log_search_results($search) {
}
}
$searchurl = get_config('wwwroot') . 'webservice/admin/webservicelogs.php?' . join('&', $params);
$searchurl = get_config('wwwroot') . 'webservice/admin/webservicelogs.php?action=search&' . join('&', $params);
$pagination = $results['pagination'] = build_pagination(array(
'id' => 'admin_usersearch_pagination',
......@@ -209,7 +209,7 @@ function get_log_search_results($search) {
FROM {external_services_logs} el
JOIN {usr} u
ON el.userid = u.id
' . $where . ' ORDER BY ' . $search->sortby, $params, $search->offset);
' . $where . ' ORDER BY ' . $search->sortby, $params, $search->offset, $search->limit);
$results = array(
'count' => $count,
......
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