Giter Site home page Giter Site logo

frialey63 / idle-notification Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vaadin-component-factory/idle-notification

0.0 1.0 0.0 153 KB

Display a notification and actions to the user before session-timeout

License: Apache License 2.0

JavaScript 40.77% Java 59.23%
library vaadin

idle-notification's Introduction

idle-notification

An add-on that displays a notification and actions to the user before session-timeout

idle-notification is an add-on that notifies the user before their session is about to expire. It enables the following features:

  • specify a message to be displayed to the user (which may include a count-down timer) before their session expires
  • set the number of seconds before session termination, at which point the notification is displayed.
  • add a button to the notification that enables the user to poke the server, thereby extending the session.
  • add a button to the notification that allow the user to immediately redirect to a different URL (e.g. a logout URL)
  • add a close button, allowing the user to close the notification without taking any action
  • specify a different message to be displayed to the user once their session has been terminated
  • determine whether an outside click when the notification is opened would extend the session
  • specify a URL to which the page would be automatically redirected upon session termination

Install

To use the component in an application using maven, add the following dependency to your pom.xml:

<dependency>
    <groupId>com.vaadin.componentfactory</groupId>
    <artifactId>idle-notification</artifactId>
    <version>${component.version}</version>
</dependency>

Usage

The notification is implemented as a standard Vaadin component that can be added to any UI or parent layout. For example, the following creates a notification with a message, a session-extending button, a redirect button. This notification has outside clicks not extending sessions. And the notification is added to the current UI.

IdleNotification idleNotification = new IdleNotification();
idleNotification
        .setMessage("Your session will expire in " + IdleNotification.MessageFormatting.SECS_TO_TIMEOUT
                + " seconds.");
idleNotification.addExtendSessionButton("Extend session");
idleNotification.addRedirectButton("Logout now", "logout");
idleNotification.addCloseButton();
idleNotification.setExtendSessionOnOutsideClick(false);

UI.getCurrent().add(idleNotification);

The following example specifies that the (default) message would be displayed to the user 90 seconds before their session timeout. Upon session timeout, the page will be automatically redirected to the "logout" URL

IdleNotification idleNotification = new IdleNotification(90);
idleNotification.setRedirectAtTimeoutUrl("logout");

UI.getCurrent().add(idleNotification);

Licnese

Apache License 2

idle-notification's People

Contributors

roastedcpu avatar tarekoraby avatar thomasharre avatar vesanieminen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.