What do you mean by Change the URL? Changing the URL will point to a different location.
I probably used the wrong terms or something saying that bit from before.
I really mean how do I make this work?
# Navigating to a perspective page with url parameters.
system.perspective.navigate(url='http://<GatewayIP>:<port>/data/perspective/client/<projectName>/view?key=8')
I think the example is less an example, and more like a format that I don't understand.
I think I understand it up until the question mark part, and also not sure how to insert variables.
When I watch the video on passing parameters, they are using slashes.
I got one of those to work, but the script commands that work with those look like they are for only vision.
The way, you were doing it was the correct approach.
If you would rather just change the URL, then I believe that is documented here, however, I don't know if that applies to you as I don't know if you've recived your upgrade from 8.1.0 or not.
Typically URL parameters would be sent as you have shown, where a ? mark denotes that parameters follow, and parameters are separated with an &
So for you that would look like /devz17?which=test&when=date
where test and date are the string representations of the actual values.
When I get to the URL I have that string. The parameters didn't pass.
I am also happy to say I have been upgraded to 8.1.19
I read through the post, but I don't understand it.
I will try to write the string for the URL in a variable before the system function so I can concat the values of my variables.
devzl7?which=6&when=1666263540000
This did not change the parameters.
Maybe my view needs to be /devzl7/:which/:when
again.
Well it is opening the URL, and I did at one point get the parameters to pass with colons in the view name. So I will try to combine those things to see if I can get it to work.
Ok this way worked, and I think it was what the post was saying that I did not understand.
No, you're going about this with two different approaches, which have two different implementations.
If you're using the /devzl7/:which/:when
approach, then you MUST supply the params like so: devzl7/6/1666263540000
. The values between the slashes are piped" into the named params in the order they're defined. In this scenario, which
would receive "6" (not 6
), and when
would receive "1666263540000" (not 1666263540000
). These would then be accessed through the params of the Primary View in use for the Page.
If you're using the /devz17?which=test&when=date
approach, this uses the urlParams
dictionary/object available as part of the properties of the page.
To reference these params after they've been passed in as part of the URL, you would reference self.page.props.urlParams.which
and self.page.props.urlParams.when
. Please remember though, that EVERY URL PARAM is passed as a string REGARDLESS OF APPROACH, so you would need to convert your date param back to the correct type when referencing it.
Thanks so much for the help.
If I understand it correctly:
I setup my parameters on the page I am going to switch to.
I setup my page url for that page with parameters in the URL.
I setup my script onRowClick to get the values, make my URL string, and then open that page.
machineNumber=event.value["Machine_ID"]
test= event.value["Date"]
mystring= 'http://<GatewayIP>:<port>/data/perspective/client/<projectName>/devzl7/'+str(machineNumber)+'/'+str(test)
system.perspective.navigate(url=myString)
I need to document this so I can remember how this worked in a year or maybe just next week depending on bombardments.
Thanks so much.
That looks to me like it should now work, assuming you handle the str -> date conversion correctly when referencing the when
param.
I would very much appreciate review and corrections of my terminology for this explanation of what I believe I have done.
In my table that I get the row values from, the Date is a DateTime datatype.
When written to the string for the URL, the portion of the string for this parameter is similar to 1666263540000
I think that is the number of milliseconds since Unix Epoch, a date back in 1969 used for DateTime datatypes.
The parameter on the perspective page becomes that value.
I am not sure what kind of datatype it is in the parameter.
I reference the parameter in my table to display the range, {view.params.when}
and I reference it a second time to get the datetime 8 hours prior for looking at the shift.
I think I handled the datatype correctly. Honestly though, I don't know how it makes the transfer through the URL. I think it became a string, then it became a datatype just because it had a good format as a string.
I want to use the correct terms.
I want to verify that this is not working because of a bug as had happened to me before with some Python code I used.
Because the URL parameters are used in a named query and label, the page is safe?
Malicious strings in the URL won't do more than show error codes related to the JSON already viewable in page source?
If I type in 'where' in the URL, then an error code shows the name of the objects that my table is in and the name of the object itself. I don't see any information about the actual query, so that is good.
Query type is Query in my named query.
That depends on how the parameters are used in the named query. Are they normal parameters or a Query String parameter?
value type
I tried to type in some semi malicious stuff.
I do see some error codes read information back, but I don't see anything that reveals something not in the source view.
I wasn't able to type something that didn't show up in the label, or make the label error.
I think I get a little paranoid when I gain some new functionality like this.
It is really cool to let users click on the table and pull up relevant data to that machine at that time related that data.
Thanks again
What icon is recommended to indicate that table can be clicked on and show the user relevant data?
I am using the material/mouse icon right now.
material/info
.