<!--

    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" layout:decorate="~{admin/view}">
    <!--@thymesVar id="announcements" type="java.util.List<nl.tudelft.queue.model.misc.Announcement>"-->

    <body>
        <section class="flex vertical" layout:fragment="subcontent">
            <div>
                <a class="button" th:href="@{/admin/announcement/create}">Create Announcement</a>
            </div>

            <table class="table">
                <tr class="table__header">
                    <th>Announcement</th>
                    <th>Start</th>
                    <th>End</th>
                    <th></th>
                </tr>
                <tbody>
                    <tr th:each="announcement : ${announcements}">
                        <td>
                            <div
                                class="banner pbl-3"
                                th:styleappend="|color: ${'#' + announcement.hexTextColour()}; --color: ${'#' + announcement.hexBackgroundColour()};|"
                                th:classappend="${announcement.isDismissible ? 'alert-dismissible' : ''}">
                                <strong th:text="${announcement.message}"></strong>
                                <button
                                    type="button"
                                    style="margin-left: auto; border: none; background: none"
                                    aria-label="Close"
                                    th:if="${announcement.isDismissible}">
                                    <span aria-hidden="true">&times;</span>
                                </button>
                            </div>
                        </td>
                        <td th:text="${#temporals.format(announcement.startTime, 'dd-MM-yyyy HH:mm')}"></td>
                        <td th:text="${(announcement.endTime != null) ? #temporals.format(announcement.endTime, 'dd-MM-yyyy HH:mm') : 'Manual'}"></td>
                        <td class="fit align-middle">
                            <form th:action="@{/admin/announcement/{aId}/end(aId=${announcement.id})}" method="post">
                                <button type="submit" class="button p-min" data-style="outlined" data-type="error">
                                    <i class="fa fa-stop"></i>
                                    Stop
                                </button>
                            </form>
                        </td>
                    </tr>
                </tbody>
            </table>
        </section>
    </body>
</html>
