merged branch vicb/profiler/pages (PR #3281)
Commits -------0d4d7e0
[WebProfilerBundle] Make the toolbar use the common JSa440279
[WebProfilerBundle] Adds panel pages762d90d
[Profiler] Buid a common infrastructure Discussion ---------- [Profiler] Provide a common infrastructure former #3206 part 3 * base JS (provides ajax, toggle, css class helpers), * panel pages (used only by the Doctrine panel for now). Successfuly tested with the (future version of the) Doctrine panel.
This commit is contained in:
commit
2a16171645
@ -36,6 +36,7 @@ class ProfilerController extends ContainerAware
|
|||||||
$profiler->disable();
|
$profiler->disable();
|
||||||
|
|
||||||
$panel = $this->container->get('request')->query->get('panel', 'request');
|
$panel = $this->container->get('request')->query->get('panel', 'request');
|
||||||
|
$page = $this->container->get('request')->query->get('page', 'home');
|
||||||
|
|
||||||
if (!$profile = $profiler->loadProfile($token)) {
|
if (!$profile = $profiler->loadProfile($token)) {
|
||||||
return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:info.html.twig', array('about' => 'no_token', 'token' => $token));
|
return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:info.html.twig', array('about' => 'no_token', 'token' => $token));
|
||||||
@ -50,6 +51,7 @@ class ProfilerController extends ContainerAware
|
|||||||
'profile' => $profile,
|
'profile' => $profile,
|
||||||
'collector' => $profile->getCollector($panel),
|
'collector' => $profile->getCollector($panel),
|
||||||
'panel' => $panel,
|
'panel' => $panel,
|
||||||
|
'page' => $page,
|
||||||
'templates' => $this->getTemplates($profiler),
|
'templates' => $this->getTemplates($profiler),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -450,3 +450,9 @@ td.main, td.menu {
|
|||||||
#collector_content .routing tr.almost td {
|
#collector_content .routing tr.almost td {
|
||||||
background-color: #fa0;
|
background-color: #fa0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.loading {
|
||||||
|
background: transparent url(../images/profiler/spinner.gif) scroll no-repeat 50% 50%;
|
||||||
|
height: 30px;
|
||||||
|
display: none;
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
@ -0,0 +1 @@
|
|||||||
|
{% block panel '' %}
|
@ -0,0 +1,72 @@
|
|||||||
|
<script type="text/javascript">/*<![CDATA[*/
|
||||||
|
Sfjs = (function() {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var noop = function() {},
|
||||||
|
request = function(url, onSuccess, onError, payload, options) {
|
||||||
|
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
|
||||||
|
options = options || {};
|
||||||
|
xhr.open(options.method || 'GET', url, true);
|
||||||
|
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||||
|
xhr.onreadystatechange = function(state) {
|
||||||
|
if (4 === xhr.readyState && 200 === xhr.status) {
|
||||||
|
(onSuccess || noop)(xhr);
|
||||||
|
} else if (4 === xhr.readyState && xhr.status != 200) {
|
||||||
|
(onError || noop)(xhr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.send(payload || '');
|
||||||
|
},
|
||||||
|
hasClass = function(el, klass) {
|
||||||
|
return el.className.match(new RegExp('\\b' + klass + '\\b'));
|
||||||
|
},
|
||||||
|
removeClass = function(el, klass) {
|
||||||
|
el.className = el.className.replace(new RegExp('\\b' + klass + '\\b'), ' ');
|
||||||
|
},
|
||||||
|
addClass = function(el, klass) {
|
||||||
|
if (!hasClass(el, klass)) { el.className += " " + klass; }
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
hasClass: hasClass,
|
||||||
|
removeClass: removeClass,
|
||||||
|
addClass: addClass,
|
||||||
|
request: request,
|
||||||
|
load: function(selector, url, onSuccess, onError, options) {
|
||||||
|
var el = document.querySelector(selector);
|
||||||
|
if (el && el.getAttribute('data-sfurl') !== url) {
|
||||||
|
request(
|
||||||
|
url,
|
||||||
|
function(xhr) {
|
||||||
|
el.innerHTML = xhr.responseText;
|
||||||
|
el.setAttribute('data-sfurl', url);
|
||||||
|
removeClass(el, 'loading');
|
||||||
|
(onSuccess || noop)(xhr, el);
|
||||||
|
},
|
||||||
|
function(xhr) { (onError || noop)(xhr, el); },
|
||||||
|
options
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
toggle: function(selector, elOn, elOff) {
|
||||||
|
var i,
|
||||||
|
style,
|
||||||
|
tmp = elOn.style.display,
|
||||||
|
els = document.querySelectorAll(selector);
|
||||||
|
|
||||||
|
elOn.style.display = elOff.style.display;
|
||||||
|
elOff.style.display = tmp;
|
||||||
|
|
||||||
|
if (els.length) {
|
||||||
|
style = 'none' === tmp ? 'none' : 'block';
|
||||||
|
for (i = els.length - 1; i >= 0; --i) {
|
||||||
|
els[i].style.display = style;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
/*]]>*/</script>
|
@ -27,6 +27,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div id="collector_content">
|
<div id="collector_content">
|
||||||
|
{% include 'WebProfilerBundle:Profiler:base_js.html.twig' %}
|
||||||
{% block panel '' %}
|
{% block panel '' %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,23 +1,16 @@
|
|||||||
<div id="sfwdt{{ token }}" class="sf-toolbar" style="display: none"></div>
|
<div id="sfwdt{{ token }}" class="sf-toolbar" style="display: none"></div>
|
||||||
|
{% include 'WebProfilerBundle:Profiler:base_js.html.twig' %}
|
||||||
<script type="text/javascript">/*<![CDATA[*/
|
<script type="text/javascript">/*<![CDATA[*/
|
||||||
(function () {
|
(function () {
|
||||||
var wdt, xhr;
|
Sfjs.load(
|
||||||
wdt = document.getElementById('sfwdt{{ token }}');
|
'#sfwdt{{ token }}',
|
||||||
if (window.XMLHttpRequest) {
|
'{{ path("_wdt", { "token": token }) }}',
|
||||||
xhr = new XMLHttpRequest();
|
function(xhr, el) {
|
||||||
} else {
|
el.style.display = -1 !== xhr.responseText.indexOf('sf-toolbarreset') ? 'block' : 'none';
|
||||||
xhr = new ActiveXObject('Microsoft.XMLHTTP');
|
},
|
||||||
}
|
function(xhr) {
|
||||||
xhr.open('GET', '{{ path("_wdt", { "token": token }) }}', true);
|
confirm('An error occurred while loading the web debug toolbar (' + xhr.status + ': ' + xhr.statusText + ').\n\nDo you want to open the profiler?') && (window.location = '{{ path("_profiler", { "token": token }) }}')
|
||||||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
|
||||||
xhr.onreadystatechange = function(state) {
|
|
||||||
if (4 === xhr.readyState && 200 === xhr.status && -1 !== xhr.responseText.indexOf('sf-toolbarreset')) {
|
|
||||||
wdt.innerHTML = xhr.responseText;
|
|
||||||
wdt.style.display = 'block';
|
|
||||||
} else if (4 === xhr.readyState && xhr.status != 200) {
|
|
||||||
confirm('An error occurred while loading the web debug toolbar (' + xhr.status + ': ' + xhr.statusText + ').\n\nDo you want to open the profiler?') && (window.location = '{{ path("_profiler", { "token": token }) }}');
|
|
||||||
}
|
}
|
||||||
};
|
);
|
||||||
xhr.send('');
|
|
||||||
})();
|
})();
|
||||||
/*]]>*/</script>
|
/*]]>*/</script>
|
||||||
|
Reference in New Issue
Block a user