Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review and comments #171

Open
wants to merge 137 commits into
base: colin
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
be1792d
refactor: change repository (#1)
Rignchen Apr 8, 2024
70f6f43
feat: implement login (#5)
jordyBSK Apr 12, 2024
9042cb9
feat: launch everything from the same docker compose (#2)
Rignchen Apr 12, 2024
308e75f
Fix: fix a few issues on the backend (#6)
Rignchen May 31, 2024
7752bef
feat: plan canvas (#8)
jordyBSK Jun 3, 2024
d85de2d
feat: get the ip address when averaging the values with the avg_date …
Rignchen Jun 7, 2024
2b4b46f
feat: setup a sqitch to handle migrations (#23)
Rignchen Jun 10, 2024
a5214ed
fix: readme and use latest docker images (#24)
Rignchen Jun 10, 2024
3148fca
refactor: reposition php code in the folder (#25)
Rignchen Jun 10, 2024
b983d79
fix: install php stan (#26)
Rignchen Jun 11, 2024
6283251
Interface next js (#28)
jordyBSK Jun 18, 2024
ad260bc
Login (#29)
jordyBSK Jun 18, 2024
16af540
Get data.ts files (#30)
jordyBSK Jun 18, 2024
d94906a
refactor: renamed file type and function for better separation (#31)
Alex-zReeZ Jun 18, 2024
e095c1b
feat: implement logout (#32)
jordyBSK Jun 19, 2024
32d7886
add Esp table (#33)
jordyBSK Jun 19, 2024
5fd26f4
fix: redirect to login when we logout (#34)
jordyBSK Jun 19, 2024
f12bde6
sort data by room ip (#35)
jordyBSK Jun 19, 2024
48db262
Revert "sort data by room ip (#35)" (#36)
jordyBSK Jun 19, 2024
00d6c9e
Revert "Revert "sort data by room ip (#35)" (#36)" (#37)
jordyBSK Jun 19, 2024
6d4434c
Plan data (#38)
jordyBSK Jun 20, 2024
38e1aec
feat: added dynamic data in dashboard and esp pages (#39)
Alex-zReeZ Jun 21, 2024
f3ed78b
Date range (#40)
jordyBSK Jun 21, 2024
8ec2912
fix: fix import duplication (#41)
jordyBSK Jun 21, 2024
2be57e8
fix: change dockerfile to work with next js
Alex-zReeZ Jun 24, 2024
4a1417d
refactor: added new Ip adresse
Alex-zReeZ Jun 24, 2024
3db6d23
refactor: removed output and added distdir to out
Alex-zReeZ Jun 24, 2024
0d16c0f
refactor: reformated file
Alex-zReeZ Jun 24, 2024
8d04934
refactor: added new Ip adresse, rounded data, moved getColor file and…
Alex-zReeZ Jun 25, 2024
4197a28
refactor: Rounded data (#42)
Alex-zReeZ Jun 25, 2024
16a782f
fix: tofixed temperature in espmap
Jun 25, 2024
36315e8
feat: added Workflow to check the format and lint (#46)
Alex-zReeZ Jun 25, 2024
1619744
refactor: resolve conflit
Jun 25, 2024
d150924
Merge branch 'Dev' of github.com:museebolo/climat_guardian into Dev
Jun 25, 2024
fbf86e5
Merge remote-tracking branch 'upstream/Dev' into Dev
Alex-zReeZ Jun 25, 2024
27f2fc5
feat: serve interface using a nodejs server (#48)
Rignchen Jun 25, 2024
b913fde
Merge remote-tracking branch 'upstream/Dev' into Dev
Alex-zReeZ Jun 25, 2024
ccd1027
fix: logout redirection (#49)
jordyBSK Jun 25, 2024
226b0a3
refactor: moved .github directory to root
Alex-zReeZ Jun 25, 2024
5934484
refactor: changed workflow execution type (#47)
Alex-zReeZ Jun 25, 2024
392eb9c
Merge branch 'Dev' of github.com:museebolo/climat_guardian into Dev
Alex-zReeZ Jun 25, 2024
f5864fb
style: properly format code
Jun 25, 2024
2a20a7e
fix: fix bugs to prepare for release (#50)
jordyBSK Jun 25, 2024
28306f3
fix: changed format commande and added format check and fix ts config…
Alex-zReeZ Jun 25, 2024
366d14c
feat: push production ready version to main (#52)
jordyBSK Jun 25, 2024
0639d73
Merge branch 'main' into fix-prettier-config
Alex-zReeZ Jun 25, 2024
f7f65b8
Revert "feat: push production ready version to main (#52)" (#53)
jordyBSK Jun 25, 2024
fa206fd
Merge pull request #54 from museebolo/Dev
jordyBSK Jun 25, 2024
df703d3
Merge branch 'main' into fix-prettier-config
Alex-zReeZ Jun 25, 2024
7940eae
refactor: removed -D flag in npm install and reformated code
Alex-zReeZ Jun 25, 2024
d456c85
Merge remote-tracking branch 'origin/fix-prettier-config' into fix-pr…
Alex-zReeZ Jun 25, 2024
5bb4b39
fix: fixed workflow not finding package lock because in the wrong dir…
Alex-zReeZ Jun 25, 2024
4a77a4a
fix: fix changed direction directory
Alex-zReeZ Jun 25, 2024
7980609
fix: fix changed cd direction
Alex-zReeZ Jun 25, 2024
92683b6
refactor: changed steps order
Alex-zReeZ Jun 25, 2024
521ba26
refactor: specified where to find package-lock.json
Alex-zReeZ Jun 25, 2024
3fb499b
refactor: removed change directory and replaced it with working-direc…
Alex-zReeZ Jun 25, 2024
c125ea7
Merge pull request #51 from Alex-zReeZ/fix-prettier-config
jordyBSK Jun 25, 2024
57152bf
fix: update developpment docker compose to work with current state of…
Rignchen Jun 26, 2024
4ef8f0a
fix: add .env inside php and nextjs folders (#57)
Rignchen Jun 26, 2024
7bcbfc3
Merge pull request #58 from museebolo/Dev
fuzoh Jun 27, 2024
5380f2a
Migration esp (#60)
jordyBSK Jun 27, 2024
f467e4d
refactor: Change interface style (#61)
Alex-zReeZ Jun 28, 2024
3ccd42e
feat: added display of the average of data in chosen range (#62)
Alex-zReeZ Jun 28, 2024
d463987
Middleware (#64)
jordyBSK Jul 1, 2024
164ee27
feat: added dark theme (#63)
Alex-zReeZ Jul 1, 2024
2c78465
feat: edit esp position (#65)
jordyBSK Jul 2, 2024
298994d
Feat: added possibility to rename an esp and added reload when adding…
Alex-zReeZ Jul 2, 2024
2567559
fix: added missing import of useState and reformated code (#67)
Alex-zReeZ Jul 2, 2024
57e298f
refactor: refactoring html structure for simpler structure (#68)
Alex-zReeZ Jul 3, 2024
38192a0
fix: resolved conflit (#71)
jordyBSK Jul 3, 2024
67625a7
refactor: changed graph hover popup, reformated files and removed unu…
Alex-zReeZ Jul 4, 2024
f694eb1
fix: replace local storage for cookies to store theme of user (#73)
Alex-zReeZ Jul 4, 2024
35505ab
refactor: changed branch and type execution of workflow to main (#74)
Alex-zReeZ Jul 4, 2024
8949ea8
ci: added workflow to check if the docker builds (#75)
Alex-zReeZ Jul 4, 2024
5146d68
style: change dark mode colors and use shadcn card (#77)
jordyBSK Jul 4, 2024
968f8fe
ci: added curl check to test (#78)
Alex-zReeZ Jul 4, 2024
0cc19ff
refactor: dashboard scroll (#79)
jordyBSK Jul 4, 2024
856f93b
Feat: added precision selector on esp page graph (#80)
Alex-zReeZ Jul 4, 2024
12f3cf3
refactor: Fix responsive in esp rooms and little details (#81)
Alex-zReeZ Jul 4, 2024
84e7b48
fix: fixed workflow to check for token (#84)
Alex-zReeZ Jul 4, 2024
d0dce56
refactor: check if token is valid (#85)
jordyBSK Jul 4, 2024
a7a3995
refactor: centered thermometer (#86)
Alex-zReeZ Jul 5, 2024
26cd04a
refactor: display ip address (#88)
jordyBSK Jul 5, 2024
92b90cc
refactor: changed border color in precision selector (#87)
Alex-zReeZ Jul 5, 2024
0056ec4
feat: allow users to remove users (#89)
Rignchen Jul 5, 2024
a856bbf
refactor: added button to show esp jwt token (#90)
Alex-zReeZ Jul 5, 2024
b3115ec
feat: implement add users in database (#91)
jordyBSK Jul 5, 2024
683f9ea
fix: fixed function getting user token instead of esp token (#92)
Alex-zReeZ Jul 5, 2024
4ec1499
feat: added gap on add user input (#93)
jordyBSK Jul 5, 2024
79b8d1b
fix: fixed jwt token fetch getting no Ip (#94)
Alex-zReeZ Jul 5, 2024
b7364e6
refactor: install the slim router for the php (#27)
Rignchen Jul 5, 2024
d8a64f5
feat: remove reload on move esp (#96)
jordyBSK Jul 8, 2024
d9a1758
feat: remove the choice of precision according to the days chosen (#95)
jordyBSK Jul 8, 2024
3aa4305
refactor: removed window reload when adding new esp to display new es…
Alex-zReeZ Jul 9, 2024
313a2a9
refactor: added verification of IP input with js (#99)
Alex-zReeZ Jul 9, 2024
e591139
docs: update readme (#101)
Rignchen Jul 9, 2024
ed38067
feat: Seperate days by a bar and added time stamp of data on graph (#…
Alex-zReeZ Jul 10, 2024
4a32441
fix: allow esp to know who they are (#106)
Rignchen Jul 10, 2024
f95ef11
fix: removed hardcoded localhost link (#107)
Alex-zReeZ Jul 10, 2024
4697933
refactor: added timestamp in graph xAxis (#108)
Alex-zReeZ Jul 10, 2024
bab4e08
refactor: removed readme in nextjs interface (#110)
Alex-zReeZ Jul 10, 2024
5e7e65a
fix: fix check build workflow and set timezon UTC+02:00 (#112)
Alex-zReeZ Aug 5, 2024
26ed858
fix: fix warning "list should have unique key" (#118)
Alex-zReeZ Aug 6, 2024
01c45dc
feat: added zooming interface in plan (#121)
adbme Aug 14, 2024
04cba05
feat: show the day when clicking on it (#122)
adbme Aug 15, 2024
c5c372f
Fix espid link when clicking on day (#123)
adbme Aug 16, 2024
5db9cfd
feat: show variance between days with two esp (#124)
adbme Aug 27, 2024
c451411
docs: add database and migrations documentation (#125)
fuzoh Aug 28, 2024
558a92a
ci: setup dependabot for automatic versions updates (#128)
fuzoh Aug 28, 2024
8c667f1
build: refactor dockerfiles name to avoid file type mismatches (#134)
fuzoh Aug 28, 2024
775dc2f
build(deps): bump micromatch from 4.0.7 to 4.0.8 in /nextjs-interface…
dependabot[bot] Aug 28, 2024
08e569a
build(deps-dev): bump @types/react in /nextjs-interface (#133)
dependabot[bot] Aug 28, 2024
0e4ecff
build(deps-dev): bump typescript in /nextjs-interface (#140)
dependabot[bot] Sep 4, 2024
e2b7852
build(deps): bump @radix-ui/react-popover in /nextjs-interface (#131)
dependabot[bot] Sep 4, 2024
7ee95a3
build(deps): bump @radix-ui/react-label in /nextjs-interface (#130)
dependabot[bot] Sep 4, 2024
2964325
build(deps): bump @radix-ui/react-slot in /nextjs-interface (#129)
dependabot[bot] Sep 4, 2024
c6b1400
build(deps-dev): bump typescript in /nextjs-interface (#141)
dependabot[bot] Oct 1, 2024
7ecabdd
build(deps): bump @radix-ui/react-select in /nextjs-interface (#152)
dependabot[bot] Oct 22, 2024
5fb51b5
build(deps): bump next from 14.2.3 to 14.2.10 in /nextjs-interface (#…
dependabot[bot] Oct 25, 2024
dd2853a
build(deps): bump @hookform/resolvers in /nextjs-interface (#142)
dependabot[bot] Oct 25, 2024
07bf449
build(deps): bump @radix-ui/react-tooltip in /nextjs-interface (#162)
dependabot[bot] Oct 30, 2024
2948901
fix: change "Token copier" to "Token copié" (#187)
ColinRgm Dec 4, 2024
0b200ff
fix: extract the IP with destructuring to get it just on time (#191)
ColinRgm Dec 4, 2024
9b263d9
fix: Inverse some directive and add some commandes to do (#192)
ColinRgm Dec 4, 2024
81c1af8
fix: delete the Symlinks between .env and the other two (#193)
ColinRgm Dec 9, 2024
6987b69
fix: disable the rule property in .eslintrc.json (#198)
ColinRgm Dec 9, 2024
62883e9
fix: correct data errors on the dashboard (#199)
ColinRgm Dec 9, 2024
875db14
Bug/copy token (#203)
ColinRgm Dec 10, 2024
280dc77
fix: fix the installation instructions (#208)
ColinRgm Dec 16, 2024
e8adb1d
fix: new file to edit the users informations (#209)
ColinRgm Jan 6, 2025
efa7a36
Fix/delete esp (#217)
ColinRgm Jan 7, 2025
7320efc
fix: delete an ESP in the backend (#219)
ColinRgm Jan 14, 2025
2d7a6da
fix: create certification (#228)
ColinRgm Jan 21, 2025
f92bb33
fix: add a verification before deleting a user or an ESP (#235)
ColinRgm Jan 27, 2025
50fb4ac
fix: create a const (#237)
ColinRgm Jan 28, 2025
f5bafd8
fix: add some way to show message (#243)
ColinRgm Jan 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: add a verification before deleting a user or an ESP (#235)
* fix: add a verification before deleting a user or an ESP

* fix: hide popover if click on NON

Closes: #230
ColinRgm authored Jan 27, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit f92bb3375e1b254d8a84c74a72d9e7be6f49c2bb
4 changes: 2 additions & 2 deletions Dockerfile/Nginx.Dockerfile
Original file line number Diff line number Diff line change
@@ -9,5 +9,5 @@ RUN sed -i '/location \/adminer\//,/}/d' /etc/nginx/conf.d/default.conf
COPY ../php/public /var/www/memoires-info/php/public

# copy the nginx certificats
COPY ../climateguardian_dev.com.pem /etc/nginx
COPY ../climateguardian_dev.com-key.pem /etc/nginx
COPY ../climateguardian_dev.com.pem /etc/nginx/climateguardian_dev.com.pem
COPY ../climateguardian_dev.com-key.pem /etc/nginx/climateguardian_dev.com-key.pem
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -77,6 +77,8 @@ services:
- "./nextjs-interface:/var/www/memoires-info/html/"

web:
build:
dockerfile: Dockerfile/Nginx.Dockerfile
image: nginx:1.26-alpine-otel
ports:
- "80:80"
@@ -86,8 +88,8 @@ services:
- "./nginx.conf:/etc/nginx/conf.d/default.conf"
- "./php:/var/www/memoires-info/php/"
# Nginx certificats
- "./climateguardian_dev.com.pem:/etc/nginx"
- "./climateguardian_dev.com-key.pem:/etc/nginx"
- "./climateguardian_dev.com.pem:/etc/nginx/climateguardian_dev.com.pem"
- "./climateguardian_dev.com-key.pem:/etc/nginx/climateguardian_dev.com-key.pem"
depends_on:
- php
- postg-rest
37 changes: 10 additions & 27 deletions nextjs-interface/src/app/dashboard/users/page.tsx
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import {
} from "@/components/ui/card";
import { getToken, user } from "@/lib/context";
import EditUsersData from "@/app/ui/dashboard/EditUsersData";
import DeleteUsersData from "@/app/ui/dashboard/DeleteUsersData";

export default function Page() {
const [users, setUsers] = useState<user[]>([]);
@@ -23,34 +24,16 @@ export default function Page() {
}
}, [allUsers]);

const handleUserDelete = (username: string) => {
setUsers((prevUsers) =>
prevUsers.filter((user) => user.username !== username),
);
};

if (!allUsers) {
return <div>Chargement...</div>;
}

// Fonction de suppression d'un utilisateur
const handleDelete = async (username: string) => {
try {
const response = await fetch(`/postgrest/users?username=eq.${username}`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${getToken()}`,
},
});

if (!response.ok) {
console.error("Erreur à la suppression de l'utilisateur");
console.error(await response.json());
return;
}

// Remove user from local state after successful deletion
setUsers(users.filter((user) => user.username !== username));
} catch (error) {
console.error("Error:", error);
}
};

return (
<>
<Card>
@@ -74,9 +57,9 @@ export default function Page() {
password={user.password}
/>

<Trash2
className="delete-icon cursor-pointer"
onClick={() => handleDelete(user.username)}
<DeleteUsersData
username={user.username}
onDelete={handleUserDelete}
/>
</div>
</div>
2 changes: 1 addition & 1 deletion nextjs-interface/src/app/ui/dashboard/AddUserElement.tsx
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ export function AddUserElement({
setUsername("");
setPassword("");
} else {
setMessage("Erreur à l'ajout 'un utilisateur. Veuillez réessayer.");
setMessage("Erreur à l'ajout de l'utilisateur. Veuillez réessayer.");
}
} catch (error: any) {
setMessage("Error: " + error.message);
45 changes: 44 additions & 1 deletion nextjs-interface/src/app/ui/dashboard/DeleteEsp.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
import { Trash2 } from "lucide-react";
import { getToken } from "@/lib/context";
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover";
import { Button } from "@/components/ui/button";
import { useState } from "react";

export default function DeleteEsp({ id }: { id: string }) {
// Function to hide the delete popup
const [isOpen, setIsOpen] = useState(false);

const hidePopover = () => {
setIsOpen(false);
};

const openPopover = () => {
setIsOpen(true);
};

const deleteEsp = async (id: string) => {
// Get the id in the URL of the page

@@ -29,14 +47,39 @@ export default function DeleteEsp({ id }: { id: string }) {
} else {
console.log("ESP supprimé avec succés");
}

setIsOpen(false);
} catch (error) {
console.error("Error: ", error);
}
};

return (
<div className="flex cursor-pointer gap-2">
<Trash2 onClick={() => deleteEsp(id)} />
<Popover open={isOpen} onOpenChange={setIsOpen}>
<PopoverTrigger>
<Trash2 />
</PopoverTrigger>

<PopoverContent className="mr-5 mt-2 flex w-fit flex-col gap-2 dark:bg-zinc-800">
<p>Supprimer cet ESP ?</p>
<Button
onClick={async () => {
try {
await deleteEsp(id);
} catch (e) {
console.error(e);
}
}}
className="w-72"
>
OUI
</Button>
<Button onClick={hidePopover} className="w-72">
NON
</Button>
</PopoverContent>
</Popover>
</div>
);
}
78 changes: 78 additions & 0 deletions nextjs-interface/src/app/ui/dashboard/DeleteUsersData.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import React, { useEffect, useState } from "react";
import { getToken, user } from "@/lib/context";
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover";
import { Trash2 } from "lucide-react";
import { Button } from "@/components/ui/button";
import { useAllUsers } from "@/lib/data";

export default function DeleteUserData({
username,
onDelete,
}: {
username: string;
onDelete: (username: string) => void;
}) {
// Function to hide the delete popup
const [isOpen, setIsOpen] = useState(false);

const hidePopover = () => {
setIsOpen(false);
};

const openPopover = () => {
setIsOpen(true);
};

// Function to delete a user
const [users, setUsers] = useState<user[]>([]);

const handleDelete = async () => {
try {
const response = await fetch(`/postgrest/users?username=eq.${username}`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${getToken()}`,
},
});

if (!response.ok) {
return;
}

onDelete(username);
// Remove user from local state after successful deletion
setUsers(users.filter((user) => user.username !== username));
setIsOpen(false);
} catch (error) {
console.error("Error:", error);
}
};

return (
<div className="flex cursor-pointer gap-2">
<Popover open={isOpen} onOpenChange={setIsOpen}>
<PopoverTrigger>
<Trash2 />
</PopoverTrigger>

<PopoverContent className="mr-5 mt-2 flex w-fit flex-col gap-2 dark:bg-zinc-800">
<p>Supprimer {username} ?</p>
<Button onClick={handleDelete} className="w-72">
OUI
</Button>
<Button
onClick={hidePopover}
className="w-72 data-[state=closed]:animate-out"
>
NON
</Button>
</PopoverContent>
</Popover>
</div>
);
}