Ewon TechForum
Providing technical solutions to technical requests


Views depending user logged in.
vangorpia Offline
Junior Member
#1
Hi,
I have the following setup a Ewon flexy and viewOn 4. The flexy is connected to a PLC (Modbus/TCP) that controls an irrigation system. The irrigation system is used by 5 orchards. Each orchard has a time slot and can set a time and duration for irrigation. On viewOn I made one main view that all the users can see with general info on pump (flow pressure etc.) and dedicated views for each user where they can set the times (these views can be selected from the main view). If possible I would make it such that when user1 is logged in, user1 can see the main view and only the view for user1.  Same for user2 etc.
 
I have been looking at the user setup of viewOn and Ewon flexy but could not find a way to achieve the above. Then I was thinking to use the basic script in the flexy and read who was logged in and set a Tag which can be used to make the view button for the different users visible or not. But I cannot find a way to get the info who is logged in? Can you read who is logged in, or is there a better way to achieve the above?
Reply

simon Offline
eWON Support
#2
Hi,
Indeed, you cannot play with the Access Rights management of viewon as it does not make differences between users of the same right level.

To know who is loggued, you can use this script trick :
1. Create a file named "userlogged.shtm" and paste the following content : <%#SessionAst,UserLogin%>
Push this page to the eWON /usr directory by FTP.
This page will give you the username of the current user.
2. In viewon, in the view object, create a javascript section and paste the following script :

if (typeof flag == 'undefined') //Do it only once
{
jQuery.ajax ({ url:"../userlogged.shtm", type:'GET', dataType:"text", success:function(user, status){$("#UID_1457533878994").text(user);}, timeout:2000 });
flag = 1;
}

This script will download the page asynchronously and display the result in a text object.
Remark : the "UID_1457533878994" is the UID of the object in which I put the content (here a text object). You can find it in the Graph properties of the object.
Reply

vangorpia Offline
Junior Member
#3
Hi Simon,
Thanks for that. Would have never found that. I updated the code so its set an ViewOn variable to true/false, which is used to enable/disable views.

if (typeof flag == 'undefined') //Do it only once

{

jQuery.ajax ({ url:"../userlogged.shtm", type:'GET', dataType:"text", success:function(user, status){$("#UID_1483519797846").text(user); wie=user;}, timeout:2000 });

setViewOnTagVal('block1', false);

setViewOnTagVal('block2', false);

if (wie == "block1") {

   setViewOnTagVal('block1', true); 

}

if (wie == "block2") {

   setViewOnTagVal('block2', true); 

}

flag = 1;
}

Reply

simon Offline
eWON Support
#4
Perfect :-)
Reply

mzapatav Offline
Junior Member
#5
Hi Simon, is there a way to get the First Name of a user displayed on the web page (Not user name)? Also, I want to create a Logout link too. Thanks.
Reply

vangorpia Offline
Junior Member
#6
(09-01-2017, 01:57 PM)Simon Wrote: Perfect :-)
Reply

simon Offline
eWON Support
#7
1. To get the First and the Last name, you can use the SSI : <%#SessionAst,UserFullName%>
2. To create a link to log off, just use the link : http://<IpAddress>/Ast/LoggedOffAst.shtm
Reply

vangorpia Offline
Junior Member
#8
Hi Simon,
When I log in using Talk2me I sometimes can see the user logged in, but more often it doesn't show the user. I can log in and see the webpage so that is working however the user is not shown. What can I do about that?

Kind regards,
Ad

P.s. when I login when the PC is connected to the Ewon I never have a problem and always the user is shown.
Reply

simon Offline
eWON Support
#9
Sorry but I do not understand. This SSI <%#SessionAst,UserFullName%> shows the user defined in the eWON, not the one defined in eCatcher.

Could you give me more details about what you do ?
Reply

vangorpia Offline
Junior Member
#10
Hi Simon,
When I connect using M2Web the user login is NOT shown. When I connect with the PC direct to the Ewon or using eCatcher the userlogin is shown.
I'm using: <%#SessionAst,UserLogin%>

Kind regards, Ad
Reply

simon Offline
eWON Support
#11
I just tried on my eWON and it works good. See snapshot attached.

Simon


Attached Files
.png   source.png (Size: 2,09 KB / Downloads: 67)
.png   users.png (Size: 2,24 KB / Downloads: 54)
.png   m2web.png (Size: 4,94 KB / Downloads: 53)
Reply

vangorpia Offline
Junior Member
#12
Hi Simon,
I'm tried for a week on several pc's and it never works. Mayby I'm doing things wrong.
1. I go to m2web.talk2m.com/ and log in. This works ok
2. On the talk2me I select the Ewon. This works ok
3. A screens pop ups where I log in with Adm. This works ok
The viewon web page is shown but the NOT the user! see attachment talk2me

With eCatcher
1. start eCatcher and log in
2. Select the Ewon and connect.
3. At the Talk2me cloud select to Ewon.
4.  A screens pop ups where I  log in with Adm.
The viewon web page is shown and the user. see attachment eCatcher

Can you explain  why it works with ecather and not with m2web/talk2me ?

Kind regards, Ad


Attached Files
.png   eCatcher.PNG (Size: 2,79 KB / Downloads: 29)
.png   talk2me.PNG (Size: 2,65 KB / Downloads: 28)
Reply

simon Offline
eWON Support
#13
Can you send me the viewon project you use for that ?
Reply

vangorpia Offline
Junior Member
#14

.zip   Viewon.zip (Size: 135,1 KB / Downloads: 23) SimonCan you send me the viewon project you use for that ?

Hi Simon,
See attachment.
Another question: When a webpage is called the hidden objects are shown at first and then after some time (depening connection) hidden. Is it possible to hid these object from the start.

Kind regards, Ad
Reply

vangorpia Offline
Junior Member
#15
Hi Simon,
As the user info is not available when using M2Web. I had the plan to work with a pin code that the user had to type in. I made a viewon tag named pin and compared this (in action of the screen) with some predefined values (see below). However I have the same problem as with the user info:
- connected directly to the Ewon Flexy it works.
- using ecather it works.
- using m2web.talk2me DOES NOT WORK.

Any suggestion?

var pinin = getViewOnTagVal('pin');
if (pinin == 1403)
setViewOnTagVal('adm', true);
else
setViewOnTagVal('adm', false);

if (pinin == 3228)
setViewOnTagVal('Nick', true);
else
setViewOnTagVal('Nick', false);
Reply



Possibly Related Threads…
15-07-2019, 01:03 PM
Last Post: jswenker
03-09-2018, 01:47 PM
Last Post: samore



Users browsing this thread:
1 Guest(s)



Theme © Ewon 2019 - Forum software by © MyBB - Cookie policy