Jump to content

Tracy Debugger


adrian

Recommended Posts

Just now, PWaddict said:

There are more than 1 bars??? How can I view the AJAX one?

The AJAX bar displays automatically when there has been an AJAX request - you can see this behavior when viewing the Page Tree in the PW admin, or triggering sub items from any of the admin menus, or any AJAX calls you make on the frontend.

You should also see "Redirect" bars when there has been a redirect call.

Do you not see any of these?

Link to comment
Share on other sites

2 minutes ago, adrian said:

The AJAX bar displays automatically when there has been an AJAX request - you can see this behavior when viewing the Page Tree in the PW admin, or triggering sub items from any of the admin menus, or any AJAX calls you make on the frontend.

You should also see "Redirect" bars when there has been a redirect call.

Do you not see any of these?

Ah yes only on backend I can see the AJAX one. On frontend I can't see it even though the entire site is based on AJAX.

Link to comment
Share on other sites

40 minutes ago, PWaddict said:

Ah yes only on backend I can see the AJAX one. On frontend I can't see it even though the entire site is based on AJAX.

Are you using a JS framework?

You need to make sure the X-Requested-With header is sent so that PHP (and therefore Tracy) can recognize it as an AJAX call. jQuery does this by default, but other frameworks may not, eg Angular.

In pure/vanilla JS, you can do:

xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");

In Angular you can do:

$http.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";

 

  • Like 3
Link to comment
Share on other sites

25 minutes ago, adrian said:

Are you using a JS framework?

You need to make sure the X-Requested-With header is sent so that PHP (and therefore Tracy) can recognize it as an AJAX call. jQuery does this by default, but other frameworks may not, eg Angular.

In pure/vanilla JS, you can do:


xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");

 In Angular you can do:


$http.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";

 

I'm using JQuery and on frontend I can see the header X-Requested-With: XMLHttpRequest but there is no AJAX bar.
On backend there is no X-Requested-With: XMLHttpRequest header but I can see the AJAX bar.

Link to comment
Share on other sites

18 minutes ago, PWaddict said:

I'm using JQuery and on frontend I can see the header X-Requested-With: XMLHttpRequest but there is no AJAX bar.
On backend there is no X-Requested-With: XMLHttpRequest header but I can see the AJAX bar.

Can you try this simple example in your template file:

<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
$( document ).ready(function() {
    $("#ajaxButton").click(function(e) {
        e.preventDefault();
        $.ajax({
            type: "POST",
            url: "/data/testajax.php?test=1",
            data: {
                id: $(this).val()
            },
            success: function(result) {
                console.log('ok');
            },
            error: function(result) {
                console.log('error');
            }
        });
    });
});
</script>

<input id="ajaxButton" type="submit" name="testAjax" value="Test Ajax" />

 

This is how it looks for me:

IZFZ2iCBzE.gif.29cefa65a889fb6284f07b61be5913f0.gif

  • Like 1
Link to comment
Share on other sites

9 minutes ago, adrian said:

Can you try this simple example in your template file:


<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
$( document ).ready(function() {
    $("#ajaxButton").click(function(e) {
        e.preventDefault();
        $.ajax({
            type: "POST",
            url: "/data/testajax.php?test=1",
            data: {
                id: $(this).val()
            },
            success: function(result) {
                console.log('ok');
            },
            error: function(result) {
                console.log('error');
            }
        });
    });
});
</script>

<input id="ajaxButton" type="submit" name="testAjax" value="Test Ajax" />

 

This is how it looks for me:

pubFcA6Bfn.thumb.gif.ba502b31274654b31b72b8ec71e1f610.gif

I still can't see the AJAX bar. Maybe the problem is caused by localhost?

Link to comment
Share on other sites

11 minutes ago, PWaddict said:

I still can't see the AJAX bar. Maybe the problem is caused by localhost?

I am testing this on localhost.

Actually, I think the issue is probably the contents of the php file (in my example /data/testajax.php) that is being called via ajax. I forgot to provide that to you. It needs to bootstrap PW so that Tracy is also loaded, eg:

<?php

include '../index.php';

Hopefully if you do that, it should work as expected.

Link to comment
Share on other sites

2 minutes ago, jmartsch said:

Hey @adrian, is there an API to turn Mail Interceptor on, before I send emails from one of my modules?

I would like to catch emails if I am on my local dev server and forgot to enable the Mail Interceptor in the Tracy Debug bar.

It can be handled by the new stuff I set up recently. Have a read here: 

It allows you to set Tracy settings in config.php or config-dev.php (so it's local only).

I think this is probably the best solution. Let me know how you find it and if you have any suggestions for improvements.

PS - there is some further discussion about the instigation of this feature starting around here: https://processwire.com/talk/topic/5693-new-module-type-wiremail/?do=findComment&amp;comment=172371

  • Like 3
Link to comment
Share on other sites

42 minutes ago, adrian said:

Can you try this simple example in your template file:


<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
$( document ).ready(function() {
    $("#ajaxButton").click(function(e) {
        e.preventDefault();
        $.ajax({
            type: "POST",
            url: "/data/testajax.php?test=1",
            data: {
                id: $(this).val()
            },
            success: function(result) {
                console.log('ok');
            },
            error: function(result) {
                console.log('error');
            }
        });
    });
});
</script>

<input id="ajaxButton" type="submit" name="testAjax" value="Test Ajax" />

 

This is how it looks for me:

IZFZ2iCBzE.gif.29cefa65a889fb6284f07b61be5913f0.gif

This actually works. I forgot earlier to modify the url.

So it seems the problem is caused from the way I ajaxified the site. Anyway, thanks for the help.

Link to comment
Share on other sites

4 minutes ago, PWaddict said:

This actually works. I forgot earlier to modify the url.

So it seems the problem is caused from the way I ajaxified the site. Anyway, thanks for the help.

It should be pretty simple to figure out - if you're using jquery, then the only reason I think it wouldn't work is if you're not bootstrapping PW in the called php file. Anyway, good luck getting it sorted out.

Link to comment
Share on other sites

Hey @adrian

what do you think of adding a fullscreen button to the dump div right beside the collapse toggles? When having large dumps this could greatly improve readability and it would just need to apply a simple class with these css rules:

element.style {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 99999;
    width: 100%;
    height: 100%;
    background-color: #fff;
    overflow: scroll;
}

Then it could turn this:

rAyxgw5.png

Into that:

uqxsU3x.png

The collapse toggles still work. Of course we'd also need a "close fullscreen" button (or maybe ESC keyboard shortcut?)

  • Like 1
Link to comment
Share on other sites

Hey @bernhard - I like this, but I am thinking of maybe applying it to the entire results windows, rather than a specific dump result, so it would look like this. This way you would still have fullscreen, but it makes it easier to inspect the different dumps without needing to exit fullscreen and then initiate it on another dump.

Does this seem ok to you?

image.thumb.png.6c5e0c29f9c3848322a82775d0a3566f.png

  • Like 1
Link to comment
Share on other sites

35 minutes ago, adrian said:

Does this seem ok to you?

Sure! ? Maybe - if it is easy - it would also make sense to have a fullscreen for the console code input. But that's only some ideas. Everything works great for me as it is. Just suggestions for improvements.

  • Like 2
Link to comment
Share on other sites

New version committed that adds a Maximize button to the Console panel as a whole which results in a fullscreen editing and review experience. Thanks to @tpr for his usual tweaks to my styling :)

I also added the regular fullscreen/halfscreen buttons to the Dumps and Dumps Recorder panels. These buttons are on several panels where the content can be quite large - they should have been on these panels all the time really.

Let me know if you have any issues with any of this - hopefully it should make things easier to work with.

  • Like 4
Link to comment
Share on other sites

  • adrian pinned and locked this topic
  • adrian unpinned and pinned this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...