Is there any way for an ignition module to get access to the perspective renderer in an iframe?
XY problem -- i've got view jsons that might be changing pretty rapidly, and I want to see how they'd render in the designer. I don't care about tag values or scripts (or interactivity atm) but i do care about view params for embedded views. (i.e. if i can use a module to translate the view json into JS components, that works too).
hmmm ok so. what i'd do then is....
set up a webdev route that took a param and set a tag value
make a single preview page that has this component, binding the view json param to the tag
Iframe that preview page inside the app?
that should work for everything except embedded views, for which the preview page will need access to the view paths as well. ok ok ok i can start to think about this tho.
(additional background, these view jsons are coming from user input outside the designer. for now they can be basically modeled as 'external scripts creating jsons')
I don't 100% follow, but it seems like you've got the pieces you need.
The Json View
component will render embedded views just fine, but yeah you need to know the paths ahead of time. You could always write a WebDev endpoint that lists them.
If you run into any issues with the component, post them in the Periscope thread and I'll be happy to help.
my only followup question is here Filesystem tags? so i can just have that view json take the results straight from a file on the machine
Perspective is only ever going to have access to the Gateway's filesystem. So if the view.json
file you want to render is on the Gateway, then yes you could load the file into the Json View component.
If you wanted to do this automatically, you could set up a file watcher that sends messages to the Perspective clients to inform them to reload.
But if the view.json
is on the Gateway, why don't you just add it to a project?
i don't want to wait the 5m for it to refresh if it's updated on system. (unless that's only for designer, not perspective?)
what would break if i made a perspective session event script that tied this to onpagestartup
i guess it'd just make every page load a bit slower?
Nothing, it should work fine. You could also assign it to a button:
- User clicks button.
- Call
requestScan
, blocking until completion.
- After
requestScan
is finished, reload the page.
I don't want this tied to a button, but on page load should be fine.
assuming that if i make the project in question public, the user won't have to relogin to see the rendered views?
Running it on page load isn't going to do what you expect; it's not going to delay loading the view until the scan is complete.
Assuming you have another system that is modifying these views, here's what I'd do:
- External system modifies a
view.json
file.
- When complete, the external system calls a WebDev endpoint (
/view-updated
) and provides the path of the modified view.
- When the WebDev endpoint is triggered, it runs
system.project.requestScan
.
- When the scan is complete, the WebDev endpoint sends a message to all the client's who have the modified view loaded.
- The client's receive this message and automatically refresh their pages.
will this work if the clients are browsers?
Perspective Session = Perspective Session in a tab = Perspective Session in an iFrame = Perspective Session anywhere
would the following flow work?
- External system modifies a
view.json
file.
- when a page is loaded, it calls system.project.requestScan in a script via onPageStartup
- When the scan is complete, the script sends a message to all the client's who have the modified view loaded.
- The client's receive this message and automatically refresh their pages via message handler