Skip to content

Commit

Permalink
fix: BUG 131913 submit form when changing filter date and populate in…
Browse files Browse the repository at this point in the history
…put value
  • Loading branch information
githost committed Jul 3, 2023
1 parent 26607a8 commit 72da6ae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
9 changes: 8 additions & 1 deletion www/assets/js/history-loggedin.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@

function handleDaySelector() {
const daySelector = document.querySelector("select[name=days]");
const filter = document.getElementById('filter');

daySelector.addEventListener("change", (e) => {
const days = e.target.value;
const protocol = window.location.protocol;
const hostname = window.location.hostname;
const redirectUri = protocol + "//" + hostname + "/testlog/" + days + "/";

if (filter.value) {
document.querySelector('form[name=filterLog]').submit();
return;
}

const redirectUri = protocol + "//" + hostname + "/testlog/" + days + "/";
window.location = redirectUri;
});
}
Expand Down
2 changes: 1 addition & 1 deletion www/resources/views/pages/testhistory.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<div class="history_filter">
<label for="filter">Filter test history:</label>
<input id="filter" name="filter" type="text" onkeyup="filterHistory()" placeholder="Search">
<input id="filter" name="filter" type="text" onkeyup="filterHistory()" placeholder="Search" value="{{ $filter ?? '' }}">
@if ($is_logged_in)
<label for="days" class="a11y-hidden">Select how far back you want to see</label>
<select name="days" id="days">
Expand Down
7 changes: 4 additions & 3 deletions www/testlog.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
$csv = isset($_GET['f']) && !strcasecmp($_GET['f'], 'csv');
$priority = (isset($_REQUEST['priority']) && is_numeric($_REQUEST['priority'])) ? intval($_REQUEST['priority']) : null;
$days = (int)($_GET['days'] ?? 7);
$filter = $_GET["filter"];
$filterstr = $filter ? preg_replace('/[^a-zA-Z0-9 \@\/\:\.\(\))\-\+]/', '', strtolower($filter)) : null;


$GLOBALS['tab'] = 'Test History';
$GLOBALS['page_description'] = 'History of website performance speed tests run on WebPageTest.';
Expand All @@ -52,7 +55,7 @@
'local' => isset($_REQUEST['local']) && $_REQUEST['local'],
'body_class' => 'history',
'page_title' => 'WebPageTest - Test History',

'filter' => $filterstr
];

echo view('pages.testhistory', $vars);
Expand All @@ -70,8 +73,6 @@
}

$from = (isset($_GET["from"]) && strlen($_GET["from"])) ? $_GET["from"] : 'now';
$filter = $_GET["filter"];
$filterstr = $filter ? preg_replace('/[^a-zA-Z0-9 \@\/\:\.\(\))\-\+]/', '', strtolower($filter)) : null;
$onlyVideo = !empty($_REQUEST['video']);
$all = ($admin || !Util::getSetting('forcePrivate')) && !empty($_REQUEST['all']);
$repeat = !empty($_REQUEST['repeat']);
Expand Down

0 comments on commit 72da6ae

Please sign in to comment.