Compare commits

5 Commits
master ... main

9 changed files with 196 additions and 48 deletions

26
.gitignore vendored Normal file
View File

@@ -0,0 +1,26 @@
# Node.js
node_modules/
npm-debug.log
yarn-error.log
# Logs
logs/
*.log
# Dependency directories
jspm_packages/
# TypeScript
*.tsbuildinfo
# IDE files
.vscode/
.idea/
*.suo
*.ntvs*
*.njsproj
*.sln
# Build directories
dist/
build/

9
Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM node:16
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]

129
README.md Normal file
View File

@@ -0,0 +1,129 @@
# Calculateur de Prix
Ce projet est une application web permettant de suivre et de calculer des montants d'articles avec un historique sauvegardé dans des fichiers. L'application utilise Node.js pour le backend et une interface utilisateur simple avec HTML, CSS et JavaScript.
---
## Prérequis
1. **Node.js** (v16 ou supérieur) : [Télécharger Node.js](https://nodejs.org/)
2. **Git** : [Télécharger Git](https://git-scm.com/)
3. **Docker** (pour le déploiement avec conteneurisation) : [Installer Docker](https://www.docker.com/)
---
## Installation
### Étape 1 : Cloner le dépôt
```bash
# Remplacez l'URL par celle de votre dépôt
git clone http://10.0.0.20:3004/gilles/calculateur_prix.git
cd calculateur_prix
```
### Étape 2 : Installer les dépendances
```bash
npm install
```
### Étape 3 : Lancer l'application en local
```bash
node server.js
```
L'application sera accessible à l'adresse : [http://localhost:3000](http://localhost:3000)
---
## Sauvegarder à nouveau sur Git
### Étape 1 : Ajouter les modifications
```bash
git add .
```
### Étape 2 : Créer un commit
```bash
git commit -m "Votre message de commit"
```
### Étape 3 : Pousser les modifications vers le serveur Gitea
```bash
git push origin main
```
---
## Déploiement avec Docker
### Étape 1 : Créer une image Docker
Un fichier `Dockerfile` est inclus dans le projet.
Construisez l'image Docker :
```bash
docker build -t calculateur_prix .
```
### Étape 2 : Lancer un conteneur Docker
```bash
docker run -d -p 3000:3000 --name calculateur_prix -v $(pwd)/data:/app/data calculateur_prix
```
L'application sera accessible à l'adresse : [http://localhost:3000](http://localhost:3000)
### Étape 3 : Utiliser Docker Compose (Optionnel)
Un fichier `docker-compose.yml` est inclus pour simplifier le déploiement. Lancez le conteneur avec :
```bash
docker-compose up -d
```
---
## Structure des fichiers
- `server.js` : Serveur backend (Node.js).
- `public/` : Contient les fichiers frontend (HTML, CSS, JS).
- `data/` : Contient les fichiers de données (montant précédent et suivi).
- `Dockerfile` : Fichier pour construire l'image Docker.
- `docker-compose.yml` : Fichier de configuration pour Docker Compose.
---
## Contribution
1. Clonez le projet :
```bash
git clone http://10.0.0.20:3004/gilles/calculateur_prix.git
```
2. Créez une branche :
```bash
git checkout -b nom_de_branche
```
3. Faites vos modifications et ajoutez-les :
```bash
git add .
```
4. Faites un commit :
```bash
git commit -m "Description de vos modifications"
```
5. Poussez votre branche :
```bash
git push origin nom_de_branche
```
---
## Licence
Ce projet est sous licence [MIT](https://opensource.org/licenses/MIT).

View File

@@ -1 +1 @@
155.34 0.79

View File

@@ -1,10 +1,2 @@
2024-12-14T10:40:26.223Z,0.00,[{"montant":1.55,"quantite":2,"total":3.1},{"montant":2.36,"quantite":3,"total":7.08},{"montant":-10,"quantite":1,"total":-10},{"montant":3.56,"quantite":3,"total":10.68}],10.86,10.86 2024-12-14T14:13:51.235Z,0.00,[{"montant":-1.56,"quantite":1,"total":-1.56}],-1.56,-1.56
2024-12-14T10:41:47.522Z,10.86,[{"montant":25.68,"quantite":2,"total":51.36},{"montant":36.45,"quantite":3,"total":109.35000000000001},{"montant":-100,"quantite":1,"total":-100}],60.71,71.57 2025-01-03T08:22:53.450Z,-1.56,[{"montant":10,"quantite":1,"total":10},{"montant":2.35,"quantite":1,"total":2.35},{"montant":-5,"quantite":2,"total":-10}],2.35,0.79
2024-12-14T10:43:53.874Z,71.57,[{"montant":34.65,"quantite":2,"total":69.3}],69.30,140.87
2024-12-14T10:57:05.724Z,140.87,[{"montant":10,"quantite":1,"total":10},{"montant":-25,"quantite":1,"total":-25},{"montant":-36,"quantite":3,"total":-108}],-123.00,17.87
2024-12-14T11:55:54.185Z,17.87,[{"montant":25.56,"quantite":2,"total":51.12},{"montant":1.52,"quantite":1,"total":1.52},{"montant":36.52,"quantite":1,"total":36.52},{"montant":2,"quantite":1,"total":2}],91.16,109.03
2024-12-14T12:01:57.014Z,109.03,[{"montant":1.25,"quantite":1,"total":1.25},{"montant":2.3,"quantite":1,"total":2.3},{"montant":1.56,"quantite":1,"total":1.56},{"montant":2.36,"quantite":1,"total":2.36},{"montant":0,"quantite":1,"total":0}],7.47,116.50
2024-12-14T12:12:38.156Z,116.50,[{"montant":1.25,"quantite":2,"total":2.5},{"montant":1.85,"quantite":1,"total":1.85},{"montant":1.74,"quantite":1,"total":1.74},{"montant":2.58,"quantite":1,"total":2.58},{"montant":25,"quantite":1,"total":25}],33.67,150.17
2024-12-14T12:29:22.160Z,150.17,[{"montant":1.52,"quantite":1,"total":1.52},{"montant":1.32,"quantite":2,"total":2.64},{"montant":1.65,"quantite":1,"total":1.65},{"montant":1.36,"quantite":1,"total":1.36},{"montant":0,"quantite":1,"total":0}],7.17,157.34
2024-12-14T12:29:25.112Z,157.34,[],0.00,157.34
2024-12-14T12:38:37.997Z,157.34,[{"montant":-2,"quantite":1,"total":-2}],-2.00,155.34
Can't render this file because it contains an unexpected character in line 1 and column 33.

9
docker-compose.yml Normal file
View File

@@ -0,0 +1,9 @@
#version: '3.8'
services:
calculateur_prix:
build: .
ports:
- "3000:3000"
volumes:
- ./data:/app/data
restart: always

View File

@@ -7,7 +7,7 @@ document.addEventListener("DOMContentLoaded", () => {
const addRowButton = document.getElementById("add-row"); const addRowButton = document.getElementById("add-row");
const saveButton = document.getElementById("save"); const saveButton = document.getElementById("save");
// Mettre à jour la date et l'heure // Mise à jour de la date et l'heure
const updateDatetime = () => { const updateDatetime = () => {
const now = new Date(); const now = new Date();
datetimeElement.textContent = now.toLocaleString("fr-FR"); datetimeElement.textContent = now.toLocaleString("fr-FR");
@@ -32,6 +32,7 @@ document.addEventListener("DOMContentLoaded", () => {
const montantInput = document.createElement("input"); const montantInput = document.createElement("input");
montantInput.type = "number"; montantInput.type = "number";
montantInput.step = "0.01"; montantInput.step = "0.01";
montantInput.inputMode = "decimal"; // Forcer le clavier numérique
montantInput.placeholder = "0.00"; montantInput.placeholder = "0.00";
montantCell.appendChild(montantInput); montantCell.appendChild(montantInput);
@@ -50,16 +51,16 @@ document.addEventListener("DOMContentLoaded", () => {
const totalCell = document.createElement("td"); const totalCell = document.createElement("td");
totalCell.textContent = "0.00 €"; totalCell.textContent = "0.00 €";
// Bouton Option // Radio Option
const optionCell = document.createElement("td"); const optionCell = document.createElement("td");
const optionButton = document.createElement("button"); const radioInput = document.createElement("input");
optionButton.textContent = "Option"; radioInput.type = "radio";
optionButton.addEventListener("click", () => { radioInput.addEventListener("change", () => {
const montant = parseFloat(montantInput.value || "0"); const montant = parseFloat(montantInput.value || "0");
montantInput.value = montant > 0 ? -montant : Math.abs(montant); montantInput.value = radioInput.checked ? -Math.abs(montant) : Math.abs(montant);
updateRowTotal(); updateRowTotal();
}); });
optionCell.appendChild(optionButton); optionCell.appendChild(radioInput);
// Calculer le total de la ligne // Calculer le total de la ligne
const updateRowTotal = () => { const updateRowTotal = () => {

View File

@@ -42,7 +42,7 @@ body {
right: 15px; right: 15px;
z-index: 2000; z-index: 2000;
padding: 10px 22px; padding: 10px 22px;
background-color: #007bff; /* Bleu */ background-color: #007bff;
color: white; color: white;
border: none; border: none;
border-radius: 5px; border-radius: 5px;
@@ -72,37 +72,33 @@ body {
} }
#articles-table { #articles-table {
width: calc(100% - 20px); width: 100%; /* Ajuste la table à 100% de la zone disponible */
max-width: 600px;
border-collapse: collapse; border-collapse: collapse;
margin: auto; margin: auto;
} }
#articles-table th, #articles-table td { #articles-table th,
#articles-table td {
border: 1px solid #ddd; border: 1px solid #ddd;
padding: 12px; padding: 8px;
text-align: center; text-align: center;
font-size: 16px; font-size: 14px; /* Taille plus petite pour éviter les débordements */
} }
#articles-table th { #articles-table th {
width: 25%; width: 20%;
} }
#articles-table td input { #articles-table td input,
#articles-table td select {
padding: 5px; padding: 5px;
font-size: 16px; /* Taille réduite */
width: 90%; width: 90%;
font-size: 16px; box-sizing: border-box; /* Pour garantir que la largeur reste contrôlée */
} }
#articles-table td button { #articles-table td input[type="radio"] {
background-color: #ffc107;
border: none;
border-radius: 5px;
color: white;
cursor: pointer; cursor: pointer;
padding: 5px 10px;
font-size: 14px;
} }
#articles-table tbody tr:nth-child(even) { #articles-table tbody tr:nth-child(even) {

View File

@@ -1,14 +0,0 @@
# Calculateur de Prix
## 1. Description
Cette application est une interface web simple permettant de :
- Ajouter des articles avec leur montant, quantité et options.
- Calculer automatiquement le total des articles et le total final.
- Sauvegarder les données dans un fichier ou les transmettre à un serveur.
## 2. Déploiement
### Étapes pour exécuter l'application :
1. Clonez le projet sur votre machine :
```bash
git clone <url_du_dépôt>
cd <nom_du_dossier>