adrian

Tracy Debugger

Recommended Posts

1 minute ago, PWaddict said:

@adrian Is it possible to view the values submitted on an ajax form and how?

Sure - just check out the RequestInfo panel on the AJAX bar and open up the Input POST section.

Does that get you what you want?

Share this post


Link to post
Share on other sites
3 minutes ago, adrian said:

Sure - just check out the RequestInfo panel on the AJAX bar and open up the Input POST section.

Does that get you what you want?

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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
3 minutes ago, gmclelland said:

Probably a silly question, but do you have Tracy enabled on the frontend? 

tracy-debug.jpg.5134601a5417fdc1d78cd9bfe13f8f9c.jpg

I haven't changed anything on module settings and yes it's enabled since I already can see the normal bar.

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thanks, that is excactly what I need. Great ideas from Ivan. I had the same, but he was quicker 🙂

  • Like 2

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

wTnIdPt.png

Thx Adrian!

@adrian and @tpr any ideas what could be done about that AOS lang-switcher appearing on top of the panel? z-index doesn't seem to help strangely.

Share this post


Link to post
Share on other sites

Perhaps you can set a higher z-index in Tracy module's settings page, but I'll take a look when I have time.

Share this post


Link to post
Share on other sites

Thx, the strange thing is that I've already tried a z-index of 999999999999999999999999999999999 on the panel and the language switcher still appears on top?!

Share this post


Link to post
Share on other sites

z-index is tricky, if a parent element has lower index then you can't make a child element positioned above it. I hope I can modify AOS to overcome this.

  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Sebi
      I've created a small module which lets you define a timestamp after which a page should be accessible. In addition you can define a timestamp when the release should end and the page should not be accessable any more.
      Github: https://github.com/Sebiworld/PageAccessReleasetime
      Usage
      PageAccessReleasetime can be installed like every other module in ProcessWire. Check the following guide for detailed information: How-To Install or Uninstall Modules
      After that, you will find checkboxes for activating the releasetime-fields at the settings-tab of each page. You don't need to add the fields to your templates manually.
      Check e.g. the checkbox "Activate Releasetime from?" and fill in a date in the future. The page will not be accessable for your users until the given date is reached.
      If you have $config->pagefileSecure = true, the module will protect files of unreleased pages as well.
      How it works
      This module hooks into Page::viewable to prevent users to access unreleased pages:
      public function hookPageViewable($event) { $page = $event->object; $viewable = $event->return; if($viewable){ // If the page would be viewable, additionally check Releasetime and User-Permission $viewable = $this->canUserSee($page); } $event->return = $viewable; } To prevent access to the files of unreleased pages, we hook into Page::isPublic and ProcessPageView::sendFile.
      public function hookPageIsPublic($e) { $page = $e->object; if($e->return && $this->isReleaseTimeSet($page)) { $e->return = false; } } The site/assets/files/ directory of pages, which isPublic() returns false, will get a '-' as prefix. This indicates ProcessWire (with activated $config->pagefileSecure) to check the file's permissions via PHP before delivering it to the client.
      The check wether a not-public file should be accessable happens in ProcessPageView::sendFile. We throw an 404 Exception if the current user must not see the file.
      public function hookProcessPageViewSendFile($e) { $page = $e->arguments[0]; if(!$this->canUserSee($page)) { throw new Wire404Exception('File not found'); } } Additionally we hook into ProcessPageEdit::buildForm to add the PageAccessReleasetime fields to each page and move them to the settings tab.
      Limitations
      In the current version, releasetime-protected pages will appear in wire('pages')->find() queries. If you want to display a list of pages, where pages could be releasetime-protected, you should double-check with $page->viewable() wether the page can be accessed. $page->viewable() returns false, if the page is not released yet.
      If you have an idea how unreleased pages can be filtered out of ProcessWire selector queries, feel free to write an issue, comment or make a pull request!
    • By David Karich
      Thanks to the great Pro module "RepeaterMatrix" I have the possibility to create complex repeater items. With it I have created a quite powerful page builder. Many different content modules, with many more possible design options. The RepeaterMatrix module supports the cloning of items, but only within the same page. Now I often have the case that very design-intensive pages and items are created. If you want to use this module on a different page (e.g. in the same design), you have to rebuild each item manually every time.
      With this proof of concept I have created a module which adds the feature to copy a repeater item to the clipboard so that you can paste this item to another page with the same repeater field. The module has been developed very rudimentarily so far. It is currently not possible to copy nested items. There is also no check of Min/Max. You can also only copy items that have the same field on different pages. And surely you can solve all this more elegantly with AJAX. But personally I lack the deeper understanding of the repeaters. Also missing on the Javascript side are event triggers for the repeaters, which would make it easier. Like e.g. RepeaterItemInitReady or similar.
      it would be great if @ryan would implement this functionality in the core of RepeaterMatrix. I think he has better ways to implement this. Or what do you think, Ryan?
      Everybody is welcome to work on this module and improve it, if it should not be integrated into the matrix core. Therefore I put it for testing and as download on GitHub: https://github.com/FlipZoomMedia/InputfieldRepeaterMatrixDublicate
      You can best see the functionality in the screencast: 
       
    • By anderson
      Hi,
      Please take a look at this:
      https://templatemag.com/demo/Good/
      The upper nav bar, including dropdowns like "pages" and "portfolios", what do you call this whole thing? At first I guess it's called "dropdown nav bar", but seems not.
      AND of course, what's the simplest way/module to achieve this in PW?
      Thanks in advance.
    • By Sebi2020
      Hey, I'm new and I created a simple module for tagging pages because I didn't found a module for it (sadly this is not a core feature). This module is licensed under the GPL3 and cames with absolutly no warranty at all. You should test the module before using it in production environments. Currently it's an alpha release. if you like the module or have ideas for improvements feel free to post a comment. Currently this fieldtype is only compatible with the Inputfield I've created to because I haven't found  an Inputfield yet, that returns arrays from a single html input.
      Greetings Sebi2020
      FieldtypeTags.zip.asc
      InputfieldTagify.zip
      InputfieldTagify.zip.asc
      FieldtypeTags.zip
    • By psy
      Background
      I'm creating a module to integrate https://pushalert.co/ into ProcessWire. You actually don't even need a module. You could just use the "Other Websites" javascript provided by PushAlert for basic functionality, ie send a broadcast notification to all subscribers. This is essentially what all the other integrations, including WordPress, do. The WP integration installs a widget with a form enabling the admin to enter details such as title, message, etc from a blog post. It does not:
      collect any statistics within the CMS about the notification enable audience fine tuning to eg a particular subscriber or subscriber segment within WP. The admin needs to use the PA dashboard for that functionality PushAlert has a javascript and REST API. It's intended that this module will use both. https://pushalert.co/documentation 
      What my module does so far:
      associate a subscription with a user. FE user clicks a button on the website front end to subscribe and/or agrees to the browser popup to accept notifications from this site send broadcast push alerts from a page within admin It doesn't have a 'widget' but easy enough to create a fieldsetpage with the relevant fields and add that fs page to any appropriate templates, then with a hook, send the notification. Need to be careful that once published/sent, the notification is not automatically re-sent on subsequent page edits.
      Looking for help/collaboration on how best:
      to send a notification, eg from a blog post, then track the statistics. Dilemma is that the push notification must come from the admin page. Responses go to the sending page which, as it's an admin page, is restricted and will not accept the https response. This is where the other CMS integrations stop. The only json response from PushAlert is the status, eg 'success', and the notification id. There is no opportunity at this point to capture the sending page id. handle, 'once sent on page publish', do not automatically resend on future page edits Am thinking along the lines that FS Page will have a @kongondo runtime markup field https://modules.processwire.com/modules/fieldtype-runtime-markup/ to pull the stats from PushAlert. Every time an admin visits the page, the stats will update.
      Once an admin checks the 'Send notification on page publish' checkbox, a hook creates new front end page that records the 'sender page', sends the notification request to PA, which then uses that newly created frontend page, as the response endpoint. Another rook re-associates the front end page with the admin page (eg blog post), to update the stats.
      Potential use cases:
      Notify individual and/or users with a particular role of an event, eg "New work opportunity" for job seekers; new blog post published; entries now open, etc...
      Looking for help/ideas/collaboration on this module. Please let me know if you're interested and as I do, believe this would be a great addition to ProcessWire