<!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">
    <title>Gallery</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

    <style>
        .normalizar{
            max-width: 65rem;
        }
    </style>

</head>
<body>
    <div class="container">
        <div class="alert alert-success" role="alert">
            <a href="/admin"  class="alert-link">Voltar</a>
        </div>

    <h1 class="display-4">Gallery - Gerenciamento de Conteúdo</h1>
    <h3 class="display-6">Gallery - Adicionar</h3>

    <form action="/alterar_gallery?id=<%=dados._id%>" method="post" enctype="multipart/form-data">
        <label for="imagem" class="form-label">Imagem:</label>
        <input type="file" name="imagem" id=""  class="form-control btn-file"><br>
    
        <img src="uploads/<%=dados.arquivo%>" class="normalizar"  alt="" > |<br>

        <input type="hidden" name="anterior" value="<%=dados.arquivo%>">


        <button type="button" onclick="window.location.href='/gallery'" class="btn btn-primary"> Cancelar </button>
        <input type="submit" value="Gravar" class="btn btn-warning">

    </form>



<!--
    <h3 class="display-6">Gallery - Listar</h3>
    <table class="table table-striped table-hover">
        <tr>
            <th>Nome</th>
            <th>Preview</th>
            <th colspan="2">Ações</th>
        </tr>
         inserir um loop para exibição da JSON Gallery 
        <% for (var n=0; n<dados.length; n++){%>
        <tr>
            <td><%=dados[n].arquivo%></td>
            <td>
                <img src="./uploads/<%=dados[n].arquivo%>" alt="" width="250">
            </td>

            <td><a href="/alterar_gallery?id=<%=dados[n]._id%>" class="btn btn-outline-info">Alterar</a></td>
            <td><a href="/excluir_gallery?id=<%=dados[n]._id%>" class="btn btn-outline-warning">Excluir</a></td>

        </tr>
        <%}%>
        <!-- fim do loop-->


    </table>
</div>
</body>
</html>