On my vision project i’m using a project script to fill my canvas with two different template.
I’d like to do the same in perspective, is it possible to do it with a flex repeater ?
If yes some one have an example of script who fill the flex repeater.
Because according to the data in my request I would like to use different templates and pass different values in my instances
The Flex Repeater requires one or more instances of a single “template” View, which you can send parameters to in order to make each templated View meaningful. You may not specify multiple templates via the FlexRepeater.props.path property.
If you need two different Views, just use the Embedded View component twice.
What you posted actually might be is 100% possible, but only if you stretch your idea of a “template”.
Here’s what I would do (just as a concept - you’ll want to tinker with the settings):
Make one View, named UserResponse, which uses a Flex Container in column mode.
UserResponse should have a PARAM key left_or_right, which I guess you could default to “left” or “right”. It should also have PARAMs for name and message.
In UserResponse, place two Flex Containers and set them both to row mode.
In UserResponse.root.FlexContainer AND UserResponse.root.FlexContainer_0, place three Flex Containers,
In both UserResponse.root.FlexContainer AND UserResponse.root.FlexContainer_0 set the SECOND Flex Container to have a props.style.backGroundColor. These second Flex Containers should also have Labels placed in them which are bound to name and message.
Bind this new background property with an expression something like this if({self.view.left_or_right}=="left","#ffffff","#aaaaaa")
Bind UserResponse.root.FlexContainer.FlexContainer.position.basis to the following expression: if({self.view.left_or_right}=="left","0px","100px") and bind UserResponse.root.FlexContainer.FlexContainer_1.position.basis to if({self.view.left_or_right}=="left","100px","0px")
Do the same for UserResponse.root.FlexContainer_0.FlexContainer.position.basis and UserResponse.root.FlexContainer_0.FlexContainer_1.position.basis
Now, you can use that single View as your template, and its color AND position are determined by the parameter you pass it. When a new response is “posted” you just add a new object to the existing FlexRepeater.props.instances array which includes which user (left_or_right) posted the message, the name of the user, and the message they posted.
I’d like the message height depends of the message size
Also I’d like to give my user the possibility to send pictures, on vision used :
system.file.openFile()
to upload picture and saving it in my datebase as bytes.
Should I do the same in perspective or should I use the " File upload " component ?
By the way how it works ?
Message height dependent on message length:
That’s going to be the tough part. What you’ll most likely need to do is make sure that the useDefaultViewHeight of the Flex Repeater is set to True, and you’ll need to bind the props.height of the template View to an expression which measures the length of the incoming message. I’ll leave the calculations to you.
Perspective requires you to use the File Upload Component for uploading files. system.file.openFIle() will execute on the Gateway, not the local Session, so you’d be opening a file on the Gateway.
You’ll want to use event.file.copyTo() as part of the onFileReceived Event to save the uploaded picture to the Gateway (make sure the directory you want to save to is already in place - I recommend a new directory for each project in C:\Program Files\Inductive Automation\Ignition\webserver\webapps\main).
Each Message template should now also have an Image Component placed within it, and the Message template should have a new param named source.
Bind Image.props.source to the View.params.source param AND you’ll need to include the path to the file.
Bind Image.position.basis to the following expression: if({self.view.params.source}!="","200px","0px").
Also, @souxifou: there was a change in a very recent nightly which introduced a new position.display property for all cildren of Flex Containers which provides the exact same functionality as the expressions I provided you. For the expressions used to determine the basis of the FlexContainers which live in a FlexContainer which is in row mode, you can bind UserResponse.root.FlexContainer.FlexContainer.position.display to the following expression: if({self.view.params.source}!="","true","false") OR you can change the left_or_right param entirely to make everything more clear.
If you change left_or_right to just left_align and pass it as a boolean value, it might make all of the expressions more clear. This would also allow you to bind UserResponse.root.FlexContainer.FlexContainer.position.display to self.view.params.left_align and exclude the logic altogether.
The permissions are needed by the Gateway service. The permissions of a user logged in on the gateway machine (you) are not relevant. Look at the user set to run the gateway service.
Who had administrator permission on the gateway to install Ignition in the first place? That’s probably the person who will have to adjust permissions on the folders in the gateway that your scripts are trying to use.
Look at “Services” under your “Computer Management” tools. Find Ignition in the list. Open that and look for the user assigned to run the background service. Give that user (probably something like “LOCALSYSTEM”) write access to the folders in question. Services run with their own identity – your permissions as a local user are non-relevant.
I’ll let other users here help you with any further details – I’m happy to work with the copies of Windows my customers install, but I otherwise avoid Windows like the plague.