<!--

    Queue - A Queueing system that can be used to handle labs in higher education
    Copyright (C) 2016-2024  Delft University of Technology

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

-->
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
    <div layout:fragment="expired" th:if="${#authenticatedP != null}">
        <dialog class="dialog" id="sessionExpiredModal">
            <div class="p-7 flex vertical">
                <h2 class="underlined font-500">Session expired</h2>

                <p>Your session has expired</p>

                <div class="flex space-between">
                    <button class="button p-less" data-style="outlined" data-cancel>Close</button>
                    <a th:href="@{/login}" class="button p-less" id="sessionExpiredLogin">Log in</a>
                </div>
            </div>
        </dialog>

        <th:block th:if="${#authenticatedP != null}">
            <!-- Import push.js -->
            <script src="/js/push.js"></script>
            <script th:inline="javascript">
                /*<![CDATA[*/

                let timeout = /*[[${#maxInactiveInterval}]]*/ "60";
                setTimeout(function () {
                    document.getElementById("sessionExpiredModal").showModal();
                    document.getElementById("sessionExpiredLogin").focus();
                }, parseInt(timeout) * 1000);

                /*]]>*/
            </script>
        </th:block>
    </div>
</html>
