This is a very quick extension (Uploading to NPM took longer than the extension took) that lets you easily parse a user agent.
The user's user agent can already be gathered from Wappler using the $_SERVER.HTTP_USER_AGENT variable, but there was no easy way to parse this previously, thus, this extension was made to easily give you an output with a users' browser name, cpu, device, engine, and operating system.
This extension can be installed via NPM. You can follow the steps here.
Really nice extension @Digo, sure that will be really useful to everyone.
I hope i wont offend you by suggesting a small tweak and adding a docs note.
When entering $_SERVER.HTTP_USER_AGENT, if this has been created via inputs and selected from there via the picker, all is good.
If entered directly into the 'User Agent' input from the Wappler UI, Wappler automatically quotes the entry so the quotes will have to be edited out. Not a fault of the extension, it's a quirk of Wappler.
As you have probably noticed, adding a defaultValue does not actually pre-populate the "Name" field which I guess you wanted to do. This used to drive me mad but apparently it does not work that way, to pre-populate the name you must also add,
baseName: 'userAgent'
This is something unique to the 'name' input
I have added that to George's docs for future reference.
Just on npm specify also the server-connect keyword to indicate that it is a server connect extension and also add a readme file with general description and installation.
You might also want to consider making an app connect client side version as well.
Oh man, thank you for this! In literally all of my extension I've wonder why it never worked and assumed it was just a bug in Wappler so left it there in case it got fixed. I had no idea it needed baseName instead. I'll go back and update all my extension with this later on. I see George has updated the docs now.
I assume you are referring to the help message, and yeah I know about this. There was an issue I had where if you set the default value to an expression it doesn't actually seem to send over the data despite it showing in the UI, so the help message was just added as a hint. I assume most people will gather you have to add it as an expression rather than text given the $_
Thanks, though I probably won't end up making an app connect version as the extensions I have published so far are all for one project I'm working on, and so they mostly just cover the basics of what I need. I don't really have time to add much else at the moment (aside from the sanitizer extension, which I do plan to update), though if someone else wants to work on an app connect version, then they are free to do so. It's pretty straight forward using the ua-parser-js NPM package.
I meant if some was just to type $_SERVER.HTTP_USER_AGENT into the input box then it will be quoted by wappler but i assume the same would apply if you set a default value in hjson also.