cancel
Showing results for 
Search instead for 
Did you mean: 

How create a plugin session timeout with a countdown timer in SAPUI5 Launchpad with backend server?

mahmood_hammood
Participant
0 Kudos

Hallo everyone,

I need to create a plugin session for timeout in the Launchpad, when the user is inactive for two minutes, he will reseive a notification ( see the photo please) with countdown timer for example 5 minutes, telling him that he will be forced to logout if in 5 minutes if inactivity continues.

The Plugin should appear next to the Search plugin.

Have someone an idea, step by step please?

 

logout.png

 

mahmood_hammood_0-1713961591886.png

 

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

sajid-khan
Explorer

You can make use of mousemove and keypress events to constantly update user's last interaction time. Upon long inactivity, you can display your timer and finally logout the user by forwarding them to logout URL. See following code for a rough idea of how to do it:

1. Constantly update user's last interaction info using "mousemove" and "keypress" events:

 

var glbl_usr_last_intrction = Date.now();
const update_timestamp = () => {
    glbl_usr_last_intrction = Date.now();
    hide_timer(); //in case timer was visible
}

window.addEventListener('mousemove', update_timestamp);
window.addEventListener('keypress', update_timestamp);

 

 2. Check user's last interaction time every 10 seconds and display the timer or logout if inactive for too long:

 

const inactive_threshold_timer = 120000; // 2 minutes
const inactive_threshold_logout = 420000; // 7 minutes

const check_last_intrction = () => {
    if (Date.now() - glbl_usr_last_intrction > inactive_threshold_logout) {
        window.location.href = "/sap/public/bc/icf/logoff";
        return;
    }
    if (Date.now() - glbl_usr_last_intrction > inactive_threshold_timer) {
        display_timer();
    }
    setTimeout(check_last_intrction, 10000);
}
check_last_intrction();

 

mahmood_hammood
Participant
0 Kudos

Thank you Sajid. Are there Timer/Logout Icon or Plugin like what in photo which one can use directly?

Other question, how I find the code of the Launchpad, where I can write my code? I have the Launchpad but do not know where is the code!

Answers (0)