<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/index.css">
    <link rel="icon" href="img/favicon.png" type="image/png" />
    <title>Intranet Saint-James</title>
</head>
<body>
    <!-- EN-TÊTE -->
    <header>
        <!--- Logo du site -->
        <img class="logo" src="img/logo.png">
        <!-- Barre de navigation -->
        <nav>
            <!-- Bouton hamburger pour les appareils mobiles -->
            <label for="toggle">☰</label>
            <input type="checkbox" id="toggle">
            <!-- Liens des pages -->
            <div class="main_pages">
                <a href="/">Accueil</a>
                <a href="/form">Formulaires</a>
                <a href="/list">Liste des téléphones</a>
                <a href="/jobs">Offres d'emploi</a>
            </div>
        </nav>
    </header>

    <div class="user-control">
        <img class="svg-color" src="img/user.svg" />
        <p><%= useremail %></p>
        <a class="logout" href="/logout">Déconnexion</a>
    </div>

    <!-- CONTENU PRINCIPAL -->
    <main>
        <div class="weather-widget card">
            <p class="card-title">Température à Saint-James</p>
            <p class="card-value"><%= weather %></p>
        </div>
        <% for(let i = 0; i < host.data.length; i++) { %>
            <% if (host.data[i].attributes.secure) { %>
                <a href="https://<%= host.data[i].attributes.ip %>" target="_blank">
            <% } else { %>
                <a href="http://<%= host.data[i].attributes.ip %>" target="_blank">
            <% } %>
                <div class="card">
                    <p class="host-title"><%= host.data[i].attributes.name %></p>
                    <p class="host-ip"><%= host.data[i].attributes.ip %></p>
                    <div class="host-div">
                        <% if (hoststatus[i]) { %>
                            <div class="status-color green"></div>
                            <p class="host-status">En ligne</p>
                        <% } else { %>
                            <div class="status-color red"></div>
                            <p class="host-status">Hors ligne</p>
                        <% } %>
                    </div>
                </div>
            </a>
        <% } %>
    </main>

    <!-- SCRIPTS -->
    <script src="js/spin.js"></script>
</body>
</html>