feat: Refactor Titre views and view models to use Administration area

This commit is contained in:
mirage
2026-03-05 15:55:07 +01:00
parent c42a4bb72c
commit de6ca18eac
13 changed files with 28 additions and 12 deletions

View File

@@ -0,0 +1,89 @@
@using Webzine.WebApplication.ViewModels
@using Webzine.Entity
@model CommentaireViewModel
@{
ViewData["Title"] = "Commentaires";
}
<style>
.commentaires-container {
overflow-x: auto;
}
.commentaires-table {
width: 100%;
border-collapse: collapse;
margin-top: 1.5rem;
background: white;
}
.commentaires-table thead {
background: #ddd;
font-weight: bold;
}
.commentaires-table th, .commentaires-table td {
padding: 1rem;
border: 1px solid #ccc;
text-align: left;
}
.btn-delete {
color: #0066cc;
border: none;
background: none;
cursor: pointer;
font-size: 1.2rem;
}
.btn-delete:hover {
color: #ff4444;
}
</style>
<h1>Commentaires</h1>
<div class="commentaires-container">
<table class="commentaires-table">
<thead>
<tr>
<th>Titre</th>
<th>Auteur</th>
<th>Commentaire</th>
<th>Date de création</th>
<th style="text-align: center;">Actions</th>
</tr>
</thead>
<tbody>
@foreach (Webzine.Entity.Commentaire commentaire in Model.Commentaires)
{
<tr>
<td>
<!-- Titre est un objet, on affiche sa propriété Libelle -->
@(commentaire.Titre != null ? commentaire.Titre.Libelle : "Titre inconnu")
</td>
<td>
<!-- On utilise Auteur (et pas Nom) -->
@commentaire.Auteur
</td>
<td>
@commentaire.Contenu
</td>
<td>
@commentaire.DateCreation.ToString("dd/MM/yyyy HH:mm:ss")
</td>
<td style="text-align: center;">
<!-- On utilise IdCommentaire (et pas Id) -->
<form method="post" action="@Url.Action("Delete", new { id = commentaire.IdCommentaire })" style="display: inline;">
@Html.AntiForgeryToken()
<button type="submit" class="btn-delete" title="Supprimer">
<i class="fas fa-trash"></i>
</button>
</form>
</td>
</tr>
}
</tbody>
</table>
</div>

View File

@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>@ViewData["Title"] - Webzine</title>
@* Ajout de bootstrap *@
<script src="/js/bootstrap.min.js" defer></script>
<link rel="stylesheet" href="/css/app.css">
<link rel="stylesheet" href="/css/bootstrap.min.css">
@* Ajout de font-awesome *@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
</head>
<body>
<div class="container">
@await Html.PartialAsync("_Header")
<div class="row mt-5">
<main class="col-9">
@RenderBody()
</main>
@await Html.PartialAsync("_Sidebar")
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,11 @@
@model Webzine.WebApplication.Areas.Administration.ViewModels.Titre.AdminTitreForm
<h1>Créer un titre</h1>
<hr />
<form asp-action="Create" method="post">
<partial name="_Form"/>
</form>

View File

@@ -0,0 +1,34 @@
@model Webzine.WebApplication.Areas.Administration.ViewModels.Titre.AdminTitreDelete
<div class="container mt-4">
<h1 class="mb-3">Supprimer un titre</h1>
<hr />
<p>
Etes-vous sûr de vouloir supprimer le titre
"@Model.Titre"
de
@Model.Artiste ?
</p>
<form asp-action="Delete" method="post">
<input type="hidden" asp-for="Id"/>
<button type="submit" class="btn btn-danger">
Supprimer
</button>
</form>
<br/>
<br/>
<a asp-action="Index">
Retour à l'administration des titres
</a>
</div>

View File

@@ -0,0 +1,13 @@
@model Webzine.WebApplication.Areas.Administration.ViewModels.Titre.AdminTitreForm
<h1>Editer un titre</h1>
<hr />
<form asp-action="Edit" method="post">
<input type="hidden" asp-for="Id"/>
<partial name="_Form"/>
</form>

View File

@@ -0,0 +1,74 @@
@model IEnumerable<Webzine.WebApplication.Areas.Administration.ViewModels.Titre.AdminTitreList>
@{
ViewData["Title"] = "Titres";
}
<div class="container mt-4">
<h1 class="mb-3">Titres</h1>
<hr />
<a asp-action="" class="btn btn-primary mb-3">
<i class="fa fa-plus"></i> Ajouter un nouvel titre
</a>
<table class="table table-striped table-bordered align-middle">
<thead class="table-light">
<tr>
<th>Artiste</th>
<th>Titre</th>
<th>Durée</th>
<th>Date de sortie</th>
<th class="text-center"><i class="fa fa-eye"></i></th>
<th class="text-center"><i class="fa fa-thumbs-up"></i></th>
<th class="text-center"><i class="fa fa-comments"></i></th>
<th class="text-center action-column">Actions</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@item.Artiste</td>
<td>@item.Titre</td>
<td>@item.Duree</td>
<td>@item.DateSortie.ToString("dd/MM/yyyy")</td>
<td class="text-center">@item.NbLectures</td>
<td class="text-center">@item.NbLikes</td>
<td class="text-center">@item.NbCommentaires</td>
<td class="text-center action-column">
<a asp-action="Edit" asp-route-id="@item.Id"
class="btn btn-sm btn-outline-primary">
<i class="fa fa-pen"></i>
</a>
<a asp-action="Delete" asp-route-id="@item.Id"
class="btn btn-sm btn-outline-danger">
<i class="fa fa-trash"></i>
</a>
</td>
</tr>
}
</tbody>
</table>
</div>
<style>
.action-column{
width:120px;
white-space:nowrap;
}
.action-column .btn{
margin-right:4px;
}
</style>

View File

@@ -0,0 +1,135 @@
@model Webzine.WebApplication.Areas.Administration.ViewModels.Titre.AdminTitreForm
<div class="container">
<!-- ARTISTE -->
<div class="row mb-3 align-items-center">
<label class="col-md-3 col-form-label">Nom de l'artiste<span class="text-danger">*</span></label>
<div class="col-md-9">
<select asp-for="IdArtiste"
asp-items="Model.Artistes"
class="form-select"></select>
</div>
</div>
<!-- TITRE -->
<div class="row mb-3 align-items-center">
<label class="col-md-3 col-form-label">Titre<span class="text-danger">*</span></label>
<div class="col-md-9">
<input asp-for="Libelle" class="form-control"/>
</div>
</div>
<!-- ALBUM -->
<div class="row mb-3 align-items-center">
<label class="col-md-3 col-form-label">Album<span class="text-danger">*</span></label>
<div class="col-md-9">
<input asp-for="Album" class="form-control"/>
</div>
</div>
<!-- CHRONIQUE -->
<div class="row mb-3">
<label class="col-md-3 col-form-label">Chronique<span class="text-danger">*</span></label>
<div class="col-md-9">
<textarea asp-for="Chronique"
class="form-control"
rows="5"></textarea>
</div>
</div>
<!-- DATE + DUREE -->
<div class="row mb-3 align-items-center">
<label class="col-md-3 col-form-label">Date de sortie<span class="text-danger">*</span></label>
<div class="col-md-3">
<input type="text"
class="form-control"
name="DateSortie"
pattern="\d{2}/\d{2}/\d{4}"
value="@Model.DateSortie.ToString("d")"/>
</div>
<label class="col-md-3 col-form-label">Durée en secondes<span class="text-danger">*</span></label>
<div class="col-md-3">
<div class="input-group">
<input asp-for="Duree"
class="form-control"
type="number"
min="0" />
<span class="input-group-text text-muted">seconds</span>
</div>
</div>
</div>
<!-- JAQUETTE -->
<div class="row mb-3 align-items-center">
<label class="col-md-3 col-form-label">Jaquette<span class="text-danger">*</span></label>
<div class="col-md-9">
<input asp-for="UrlJaquette"
class="form-control"/>
</div>
</div>
<!-- URL ECOUTE -->
<div class="row mb-3 align-items-center">
<label class="col-md-3 col-form-label">URL d'écoute</label>
<div class="col-md-9">
<input asp-for="UrlEcoute"
class="form-control"/>
</div>
</div>
<!-- STYLES -->
<div class="row mb-4">
<label class="col-md-3 col-form-label">Styles</label>
<div class="col-md-9">
<div class="row">
@foreach (var style in Model.AllStyles)
{
<div class="col-md-4 form-check">
<input class="form-check-input"
type="checkbox"
name="Styles"
value="@style.Value"
@(Model.Styles.Contains(int.Parse(style.Value)) ? "checked" : "") />
<label class="form-check-label">
@style.Text
</label>
</div>
}
</div>
</div>
</div>
<!-- LECTURES / LIKES (AFFICHAGE UNIQUEMENT) -->
<div class="row mb-4 align-items-center">
<label class="col-md-3 col-form-label">Nb de lectures<span class="text-danger">*</span></label>
<div class="col-md-3">
@Model.NbLectures
</div>
</div>
<div class="row mb-4 align-items-center">
<label class="col-md-3 col-form-label">Nb de likes<span class="text-danger">*</span></label>
<div class="col-md-3">
@Model.NbLikes
</div>
</div>
<!-- BOUTONS -->
<div class="row mt-4">
<div class="col-md-9 offset-md-3">
<button type="submit" class="btn btn-primary me-2">
Sauvegarder
</button>
</div>
</div>
<br />
<br />
<a asp-action="Index"
class="btn text-primary">
Retour à l'administration des titres
</a>
</div>