Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d0999e2bb4 | |||
| d5f034e47f | |||
| 4a0c080ad0 | |||
| b6f5f602bd | |||
| 891fee7c11 |
26
.gitignore
vendored
Normal file
26
.gitignore
vendored
Normal 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
9
Dockerfile
Normal 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
129
README.md
Normal 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).
|
||||
|
||||
@@ -1 +1 @@
|
||||
155.34
|
||||
0.79
|
||||
@@ -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-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
|
||||
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
|
||||
2024-12-14T14:13:51.235Z,0.00,[{"montant":-1.56,"quantite":1,"total":-1.56}],-1.56,-1.56
|
||||
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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 1 and column 33.
|
9
docker-compose.yml
Normal file
9
docker-compose.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
#version: '3.8'
|
||||
services:
|
||||
calculateur_prix:
|
||||
build: .
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- ./data:/app/data
|
||||
restart: always
|
||||
@@ -7,7 +7,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
const addRowButton = document.getElementById("add-row");
|
||||
const saveButton = document.getElementById("save");
|
||||
|
||||
// Mettre à jour la date et l'heure
|
||||
// Mise à jour de la date et l'heure
|
||||
const updateDatetime = () => {
|
||||
const now = new Date();
|
||||
datetimeElement.textContent = now.toLocaleString("fr-FR");
|
||||
@@ -32,6 +32,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
const montantInput = document.createElement("input");
|
||||
montantInput.type = "number";
|
||||
montantInput.step = "0.01";
|
||||
montantInput.inputMode = "decimal"; // Forcer le clavier numérique
|
||||
montantInput.placeholder = "0.00";
|
||||
montantCell.appendChild(montantInput);
|
||||
|
||||
@@ -50,16 +51,16 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
const totalCell = document.createElement("td");
|
||||
totalCell.textContent = "0.00 €";
|
||||
|
||||
// Bouton Option
|
||||
// Radio Option
|
||||
const optionCell = document.createElement("td");
|
||||
const optionButton = document.createElement("button");
|
||||
optionButton.textContent = "Option";
|
||||
optionButton.addEventListener("click", () => {
|
||||
const radioInput = document.createElement("input");
|
||||
radioInput.type = "radio";
|
||||
radioInput.addEventListener("change", () => {
|
||||
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();
|
||||
});
|
||||
optionCell.appendChild(optionButton);
|
||||
optionCell.appendChild(radioInput);
|
||||
|
||||
// Calculer le total de la ligne
|
||||
const updateRowTotal = () => {
|
||||
|
||||
@@ -42,7 +42,7 @@ body {
|
||||
right: 15px;
|
||||
z-index: 2000;
|
||||
padding: 10px 22px;
|
||||
background-color: #007bff; /* Bleu */
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
@@ -72,37 +72,33 @@ body {
|
||||
}
|
||||
|
||||
#articles-table {
|
||||
width: calc(100% - 20px);
|
||||
max-width: 600px;
|
||||
width: 100%; /* Ajuste la table à 100% de la zone disponible */
|
||||
border-collapse: collapse;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
#articles-table th, #articles-table td {
|
||||
#articles-table th,
|
||||
#articles-table td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 12px;
|
||||
padding: 8px;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
font-size: 14px; /* Taille plus petite pour éviter les débordements */
|
||||
}
|
||||
|
||||
#articles-table th {
|
||||
width: 25%;
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
#articles-table td input {
|
||||
#articles-table td input,
|
||||
#articles-table td select {
|
||||
padding: 5px;
|
||||
font-size: 16px; /* Taille réduite */
|
||||
width: 90%;
|
||||
font-size: 16px;
|
||||
box-sizing: border-box; /* Pour garantir que la largeur reste contrôlée */
|
||||
}
|
||||
|
||||
#articles-table td button {
|
||||
background-color: #ffc107;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
color: white;
|
||||
#articles-table td input[type="radio"] {
|
||||
cursor: pointer;
|
||||
padding: 5px 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#articles-table tbody tr:nth-child(even) {
|
||||
|
||||
14
readme.md
14
readme.md
@@ -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>
|
||||
Reference in New Issue
Block a user