-
Notifications
You must be signed in to change notification settings - Fork 4
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
Global code review #9
Open
jpilet
wants to merge
117
commits into
reviewed
Choose a base branch
from
main
base: reviewed
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
117 commits
Select commit
Hold shift + click to select a range
be1792d
refactor: change repository (#1)
Rignchen 70f6f43
feat: implement login (#5)
jordyBSK 9042cb9
feat: launch everything from the same docker compose (#2)
Rignchen 308e75f
Fix: fix a few issues on the backend (#6)
Rignchen 7752bef
feat: plan canvas (#8)
jordyBSK d85de2d
feat: get the ip address when averaging the values with the avg_date …
Rignchen 2b4b46f
feat: setup a sqitch to handle migrations (#23)
Rignchen a5214ed
fix: readme and use latest docker images (#24)
Rignchen 3148fca
refactor: reposition php code in the folder (#25)
Rignchen b983d79
fix: install php stan (#26)
Rignchen 6283251
Interface next js (#28)
jordyBSK ad260bc
Login (#29)
jordyBSK 16af540
Get data.ts files (#30)
jordyBSK d94906a
refactor: renamed file type and function for better separation (#31)
Alex-zReeZ e095c1b
feat: implement logout (#32)
jordyBSK 32d7886
add Esp table (#33)
jordyBSK 5fd26f4
fix: redirect to login when we logout (#34)
jordyBSK f12bde6
sort data by room ip (#35)
jordyBSK 48db262
Revert "sort data by room ip (#35)" (#36)
jordyBSK 00d6c9e
Revert "Revert "sort data by room ip (#35)" (#36)" (#37)
jordyBSK 6d4434c
Plan data (#38)
jordyBSK 38e1aec
feat: added dynamic data in dashboard and esp pages (#39)
Alex-zReeZ f3ed78b
Date range (#40)
jordyBSK 8ec2912
fix: fix import duplication (#41)
jordyBSK 2be57e8
fix: change dockerfile to work with next js
Alex-zReeZ 4a1417d
refactor: added new Ip adresse
Alex-zReeZ 3db6d23
refactor: removed output and added distdir to out
Alex-zReeZ 0d16c0f
refactor: reformated file
Alex-zReeZ 8d04934
refactor: added new Ip adresse, rounded data, moved getColor file and…
Alex-zReeZ 4197a28
refactor: Rounded data (#42)
Alex-zReeZ 16a782f
fix: tofixed temperature in espmap
36315e8
feat: added Workflow to check the format and lint (#46)
Alex-zReeZ 1619744
refactor: resolve conflit
d150924
Merge branch 'Dev' of github.com:museebolo/climat_guardian into Dev
fbf86e5
Merge remote-tracking branch 'upstream/Dev' into Dev
Alex-zReeZ 27f2fc5
feat: serve interface using a nodejs server (#48)
Rignchen b913fde
Merge remote-tracking branch 'upstream/Dev' into Dev
Alex-zReeZ ccd1027
fix: logout redirection (#49)
jordyBSK 226b0a3
refactor: moved .github directory to root
Alex-zReeZ 5934484
refactor: changed workflow execution type (#47)
Alex-zReeZ 392eb9c
Merge branch 'Dev' of github.com:museebolo/climat_guardian into Dev
Alex-zReeZ f5864fb
style: properly format code
2a20a7e
fix: fix bugs to prepare for release (#50)
jordyBSK 28306f3
fix: changed format commande and added format check and fix ts config…
Alex-zReeZ 366d14c
feat: push production ready version to main (#52)
jordyBSK 0639d73
Merge branch 'main' into fix-prettier-config
Alex-zReeZ f7f65b8
Revert "feat: push production ready version to main (#52)" (#53)
jordyBSK fa206fd
Merge pull request #54 from museebolo/Dev
jordyBSK df703d3
Merge branch 'main' into fix-prettier-config
Alex-zReeZ 7940eae
refactor: removed -D flag in npm install and reformated code
Alex-zReeZ d456c85
Merge remote-tracking branch 'origin/fix-prettier-config' into fix-pr…
Alex-zReeZ 5bb4b39
fix: fixed workflow not finding package lock because in the wrong dir…
Alex-zReeZ 4a77a4a
fix: fix changed direction directory
Alex-zReeZ 7980609
fix: fix changed cd direction
Alex-zReeZ 92683b6
refactor: changed steps order
Alex-zReeZ 521ba26
refactor: specified where to find package-lock.json
Alex-zReeZ 3fb499b
refactor: removed change directory and replaced it with working-direc…
Alex-zReeZ c125ea7
Merge pull request #51 from Alex-zReeZ/fix-prettier-config
jordyBSK 57152bf
fix: update developpment docker compose to work with current state of…
Rignchen 4ef8f0a
fix: add .env inside php and nextjs folders (#57)
Rignchen 7bcbfc3
Merge pull request #58 from museebolo/Dev
fuzoh 5380f2a
Migration esp (#60)
jordyBSK f467e4d
refactor: Change interface style (#61)
Alex-zReeZ 3ccd42e
feat: added display of the average of data in chosen range (#62)
Alex-zReeZ d463987
Middleware (#64)
jordyBSK 164ee27
feat: added dark theme (#63)
Alex-zReeZ 2c78465
feat: edit esp position (#65)
jordyBSK 298994d
Feat: added possibility to rename an esp and added reload when adding…
Alex-zReeZ 2567559
fix: added missing import of useState and reformated code (#67)
Alex-zReeZ 57e298f
refactor: refactoring html structure for simpler structure (#68)
Alex-zReeZ 38192a0
fix: resolved conflit (#71)
jordyBSK 67625a7
refactor: changed graph hover popup, reformated files and removed unu…
Alex-zReeZ f694eb1
fix: replace local storage for cookies to store theme of user (#73)
Alex-zReeZ 35505ab
refactor: changed branch and type execution of workflow to main (#74)
Alex-zReeZ 8949ea8
ci: added workflow to check if the docker builds (#75)
Alex-zReeZ 5146d68
style: change dark mode colors and use shadcn card (#77)
jordyBSK 968f8fe
ci: added curl check to test (#78)
Alex-zReeZ 0cc19ff
refactor: dashboard scroll (#79)
jordyBSK 856f93b
Feat: added precision selector on esp page graph (#80)
Alex-zReeZ 12f3cf3
refactor: Fix responsive in esp rooms and little details (#81)
Alex-zReeZ 84e7b48
fix: fixed workflow to check for token (#84)
Alex-zReeZ d0dce56
refactor: check if token is valid (#85)
jordyBSK a7a3995
refactor: centered thermometer (#86)
Alex-zReeZ 26cd04a
refactor: display ip address (#88)
jordyBSK 92b90cc
refactor: changed border color in precision selector (#87)
Alex-zReeZ 0056ec4
feat: allow users to remove users (#89)
Rignchen a856bbf
refactor: added button to show esp jwt token (#90)
Alex-zReeZ b3115ec
feat: implement add users in database (#91)
jordyBSK 683f9ea
fix: fixed function getting user token instead of esp token (#92)
Alex-zReeZ 4ec1499
feat: added gap on add user input (#93)
jordyBSK 79b8d1b
fix: fixed jwt token fetch getting no Ip (#94)
Alex-zReeZ b7364e6
refactor: install the slim router for the php (#27)
Rignchen d8a64f5
feat: remove reload on move esp (#96)
jordyBSK d9a1758
feat: remove the choice of precision according to the days chosen (#95)
jordyBSK 3aa4305
refactor: removed window reload when adding new esp to display new es…
Alex-zReeZ 313a2a9
refactor: added verification of IP input with js (#99)
Alex-zReeZ e591139
docs: update readme (#101)
Rignchen ed38067
feat: Seperate days by a bar and added time stamp of data on graph (#…
Alex-zReeZ 4a32441
fix: allow esp to know who they are (#106)
Rignchen f95ef11
fix: removed hardcoded localhost link (#107)
Alex-zReeZ 4697933
refactor: added timestamp in graph xAxis (#108)
Alex-zReeZ bab4e08
refactor: removed readme in nextjs interface (#110)
Alex-zReeZ 5e7e65a
fix: fix check build workflow and set timezon UTC+02:00 (#112)
Alex-zReeZ 26ed858
fix: fix warning "list should have unique key" (#118)
Alex-zReeZ 01c45dc
feat: added zooming interface in plan (#121)
adbme 04cba05
feat: show the day when clicking on it (#122)
adbme c5c372f
Fix espid link when clicking on day (#123)
adbme 5db9cfd
feat: show variance between days with two esp (#124)
adbme c451411
docs: add database and migrations documentation (#125)
fuzoh 558a92a
ci: setup dependabot for automatic versions updates (#128)
fuzoh 8c667f1
build: refactor dockerfiles name to avoid file type mismatches (#134)
fuzoh 775dc2f
build(deps): bump micromatch from 4.0.7 to 4.0.8 in /nextjs-interface…
dependabot[bot] 08e569a
build(deps-dev): bump @types/react in /nextjs-interface (#133)
dependabot[bot] 0e4ecff
build(deps-dev): bump typescript in /nextjs-interface (#140)
dependabot[bot] e2b7852
build(deps): bump @radix-ui/react-popover in /nextjs-interface (#131)
dependabot[bot] 7ee95a3
build(deps): bump @radix-ui/react-label in /nextjs-interface (#130)
dependabot[bot] 2964325
build(deps): bump @radix-ui/react-slot in /nextjs-interface (#129)
dependabot[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
POSTGREST_API=http://postg-rest:3000 | ||
DETAILED_ERRORS=false | ||
|
||
ESP_PATH=./esp32/config | ||
DB_PATH=./database/data | ||
|
||
JWT_SECRET= | ||
POSTGRES_PASSWORD= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.idea/ | ||
# vim backup files | ||
*.sw[pon] | ||
.env | ||
# nohup | ||
nohup.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# node 20, build the application | ||
FROM node:20.12.2-alpine3.19 | ||
COPY ../Interface . | ||
RUN npm install | ||
RUN npm run build | ||
|
||
|
||
# nginx 1.26 on port 80, keep the build output, nginx config | ||
FROM nginx:1.26-alpine-otel | ||
EXPOSE 80 | ||
COPY --from=0 ../dist /var/www/memoires-info/html | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ../dist does not exist... |
||
COPY ../.env /var/www/memoires-info/html/.env | ||
|
||
# copy the nginx config | ||
COPY ../nginx.conf /etc/nginx/conf.d/default.conf | ||
RUN sed -i '/location \/adminer\//,/}/d' /etc/nginx/conf.d/default.conf | ||
# copy php files for ngnix to know they exist | ||
COPY ../php/public /var/www/memoires-info/php/public | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# php 8.3 with the files, install dependencies | ||
FROM composer:2.7 | ||
COPY ../php . | ||
RUN composer install | ||
|
||
# copy required files to new image | ||
FROM php:8.3-fpm-alpine | ||
COPY ../php/public /var/www/memoires-info/php/public | ||
COPY ../php/private /var/www/memoires-info/php/private | ||
COPY ../php/lib.php /var/www/memoires-info/php | ||
COPY ../.env /var/www/memoires-info/php/ | ||
COPY --from=0 ../app/vendor /var/www/memoires-info/php/vendor | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM sqitch/sqitch:v1.4.1.0 | ||
CMD ["deploy"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,116 @@ | ||
# climat_guardian | ||
Système de surveillance climatique | ||
[Info]: <> ( | ||
All the information that are likely to need to be updated have a comment above them like this one | ||
) | ||
# Climate-Guardian | ||
This project was made for the non-profit organization memoires-informatiques\ | ||
Memoires-informatiques has a lot of old computers and other electronic devices that need to be stored in a controlled environment\ | ||
The goal of this project is to monitor the temperature and humidity of the different rooms of the organization and to display the data on a web interface | ||
|
||
# Setup | ||
From now on, the computer that runs the docker will be called "server" and | ||
the computer used by the user will be called "computer" | ||
|
||
## Network | ||
The server and the esp need to be connected to the same network, it is recommended to give both of them a static ip address\ | ||
The computer can be connected from any network as long as the network has open ports, otherwise you'll have to be on the same network as the server | ||
|
||
![hardware](/.assets/hardware-diagram.png)\ | ||
![software](/.assets/software-diagram.png) | ||
|
||
## Requirements | ||
For this project to work you need to have the following installed on the server: | ||
- Linux (Tested on [Ubuntu Server 22.04](https://ubuntu.com/download/server)) | ||
- [Docker Engine](https://docs.docker.com/engine/install/ubuntu/) | ||
- [Docker Compose](https://docs.docker.com/compose/install/) | ||
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) | ||
- [Curl](https://curl.se/download.html) | ||
- [jq](https://stedolan.github.io/jq/download/) | ||
```bash | ||
sudo apt-get update | ||
sudo apt-get install git curl jq | ||
sudo apt-get install ca-certificates | ||
sudo install -m 0755 -d /etc/apt/keyrings | ||
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc | ||
sudo chmod a+r /etc/apt/keyrings/docker.asc | ||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
sudo apt-get update | ||
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | ||
``` | ||
|
||
## Installation | ||
First thing you need to do is to clone the repository from GitHub on the server | ||
```bash | ||
git clone https://github.com/museebolo/climat-guardian.git && cd climat-guardian | ||
``` | ||
|
||
--- | ||
[Info]: <> ( | ||
This is the list of all the files that end with .example | ||
) | ||
Once the repository is cloned you can remove the `.example` at the end of the following files: | ||
- .env.example | ||
- esp32/config/secrets.yaml.example | ||
- Interface/src/contexts/SampleContext.example.tsx | ||
```bash | ||
cp .env.example .env | ||
cp esp32/config/secrets.yaml.example esp32/config/secrets.yaml | ||
cp Interface/src/contexts/SampleContext.example.tsx Interface/src/contexts/SampleContext.tsx | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the file SampleContext.example.tsx does not exist. |
||
``` | ||
|
||
--- | ||
Now you want to generate a secret key for the jwt tokens used by the api | ||
```bash | ||
sed -i '/JWT_SECRET/d' .env | ||
echo "JWT_SECRET=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 32)" >> .env | ||
``` | ||
|
||
You may also want to generate a random password for the database | ||
```bash | ||
sed -i '/POSTGRES_PASSWORD/d' .env | ||
echo "POSTGRES_PASSWORD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 32)" >> .env | ||
``` | ||
|
||
It is recommended to let the other environment variables as they are | ||
|
||
--- | ||
Finally, you **have to** fill the Wi-Fi credentials in `esp32/config/secrets.yaml`\ | ||
You also **have to** change the `127.0.0.1` in `Interface/src/contexts/SampleContext.tsx` and `esp32/config/secrets.yaml` by the ip address of the server | ||
|
||
## Start the project | ||
Once everything is configured on the server, you can start the project by running the docker compose on the server | ||
```bash | ||
docker compose -f docker-compose.prod.yml up -d --remove-orphans --build | ||
``` | ||
Once the docker is running you can access the web interface by going to the ip address of the server in the web browser of the computer\ | ||
the default user is `admin` and has `admin` as password | ||
|
||
![web interface](/.assets/dashboard.png) | ||
|
||
## ESP 32 Installation | ||
This project uses [esp home](https://github.com/esphome/esphome) to manage the esp32, you can configure the esp32 by following the instructions below | ||
- Connect yourself to the esp home interface by going to `127.0.0.1/esp` in the web browser of the computer (replace `127.0.0.1` with the ip address of the server) | ||
- Plug the esp32 to the server | ||
- Press the `+ NEW DEVICE` button inside esp home | ||
- Name your device | ||
- Select `ESP32` (on the top of the list) | ||
- Press `INSTALL` and select `Plug into the computer running ESPHome Dashboard` (the 3rd option) | ||
- Select the device with ``/dev/ttyUSB0`` as path | ||
- Wait for the installation to finish\ | ||
Be sure to memorize the ip address of the esp32 (you can find it in the logs) | ||
$${\color{gray} \text{[15:39:12]} \color{magenta} \text{[C][wifi:416]: IP Address: 172.16.5.65}}$$ | ||
- You can now unplug the esp32 and plug it to any other power source | ||
- Press `Edit` at the bottom of the logs | ||
- Copy everything from the line 31 of the file `esp32/esp32.yaml` on the server and paste it at the end of your esp32's configuration file | ||
```bash | ||
clear && cat esp32/esp32.yaml | sed -n '31,$p' | ||
``` | ||
- Replace the XXX... at the end of the code with the token of your esp32\ | ||
you can generate this token by running the following command on the server (replace `255.255.255.255` with the ip address of the esp32) | ||
```bash | ||
export TOKEN=$(curl 'http://127.0.0.1/php/login.php' -d '{"username":"admin","password":"admin"}' -X POST | jq '.token' -r) | ||
curl -H "Authorization: Bearer $TOKEN" "http://127.0.0.1/php/esp.php" -d '{"ip":"255.255.255.255"}' -X POST | jq '.token' -r | ||
``` | ||
- Press `INSTALL` and select `Wirelessly` (the 1st option) | ||
- Wait for the installation to finish | ||
- Press `STOP` to exit the logs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
-- Deploy climat-guardian:data to pg | ||
|
||
BEGIN; | ||
|
||
create table api.data ( | ||
temperature real, | ||
humidity real, | ||
timestamp timestamp NOT NULL, | ||
ip character varying(15) NOT NULL | ||
); | ||
grant select on api.data to web_user; | ||
|
||
-- convert unix timestamp to timestamp and insert it | ||
create or replace function api.insert_data( | ||
temperature real, | ||
humidity real, | ||
ip varchar(15), | ||
unix_timestamp bigint | ||
) | ||
returns void as $$ | ||
begin | ||
-- if the ip said in the token is not the same as the one in the request, then this means that the user is not who he pretends to be and we should throw an error | ||
if (current_setting('request.jwt.claims', true)::json->>'ip' != ip) then | ||
raise exception insufficient_privilege | ||
using hint = 'You are not who you pretend to be'; | ||
end if; | ||
-- insert the data | ||
insert into api.data("temperature", "humidity", "ip", "timestamp") values (temperature, humidity, ip, to_timestamp(unix_timestamp)); | ||
end $$ language plpgsql; | ||
grant insert on api.data to esp32; | ||
|
||
-- create a function to get the average temperature and humidity of each delta time | ||
create function api.avg_date( | ||
delta varchar | ||
) | ||
returns table( | ||
avg_temperature double precision, | ||
avg_humidity double precision, | ||
date timestamp, | ||
ip character varying(15), | ||
count bigint | ||
) as $$ | ||
begin | ||
return query select | ||
avg(temperature) as avg_temperature, | ||
avg(humidity) as avg_humidity, | ||
date_trunc(delta, timestamp) as date, | ||
data.ip, | ||
count(*) as count | ||
from api.data | ||
group by date, data.ip | ||
order by date; | ||
end; | ||
$$ language plpgsql; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- Deploy climat-guardian:postgrest to pg | ||
|
||
BEGIN; | ||
|
||
create schema api; | ||
create role authenticator noinherit login password 'mysecretpassword'; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-- Deploy climat-guardian:roles to pg | ||
|
||
BEGIN; | ||
|
||
-- anonymous role | ||
create role web_anon nologin; | ||
grant usage on schema api to web_anon; | ||
grant web_anon to authenticator; | ||
|
||
-- create role for the esp 32 | ||
create role esp32 nologin; | ||
grant usage on schema api to esp32; | ||
grant esp32 to authenticator; | ||
|
||
-- create role for the users | ||
create role web_user nologin; | ||
grant usage on schema api to web_user; | ||
grant web_user to authenticator; | ||
|
||
-- create a role for the login | ||
create role web_login nologin; | ||
grant usage on schema api to web_login; | ||
grant web_login to authenticator; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-- Deploy climat-guardian:user to pg | ||
|
||
BEGIN; | ||
|
||
create table api.users ( | ||
id serial primary key, | ||
username character varying(50) NOT NULL UNIQUE, | ||
password character varying(60) NOT NULL | ||
); | ||
|
||
grant usage, select on sequence api.users_id_seq to web_user; | ||
grant insert on api.users to web_user; -- any user can add new users | ||
grant select on api.users to web_login; | ||
|
||
-- create first user to be able to connect first time | ||
insert into api.users(username, password) values ('admin', '$2y$10$vJMf8H4u0f913VOJJDqVIeYrqnZBSzgYZ3Zyoh76MDjf6ZlmNDKPu'); | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- Revert climat-guardian:data from pg | ||
|
||
BEGIN; | ||
|
||
drop table api.data; | ||
drop function api.avg_date; | ||
drop function api.insert_data; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- Revert climat-guardian:postgrest from pg | ||
|
||
BEGIN; | ||
|
||
drop schema api; | ||
drop role authenticator; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- Revert climat-guardian:roles from pg | ||
|
||
BEGIN; | ||
|
||
-- anonymous role | ||
revoke usage on schema api from web_anon; | ||
drop role web_anon; | ||
|
||
-- esp 32 | ||
revoke usage on schema api from esp32; | ||
drop role esp32; | ||
|
||
-- users | ||
revoke usage on schema api from web_user; | ||
drop role web_user; | ||
|
||
-- login | ||
revoke usage on schema api from web_login; | ||
drop role web_login; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Revert climat-guardian:user from pg | ||
|
||
BEGIN; | ||
|
||
drop table api.users; | ||
|
||
COMMIT; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not have the Interface folder. Where does it come from?
is it nextjs-interface ?