<!--

    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/>.

-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
    <!--@thymesVar id="#authenticatedP" type="nl.tudelft.labracore.lib.security.user.Person"-->

    <!--@thymesVar id="qSession" type="nl.tudelft.queue.dto.view.labs.CapacitySessionViewDTO"-->

    <!--@thymesVar id="rooms" type="java.util.List<nl.tudelft.labracore.api.dto.RoomDetailsDTO>"-->
    <!--@thymesVar id="assignments" type="java.util.List<nl.tudelft.labracore.api.dto.AssignmentSummaryDTO>"-->
    <!--@thymesVar id="modules" type="java.util.List<nl.tudelft.labracore.api.dto.ModuleDetailsDTO>"-->

    <body>
        <th:block th:fragment="capacity-lab-info">
            <div class="flex vertical">
                <div class="grid auto-fit">
                    <div class="surface p-0">
                        <h3 class="surface__header">Session info</h3>

                        <div class="surface__content">
                            <dl>
                                <dt class="fw-500">Slot</dt>
                                <dd
                                    th:text="|${#temporals.format(qSession.session.start, 'dd MMMM yyyy HH:mm')} - ${#temporals.format(qSession.session.endTime, 'dd MMMM yyyy HH:mm')}|"></dd>

                                <dt class="fw-500 mt-3">Rooms</dt>
                                <dd th:text="${#strings.listJoin(@roomDTOService.names(rooms), ', ')}"></dd>

                                <dt class="fw-500 mt-3">Total capacity</dt>
                                <dd th:text="${qSession.capacity}"></dd>

                                <th:block th:if="${qSession.capacitySessionConfig.procedure.isFcfs()}">
                                    <dt class="fw-500 mt-3">Currently selected or pending per room</dt>
                                    <dd>
                                        <ul class="list">
                                            <li
                                                th:each="e : ${qSession.selectedOrPendingCountsPerRoom().entrySet()}"
                                                th:text="|${e.key.building.name}: ${e.key.name} (${e.value}/${e.key.capacity})|"></li>
                                        </ul>
                                    </dd>
                                </th:block>

                                <th:block th:unless="${qSession.capacitySessionConfig.procedure.isFcfs()}" th:with="data = ${qSession.data}">
                                    <!--@thymesVar id="data" type="nl.tudelft.queue.model.labs.CapacitySession"-->
                                    <th:block th:if="${qSession.isAfterSelection()}">
                                        <dt class="fw-500 mt-3">Total selected</dt>
                                        <dd th:text="|${#lists.size(data.getSelectedRequests())} / ${#lists.size(data.getProcessedRequests())}|"></dd>
                                    </th:block>
                                    <th:block th:unless="${qSession.isAfterSelection()}">
                                        <dt class="fw-500 mt-3">Currently enqueued for selection</dt>
                                        <dd th:text="${#lists.size(data.getPendingRequests())}"></dd>
                                    </th:block>
                                </th:block>

                                <dt class="fw-500 mt-3">Modules</dt>
                                <dd th:if="${#lists.isEmpty(modules)}" class="text-danger">This lab does not have any modules configured</dd>
                                <dd th:unless="${#lists.isEmpty(modules)}">
                                    <ul class="list">
                                        <li th:each="m : ${modules}" th:text="${m.name}"></li>
                                    </ul>
                                </dd>

                                <th:block th:if="${!#lists.isEmpty(qSession.constraints.toList())}">
                                    <dt class="fw-500 mt-3">Constraints</dt>
                                    <dd>
                                        <ul>
                                            <li
                                                th:each="constraint : ${qSession.constraints.toList()}"
                                                th:text="|${@constraintService.constraintDescription(constraintDescription())} ${@labRequestConstraintService.canCreateRequest(constraint, #authenticatedP.id) ? '' : '(you do not satisfy this)'}|"
                                                th:classappend="${!@labRequestConstraintService.canCreateRequest(constraint, #authenticatedP.id)} ? 'text-danger'"></li>
                                        </ul>
                                    </dd>
                                </th:block>
                            </dl>
                        </div>
                    </div>

                    <div class="surface p-0">
                        <h3 class="surface__header">Limited Capacity Info</h3>
                        <div class="surface__content">
                            <dl>
                                <dt class="fw-500">Enrolment</dt>
                                <dd>
                                    <th:block
                                        th:text="${#temporals.format(qSession.capacitySessionConfig.enrolmentOpensAt, 'dd MMMM yyyy HH:mm')}"></th:block>
                                    -
                                    <th:block
                                        th:text="${#temporals.format(qSession.capacitySessionConfig.enrolmentClosesAt, 'dd MMMM yyyy HH:mm')}"></th:block>

                                    <span class="chip" data-type="accept" th:if="${qSession.capacitySessionConfig.enrolmentOpen()}">Open</span>
                                    <span class="chip" data-type="error" th:unless="${qSession.capacitySessionConfig.enrolmentOpen()}">Closed</span>
                                </dd>

                                <dt class="fw-500 mt-3">Selection happens at</dt>
                                <dd th:text="${#temporals.format(qSession.capacitySessionConfig.selectionAt, 'dd MMMM yyyy HH:mm')}"></dd>

                                <dt class="fw-500 mt-3">Selection procedure</dt>
                                <dd th:text="${qSession.capacitySessionConfig.procedure.displayName}"></dd>
                            </dl>
                        </div>
                    </div>
                </div>

                <div class="surface p-0" th:if="${!#strings.isEmpty(qSession.extraInfo)}">
                    <h3 class="surface__header">Extra information for this session</h3>
                    <div class="surface__content" th:utext="${qSession.extraInfo}"></div>
                </div>
            </div>
        </th:block>
    </body>
</html>
