I want to display a countdown timer on one of my perspective view.
For eg. as soon as a user logs-in I want to display a countdown timer for 1hr. Is there any way I can achieve this ?
- Create a session custom property,
countdownStart
. - When the user logs in run the following code in a script:
self.session.custom.countdownStart = system.date.now()
- On your countdown label create an expression binding to calculate the time remaining. For example,
floor((now(1000) - {session.custom.countdownStart}) /1000)
will tell you the number of seconds since countdownStart. - Modify the expression to give the number of seconds remaining.
- Modify the expression to clamp the time remaining at zero (to prevent it going negative).
- Modify the expression to give the time remaining in mm:ss format.
where to write this script ?: self.session.custom.countdownStart = system.date.now()
In your login script. You haven't explained how you're doing this.
I just want thing like whenever a user login(opens a session in browser) the timer countdown timer should start.
That's what you wrote in your opening post. It doesn't add any new information.
I'm logging in with IDP.
Need guidance how to proceed with the timer thing
How are you logging in? Button event? Script? Application launch? You need to be much more specific in the details you supply.
I'm launching the project from the designer.
It then opens in browser as usual there it asks for user id and pw (initially I told doing it with idp but for now keeping that aside).
After this it launches my project
That's better.
Add the code into Project Browser → Perspective → Session Events → Page Startup.
You might also go back through some of your other threads and see if any of the problems were answered to your satisfaction. As far as I can see you haven't marked any of the answers as 'Solution'.
Not sure about this. I would be putting a value change event handler on the session.props.auth.user.userName to set the custom session prop
Good idea. Can you post a step-by-step?
Can do when I'm in the office in a few hours
I was wondering, will "putting a value change event handler on the session.props.auth.user.userName to set the custom session prop" will work if the same user logs in again?
Asking this because i'm building something like : every one hour the user need to log in again.
It will run whenever the userName changes
Can you post a step-by-step solution pls.