FileServer/views/templates/index.html

85 lines
2.9 KiB
HTML

{{define "index"}}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>FileServer</title>
<link rel="stylesheet" href="/assets/bulma.min.css">
<script src="https://kit.fontawesome.com/2effe35473.js" crossorigin="anonymous"></script>
</head>
<body>
<section class="section">
<div class="container">
<h1 class="title is-1">Hébergement de fichiers</h1>
<p class="subtitle">
Enfin une solution simple que vous gérez vous même
</p>
<form action="/admin/upload" method="post" enctype="multipart/form-data">
<div id="file-js-example" class="file has-name is-boxed">
<label class="file-label">
<input class="file-input" type="file" name="file" />
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label"> Choose a file… </span>
</span>
<span class="file-name"> No file selected </span>
</label>
</div>
<div class="field is-grouped">
<div class="control">
<input type="submit" value="Uploader" class="button is-link"/>
</div>
</div>
</form>
</div>
</section>
<section class="section">
<div class="container">
<h1 class="title is-4">Liste des fichiers</h1>
<table class="table is-striped is-hoverable is-fullwidth">
<thead>
<tr>
<th>Nom de fichier</th>
<th>URL</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{{ range .Files }}
<tr>
<th>{{ .Filename }}</th>
<td><a href="{{ .URL }}">{{ .URL }}</a></td>
<td>
<form action="/admin/remove" method="get" enctype="multipart/form-data" onsubmit="return confirm('Êtes-vous certain ? Cette action est irréversible');">
<input type="hidden" name="Filename" value="{{ .Filename }}"/>
<div class="field is-grouped">
<div class="control">
<input type="submit" value="Supprimer" class="button is-danger is-small"/>
</div>
</div>
</form>
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
</section>
</body>
<script>
const fileInput = document.querySelector("#file-js-example input[type=file]");
fileInput.onchange = () => {
if (fileInput.files.length > 0) {
const fileName = document.querySelector("#file-js-example .file-name");
fileName.textContent = fileInput.files[0].name;
}
};
</script>
</html>
{{end}}