Compare commits

...

1 Commits

Author SHA1 Message Date
Maxime ROCHER 9ea87ca528 test CI
3 months ago

@ -0,0 +1,26 @@
kind: pipeline
type: docker
name: build
steps:
- name: Build and push Docker image
image: plugins/docker
settings:
# Nom complet de l'image à builder et pousser
repo: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui
# Chemin vers le Dockerfile (à adapter si nécessaire)
dockerfile: Dockerfile
# Tag à appliquer à l'image
tags:
- latest
# Ces variables secrets doivent être définies dans linterface Drone
username:
from_secret: docker_username
password:
from_secret: docker_password
trigger:
branch:
- main
event:
- push

Binary file not shown.

@ -0,0 +1,11 @@
@page "/ajout-citation-complex"
<h3>Analyse des Commentaires</h3>
<div class="year-selector">
<button @onclick="() => ChangerAnnee(-1)">⬅ Année précédente</button>
<span>@selectedYear</span>
<button @onclick="() => ChangerAnnee(1)">Année suivante ➡</button>
</div>
<canvas id="citationChart"></canvas>

@ -0,0 +1,80 @@
using System.Net.Http.Json;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using WF_WebAdmin.Service;
using System.Globalization;
namespace WF_WebAdmin.Pages
{
public partial class AjoutCitationComplex
{
[Inject] private HttpClient Http { get; set; } = default!;
[Inject] private IJSRuntime JS { get; set; } = default!;
private Dictionary<string, int> commentairesParMois = new();
private bool _isRendered = false;
private static readonly string[] MoisNoms = CultureInfo.CurrentCulture.DateTimeFormat.MonthNames[..12];
private int selectedYear = DateTime.Now.Year;
protected override async Task OnInitializedAsync()
{
await ChargerCommentaires();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender && _isRendered == false)
{
_isRendered = true;
await JS.InvokeVoidAsync("updateChart", commentairesParMois, selectedYear);
}
}
private async Task ChargerCommentaires()
{
try
{
var commentaires = await Http.GetFromJsonAsync<List<Commentaire>>("fake-dataCommentaty.json");
if (commentaires != null)
{
commentairesParMois = MoisNoms.ToDictionary(m => m, _ => 0);
foreach (var commentaire in commentaires)
{
if (!string.IsNullOrEmpty(commentaire.DateC) && DateTime.TryParseExact(commentaire.DateC, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var date))
{
if (date.Year == selectedYear)
{
var moisNom = MoisNoms[date.Month - 1];
if (commentairesParMois.ContainsKey(moisNom))
{
commentairesParMois[moisNom]++;
}
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("Erreur de chargement des commentaires: " + ex.Message);
}
}
private async Task ChangerAnnee(int delta)
{
selectedYear += delta;
await ChargerCommentaires();
await JS.InvokeVoidAsync("updateChart", commentairesParMois, selectedYear);
}
private class Commentaire
{
public int IdComment { get; set; }
public int Quote { get; set; }
public int Users { get; set; }
public string DateC { get; set; } = "";
public string Comment { get; set; } = "";
}
}
}

@ -5,4 +5,9 @@
Layout = "_Layout"; Layout = "_Layout";
} }
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-zoom"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="chart.js"></script>
<component type="typeof(App)" render-mode="ServerPrerendered" /> <component type="typeof(App)" render-mode="ServerPrerendered" />

@ -43,6 +43,14 @@
</NavLink> </NavLink>
</div> </div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="ajout-citation-complex">
<span class="oi oi-bar-chart" aria-hidden="true"></span> Analyse Citations
</NavLink>
</div>
</nav> </nav>
</div> </div>

@ -10,3 +10,4 @@
@using WF_WebAdmin.Shared @using WF_WebAdmin.Shared
@using Blazorise.DataGrid @using Blazorise.DataGrid

@ -0,0 +1,61 @@
window.updateChart = (data, year) => {
setTimeout(() => {
const canvas = document.getElementById('citationChart');
if (!canvas) {
console.error("Erreur: Le canvas #citationChart n'existe pas.");
return;
}
const ctx = canvas.getContext('2d');
if (!ctx) {
console.error("Erreur: Impossible d'obtenir le contexte 2D.");
return;
}
// Détruire complètement l'instance précédente du graphique
if (window.citationChartInstance) {
window.citationChartInstance.destroy();
window.citationChartInstance = null;
}
// Liste des mois
const mois = [
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
"Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
];
// S'assurer que tous les mois sont présents avec une valeur par défaut de 0
const values = mois.map(m => data[m] || 0);
// Création du graphique sans zoom
window.citationChartInstance = new Chart(ctx, {
type: 'bar',
data: {
labels: mois,
datasets: [{
label: `Commentaires en ${year}`,
data: values,
backgroundColor: 'rgba(54, 162, 235, 0.6)',
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
x: {
ticks: { autoSkip: false }
},
y: {
beginAtZero: true
}
},
plugins: {
legend: { display: true }
}
}
});
}, 500);
};
Loading…
Cancel
Save