Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
fix(pagination) fix filter save with pagination (#7732)
Browse files Browse the repository at this point in the history
  • Loading branch information
loiclau committed Jul 31, 2019
1 parent 1d50c92 commit 9a10e97
Show file tree
Hide file tree
Showing 67 changed files with 1,252 additions and 1,033 deletions.
2 changes: 1 addition & 1 deletion www/include/Administration/configChangelog/viewLogs.ihtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<td><input type='text' name='searchO' value="{$searchO}" /></td>
<td><input type='text' name='searchU' value="{$searchU}" /></td>
<td><select name='otype'>{$obj_type}</select></td>
<td><input type='submit' class="btc bt_success" name='SearchB' value='{$Search}' /></td>
<td>{$form.SearchB.html}</td>
</tr>
</tbody>
</table>
Expand Down
6 changes: 6 additions & 0 deletions www/include/Administration/configChangelog/viewLogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ function searchUserName($username)
//Init QuickForm
$form = new HTML_QuickFormCustom('select_form', 'POST', "?p=" . $p);

$attrBtnSuccess = array(
"class" => "btc bt_success",
"onClick" => "window.history.replaceState('', '', '?p=" . $p . "');"
);
$form->addElement('submit', 'SearchB', _("Search"), $attrBtnSuccess);

//Init Smarty
$tpl = initSmartyTpl($path, new Smarty());

Expand Down
2 changes: 1 addition & 1 deletion www/include/Administration/parameters/ldap/list.ihtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</tr>
<tr>
<td><input type="text" name="searchLdap" value="{$searchLdap}"></td>
<td><input type="submit" value="{t}Search{/t}" class="btc bt_success"></td>
<td>{$form.Search.html}</td>
</tr>
</tbody>
</table>
Expand Down
6 changes: 6 additions & 0 deletions www/include/Administration/parameters/ldap/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@

$form = new HTML_QuickFormCustom('select_form', 'POST', "?o=ldap&p=" . $p);

$attrBtnSuccess = array(
"class" => "btc bt_success",
"onClick" => "window.history.replaceState('', '', '?p=" . $p . "');"
);
$form->addElement('submit', 'Search', _("Search"), $attrBtnSuccess);

$tpl->assign('list', $list);
$tpl->assign(
'msg',
Expand Down
150 changes: 75 additions & 75 deletions www/include/Administration/performance/viewData.ihtml
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
<script type="text/javascript" src="./include/common/javascript/tool.js"></script>
<form name='form' method='POST'>
<input name="o" type="hidden">
<table class="ajaxOption table">
<tbody>
<input name="o" type="hidden">
<table class="ajaxOption table">
<tbody>
<tr>
<th><h5>{t}Filters{/t}</h5></th>
<th><h5>{t}Filters{/t}</h5></th>
</tr>
<tr>
<tr>
<td><h4>{$Hosts}</h4></td>
<td><h4>{$Services}</h4></td>
<td><h4>{$Pollers}</h4></td>
</tr>
<td><h4>{$Services}</h4></td>
<td><h4>{$Pollers}</h4></td>
</tr>
<tr>
<td><input type='text' name='searchH' value="{$searchH}" /></td>
<td><input type='text' name='searchS' value="{$searchS}" /></td>
<td>
<select name="searchP">
<option value=""></option>
{foreach from=$instances key=instanceId item=instanceName}
<option value="{$instanceId}"{if $instanceId == $searchP} selected{/if}>{$instanceName}</option>
{/foreach}
</select>
</td>
<td><input type='submit' name='Search' value='{$Search}' class="btc bt_success" /></td>
<td><input type='text' name='searchH' value="{$searchH}"/></td>
<td><input type='text' name='searchS' value="{$searchS}"/></td>
<td>
<select name="searchP">
<option value=""></option>
{foreach from=$instances key=instanceId item=instanceName}
<option value="{$instanceId}" {if $instanceId== $searchP} selected{
/if}>{$instanceName}</option>
{/foreach}
</select>
</td>
<td>{$form.Search.html}</td>
</tr>
</tbody>
</table>
<table class="ToolbarTable table">
<tr class="ToolbarTR">
<td>
{$msg.options} {$form.o1.html}
&nbsp;&nbsp;&nbsp;
</td>
<input name="p" value="{$p}" type="hidden">
{php}
include('./include/common/pagination.php');
{/php}
</tr>
</table>
<table class="ListTable">
<tr class="ListHeader">
<td class="ListColHeaderPicker"><input type="checkbox" name="checkall" onclick="checkUncheckAll(this);"/>
</td>
<td class="ListColLeft">{$Host}</td>
<td class="ListColCenter">{$Service}</td>
<td class="ListColCenter">{$Metrics}</td>
<td class="ListColCenter">{$RebuildWaiting}</td>
<td class="ListColCenter">{$Delete}</td>
<td class="ListColCenter">{$Hidden}</td>
<td class="ListColCenter">{$Locked}</td>
</tr>
{assign var='host_name' value=''}
{foreach item=d from=$data}
<tr class="{$d.class}">
<td class="ListColCenter"><input name="select[{$d.id}]" value="1" type="checkbox"></td>
<td class="ListColLeft">{if !$host_name || $host_name != $d.host_name}{$d.host_name}{/if}</td>
<td class="ListColLeft">{$d.service_description}</td>
<td class="ListColCenter">{$d.metrics_name}</td>
<td class="ListColCenter">{$d.must_be_rebuild}</td>
<td class="ListColCenter">{$d.to_delete}</td>
<td class="ListColCenter">{$d.hidden}</td>
<td class="ListColCenter">{$d.locked}</td>
</tr>
{assign var='host_name' value=$d.host_name}
{/foreach}
</table>
<table class="ToolbarTable table">
<tr class="ToolbarTR">
<td>
{$msg.options} {$form.o2.html}
&nbsp;&nbsp;&nbsp;
</td>
<input name="p" value="{$p}" type="hidden">
{php}
include('./include/common/pagination.php');
{/php}
</tr>
</tbody>
</table>
<table class="ToolbarTable table">
<tr class="ToolbarTR">
<td>
{$msg.options} {$form.o1.html}
&nbsp;&nbsp;&nbsp;
<!-- <a href="{$msg.addL}" class="btc bt_success">{$msg.addT}</a> -->
</td>
<input name="p" value="{$p}" type="hidden">
{php}
include('./include/common/pagination.php');
{/php}
</tr>
</table>
<table class="ListTable">
<tr class="ListHeader">
<td class="ListColHeaderPicker"><input type="checkbox" name="checkall" onclick="checkUncheckAll(this);"/></td>
<td class="ListColLeft">{$Host}</td>
<td class="ListColCenter">{$Service}</td>
<td class="ListColCenter">{$Metrics}</td>
<td class="ListColCenter">{$RebuildWaiting}</td>
<td class="ListColCenter">{$Delete}</td>
<td class="ListColCenter">{$Hidden}</td>
<td class="ListColCenter">{$Locked}</td>
</tr>
{assign var='host_name' value=''}
{foreach item=d from=$data}
<tr class="{$d.class}">
<td class="ListColCenter"><input name="select[{$d.id}]" value="1" type="checkbox"></td>
<td class="ListColLeft">{if !$host_name || $host_name != $d.host_name}{$d.host_name}{/if}</td>
<td class="ListColLeft">{$d.service_description}</td>
<td class="ListColCenter">{$d.metrics_name}</td>
<td class="ListColCenter">{$d.must_be_rebuild}</td>
<td class="ListColCenter">{$d.to_delete}</td>
<td class="ListColCenter">{$d.hidden}</td>
<td class="ListColCenter">{$d.locked}</td>
</tr>
{assign var='host_name' value=$d.host_name}
{/foreach}
</table>
<table class="ToolbarTable table">
<tr class="ToolbarTR">
<td>
{$msg.options} {$form.o2.html}
&nbsp;&nbsp;&nbsp;
<!-- <a href="{$msg.addL}" class="btc bt_success">{$msg.addT}</a> -->
</td>
<input name="p" value="{$p}" type="hidden">
{php}
include('./include/common/pagination.php');
{/php}
</tr>
</table>
<input type='hidden' id='limit' name='limit' value='{$limit}'>
{$form.hidden}
</table>
<input type='hidden' id='limit' name='limit' value='{$limit}'>
{$form.hidden}
</form>
7 changes: 7 additions & 0 deletions www/include/Administration/performance/viewData.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@

$form = new HTML_QuickFormCustom('form', 'POST', "?p=" . $p);

$attrBtnSuccess = array(
"class" => "btc bt_success",
"onClick" => "window.history.replaceState('', '', '?p=" . $p . "');"
);
$form->addElement('submit', 'Search', _("Search"), $attrBtnSuccess);


?>
<script type="text/javascript">
function setO(_i) {
Expand Down
13 changes: 8 additions & 5 deletions www/include/common/autoNumLimit.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,22 @@
} else {
if (($p >= 200 && $p < 300) || ($p >= 20000 && $p < 30000)) {
$dbResult = $pearDB->query("SELECT * FROM `options` WHERE `key` = 'maxViewMonitoring'");
$gopt = $dbResult->fetch();
$limit = myDecode($gopt['value']);
} else {
$dbResult = $pearDB->query("SELECT * FROM `options` WHERE `key` = 'maxViewConfiguration'");
$gopt = $dbResult->fetch();
$limit = myDecode($gopt['value']);
}
$gopt = $dbResult->fetch();
if ((int)$gopt['value']) {
$limit = (int)$gopt['value'];
} else {
$limit = 30;
}
}

$_SESSION[$sessionLimitKey] = $limit;

// Setting the pagination filter
if (isset($_POST['num']) && isset($_POST['search'])
if (isset($_POST['num'])
&& isset($_POST['search'])
|| (isset($centreon->historyLastUrl) && $centreon->historyLastUrl !== $url)
) {
// Checking if the current page and the last displayed page are the same and resetting the filters
Expand Down
39 changes: 19 additions & 20 deletions www/include/common/pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
global $num, $limit, $search, $url, $pearDB, $search_type_service, $search_type_host,
$host_name, $hostgroup, $rows, $p, $gopt, $pagination, $poller, $template, $search_output, $search_service;

$type = $_REQUEST["type"] ?? null;
$type = filter_var(
$_POST['type'] ?? $_GET['type'] ?? null,
FILTER_VALIDATE_INT
);
$type = $type ? '&type=' . $type : '';
$o = $_GET["o"] ?? null;

//saving current pagination filter value and current displayed page
Expand Down Expand Up @@ -175,8 +179,7 @@

if ($rows != 0) {
for ($i = $iStart; $i <= $iEnd; $i++) {
$urlPage = "main.php?p=" . $p . "&num=" . $i . "&limit=" . $limit . "&poller=" . $poller .
"&template=" . $template . "&search=" . $search . "&type=" . $type . "&o=" . $o . $url_var;
$urlPage = "main.php?p=" . $p . "&num=" . $i . $type;
$pageArr[$i] = array(
"url_page" => $urlPage,
"label_page" => "<b>" . ($i + 1) . "</b>",
Expand All @@ -197,16 +200,14 @@
if (($prev = $num - 1) >= 0) {
$tpl->assign(
'pagePrev',
("main.php?p=" . $p . "&num=" . $prev . "&limit=" . $limit . "&poller=" . $poller .
"&template=" . $template . "&search=" . $search . "&type=" . $type . "&o=" . $o . $url_var)
("main.php?p=" . $p . "&num=" . $prev . "&limit=" . $limit . $type)
);
}

if (($next = $num + 1) < ($rows / $limit)) {
$tpl->assign(
'pageNext',
("main.php?p=" . $p . "&num=" . $next . "&limit=" . $limit . "&poller=" . $poller .
"&template=" . $template . "&search=" . $search . "&type=" . $type . "&o=" . $o . $url_var)
("main.php?p=" . $p . "&num=" . $next . "&limit=" . $limit . $type)
);
}

Expand All @@ -220,16 +221,13 @@
if ($page_max > 5 && $num != 0) {
$tpl->assign(
'firstPage',
("main.php?p=" . $p . "&num=0&limit=" . $limit . "&poller=" . $poller .
"&template=" . $template . "&search=" . $search . "&type=" . $type . "&o=" . $o . $url_var)
("main.php?p=" . $p . "&num=0&limit=" . $limit . $type)
);
}
if ($page_max > 5 && $num != ($pageNumber - 1)) {
$tpl->assign(
'lastPage',
("main.php?p=" . $p . "&num=" . ($pageNumber - 1) . "&limit=" . $limit .
"&template=" . $template . "&poller=" . $poller . "&search=" . $search .
"&type=" . $type . "&o=" . $o . $url_var)
("main.php?p=" . $p . "&num=" . ($pageNumber - 1) . "&limit=" . $limit . $type)
);
}

Expand All @@ -251,14 +249,15 @@
}

?>
<script type="text/javascript">
function setL(_this) {
var _l = document.getElementsByName('l');
document.forms['form'].elements['limit'].value = _this;
_l[0].value = _this;
_l[1].value = _this;
}
</script>
<script type="text/javascript">
function setL(_this) {
var _l = document.getElementsByName('l');
document.forms['form'].elements['limit'].value = _this;
_l[0].value = _this;
_l[1].value = _this;
window.history.replaceState('', '', '?p=<?= $p.$type ?>');
}
</script>
<?php
$form = new HTML_QuickFormCustom(
'select_form',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</tr>
<tr>
<td><input type="text" name="searchC" value="{$searchC}"></td>
<td><input type="submit" value="{t}Search{/t}" class="btc bt_success"></td>
<td>{$form.Search.html}</td>
</tr>
</tbody>
</table>
Expand Down
13 changes: 8 additions & 5 deletions www/include/configuration/configObject/command/listCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
FILTER_SANITIZE_STRING
);

$num = filter_var(
$_POST['num'] ?? $_GET['num'] ?? $centreon->historyPage[$url] ?? 0,
FILTER_VALIDATE_INT
);

$type = filter_var(
$_POST['type'] ?? $_GET['type'] ?? null,
FILTER_VALIDATE_INT
Expand Down Expand Up @@ -81,6 +76,7 @@
$search = $centreon->historySearch[$url]['search' . $type] ?? null;
}


$type_str = $type ? " AND `command_type` = " . $type : "";
$search = tidySearchKey($search, $advanced_search);

Expand Down Expand Up @@ -126,6 +122,13 @@
// Different style between each lines
$style = "one";

$addrType = $type ? "&type=" . $type : "";
$attrBtnSuccess = array(
"class" => "btc bt_success",
"onClick" => "window.history.replaceState('', '', '?p=" . $p . $addrType. "');"
);
$form->addElement('submit', 'Search', _("Search"), $attrBtnSuccess);

// Define command Type table
$commandType = array(
"1" => _("Notification"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<td><h4>{t}Contact{/t}</h4></td>
</tr>
<tr>
<td><input type="text" name="searchC" value="{$searchC}"></td>
<td><input type="submit" value="{t}Search{/t}" class="btc bt_success"></td>
<td><input type="text" name="searchC" value="{$searchC}"></td>
<td>{$form.Search.html}</td>
</tr>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@

// Different style between each lines
$style = "one";

$attrBtnSuccess = array(
"class" => "btc bt_success",
"onClick" => "window.history.replaceState('', '', '?p=" . $p . "');"
);
$form->addElement('submit', 'Search', _("Search"), $attrBtnSuccess);

$contactTypeIcone = array(
1 => "./img/icons/admin.png",
2 => "./img/icons/user.png",
Expand Down
Loading

0 comments on commit 9a10e97

Please sign in to comment.