v1.0.0
This commit is contained in:
1 parent
070168639d
commit
b05cbe61e8
23 files changed
+983
No files matched your search
@@ -0,0 +1,30 @@
|
|||||||
|
**/.classpath
|
||||||
|
**/.dockerignore
|
||||||
|
**/.env
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
**/.project
|
||||||
|
**/.settings
|
||||||
|
**/.toolstarget
|
||||||
|
**/.vs
|
||||||
|
**/.vscode
|
||||||
|
**/*.*proj.user
|
||||||
|
**/*.dbmdl
|
||||||
|
**/*.jfm
|
||||||
|
**/azds.yaml
|
||||||
|
**/bin
|
||||||
|
**/charts
|
||||||
|
**/docker-compose*
|
||||||
|
**/Dockerfile*
|
||||||
|
**/node_modules
|
||||||
|
**/npm-debug.log
|
||||||
|
**/obj
|
||||||
|
**/secrets.dev.yaml
|
||||||
|
**/values.dev.yaml
|
||||||
|
LICENSE
|
||||||
|
README.md
|
||||||
|
!**/.gitignore
|
||||||
|
!.git/HEAD
|
||||||
|
!.git/config
|
||||||
|
!.git/packed-refs
|
||||||
|
!.git/refs/heads/**
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
## ==========================================
|
||||||
|
## 1. Fichiers de compilation & Cache .NET
|
||||||
|
## ==========================================
|
||||||
|
**/bin/
|
||||||
|
**/obj/
|
||||||
|
**/out/
|
||||||
|
|
||||||
|
## ==========================================
|
||||||
|
## 2. Visual Studio & IDE (VS Code, JetBrains)
|
||||||
|
## ==========================================
|
||||||
|
.vs/
|
||||||
|
.vscode/
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
## ==========================================
|
||||||
|
## 3. Packages NuGet temporaires
|
||||||
|
## ==========================================
|
||||||
|
nupkgs/
|
||||||
|
*.nupkg
|
||||||
|
*.snupkg
|
||||||
|
|
||||||
|
## ==========================================
|
||||||
|
## 4. Fichiers système
|
||||||
|
## ==========================================
|
||||||
|
Thumbs.db
|
||||||
|
[Dd]esktop.ini
|
||||||
|
.DS_Store
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<base href="./" />
|
||||||
|
<link rel="stylesheet" href="HA_Shopping_List.Server.styles.css" />
|
||||||
|
<HeadOutlet />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body style="margin: 0; background-color: #f1f5f9; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;">
|
||||||
|
<Routes />
|
||||||
|
<script src="_framework/blazor.web.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
@inherits LayoutComponentBase
|
||||||
|
|
||||||
|
<div style="min-height: 100vh;">
|
||||||
|
@Body
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="blazor-error-ui" style="display: none; background: #fef2f2; color: #991b1b; padding: 0.75rem; position: fixed; bottom: 0; width: 100%; border-top: 1px solid #fecaca; text-align: center;">
|
||||||
|
Une erreur inattendue est survenue.
|
||||||
|
<a href="" style="color: #0284c7; margin-left: 0.5rem;">Recharger</a>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#blazor-error-ui {
|
||||||
|
background: lightyellow;
|
||||||
|
bottom: 0;
|
||||||
|
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
|
||||||
|
display: none;
|
||||||
|
left: 0;
|
||||||
|
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
|
||||||
|
position: fixed;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
#blazor-error-ui .dismiss {
|
||||||
|
cursor: pointer;
|
||||||
|
position: absolute;
|
||||||
|
right: 0.75rem;
|
||||||
|
top: 0.5rem;
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
@page "/Error"
|
||||||
|
@using System.Diagnostics
|
||||||
|
|
||||||
|
<PageTitle>Error</PageTitle>
|
||||||
|
|
||||||
|
<h1 class="text-danger">Error.</h1>
|
||||||
|
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||||
|
|
||||||
|
@if (ShowRequestId)
|
||||||
|
{
|
||||||
|
<p>
|
||||||
|
<strong>Request ID:</strong> <code>@RequestId</code>
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
<h3>Development Mode</h3>
|
||||||
|
<p>
|
||||||
|
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
||||||
|
It can result in displaying sensitive information from exceptions to end users.
|
||||||
|
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
||||||
|
and restarting the app.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
@code{
|
||||||
|
[CascadingParameter]
|
||||||
|
private HttpContext? HttpContext { get; set; }
|
||||||
|
|
||||||
|
private string? RequestId { get; set; }
|
||||||
|
private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||||
|
|
||||||
|
protected override void OnInitialized() =>
|
||||||
|
RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
|
||||||
|
}
|
||||||
@@ -0,0 +1,445 @@
|
|||||||
|
@page "/"
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
@using HA_Shopping_List.Server.Data
|
||||||
|
@using HA_Shopping_List.Server.Enum
|
||||||
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@inject IDbContextFactory<AppDbContext> DbFactory
|
||||||
|
|
||||||
|
<PageTitle>Liste de Courses</PageTitle>
|
||||||
|
|
||||||
|
<div style="max-width: 760px; margin: 1rem auto; padding: 0 1rem;">
|
||||||
|
<!-- En-tête -->
|
||||||
|
<h2 style="color: #0f172a; margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem;">
|
||||||
|
🛒 <span>Courses de la Maison</span>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<!-- Navigation par 3 onglets en partie haute -->
|
||||||
|
<div style="display: flex; gap: 0.5rem; margin-bottom: 1.25rem; border-bottom: 2px solid #e2e8f0; padding-bottom: 0.5rem;">
|
||||||
|
<button type="button" @onclick="() => currentTab = Tab.ShoppingList"
|
||||||
|
style="flex: 1; padding: 0.65rem 0.5rem; border: none; border-radius: 6px; font-weight: bold; cursor: pointer; transition: all 0.2s;
|
||||||
|
background: @(currentTab == Tab.ShoppingList ? "#0284c7" : "#e2e8f0");
|
||||||
|
color: @(currentTab == Tab.ShoppingList ? "#ffffff" : "#475569");">
|
||||||
|
📝 Liste de courses (@activeItems.Count)
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button type="button" @onclick="() => currentTab = Tab.Cart"
|
||||||
|
style="flex: 1; padding: 0.65rem 0.5rem; border: none; border-radius: 6px; font-weight: bold; cursor: pointer; transition: all 0.2s;
|
||||||
|
background: @(currentTab == Tab.Cart ? "#0284c7" : "#e2e8f0");
|
||||||
|
color: @(currentTab == Tab.Cart ? "#ffffff" : "#475569");">
|
||||||
|
🛒 Dans le chariot (@cartItems.Count)
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button type="button" @onclick="() => currentTab = Tab.History"
|
||||||
|
style="flex: 1; padding: 0.65rem 0.5rem; border: none; border-radius: 6px; font-weight: bold; cursor: pointer; transition: all 0.2s;
|
||||||
|
background: @(currentTab == Tab.History ? "#0284c7" : "#e2e8f0");
|
||||||
|
color: @(currentTab == Tab.History ? "#ffffff" : "#475569");">
|
||||||
|
🕒 Historique (@historySuggestions.Count)
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ========================================== -->
|
||||||
|
<!-- ONGLET 1 : LISTE DE COURSES -->
|
||||||
|
<!-- ========================================== -->
|
||||||
|
@if (currentTab == Tab.ShoppingList)
|
||||||
|
{
|
||||||
|
<!-- Formulaire d'ajout rapide avec autocomplétion issue de l'historique -->
|
||||||
|
<div style="background: #ffffff; border: 1px solid #cbd5e1; border-radius: 8px; padding: 1rem; margin-bottom: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05);">
|
||||||
|
<div style="display: flex; gap: 0.5rem; flex-wrap: wrap;">
|
||||||
|
<!-- Champ avec datalist liée à l'historique -->
|
||||||
|
<input type="text"
|
||||||
|
list="historySuggestionsList"
|
||||||
|
@bind="newItemName"
|
||||||
|
placeholder="Ajouter un article (ex: Lait, Pommes, Café...)"
|
||||||
|
style="flex: 3; min-width: 200px; padding: 0.55rem; border: 1px solid #cbd5e1; border-radius: 6px;" />
|
||||||
|
<datalist id="historySuggestionsList">
|
||||||
|
@foreach (var suggestion in historySuggestions)
|
||||||
|
{
|
||||||
|
<option value="@suggestion"></option>
|
||||||
|
}
|
||||||
|
</datalist>
|
||||||
|
|
||||||
|
<!-- Quantité -->
|
||||||
|
<input type="number"
|
||||||
|
@bind="newItemQuantity"
|
||||||
|
min="1"
|
||||||
|
style="width: 60px; padding: 0.55rem; border: 1px solid #cbd5e1; border-radius: 6px; text-align: center;" />
|
||||||
|
|
||||||
|
<button type="button"
|
||||||
|
@onclick="AddItem"
|
||||||
|
style="background: #16a34a; color: white; border: none; padding: 0.55rem 1.25rem; border-radius: 6px; font-weight: bold; cursor: pointer;">
|
||||||
|
+ Ajouter
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Liste des articles à acheter -->
|
||||||
|
<div style="background: #ffffff; border: 1px solid #cbd5e1; border-radius: 8px; padding: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05);">
|
||||||
|
@if (!activeItems.Any())
|
||||||
|
{
|
||||||
|
<div style="text-align: center; color: #64748b; padding: 2rem 0;">
|
||||||
|
La liste est vide ! Utilisez le champ ci-dessus ou piochez dans l'historique.
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@foreach (var item in activeItems)
|
||||||
|
{
|
||||||
|
<div style="display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0; border-bottom: 1px solid #f1f5f9;">
|
||||||
|
<div>
|
||||||
|
<span style="font-weight: 600; color: #1e293b; font-size: 1.05rem;">@item.Name</span>
|
||||||
|
@if (item.Quantity > 1)
|
||||||
|
{
|
||||||
|
<span style="background: #e2e8f0; color: #334155; font-size: 0.8rem; padding: 0.15rem 0.5rem; border-radius: 12px; margin-left: 0.5rem; font-weight: bold;">
|
||||||
|
x@(item.Quantity)
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="display: flex; align-items: center; gap: 0.5rem;">
|
||||||
|
<!-- Contrôles de quantité (- et +) -->
|
||||||
|
<div style="display: flex; align-items: center; background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 6px; padding: 0.15rem;">
|
||||||
|
<button type="button"
|
||||||
|
@onclick="() => DecreaseQuantity(item)"
|
||||||
|
title="Diminuer la quantité"
|
||||||
|
style="background: transparent; border: none; color: #475569; width: 28px; height: 28px; font-weight: bold; font-size: 1rem; cursor: pointer; border-radius: 4px; display: flex; align-items: center; justify-content: center;">
|
||||||
|
-
|
||||||
|
</button>
|
||||||
|
<span style="font-weight: 600; min-width: 24px; text-align: center; font-size: 0.95rem; color: #1e293b;">
|
||||||
|
@item.Quantity
|
||||||
|
</span>
|
||||||
|
<button type="button"
|
||||||
|
@onclick="() => IncreaseQuantity(item)"
|
||||||
|
title="Augmenter la quantité"
|
||||||
|
style="background: transparent; border: none; color: #475569; width: 28px; height: 28px; font-weight: bold; font-size: 1rem; cursor: pointer; border-radius: 4px; display: flex; align-items: center; justify-content: center;">
|
||||||
|
+
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Mettre dans le panier -->
|
||||||
|
<button type="button"
|
||||||
|
@onclick="() => MoveToCart(item)"
|
||||||
|
title="Mettre dans le chariot"
|
||||||
|
style="background: #0284c7; color: white; border: none; padding: 0.45rem 0.8rem; border-radius: 6px; cursor: pointer; font-weight: 500;">
|
||||||
|
🛒 Au chariot
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Supprimer de la liste -->
|
||||||
|
<button type="button"
|
||||||
|
@onclick="() => RemoveActiveItem(item)"
|
||||||
|
title="Supprimer"
|
||||||
|
style="background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; padding: 0.45rem 0.65rem; border-radius: 6px; cursor: pointer;">
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<!-- ========================================== -->
|
||||||
|
<!-- ONGLET 2 : DANS LE CHARIOT -->
|
||||||
|
<!-- ========================================== -->
|
||||||
|
@if (currentTab == Tab.Cart)
|
||||||
|
{
|
||||||
|
<div style="background: #ffffff; border: 1px solid #cbd5e1; border-radius: 8px; padding: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05);">
|
||||||
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; border-bottom: 1px solid #e2e8f0; padding-bottom: 0.75rem;">
|
||||||
|
<h4 style="margin: 0; color: #1e293b;">Articles actuellement dans le panier</h4>
|
||||||
|
@if (cartItems.Any())
|
||||||
|
{
|
||||||
|
<button type="button"
|
||||||
|
@onclick="ClearCartAndArchive"
|
||||||
|
style="background: #dc2626; color: white; border: none; padding: 0.5rem 1rem; border-radius: 6px; cursor: pointer; font-weight: bold;">
|
||||||
|
🗑️ Vider le chariot
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (!cartItems.Any())
|
||||||
|
{
|
||||||
|
<div style="text-align: center; color: #64748b; padding: 2rem 0;">
|
||||||
|
Votre chariot est vide pour l'instant.
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@foreach (var item in cartItems)
|
||||||
|
{
|
||||||
|
<div style="display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0; border-bottom: 1px solid #f1f5f9;">
|
||||||
|
<div>
|
||||||
|
<span style="text-decoration: line-through; color: #64748b; font-size: 1rem;">@item.Name</span>
|
||||||
|
@if (item.Quantity > 1)
|
||||||
|
{
|
||||||
|
<span style="color: #94a3b8; font-size: 0.8rem; margin-left: 0.4rem;">(x@(item.Quantity))</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<button type="button"
|
||||||
|
@onclick="() => ReturnToList(item)"
|
||||||
|
title="Remettre dans la liste"
|
||||||
|
style="background: #f8fafc; border: 1px solid #cbd5e1; color: #475569; padding: 0.35rem 0.65rem; border-radius: 6px; cursor: pointer; font-size: 0.85rem;">
|
||||||
|
↩ Remettre en liste
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<!-- ========================================== -->
|
||||||
|
<!-- ONGLET 3 : HISTORIQUE -->
|
||||||
|
<!-- ========================================== -->
|
||||||
|
@if (currentTab == Tab.History)
|
||||||
|
{
|
||||||
|
<div style="background: #ffffff; border: 1px solid #cbd5e1; border-radius: 8px; padding: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05);">
|
||||||
|
<!-- Barre de recherche -->
|
||||||
|
<div style="margin-bottom: 1rem;">
|
||||||
|
<input type="text"
|
||||||
|
@bind="searchQuery"
|
||||||
|
@bind:event="oninput"
|
||||||
|
placeholder="🔍 Rechercher dans l'historique des achats..."
|
||||||
|
style="width: 100%; padding: 0.6rem; border: 1px solid #cbd5e1; border-radius: 6px; box-sizing: border-box;" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@{
|
||||||
|
var filteredHistory = string.IsNullOrWhiteSpace(searchQuery)
|
||||||
|
? historyItems
|
||||||
|
: historyItems.Where(h => h.Name.Contains(searchQuery, StringComparison.OrdinalIgnoreCase)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (!filteredHistory.Any())
|
||||||
|
{
|
||||||
|
<div style="text-align: center; color: #64748b; padding: 2rem 0;">
|
||||||
|
Aucun article trouvé dans l'historique.
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@foreach (var item in filteredHistory)
|
||||||
|
{
|
||||||
|
<div style="display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0; border-bottom: 1px solid #f1f5f9;">
|
||||||
|
<div>
|
||||||
|
<strong style="color: #1e293b;">@item.Name</strong>
|
||||||
|
<div style="font-size: 0.8rem; color: #94a3b8;">
|
||||||
|
Dernier achat : @item.LastPurchasedAt.ToString("dd/MM/yyyy")
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="display: flex; gap: 0.5rem;">
|
||||||
|
<button type="button"
|
||||||
|
@onclick="() => ReAddFromHistory(item)"
|
||||||
|
style="background: #0284c7; color: white; border: none; padding: 0.4rem 0.8rem; border-radius: 6px; cursor: pointer; font-weight: 500;">
|
||||||
|
+ Ajouter à la liste
|
||||||
|
</button>
|
||||||
|
<button type="button"
|
||||||
|
@onclick="() => DeleteFromHistory(item.Id)"
|
||||||
|
style="background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; padding: 0.4rem 0.6rem; border-radius: 6px; cursor: pointer;">
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private enum Tab { ShoppingList, Cart, History }
|
||||||
|
private Tab currentTab = Tab.ShoppingList;
|
||||||
|
|
||||||
|
private List<ShoppingItem> activeItems = new();
|
||||||
|
private List<ShoppingItem> cartItems = new();
|
||||||
|
private List<ShoppingItem> historyItems = new();
|
||||||
|
private List<string> historySuggestions = new();
|
||||||
|
|
||||||
|
private string newItemName = string.Empty;
|
||||||
|
private int newItemQuantity = 1;
|
||||||
|
private string searchQuery = string.Empty;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
await LoadAllData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadAllData()
|
||||||
|
{
|
||||||
|
using var db = await DbFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
|
var all = await db.Items.ToListAsync();
|
||||||
|
|
||||||
|
activeItems = all.Where(i => i.Status == ShoppingItemStatus.Active)
|
||||||
|
.OrderBy(i => i.Name)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
cartItems = all.Where(i => i.Status == ShoppingItemStatus.InCart)
|
||||||
|
.OrderBy(i => i.Name)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
// L'historique regroupe les articles par nom distinct pour l'affichage et l'autocomplétion
|
||||||
|
historyItems = all.GroupBy(i => i.Name.Trim().ToLowerInvariant())
|
||||||
|
.Select(g => g.OrderByDescending(x => x.LastPurchasedAt).First())
|
||||||
|
.OrderBy(i => i.Name)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
historySuggestions = historyItems.Select(h => h.Name).ToList();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task AddItem()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(newItemName)) return;
|
||||||
|
|
||||||
|
using var db = await DbFactory.CreateDbContextAsync();
|
||||||
|
var normalizedName = newItemName.Trim();
|
||||||
|
|
||||||
|
// Vérifie si l'article est déjà présent dans la liste active
|
||||||
|
var existingActive = await db.Items.FirstOrDefaultAsync(i =>
|
||||||
|
i.Status == ShoppingItemStatus.Active &&
|
||||||
|
i.Name.ToLower() == normalizedName.ToLower());
|
||||||
|
|
||||||
|
if (existingActive != null)
|
||||||
|
{
|
||||||
|
existingActive.Quantity += newItemQuantity;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
db.Items.Add(new ShoppingItem
|
||||||
|
{
|
||||||
|
Name = normalizedName,
|
||||||
|
Quantity = newItemQuantity,
|
||||||
|
Status = ShoppingItemStatus.Active,
|
||||||
|
LastPurchasedAt = DateTime.Now
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
|
||||||
|
newItemName = string.Empty;
|
||||||
|
newItemQuantity = 1;
|
||||||
|
await LoadAllData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task MoveToCart(ShoppingItem item)
|
||||||
|
{
|
||||||
|
using var db = await DbFactory.CreateDbContextAsync();
|
||||||
|
var entity = await db.Items.FindAsync(item.Id);
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
entity.Status = ShoppingItemStatus.InCart;
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
await LoadAllData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ReturnToList(ShoppingItem item)
|
||||||
|
{
|
||||||
|
using var db = await DbFactory.CreateDbContextAsync();
|
||||||
|
var entity = await db.Items.FindAsync(item.Id);
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
entity.Status = ShoppingItemStatus.Active;
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
await LoadAllData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RemoveActiveItem(ShoppingItem item)
|
||||||
|
{
|
||||||
|
using var db = await DbFactory.CreateDbContextAsync();
|
||||||
|
var entity = await db.Items.FindAsync(item.Id);
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
// Passe en statut Purchased pour rester consultable dans l'historique
|
||||||
|
entity.Status = ShoppingItemStatus.Purchased;
|
||||||
|
entity.LastPurchasedAt = DateTime.Now;
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
await LoadAllData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ClearCartAndArchive()
|
||||||
|
{
|
||||||
|
using var db = await DbFactory.CreateDbContextAsync();
|
||||||
|
var inCart = await db.Items.Where(i => i.Status == ShoppingItemStatus.InCart).ToListAsync();
|
||||||
|
|
||||||
|
foreach (var item in inCart)
|
||||||
|
{
|
||||||
|
item.Status = ShoppingItemStatus.Purchased;
|
||||||
|
item.LastPurchasedAt = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
await LoadAllData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ReAddFromHistory(ShoppingItem item)
|
||||||
|
{
|
||||||
|
using var db = await DbFactory.CreateDbContextAsync();
|
||||||
|
var existingActive = await db.Items.FirstOrDefaultAsync(i =>
|
||||||
|
i.Status == ShoppingItemStatus.Active &&
|
||||||
|
i.Name.ToLower() == item.Name.ToLower());
|
||||||
|
|
||||||
|
if (existingActive != null)
|
||||||
|
{
|
||||||
|
existingActive.Quantity += 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
db.Items.Add(new ShoppingItem
|
||||||
|
{
|
||||||
|
Name = item.Name,
|
||||||
|
Quantity = 1,
|
||||||
|
Status = ShoppingItemStatus.Active,
|
||||||
|
LastPurchasedAt = DateTime.Now
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
await LoadAllData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteFromHistory(int id)
|
||||||
|
{
|
||||||
|
using var db = await DbFactory.CreateDbContextAsync();
|
||||||
|
var entity = await db.Items.FindAsync(id);
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
db.Items.Remove(entity);
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
await LoadAllData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task IncreaseQuantity(ShoppingItem item)
|
||||||
|
{
|
||||||
|
using var db = await DbFactory.CreateDbContextAsync();
|
||||||
|
var entity = await db.Items.FindAsync(item.Id);
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
entity.Quantity++;
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
await LoadAllData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DecreaseQuantity(ShoppingItem item)
|
||||||
|
{
|
||||||
|
using var db = await DbFactory.CreateDbContextAsync();
|
||||||
|
var entity = await db.Items.FindAsync(item.Id);
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
if (entity.Quantity > 1)
|
||||||
|
{
|
||||||
|
entity.Quantity--;
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Si la quantité passe en dessous de 1, l'article est retiré de la liste active vers l'historique
|
||||||
|
await RemoveActiveItem(item);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await LoadAllData();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<Router AppAssembly="typeof(Program).Assembly">
|
||||||
|
<Found Context="routeData">
|
||||||
|
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" />
|
||||||
|
<FocusOnNavigate RouteData="routeData" Selector="h1" />
|
||||||
|
</Found>
|
||||||
|
</Router>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
@using System.Net.Http
|
||||||
|
@using System.Net.Http.Json
|
||||||
|
@using Microsoft.AspNetCore.Components.Forms
|
||||||
|
@using Microsoft.AspNetCore.Components.Routing
|
||||||
|
@using Microsoft.AspNetCore.Components.Web
|
||||||
|
@using static Microsoft.AspNetCore.Components.Web.RenderMode
|
||||||
|
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
||||||
|
@using Microsoft.JSInterop
|
||||||
|
@using HA_Shopping_List.Server
|
||||||
|
@using HA_Shopping_List.Server.Components
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Reflection.Emit;
|
||||||
|
|
||||||
|
namespace HA_Shopping_List.Server.Data
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Classe AppDbContext.
|
||||||
|
/// Implémente le <see cref="DbContext" />
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="DbContext" />
|
||||||
|
public class AppDbContext : DbContext
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initialise une nouvelle instance de la classe <see cref="AppDbContext"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options">L'options.</param>
|
||||||
|
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Obtient le items.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>La valeur "items"</value>
|
||||||
|
public DbSet<ShoppingItem> Items => Set<ShoppingItem>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Appelé lorsque [model creating].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modelBuilder">Le model builder.</param>
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
base.OnModelCreating(modelBuilder);
|
||||||
|
modelBuilder.Entity<ShoppingItem>()
|
||||||
|
.HasIndex(i => i.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
using HA_Shopping_List.Server.Enum;
|
||||||
|
|
||||||
|
namespace HA_Shopping_List.Server.Data
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Classe ShoppingItem.
|
||||||
|
/// </summary>
|
||||||
|
public class ShoppingItem
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Obtient ou définit le identifier.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>La valeur "identifier"</value>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Obtient ou définit le name.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>La valeur "name"</value>
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Obtient ou définit le quantity.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>La valeur "quantity"</value>
|
||||||
|
public int Quantity { get; set; } = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Obtient ou définit le unit.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>La valeur "unit"</value>
|
||||||
|
public string? Unit { get; set; } // Ex: kg, pack, bouteille, ou null
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Obtient ou définit le status.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>La valeur "status"</value>
|
||||||
|
public ShoppingItemStatus Status { get; set; } = ShoppingItemStatus.Active;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Obtient ou définit le last purchased at.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>La valeur "last purchased at"</value>
|
||||||
|
public DateTime LastPurchasedAt { get; set; } = DateTime.Now;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
RUN mkdir -p /data && chmod 777 /data
|
||||||
|
EXPOSE 8099
|
||||||
|
ENV ASPNETCORE_URLS=http://+:8099
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["HA_Shopping_List.Server/HA_Shopping_List.Server.csproj", "HA_Shopping_List.Server/"]
|
||||||
|
RUN dotnet restore "./HA_Shopping_List.Server/HA_Shopping_List.Server.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/HA_Shopping_List.Server"
|
||||||
|
RUN dotnet build "./HA_Shopping_List.Server.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
RUN dotnet publish "./HA_Shopping_List.Server.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "HA_Shopping_List.Server.dll"]
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
namespace HA_Shopping_List.Server.Enum
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Énumération ShoppingItemStatus
|
||||||
|
/// </summary>
|
||||||
|
public enum ShoppingItemStatus
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Le Active.
|
||||||
|
/// </summary>
|
||||||
|
Active = 0, // Dans la liste de courses
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Le In cart.
|
||||||
|
/// </summary>
|
||||||
|
InCart = 1, // Dans le chariot
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Le Purchased.
|
||||||
|
/// </summary>
|
||||||
|
Purchased = 2 // Acheté / uniquement dans l'historique
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.33">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.33" />
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.24.2-preview.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
using HA_Shopping_List.Server.Components;
|
||||||
|
using HA_Shopping_List.Server.Data;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
// Blazor Server interactif
|
||||||
|
builder.Services.AddRazorComponents()
|
||||||
|
.AddInteractiveServerComponents(options => options.DetailedErrors = true);
|
||||||
|
|
||||||
|
// Persistance dans /data (Home Assistant) ou dans le dossier local en Dev
|
||||||
|
var dbFolder = Directory.Exists("/data") ? "/data" : AppContext.BaseDirectory;
|
||||||
|
Directory.CreateDirectory(dbFolder);
|
||||||
|
var dbPath = Path.Combine(dbFolder, "shopping.db");
|
||||||
|
|
||||||
|
builder.Services.AddDbContextFactory<AppDbContext>(options =>
|
||||||
|
options.UseSqlite($"Data Source={dbPath}"));
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
// Création automatique de la base SQLite au démarrage
|
||||||
|
using (var scope = app.Services.CreateScope())
|
||||||
|
{
|
||||||
|
var factory = scope.ServiceProvider.GetRequiredService<IDbContextFactory<AppDbContext>>();
|
||||||
|
using var db = factory.CreateDbContext();
|
||||||
|
db.Database.EnsureCreated();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
app.Use(async (context, next) =>
|
||||||
|
{
|
||||||
|
context.Response.Headers.Append("Permissions-Policy", "unload=(self)");
|
||||||
|
await next();
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Gestion du préfixe dynamique Ingress de Home Assistant
|
||||||
|
app.Use(async (context, next) =>
|
||||||
|
{
|
||||||
|
if (context.Request.Headers.TryGetValue("X-Ingress-Path", out var ingressPath))
|
||||||
|
{
|
||||||
|
context.Request.PathBase = ingressPath.ToString();
|
||||||
|
}
|
||||||
|
await next();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
app.UseStaticFiles();
|
||||||
|
app.UseAntiforgery();
|
||||||
|
|
||||||
|
app.MapRazorComponents<App>()
|
||||||
|
.AddInteractiveServerRenderMode();
|
||||||
|
|
||||||
|
// Port Ingress standard
|
||||||
|
app.Run("http://0.0.0.0:8099");
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"applicationUrl": "http://localhost:8099"
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Container (Dockerfile)": {
|
||||||
|
"commandName": "Docker",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_HTTP_PORTS": "8099"
|
||||||
|
},
|
||||||
|
"publishAllPorts": true,
|
||||||
|
"useSSL": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:33927",
|
||||||
|
"sslPort": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
h1:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.valid.modified:not([type=checkbox]) {
|
||||||
|
outline: 1px solid #26b050;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invalid {
|
||||||
|
outline: 1px solid #e50000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.validation-message {
|
||||||
|
color: #e50000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.blazor-error-boundary {
|
||||||
|
background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
|
||||||
|
padding: 1rem 1rem 1rem 3.7rem;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.blazor-error-boundary::after {
|
||||||
|
content: "An error has occurred."
|
||||||
|
}
|
||||||
|
|
||||||
|
.darker-border-checkbox.form-check-input {
|
||||||
|
border-color: #929292;
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 264 KiB |
@@ -0,0 +1,7 @@
|
|||||||
|
<Solution>
|
||||||
|
<Folder Name="/Éléments de solution/">
|
||||||
|
<File Path="docker_launch.ps1" />
|
||||||
|
<File Path="publish.ps1" />
|
||||||
|
</Folder>
|
||||||
|
<Project Path="HA_Shopping_List.Server/HA_Shopping_List.Server.csproj" />
|
||||||
|
</Solution>
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
function Start-DockerDesktop {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter()]
|
||||||
|
[string]$Path = "$env:ProgramFiles\Docker\Docker\Docker Desktop.exe",
|
||||||
|
|
||||||
|
[Parameter()]
|
||||||
|
[int]$TimeoutSeconds = 120
|
||||||
|
)
|
||||||
|
|
||||||
|
if (-not (Test-Path $Path)) {
|
||||||
|
Write-Error "Docker Desktop est introuvable au chemin : $Path"
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
|
||||||
|
$dockerProcess = Get-Process -Name "Docker Desktop" -ErrorAction SilentlyContinue
|
||||||
|
if ($null -eq $dockerProcess) {
|
||||||
|
Write-Host "Démarrage de Docker Desktop..." -ForegroundColor Cyan
|
||||||
|
Start-Process -FilePath $Path
|
||||||
|
} else {
|
||||||
|
Write-Host "Le processus Docker Desktop est déjà en cours." -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "En attente du moteur Docker..." -NoNewline
|
||||||
|
$elapsed = 0
|
||||||
|
$interval = 2
|
||||||
|
|
||||||
|
while ($elapsed -lt $TimeoutSeconds) {
|
||||||
|
cmd.exe /c "docker info >nul 2>&1"
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
Write-Host " Prêt !" -ForegroundColor Green
|
||||||
|
docker --version
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
|
||||||
|
Start-Sleep -Seconds $interval
|
||||||
|
Write-Host "." -NoNewline
|
||||||
|
$elapsed += $interval
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Warning "Le moteur Docker n'a pas répondu dans le délai imparti ($TimeoutSeconds s)."
|
||||||
|
return $false
|
||||||
|
}
|
||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
# S'assurer que le script s'arrête immédiatement en cas d'erreur
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
. "$PSScriptRoot\docker_launch.ps1"
|
||||||
|
|
||||||
|
Write-Host "=== 1/5. Demarage de docker ===" -ForegroundColor Cyan
|
||||||
|
Start-DockerDesktop
|
||||||
|
|
||||||
|
$RegistryUrl = "gitea.mragot1408.synology.me"
|
||||||
|
$User = "admin_gitea"
|
||||||
|
$Pass = "Z7Q2kKELozwno0Eve8b4FYnlCw"
|
||||||
|
$ImageName = "hashoppinglist"
|
||||||
|
$VersionNumber = "1.0.0"
|
||||||
|
$Version = "latest"
|
||||||
|
|
||||||
|
|
||||||
|
Write-Host "`n=== 2/5. Nettoyage et Compilation de la Solution (Release | Any CPU) ===" -ForegroundColor Cyan
|
||||||
|
dotnet restore
|
||||||
|
docker login https://$RegistryUrl -u $User -p $Pass
|
||||||
|
|
||||||
|
Write-Host "`n=== 3/5. Build de Blazor / Docker ===" -ForegroundColor Cyan
|
||||||
|
dotnet build ./HA_Shopping_List.Server/HA_Shopping_List.Server.csproj --configuration Release -p:Platform="Any CPU"
|
||||||
|
|
||||||
|
# Format obligatoire pour Gitea : Domaine/Utilisateur/NomImage (en minuscules)
|
||||||
|
$FullImage = "gitea.mragot1408.synology.me/$($User.ToLower())/$($ImageName.ToLower())"
|
||||||
|
|
||||||
|
Write-Host "`n=== 4/5. Publication du Blazor / Docker ===" -ForegroundColor Cyan
|
||||||
|
docker build --no-cache `
|
||||||
|
-t "${FullImage}:${VersionNumber}" `
|
||||||
|
-t "${FullImage}:${Version}" `
|
||||||
|
-f ./HA_Shopping_List.Server/Dockerfile .
|
||||||
|
|
||||||
|
Write-Host "`n=== 5/5. Push du Blazor ===" -ForegroundColor Cyan
|
||||||
|
docker push "${FullImage}:${VersionNumber}"
|
||||||
|
docker push "${FullImage}:${Version}"
|
||||||
|
|
||||||
|
Write-Host "`n==========================================" -ForegroundColor Green
|
||||||
|
Write-Host " Terminé avec succès !" -ForegroundColor Green
|
||||||
|
Write-Host "==========================================" -ForegroundColor Green
|
||||||
Reference in new issue
Block a user