JS Control Report Preview Time

  • Last update:  2020-12-17
  • I. Description

    This document provides a method which uese JS to control the longest preview time of a report and automatically exit if time is out, so as to prevent the system from shutting down because the user previews the report for too long.

    II. Method

    Use the setTimeout() method provided by JavaScript to perform an operation after a specified period of time. The operation uses window.location to redirect to the login page from the report preview page. However, after jump to the login page, the user's old login session is not over, so we need to use Ajax to interact with the data.

    III. Implementation Process

    1) Create a new logout.js file in folder %FR_HOME%\webapps\webroot\help, enter the following code, and save

    setTimeout(function(){
        jQuery.ajax({
            URL: "/webroot/decision/logout/cross/domain", // the server provides single sign-on service
            data:{},
            Timeout: 5000,
            Success: function (data) {
                window.location = "/webroot/decision/login";
            },
            Error: function() {
                alert("error"); //If fails to login (timeout or other server errors)
            }
        });
     }, 3600); //Maximum preview time (unit: millisecond)

    For testing purposes, it is set to exit the report after 3600 milliseconds, i.e. 3.6 seconds, which can be modified according to actual needs.

    2) Open Template > Web Attributes > Reference JavaScript, select the file logout.js, click Add, and then the report can reference the JS file:

    1606370608552369.png

    3) Preview. You will find that after 3.6 seconds, the report will automatically exit and enter the system re-login interface, as shown below:

    1606370608328045.gif

    So far, our method of controlling the template preview life cycle through JavaScript has been successfully implemented.

    Note: If you want all reports in the server follow this setting, you need to reference logout.js in Server > Server Configuration Managemer > Reference Javascript.

    Attachment List


    Theme: Secondary Development
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy