From 4bffacc942a071ace5e7e6f2e04eaba9590b6a02 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 26 Oct 2015 10:43:18 +0100 Subject: [PATCH] [WebProfilerBundle] Filter links in search results --- .../Controller/ProfilerController.php | 17 ++++++---- .../Resources/views/Profiler/layout.html.twig | 2 +- .../views/Profiler/profiler.css.twig | 34 +++++++++++++++++++ .../views/Profiler/results.html.twig | 27 +++++++++++++-- 4 files changed, 69 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index 0adda7848c..51a52099b7 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -207,6 +207,7 @@ class ProfilerController } return new Response($this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array( + 'request' => $request, 'position' => $position, 'profile' => $profile, 'templates' => $this->getTemplateManager()->getTemplates($profile), @@ -242,13 +243,13 @@ class ProfilerController $limit = $token = null; } else { - $ip = $session->get('_profiler_search_ip'); - $method = $session->get('_profiler_search_method'); - $url = $session->get('_profiler_search_url'); - $start = $session->get('_profiler_search_start'); - $end = $session->get('_profiler_search_end'); - $limit = $session->get('_profiler_search_limit'); - $token = $session->get('_profiler_search_token'); + $ip = $request->query->get('ip', $session->get('_profiler_search_ip')); + $method = $request->query->get('method', $session->get('_profiler_search_method')); + $url = $request->query->get('url', $session->get('_profiler_search_url')); + $start = $request->query->get('start', $session->get('_profiler_search_start')); + $end = $request->query->get('end', $session->get('_profiler_search_end')); + $limit = $request->query->get('limit', $session->get('_profiler_search_limit')); + $token = $request->query->get('token', $session->get('_profiler_search_token')); } return new Response( @@ -295,6 +296,7 @@ class ProfilerController $limit = $request->query->get('limit'); return new Response($this->twig->render('@WebProfiler/Profiler/results.html.twig', array( + 'request' => $request, 'token' => $token, 'profile' => $profile, 'tokens' => $this->profiler->find($ip, $url, $limit, $method, $start, $end), @@ -351,6 +353,7 @@ class ProfilerController $tokens = $this->profiler->find($ip, $url, $limit, $method, $start, $end); return new RedirectResponse($this->generator->generate('_profiler_search_results', array( + 'request' => $request, 'token' => $tokens ? $tokens[0]['token'] : 'empty', 'ip' => $ip, 'method' => $method, diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig index 17aa347439..e2bc8f8013 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig @@ -64,7 +64,7 @@ {{ include('@WebProfiler/Icon/search.svg') }} Search - {{ render(path('_profiler_search_bar')) }} + {{ render(path('_profiler_search_bar', request.query.all)) }} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig index f8cc023642..2f057958ca 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig @@ -365,6 +365,32 @@ tr.status-warning td { .highlight .number { color: #F5871F; font-weight: bold; } .highlight .error { color: #C82829; } +{# Icons + ========================================================================= #} +.sf-icon { + vertical-align: middle; + background-repeat: no-repeat; + background-size: contain; + width: 16px; + height: 16px; + display: inline-block; +} +.sf-icon svg { + width: 16px; + height: 16px; +} +.sf-icon.sf-medium, +.sf-icon.sf-medium svg { + width: 24px; + height: 24px; +} +.sf-icon.sf-large, +.sf-icon.sf-large svg { + width: 32px; + height: 32px; +} + + {# Layout ========================================================================= #} .container { @@ -849,6 +875,14 @@ table.logs .metadata strong { vertical-align: middle; } +#search-results .sf-search { + visibility: hidden; + margin-left: 2px; +} +#search-results tr:hover .sf-search { + visibility: visible; +} + {# Small screens ========================================================================= #} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/results.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/results.html.twig index 1c84715792..cd9fd06cc6 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/results.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/results.html.twig @@ -31,9 +31,30 @@ {{ result.status_code|default('n/a') }} - {{ result.ip }} - {{ result.method }} - {{ result.url }} + + {{ result.ip }} + {% if request.session is not null %} + + {{ include('@WebProfiler/Icon/search.svg') }} + + {% endif %} + + + {{ result.method }} + {% if request.session is not null %} + + {{ include('@WebProfiler/Icon/search.svg') }} + + {% endif %} + + + {{ result.url }} + {% if request.session is not null %} + + {{ include('@WebProfiler/Icon/search.svg') }} + + {% endif %} + {{ result.time|date('d-M-Y') }} {{ result.time|date('H:i:s') }}