Merge branch 'Atilla', remote-tracking branch 'origin'
This commit is contained in:
35
ReadMe.md
Normal file
35
ReadMe.md
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# GoodGarden
|
||||||
|
|
||||||
|
Welkom bij ons project genaamd "GoodGarden". Wij hebben besloten om er een monolitische project van te maken. Alles is te vinden binnen deze repository.
|
||||||
|
|
||||||
|
### Vereisten
|
||||||
|
|
||||||
|
* Python
|
||||||
|
* Node.Js
|
||||||
|
* XAMPP (of andere naar keuze)
|
||||||
|
|
||||||
|
### Installeren
|
||||||
|
|
||||||
|
Zorg dat je in de hoofdmap "GoodGarden" zit. Kijk in je path: "/GoodGarden". Als je in de correcte map zit moet je de volgende items installeren:
|
||||||
|
|
||||||
|
- npm install electron
|
||||||
|
- npm install express
|
||||||
|
- npm install body-parser
|
||||||
|
- npm install python-shell
|
||||||
|
|
||||||
|
- pip install mysql-connector-python
|
||||||
|
- pip install requests
|
||||||
|
|
||||||
|
## Gebruik
|
||||||
|
|
||||||
|
Een paar voorbeelden van nuttig gebruik van dit project of hoe het gebruikt kan worden.
|
||||||
|
|
||||||
|
## Versiebeheer
|
||||||
|
|
||||||
|
We gebruiken [SemVer](http://semver.org/) voor versiebeheer. Voor de beschikbare versies, zie de [tags op deze repository](https://example.com/tags).
|
||||||
|
|
||||||
|
## Auteurs
|
||||||
|
|
||||||
|
* **Jouw Naam** - *Initieel werk* - [Gebruikersnaam](https://example.com/)
|
||||||
|
|
||||||
|
Zie ook de lijst van [bijdragers](https://example.com/contributors) die hebben bijgedragen aan dit project.
|
||||||
BIN
__pycache__/db_connect.cpython-311.pyc
Normal file
BIN
__pycache__/db_connect.cpython-311.pyc
Normal file
Binary file not shown.
101
app.js
Normal file
101
app.js
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
const { app, BrowserWindow,ipcMain } = require('electron'); /* TYPE IN TERMINAL: "npm install electron" */
|
||||||
|
const express = require('express'); /* TYPE IN TERMINAL: "npm install express" */
|
||||||
|
const bodyParser = require('body-parser'); /* TYPE IN TERMINAL: "npm install body-parser" */
|
||||||
|
const { PythonShell } = require('python-shell'); /* TYPE IN TERMINAL: "npm install python-shell" */
|
||||||
|
const path = require('path');
|
||||||
|
const urlElectron = path.join(__dirname, "src/index.html");
|
||||||
|
|
||||||
|
// Maak een Express-app
|
||||||
|
const server = express();
|
||||||
|
server.use(bodyParser.urlencoded({ extended: true }));
|
||||||
|
|
||||||
|
// Definieer een route voor form POST verzoeken
|
||||||
|
server.post('/submit-form', (req, res) => {
|
||||||
|
const { plant_naam, plantensoort } = req.body; // Verkrijg de plant_naam uit het formulier
|
||||||
|
const plant_geteelt = req.body.plant_geteelt == 'true' ? 'true' : 'false'; // Zorgt dat de string "true" herkent wordt
|
||||||
|
|
||||||
|
let options = {
|
||||||
|
mode: 'text',
|
||||||
|
args: [plant_naam, plantensoort, plant_geteelt], // Zet hier een variable bij om de data toe te voegen aan de databas
|
||||||
|
};
|
||||||
|
|
||||||
|
/*Om python te gebruiken*/
|
||||||
|
// ipcMain.on('request-update-temp', (event, args) => {
|
||||||
|
// let options = {
|
||||||
|
// mode: 'text',
|
||||||
|
// scriptPath: 'path/to/your/python/script',
|
||||||
|
// args: args
|
||||||
|
// };
|
||||||
|
|
||||||
|
// PythonShell.run('calculate.py', options, (err, results) => {
|
||||||
|
// if (err) {
|
||||||
|
// console.error('Error running python script', err);
|
||||||
|
// event.reply('update-temp-result', 'error');
|
||||||
|
// } else {
|
||||||
|
// console.log('Python script results:', results);
|
||||||
|
// event.reply('update-temp-result', results[0]); // Verstuur het resultaat terug naar de renderer proces
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
// En dan in je renderer proces, stuur je een bericht om de update te verzoeken
|
||||||
|
ipcRenderer.send('request-update-temp', [/* hier kunnen argumenten komen die je Python script nodig heeft */]);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// Start de server voor verbinding met de database
|
||||||
|
const PORT = 3000;
|
||||||
|
server.listen(PORT, () => {
|
||||||
|
console.log(`Server luistert op port ${PORT}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Maak de Electron applicatie aan met bijbehorende waardes
|
||||||
|
function createWindow() {
|
||||||
|
const mainWindow = new BrowserWindow({
|
||||||
|
width: 1280,
|
||||||
|
height: 800,
|
||||||
|
frame: false,
|
||||||
|
webPreferences: {
|
||||||
|
nodeIntegration: true,
|
||||||
|
contextIsolation: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mainWindow.loadURL(urlElectron);
|
||||||
|
|
||||||
|
/*Is om het Python script te kunnen gebruiken*/
|
||||||
|
ipcMain.on('run-python-script', (event, args) => {
|
||||||
|
let options = {
|
||||||
|
mode: 'text',
|
||||||
|
args: args
|
||||||
|
};
|
||||||
|
|
||||||
|
PythonShell.run('../src/py/calculate.py', options, (err, results) => {
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
console.error('Error running python script', err);
|
||||||
|
event.reply('python-script-response', 'error');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
console.log('Python script results:', results);
|
||||||
|
event.reply('python-script-response', results);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
app.whenReady().then(createWindow);
|
||||||
|
|
||||||
|
// Functionaliteit voor het openen en sluiten van de app
|
||||||
|
app.on('window-all-closed', () => {
|
||||||
|
if (process.platform !== 'darwin') {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.on('activate', () => {
|
||||||
|
if (BrowserWindow.getAllWindows().length === 0) {
|
||||||
|
createWindow();
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
DROP DATABASE IF EXISTS goodgarden;
|
|
||||||
CREATE DATABASE goodgarden;
|
|
||||||
|
|
||||||
CREATE TABLE goodgarden.sensor_data (
|
|
||||||
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
||||||
timestamp INT,
|
|
||||||
gateway_receive_time VARCHAR(50),
|
|
||||||
device INT,
|
|
||||||
value DECIMAL(10, 5),
|
|
||||||
PRIMARY KEY (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
Invoegen van gegevens in de 'sensor_data'-tabel
|
|
||||||
INSERT INTO goodgarden.sensor_data (timestamp, gateway_receive_time, device, value)
|
|
||||||
VALUES (1707295162, '2024-02-07T08:39:22Z', 256, 4.107448101043701),
|
|
||||||
(1707261284, '2024-02-06T23:14:44Z', 322, 4.111111164093018);
|
|
||||||
39
main.js
39
main.js
@@ -1,39 +0,0 @@
|
|||||||
const { app, BrowserWindow, nativeImage, shell } = require("electron");
|
|
||||||
// const screen = require("electron").screen;
|
|
||||||
const path = require("path");
|
|
||||||
|
|
||||||
let mainWindow;
|
|
||||||
|
|
||||||
function createWindow()
|
|
||||||
{
|
|
||||||
// const iconPath = path.join(__dirname, "images/logo.png");
|
|
||||||
// const icon = nativeImage.createFromPath(iconPath);
|
|
||||||
const urlElectron = path.join(__dirname, "src/main.html");
|
|
||||||
|
|
||||||
mainWindow = new BrowserWindow(
|
|
||||||
{
|
|
||||||
width: 1000,
|
|
||||||
height: 650,
|
|
||||||
webPreferences:
|
|
||||||
{
|
|
||||||
nodeIntegration: true,
|
|
||||||
},
|
|
||||||
resizable: false,
|
|
||||||
frame: true,
|
|
||||||
// icon: icon,
|
|
||||||
alwaysOnTop: true,
|
|
||||||
// backgroundColor: "green"
|
|
||||||
});
|
|
||||||
|
|
||||||
// const { width, height } = screen.getPrimaryDisplay().workAreaSize;
|
|
||||||
// mainWindow.setPosition(width - 450, height - 500);
|
|
||||||
|
|
||||||
mainWindow.loadURL(urlElectron);
|
|
||||||
|
|
||||||
// mainWindow.on("closed", function ()
|
|
||||||
// {
|
|
||||||
// mainWindow = null;
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
app.on("ready", createWindow);
|
|
||||||
1577
package-lock.json
generated
1577
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "goodgarden",
|
"name": "goodgarden",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "main.js",
|
"main": "app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"start": "electron main.js"
|
"start": "electron app.js"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
@@ -12,6 +12,10 @@
|
|||||||
"electron": "^23.3.13"
|
"electron": "^23.3.13"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"elctron": "^0.0.1-security"
|
"body-parser": "^1.20.2",
|
||||||
|
"elctron": "^0.0.1-security",
|
||||||
|
"express": "^4.18.2",
|
||||||
|
"mysql2": "^3.9.1",
|
||||||
|
"python-shell": "^5.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
123
script/DUMMY.json
Normal file
123
script/DUMMY.json
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
|
||||||
|
// Deze spanningswaarden zijn relatief hoog, wat suggereert dat de batterijen van de sensoren goed opgeladen zijn. De meeste sensorapparaten gebruiken batterijen die een nominale spanning van ongeveer 3,7 volt hebben (typisch voor lithium-ion batterijen) en kunnen worden beschouwd als "volledig opgeladen" wanneer ze een spanning dicht bij of iets boven 4,1 volt bereiken
|
||||||
|
"battery_voltage_events": [
|
||||||
|
{
|
||||||
|
"timestamp": 1707825721,
|
||||||
|
"gateway_receive_time": "2024-02-13T12:02:01Z",
|
||||||
|
"device": 256,
|
||||||
|
"value": 4.098901271820068
|
||||||
|
// Volledig opgeladen: Rond 4.2 volt.
|
||||||
|
// Nominale spanning: Ongeveer 3.7 volt.
|
||||||
|
// Kritiek laag: Minder dan 3.0 volt.
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1707837460,
|
||||||
|
"gateway_receive_time": "2024-02-13T15:17:40Z",
|
||||||
|
"device": 322,
|
||||||
|
"value": 4.105006217956543
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"devices": [
|
||||||
|
{
|
||||||
|
"id": 256,
|
||||||
|
"serial_number": "0033889B1BAB1169",
|
||||||
|
"name": "firefly2_0051",
|
||||||
|
"label": "The Field",
|
||||||
|
"last_seen": 1707765066,
|
||||||
|
"last_battery_voltage": 4.09768009185791
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 322,
|
||||||
|
"serial_number": "006FE1FC316ED7D8",
|
||||||
|
"name": "firefly2_0111",
|
||||||
|
"label": "The Field",
|
||||||
|
"last_seen": 1707764966,
|
||||||
|
"last_battery_voltage": 4.107448101043701
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Fotosyntese??? (zonlicht)
|
||||||
|
"par_events": [
|
||||||
|
{
|
||||||
|
"timestamp": 1707844638,
|
||||||
|
"gateway_receive_time": "2024-02-13T17:17:18Z",
|
||||||
|
"device": 322,
|
||||||
|
"value": 0.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1707851099,
|
||||||
|
"gateway_receive_time": "2024-02-13T19:04:59Z",
|
||||||
|
"device": 256,
|
||||||
|
"value": 0.0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Luchtvochtigheid
|
||||||
|
"relative_humidity_events": [
|
||||||
|
{
|
||||||
|
"timestamp": 1707844638,
|
||||||
|
"gateway_receive_time": "2024-02-13T17:17:18Z",
|
||||||
|
"device": 322,
|
||||||
|
"value": 71.08984375
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1707851099,
|
||||||
|
"gateway_receive_time": "2024-02-13T19:04:59Z",
|
||||||
|
"device": 256,
|
||||||
|
"value": 66.7294921875
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// De "soil_electric_conductivity_events" gegevens wijzen op metingen van de elektrische geleidbaarheid (EC) van de bodem, een indicator van de hoeveelheid oplosbare zouten of voedingsstoffen in de bodem. EC wordt gemeten in Siemens per meter (S/m) of, voor bodemmetingen, vaak in milliSiemens per centimeter (mS/cm). Een hogere EC-waarde duidt op een hogere concentratie van opgeloste zouten, wat belangrijk is voor het bepalen van de voedingsstatus van de bodem en het beheren van de bemesting voor optimale plantengroei.
|
||||||
|
"soil_electric_conductivity_events": [
|
||||||
|
{
|
||||||
|
"timestamp": 1707851215,
|
||||||
|
"gateway_receive_time": "2024-02-13T19:06:55Z",
|
||||||
|
"device": 322,
|
||||||
|
"value": 0.0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// In de context van bodemmetingen, geeft deze waarde inzicht in het vochtgehalte van de bodem, omdat water een relatief hoge diëlektrische constante heeft in vergelijking met droge bodem of lucht.
|
||||||
|
"soil_relative_permittivity_events": [
|
||||||
|
{
|
||||||
|
"timestamp": 1707851215,
|
||||||
|
"gateway_receive_time": "2024-02-13T19:06:55Z",
|
||||||
|
"device": 322,
|
||||||
|
"value": 1.52
|
||||||
|
// Een waarde van 1.52 is relatief laag en suggereert dat de bodem droog kan zijn op het moment van meting. Ter referentie, de diëlektrische constante van lucht is ongeveer 1, terwijl water een diëlektrische constante heeft van ongeveer 80 bij kamertemperatuur.
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//De "soil_temperature_events" gegevens bevatten informatie over de temperatuur van de bodem op een specifiek tijdstip. De waarde geeft de temperatuur van de bodem aan in graden Celsius (°C).
|
||||||
|
"soil_temperature_events": [
|
||||||
|
{
|
||||||
|
"timestamp": 1707851215,
|
||||||
|
"gateway_receive_time": "2024-02-13T19:06:55Z",
|
||||||
|
"device": 322,
|
||||||
|
"value": 12.06
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
BIN
script/__pycache__/db_connect.cpython-311.pyc
Normal file
BIN
script/__pycache__/db_connect.cpython-311.pyc
Normal file
Binary file not shown.
418
script/battery_voltage_events.py
Normal file
418
script/battery_voltage_events.py
Normal file
@@ -0,0 +1,418 @@
|
|||||||
|
# import requests #** TYPE IN TERMINAL: "pip install requests"
|
||||||
|
# import time
|
||||||
|
# import mysql.connector #** TYPE IN TERMINAL: "pip install mysql-connector-python"
|
||||||
|
|
||||||
|
# # Import python db_connect.py script
|
||||||
|
# from db_connect import database_connect
|
||||||
|
|
||||||
|
# # Functie voor het aanmaken van gegevens in de database
|
||||||
|
# def create_data(url, access_token, repeat_count=5):
|
||||||
|
# for _ in range(repeat_count):
|
||||||
|
# try:
|
||||||
|
# headers = {
|
||||||
|
# "Authorization": f"Token {access_token}"
|
||||||
|
# }
|
||||||
|
# response = requests.get(url, headers=headers)
|
||||||
|
# response.raise_for_status()
|
||||||
|
|
||||||
|
# data = response.json()
|
||||||
|
|
||||||
|
# # print(f"Data from {url}:")
|
||||||
|
# print(data)
|
||||||
|
# insert_data(data)
|
||||||
|
|
||||||
|
# except requests.exceptions.RequestException as e:
|
||||||
|
# print(f"Error fetching data from {url}: {e}")
|
||||||
|
|
||||||
|
# print("Waiting for the next create action...")
|
||||||
|
# time.sleep(10)
|
||||||
|
# # time.sleep(300)
|
||||||
|
|
||||||
|
# # Functie voor het invoegen van gegevens in de database
|
||||||
|
# def insert_data(data):
|
||||||
|
# mydb = database_connect()
|
||||||
|
# if mydb.is_connected():
|
||||||
|
# mycursor = mydb.cursor()
|
||||||
|
|
||||||
|
# insert_query = """
|
||||||
|
# INSERT INTO goodgarden.battery_voltage_events (timestamp, gateway_receive_time, device, value)
|
||||||
|
# VALUES (%s, %s, %s, %s)
|
||||||
|
# """
|
||||||
|
|
||||||
|
# for record in data['results']: # Pas dit aan op basis van de werkelijke structuur van de JSON
|
||||||
|
|
||||||
|
# timestamp = record.get('timestamp', '')
|
||||||
|
# gateway_receive_time = record.get('gateway_receive_time', '')
|
||||||
|
# device = record.get('device', '')
|
||||||
|
# value = record.get('value', '')
|
||||||
|
|
||||||
|
# print(f"Inserting data: timestamp={timestamp}, gateway_receive_time={gateway_receive_time}, device={device}, value={value}")
|
||||||
|
|
||||||
|
# # Voer de query uit
|
||||||
|
# mycursor.execute(insert_query, (timestamp, gateway_receive_time, device, value))
|
||||||
|
|
||||||
|
# # Bevestig de wijzigingen
|
||||||
|
# mydb.commit()
|
||||||
|
|
||||||
|
# # Sluit cursor en verbinding
|
||||||
|
# mycursor.close()
|
||||||
|
# mydb.close()
|
||||||
|
|
||||||
|
# # Functie voor het lezen van gegevens uit de database
|
||||||
|
# def read_data(url, access_token, repeat_count=5):
|
||||||
|
# for _ in range(repeat_count):
|
||||||
|
# try:
|
||||||
|
# headers = {
|
||||||
|
# "Authorization": f"Token {access_token}"
|
||||||
|
# }
|
||||||
|
# response = requests.get(url, headers=headers)
|
||||||
|
# response.raise_for_status()
|
||||||
|
|
||||||
|
# data = response.json()
|
||||||
|
# print(f"Data from {url}:")
|
||||||
|
# print(data)
|
||||||
|
|
||||||
|
# except requests.exceptions.RequestException as e:
|
||||||
|
# print(f"Error fetching data from {url}: {e}")
|
||||||
|
|
||||||
|
# # Wacht een bepaalde tijd in secondes
|
||||||
|
# print("Waiting for the next read action...")
|
||||||
|
# time.sleep(300)
|
||||||
|
|
||||||
|
# # Functie voor het bijwerken van gegevens in de database
|
||||||
|
# def update_data(record_id, new_value):
|
||||||
|
# try:
|
||||||
|
# mydb = database_connect()
|
||||||
|
|
||||||
|
# if mydb.is_connected():
|
||||||
|
# mycursor = mydb.cursor()
|
||||||
|
|
||||||
|
# # Controleer of het record bestaat voordat je het bijwerkt
|
||||||
|
# mycursor.execute("SELECT * FROM goodgarden.battery_voltage_events WHERE id = %s", (record_id,))
|
||||||
|
# existing_record = mycursor.fetchone()
|
||||||
|
|
||||||
|
# if not existing_record:
|
||||||
|
# print(f"Record with ID {record_id} not found. Update operation aborted.")
|
||||||
|
# return
|
||||||
|
|
||||||
|
# # Hier moet je de juiste kolomnamen aanpassen op basis van de structuur van je database
|
||||||
|
# update_query = """
|
||||||
|
# UPDATE goodgarden.battery_voltage_events
|
||||||
|
# SET value = %s
|
||||||
|
# WHERE id = %s
|
||||||
|
# """
|
||||||
|
|
||||||
|
# # Voer de query uit
|
||||||
|
# print(f"Executing update query: {update_query}")
|
||||||
|
# print(f"Updating record with ID {record_id} to new value: {new_value}")
|
||||||
|
|
||||||
|
# mycursor.execute(update_query, (new_value, record_id)) # Provide the tuple with values here
|
||||||
|
|
||||||
|
# # Bevestig de wijzigingen
|
||||||
|
# mydb.commit()
|
||||||
|
|
||||||
|
# print(f"Update executed. Rowcount: {mycursor.rowcount}")
|
||||||
|
|
||||||
|
# except mysql.connector.Error as update_err:
|
||||||
|
# print(f"Error updating data: {update_err}")
|
||||||
|
# finally:
|
||||||
|
# # Zorg ervoor dat je altijd de cursor en de databaseverbinding sluit
|
||||||
|
# if 'mycursor' in locals() and mycursor is not None:
|
||||||
|
# mycursor.close()
|
||||||
|
# if 'mydb' in locals() and mydb.is_connected():
|
||||||
|
# mydb.close()
|
||||||
|
|
||||||
|
|
||||||
|
# # Functie voor het verwijderen van gegevens uit de database
|
||||||
|
# def delete_data(record_id):
|
||||||
|
# mydb = database_connect()
|
||||||
|
# if mydb.is_connected():
|
||||||
|
# mycursor = mydb.cursor()
|
||||||
|
|
||||||
|
# # Hier moet je de juiste kolomnamen aanpassen op basis van de structuur van je database
|
||||||
|
# delete_query = """
|
||||||
|
# DELETE FROM goodgarden.battery_voltage_events
|
||||||
|
# WHERE id = %s
|
||||||
|
# """
|
||||||
|
|
||||||
|
# # Voer de query uit
|
||||||
|
# mycursor.execute(delete_query, (record_id,))
|
||||||
|
|
||||||
|
# # Bevestig de wijzigingen
|
||||||
|
# mydb.commit()
|
||||||
|
|
||||||
|
# # Sluit cursor en verbinding
|
||||||
|
# mycursor.close()
|
||||||
|
# mydb.close()
|
||||||
|
|
||||||
|
# print(f"Data with ID {record_id} deleted.")
|
||||||
|
|
||||||
|
# if __name__ == "__main__":
|
||||||
|
# url = "https://garden.inajar.nl/api/battery_voltage_events/?format=json"
|
||||||
|
# access_token = "33bb3b42452306c58ecedc3c86cfae28ba22329c"
|
||||||
|
|
||||||
|
# repeat_count = 10
|
||||||
|
|
||||||
|
# operation_choice = input("Choose operation (C for Create, R for Read, U for Update, D for Delete): ").upper()
|
||||||
|
|
||||||
|
# # Maak gegevens aan
|
||||||
|
# if operation_choice == "C":
|
||||||
|
# create_data(url, access_token, repeat_count)
|
||||||
|
|
||||||
|
# # Lees gegevens
|
||||||
|
# elif operation_choice == "R":
|
||||||
|
# read_data(url, access_token, repeat_count)
|
||||||
|
|
||||||
|
# # Update gegevens
|
||||||
|
# elif operation_choice == "U":
|
||||||
|
# record_id = int(input("Enter record ID to update: "))
|
||||||
|
# new_value = input("Enter new value: ")
|
||||||
|
# update_data(record_id, new_value)
|
||||||
|
|
||||||
|
# # Verwijder gegevens
|
||||||
|
# elif operation_choice == "D":
|
||||||
|
# record_id = int(input("Enter record ID to delete: "))
|
||||||
|
# delete_data(record_id)
|
||||||
|
|
||||||
|
# else:
|
||||||
|
# print("Invalid operation choice. Please choose C, R, U, or D.")
|
||||||
|
|
||||||
|
import mysql.connector
|
||||||
|
import requests
|
||||||
|
from datetime import datetime, timezone, timedelta
|
||||||
|
import time
|
||||||
|
import os
|
||||||
|
import paho.mqtt.client as mqtt
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
# Functie om verbinding te maken met de database
|
||||||
|
def database_connect():
|
||||||
|
return mysql.connector.connect(
|
||||||
|
host="localhost",
|
||||||
|
user="root",
|
||||||
|
password="",
|
||||||
|
database="goodgarden"
|
||||||
|
)
|
||||||
|
|
||||||
|
def calculate_timestamp(gateway_receive_time):
|
||||||
|
# Converteer de stringrepresentatie naar een datetime-object in UTC
|
||||||
|
datetime_obj_utc = datetime.strptime(gateway_receive_time, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=timezone.utc)
|
||||||
|
|
||||||
|
# Voeg het tijdsverschil van 1 uur toe voor de Nederlandse tijdzone (UTC+1)
|
||||||
|
datetime_obj_nl = datetime_obj_utc + timedelta(hours=0)
|
||||||
|
|
||||||
|
# Formateer het datetime-object als een leesbare datumstring
|
||||||
|
formatted_date = datetime_obj_nl.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
return formatted_date
|
||||||
|
|
||||||
|
# Functie voor het aanmaken van gegevens in de database
|
||||||
|
def create_data(url, access_token, repeat_count=5):
|
||||||
|
for _ in range(repeat_count):
|
||||||
|
try:
|
||||||
|
headers = {"Authorization": f"Token {access_token}"}
|
||||||
|
response = requests.get(url, headers=headers)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
print(f"Data from {url}:\n")
|
||||||
|
|
||||||
|
# Check if data is a list (records directly under the root)
|
||||||
|
if isinstance(data, list):
|
||||||
|
records = data
|
||||||
|
elif isinstance(data, dict) and 'results' in data:
|
||||||
|
records = data['results']
|
||||||
|
else:
|
||||||
|
print(f"Unexpected data format received: {data}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
for record in records:
|
||||||
|
# Now, record is assumed to be a dictionary
|
||||||
|
timestamp = record.get('timestamp', '')
|
||||||
|
gateway_receive_time = record.get('gateway_receive_time', '')
|
||||||
|
device = record.get('device', '')
|
||||||
|
value = record.get('value', '')
|
||||||
|
|
||||||
|
# Voeg de timestamp-berekening toe
|
||||||
|
calculated_timestamp = calculate_timestamp(gateway_receive_time)
|
||||||
|
|
||||||
|
print(f"\nInserted data: Timestamp: {calculated_timestamp}, Device: {device}, Battery Voltage: {value}V")
|
||||||
|
if float(value) < 3.0:
|
||||||
|
print("Waarschuwing: Batterijspanning is lager dan 3.0 volt. Opladen aanbevolen.\n")
|
||||||
|
# Controleer of de batterijspanning hoger is dan 4.2 volt en geef een melding
|
||||||
|
elif float(value) > 4.2:
|
||||||
|
print("Melding: Batterijspanning is hoger dan 4.2 volt. Batterij is vol.\n")
|
||||||
|
else:
|
||||||
|
print("Melding: Batterijspanning is binnen het gewenste bereik.\n\n")
|
||||||
|
|
||||||
|
# Insert data into the database
|
||||||
|
insert_data(record)
|
||||||
|
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(f"Error fetching data from {url}: {e}")
|
||||||
|
|
||||||
|
print("Waiting for the next create action...\n")
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
# Functie voor het invoegen van gegevens in de database
|
||||||
|
def insert_data(record):
|
||||||
|
mydb = database_connect()
|
||||||
|
if mydb.is_connected():
|
||||||
|
mycursor = mydb.cursor()
|
||||||
|
|
||||||
|
# Hier moet je de juiste kolomnamen en gegevensindeling aanpassen op basis van de API-respons
|
||||||
|
insert_query = """
|
||||||
|
INSERT INTO goodgarden.battery_voltage_events (timestamp, gateway_receive_time, device, value)
|
||||||
|
VALUES (%s, %s, %s, %s)
|
||||||
|
"""
|
||||||
|
# Pas dit aan op basis van de werkelijke structuur van de JSON
|
||||||
|
timestamp = calculate_timestamp(record.get('gateway_receive_time', ''))
|
||||||
|
gateway_receive_time = record.get('gateway_receive_time', '')
|
||||||
|
device = record.get('device', '')
|
||||||
|
value = record.get('value', '')
|
||||||
|
|
||||||
|
print(f"Inserting data: timestamp={timestamp}, gateway_receive_time={gateway_receive_time}, device={device}, value={value}\n\n") # Print de ingevoerde gegevens
|
||||||
|
|
||||||
|
# Voer de query uit
|
||||||
|
mycursor.execute(insert_query, (timestamp, gateway_receive_time, device, value))
|
||||||
|
|
||||||
|
# Bevestig de wijzigingen
|
||||||
|
mydb.commit()
|
||||||
|
|
||||||
|
# Sluit cursor en verbinding
|
||||||
|
mycursor.close()
|
||||||
|
mydb.close()
|
||||||
|
|
||||||
|
print("Data inserted into the database.")
|
||||||
|
|
||||||
|
# Functie voor het lezen van gegevens uit de database
|
||||||
|
def read_data(url, access_token, repeat_count=5):
|
||||||
|
for _ in range(repeat_count):
|
||||||
|
try:
|
||||||
|
headers = {"Authorization": f"Token {access_token}"}
|
||||||
|
response = requests.get(url, headers=headers)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
print(f"Data from {url}:\n")
|
||||||
|
|
||||||
|
for record in data['results']:
|
||||||
|
timestamp = record.get('timestamp', '')
|
||||||
|
device = record.get('device', '')
|
||||||
|
value = record.get('value', '')
|
||||||
|
print(f"Timestamp: {timestamp}, Device: {device}, Battery Voltage: {value}V\n")
|
||||||
|
|
||||||
|
if float(value) < 3.0:
|
||||||
|
print("Waarschuwing: Batterijspanning is lager dan 3.0 volt. Opladen aanbevolen.\n")
|
||||||
|
# Controleer of de batterijspanning hoger is dan 4.2 volt en geef een melding
|
||||||
|
elif float(value) > 4.2:
|
||||||
|
print("Melding: Batterijspanning is hoger dan 4.2 volt. Batterij is vol.\n")
|
||||||
|
else:
|
||||||
|
print("Melding: Batterijspanning is binnen het gewenste bereik.\n\n")
|
||||||
|
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(f"Error fetching data from {url}: {e}")
|
||||||
|
|
||||||
|
print("Waiting for the next read action...\n")
|
||||||
|
time.sleep(300)
|
||||||
|
|
||||||
|
# Functie voor het bijwerken van gegevens in de database
|
||||||
|
def update_data(record_id):
|
||||||
|
try:
|
||||||
|
mydb = database_connect()
|
||||||
|
|
||||||
|
if mydb.is_connected():
|
||||||
|
mycursor = mydb.cursor()
|
||||||
|
|
||||||
|
# Controleer of het record bestaat voordat je het bijwerkt
|
||||||
|
mycursor.execute("SELECT * FROM goodgarden.battery_voltage_events WHERE id = %s", (record_id,))
|
||||||
|
existing_record = mycursor.fetchone()
|
||||||
|
|
||||||
|
if not existing_record:
|
||||||
|
print(f"Record with ID {record_id} not found. Update operation aborted.")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Vraag de gebruiker om nieuwe waarden voor de andere velden
|
||||||
|
new_timestamp = input("Enter new timestamp: ")
|
||||||
|
new_gateway_receive_time = input("Enter new gateway_receive_time: ")
|
||||||
|
new_device = input("Enter new device: ")
|
||||||
|
new_value = input("Enter new value: ")
|
||||||
|
|
||||||
|
# Hier moet je de juiste kolomnamen aanpassen op basis van de structuur van je database
|
||||||
|
update_query = """
|
||||||
|
UPDATE goodgarden.battery_voltage_events
|
||||||
|
SET timestamp = %s, gateway_receive_time = %s, device = %s, value = %s
|
||||||
|
WHERE id = %s
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Voer de query uit
|
||||||
|
print(f"Executing update query: {update_query}")
|
||||||
|
print(f"Updating record with ID {record_id} to new values - timestamp: {new_timestamp}, gateway_receive_time: {new_gateway_receive_time}, device: {new_device}, value: {new_value}")
|
||||||
|
|
||||||
|
mycursor.execute(update_query, (new_timestamp, new_gateway_receive_time, new_device, new_value, record_id))
|
||||||
|
|
||||||
|
# Bevestig de wijzigingen
|
||||||
|
mydb.commit()
|
||||||
|
|
||||||
|
print(f"Update executed. Rowcount: {mycursor.rowcount}")
|
||||||
|
|
||||||
|
except mysql.connector.Error as update_err:
|
||||||
|
print(f"Error updating data: {update_err}")
|
||||||
|
finally:
|
||||||
|
# Zorg ervoor dat je altijd de cursor en de databaseverbinding sluit
|
||||||
|
if 'mycursor' in locals() and mycursor is not None:
|
||||||
|
mycursor.close()
|
||||||
|
if 'mydb' in locals() and mydb.is_connected():
|
||||||
|
mydb.close()
|
||||||
|
|
||||||
|
# Functie voor het verwijderen van gegevens uit de database
|
||||||
|
def delete_data(record_id):
|
||||||
|
mydb = database_connect()
|
||||||
|
if mydb.is_connected():
|
||||||
|
mycursor = mydb.cursor()
|
||||||
|
|
||||||
|
# Hier moet je de juiste kolomnamen aanpassen op basis van de structuur van je database
|
||||||
|
delete_query = """
|
||||||
|
DELETE FROM goodgarden.battery_voltage_events
|
||||||
|
WHERE id = %s
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Voer de query uit
|
||||||
|
mycursor.execute(delete_query, (record_id,))
|
||||||
|
|
||||||
|
# Bevestig de wijzigingen
|
||||||
|
mydb.commit()
|
||||||
|
|
||||||
|
# Sluit cursor en verbinding
|
||||||
|
mycursor.close()
|
||||||
|
mydb.close()
|
||||||
|
|
||||||
|
print(f"Data with ID {record_id} deleted.")
|
||||||
|
|
||||||
|
# Functie voor het aanmaken van gegevens in de database op basis van batterijspanningsinformatie
|
||||||
|
if __name__ == "__main__":
|
||||||
|
url = "https://garden.inajar.nl/api/battery_voltage_events/?format=json"
|
||||||
|
access_token = "33bb3b42452306c58ecedc3c86cfae28ba22329c" # Vervang dit door je werkelijke toegangstoken
|
||||||
|
|
||||||
|
# Je kunt repeat_count wijzigen om te bepalen hoe vaak je de bewerking wilt herhalen
|
||||||
|
repeat_count = 10
|
||||||
|
|
||||||
|
# Keuze voor de bewerking
|
||||||
|
operation_choice = input("Choose operation (C for Create, R for Read, U for Update, D for Delete): ").upper()
|
||||||
|
|
||||||
|
if operation_choice == "C":
|
||||||
|
# Maak gegevens aan
|
||||||
|
create_data(url, access_token, repeat_count)
|
||||||
|
elif operation_choice == "R":
|
||||||
|
# Lees gegevens
|
||||||
|
read_data(url, access_token, repeat_count)
|
||||||
|
elif operation_choice == "U":
|
||||||
|
# Update gegevens
|
||||||
|
record_id = int(input("Enter record ID to update: "))
|
||||||
|
# Call the update_data function without additional arguments
|
||||||
|
update_data(record_id)
|
||||||
|
elif operation_choice == "D":
|
||||||
|
# Verwijder gegevens
|
||||||
|
record_id = int(input("Enter record ID to delete: "))
|
||||||
|
delete_data(record_id)
|
||||||
|
else:
|
||||||
|
print("Invalid operation choice. Please choose C, R, U, or D.")
|
||||||
19
script/db_connect.py
Normal file
19
script/db_connect.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import mysql.connector #** TYPE IN TERMINAL: "pip install mysql-connector-python"
|
||||||
|
from mysql.connector import Error
|
||||||
|
|
||||||
|
def database_connect():
|
||||||
|
try:
|
||||||
|
connection = mysql.connector.connect(
|
||||||
|
host="localhost",
|
||||||
|
user="root",
|
||||||
|
password="",
|
||||||
|
database="goodgarden"
|
||||||
|
)
|
||||||
|
if connection.is_connected():
|
||||||
|
# print("Connection gelukt!")
|
||||||
|
return connection
|
||||||
|
except Error as e:
|
||||||
|
print(f"Connection NIET gelukt! ${e}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
# database_connect()
|
||||||
50
script/db_connect_form.py
Normal file
50
script/db_connect_form.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import sys
|
||||||
|
import json
|
||||||
|
import mysql.connector #** TYPE IN TERMINAL: "pip install mysql-connector-python"
|
||||||
|
from mysql.connector import Error
|
||||||
|
|
||||||
|
|
||||||
|
# Voeg de data uit het formulier toe aan de database
|
||||||
|
def insert_plant_name(plant_naam, plantensoort, plant_geteelt):
|
||||||
|
|
||||||
|
# Als er "true" is meegeven als waarde dan komt in de database 1 anders 0 (false)
|
||||||
|
plant_geteelt_value = 1 if plant_geteelt.lower() == "true" else 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
connection = mysql.connector.connect(
|
||||||
|
host='localhost',
|
||||||
|
database='goodgarden',
|
||||||
|
user='root',
|
||||||
|
password=''
|
||||||
|
)
|
||||||
|
|
||||||
|
# Als er verbinding gemaakt kan worden voer dan onderstaande query uit
|
||||||
|
if connection.is_connected():
|
||||||
|
|
||||||
|
# De crusor() zorgt ervoor dat er een verbinding met de database gelegt kan worden en de data gemanipuleerd
|
||||||
|
cursor = connection.cursor()
|
||||||
|
query = "INSERT INTO goodgarden.planten (plant_naam, plantensoort, plant_geteelt) VALUES (%s, %s, %s)"
|
||||||
|
cursor.execute(query, (plant_naam, plantensoort, plant_geteelt_value)) # "%s" wordt hier ingevuld doormiddel van de variable (parameter)
|
||||||
|
connection.commit()
|
||||||
|
print(json.dumps({"success": True}))
|
||||||
|
|
||||||
|
else:
|
||||||
|
print(json.dumps({"success": False, "error": "Database connection failed"}))
|
||||||
|
|
||||||
|
except Error as e:
|
||||||
|
print(json.dumps({"success": False, "error": str(e)}))
|
||||||
|
|
||||||
|
finally:
|
||||||
|
if connection and connection.is_connected():
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
|
|
||||||
|
# Wordt alleen uitgevoerd als het een standalone script is (geen import!!!)
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# Dit zijn de variables die door het JavaScript bestand (app.js) worden meegegeven --- NOTE: sys.argv[0] is altijd de naam van het script!
|
||||||
|
plant_naam = sys.argv[1]
|
||||||
|
plantensoort = sys.argv[2]
|
||||||
|
plant_geteelt = sys.argv[3]
|
||||||
|
|
||||||
|
# Call de function met de variables
|
||||||
|
insert_plant_name(plant_naam, plantensoort, plant_geteelt)
|
||||||
71
script/devices.py
Normal file
71
script/devices.py
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
import requests
|
||||||
|
import time
|
||||||
|
|
||||||
|
from db_connect import database_connect
|
||||||
|
|
||||||
|
def fetch_and_display_all(url, access_token, repeat_count=5):
|
||||||
|
for _ in range(repeat_count):
|
||||||
|
try:
|
||||||
|
headers = {
|
||||||
|
"Authorization": f"Token {access_token}"
|
||||||
|
}
|
||||||
|
response = requests.get(url, headers=headers)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
print(f"Data from {url}:")
|
||||||
|
print(data)
|
||||||
|
load_data(data)
|
||||||
|
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(f"Error fetching data from {url}: {e}")
|
||||||
|
|
||||||
|
print("Waiting for the next retrieval action...")
|
||||||
|
|
||||||
|
# time.sleep(300) # Time here is in seconds.
|
||||||
|
|
||||||
|
time.sleep(1) # Time here is in seconds.
|
||||||
|
|
||||||
|
def load_data(data):
|
||||||
|
mydb = database_connect()
|
||||||
|
if mydb.is_connected():
|
||||||
|
mycursor = mydb.cursor()
|
||||||
|
|
||||||
|
# Here you need to adjust the correct column names and data formats based on the API response
|
||||||
|
insert_query = """
|
||||||
|
INSERT INTO goodgarden.devices (serial_number, name, label, last_seen, last_battery_voltage)
|
||||||
|
VALUES (%s, %s, %s, %s, %s )
|
||||||
|
"""
|
||||||
|
for record in data['results']:
|
||||||
|
serial_number = record.get('serial_number', '')
|
||||||
|
name = record.get('name', '')
|
||||||
|
label = record.get('label', '')
|
||||||
|
last_seen = record.get('last_seen', '')
|
||||||
|
last_battery_voltage = record.get('last_battery_voltage', '')
|
||||||
|
|
||||||
|
print(f"Inserting data: serial_number={serial_number}, name={name}, label={label}, last_seen={last_seen}, last_battery_voltage={last_battery_voltage}")
|
||||||
|
|
||||||
|
# Execute the query
|
||||||
|
mycursor.execute(insert_query, (serial_number, name, label, last_seen, last_battery_voltage))
|
||||||
|
|
||||||
|
# Commit the changes
|
||||||
|
mydb.commit()
|
||||||
|
|
||||||
|
# Close cursor and connection
|
||||||
|
mycursor.close()
|
||||||
|
mydb.close()
|
||||||
|
|
||||||
|
print("Data inserted into the database.")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
url = "https://garden.inajar.nl/api/devices/?format=json"
|
||||||
|
access_token = "33bb3b42452306c58ecedc3c86cfae28ba22329c" # Replace this with your actual access token
|
||||||
|
|
||||||
|
|
||||||
|
# access_token = "33bb3b42452306c58ecedc3c86cfae28ba22329c"
|
||||||
|
|
||||||
|
# You can change the repeat_count to control how many times you want to repeat the process
|
||||||
|
repeat_count = 10
|
||||||
|
|
||||||
|
|
||||||
|
fetch_and_display_all(url, access_token, repeat_count)
|
||||||
73
script/fetch.py
Normal file
73
script/fetch.py
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import requests
|
||||||
|
import time
|
||||||
|
|
||||||
|
from db_connect import database_connect
|
||||||
|
|
||||||
|
# Establish a database connection
|
||||||
|
connection = database_connect()
|
||||||
|
|
||||||
|
def fetch_and_display_all(urls, access_token):
|
||||||
|
for url in urls:
|
||||||
|
try:
|
||||||
|
headers = {
|
||||||
|
"Authorization": f"Token {access_token}"
|
||||||
|
}
|
||||||
|
response = requests.get(url, headers=headers)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
print(f"Data from {url}:")
|
||||||
|
print(data)
|
||||||
|
load_data(data)
|
||||||
|
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(f"Error fetching data from {url}: {e}")
|
||||||
|
|
||||||
|
# Wait for a certain time (e.g., 60 seconds) before making the next call
|
||||||
|
print("Waiting for the next retrieval action...")
|
||||||
|
time.sleep(10) # Time here is in seconds.
|
||||||
|
|
||||||
|
def load_data(data):
|
||||||
|
mydb = database_connect()
|
||||||
|
if mydb.is_connected():
|
||||||
|
mycursor = mydb.cursor()
|
||||||
|
|
||||||
|
# Here you need to adjust the correct column names and data formats based on the API response
|
||||||
|
insert_query = """
|
||||||
|
INSERT INTO goodgarden.fetch (timestamp, gateway_receive_time, device, value)
|
||||||
|
VALUES (%s, %s, %s, %s)
|
||||||
|
"""
|
||||||
|
for record in data['results']: # Adjust this based on the actual structure of the JSON
|
||||||
|
timestamp = record.get('timestamp', '')
|
||||||
|
gateway_receive_time = record.get('gateway_receive_time', '')
|
||||||
|
device = record.get('device', '')
|
||||||
|
value = record.get('value', '')
|
||||||
|
|
||||||
|
print(f"Inserting data: timestamp={timestamp}, gateway_receive_time={gateway_receive_time}, device={device}, value={value}") # Print the data being inserted
|
||||||
|
|
||||||
|
# Execute the query
|
||||||
|
mycursor.execute(insert_query, (timestamp, gateway_receive_time, device, value))
|
||||||
|
|
||||||
|
# Commit the changes
|
||||||
|
mydb.commit()
|
||||||
|
|
||||||
|
# Close cursor and connection
|
||||||
|
mycursor.close()
|
||||||
|
mydb.close()
|
||||||
|
|
||||||
|
print("Data inserted into the database.")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
urls = [
|
||||||
|
"https://garden.inajar.nl/api/battery_voltage_events/?format=json",
|
||||||
|
"https://garden.inajar.nl/api/devices/?format=json",
|
||||||
|
"https://garden.inajar.nl/api/par_events/?format=json",
|
||||||
|
"https://garden.inajar.nl/api/relative_humidity_events/?format=json",
|
||||||
|
"https://garden.inajar.nl/api/soil_electric_conductivity_events/?format=json",
|
||||||
|
"https://garden.inajar.nl/api/soil_relative_permittivity_events/?format=json",
|
||||||
|
"https://garden.inajar.nl/api/soil_temperature_events/?format=json"
|
||||||
|
]
|
||||||
|
|
||||||
|
access_token = "33bb3b42452306c58ecedc3c86cfae28ba22329c" # Vervang dit met jouw echte toegangstoken
|
||||||
|
|
||||||
|
fetch_and_display_all(urls, access_token)
|
||||||
@@ -1,16 +1,9 @@
|
|||||||
import mysql.connector
|
|
||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
|
|
||||||
def database_connect():
|
from db_connect import database_connect
|
||||||
return mysql.connector.connect(
|
|
||||||
host="localhost",
|
|
||||||
user="root",
|
|
||||||
password="",
|
|
||||||
database="goodgarden"
|
|
||||||
)
|
|
||||||
|
|
||||||
def fetch_data():
|
def fetch_battery_voltage_events():
|
||||||
url = "https://garden.inajar.nl/api/battery_voltage_events/?format=json"
|
url = "https://garden.inajar.nl/api/battery_voltage_events/?format=json"
|
||||||
headers = {
|
headers = {
|
||||||
"Authorization": "Token 33bb3b42452306c58ecedc3c86cfae28ba22329c"
|
"Authorization": "Token 33bb3b42452306c58ecedc3c86cfae28ba22329c"
|
||||||
@@ -24,9 +17,8 @@ def fetch_data():
|
|||||||
data = response.json()
|
data = response.json()
|
||||||
load_data(data)
|
load_data(data)
|
||||||
|
|
||||||
# Wacht voor een bepaalde tijd (bijvoorbeeld 60 seconden) voordat je de volgende oproep doet
|
|
||||||
print("Wachten voor de volgende ophaalactie...")
|
print("Wachten voor de volgende ophaalactie...")
|
||||||
time.sleep(60) # De tijd hier is in seconden.
|
time.sleep(300) # De tijd hier is in seconden.
|
||||||
|
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
print(f"Error fetching data: {e}")
|
print(f"Error fetching data: {e}")
|
||||||
@@ -40,18 +32,16 @@ def load_data(data):
|
|||||||
|
|
||||||
# Hier moet je de juiste kolomnamen en dataformaten aanpassen op basis van de API-respons
|
# Hier moet je de juiste kolomnamen en dataformaten aanpassen op basis van de API-respons
|
||||||
insert_query = """
|
insert_query = """
|
||||||
INSERT INTO goodgarden.sensor_data (timestamp, gateway_receive_time, device, value)
|
INSERT INTO goodgarden.battery_voltage_events (timestamp, gateway_receive_time, device, value)
|
||||||
VALUES (%s, %s, %s, %s)
|
VALUES (%s, %s, %s, %s)
|
||||||
"""
|
"""
|
||||||
for record in data['results']: # Pas dit aan op basis van de werkelijke structuur van de JSON
|
for record in data['results']:
|
||||||
timestamp = record['timestamp']
|
timestamp = record['timestamp']
|
||||||
gateway_receive_time = record['gateway_receive_time']
|
gateway_receive_time = record['gateway_receive_time']
|
||||||
device = record['device']
|
device = record['device']
|
||||||
value = record['value']
|
value = record['value']
|
||||||
|
|
||||||
print(f"Inserting data: timestamp={timestamp}, gateway_receive_time={gateway_receive_time}, device={device}, value={value}") # Print de data die wordt ingevoegd
|
# print(f"Inserting data: timestamp={timestamp}, gateway_receive_time={gateway_receive_time}, device={device}, value={value}")
|
||||||
|
|
||||||
# Voer de query uit
|
|
||||||
mycursor.execute(insert_query, (timestamp, gateway_receive_time, device, value))
|
mycursor.execute(insert_query, (timestamp, gateway_receive_time, device, value))
|
||||||
|
|
||||||
# Commit de wijzigingen
|
# Commit de wijzigingen
|
||||||
@@ -64,4 +54,4 @@ def load_data(data):
|
|||||||
print("Data ingevoegd in de database.")
|
print("Data ingevoegd in de database.")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
fetch_data()
|
fetch_battery_voltage_events()
|
||||||
0
script/main.py
Normal file
0
script/main.py
Normal file
64
script/par_events.py
Normal file
64
script/par_events.py
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
import requests
|
||||||
|
import time
|
||||||
|
|
||||||
|
from db_connect import database_connect
|
||||||
|
|
||||||
|
def fetch_and_display_all(url, access_token, repeat_count=5):
|
||||||
|
for _ in range(repeat_count):
|
||||||
|
try:
|
||||||
|
headers = {
|
||||||
|
"Authorization": f"Token {access_token}"
|
||||||
|
}
|
||||||
|
response = requests.get(url, headers=headers)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
print(f"Data from {url}:")
|
||||||
|
print(data)
|
||||||
|
load_data(data)
|
||||||
|
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(f"Error fetching data from {url}: {e}")
|
||||||
|
|
||||||
|
print("Waiting for the next retrieval action...")
|
||||||
|
|
||||||
|
time.sleep(1) # Time here is in seconds.
|
||||||
|
|
||||||
|
|
||||||
|
def load_data(data):
|
||||||
|
mydb = database_connect()
|
||||||
|
if mydb.is_connected():
|
||||||
|
mycursor = mydb.cursor()
|
||||||
|
|
||||||
|
# Here you need to adjust the correct column names and data formats based on the API response
|
||||||
|
insert_query = """
|
||||||
|
INSERT INTO goodgarden.par_events (timestamp, gateway_receive_time, device, value)
|
||||||
|
VALUES (%s, %s, %s, %s)
|
||||||
|
"""
|
||||||
|
for record in data['results']:
|
||||||
|
timestamp = record.get('timestamp', '')
|
||||||
|
gateway_receive_time = record.get('gateway_receive_time', '')
|
||||||
|
device = record.get('device', '')
|
||||||
|
value = record.get('value', '')
|
||||||
|
|
||||||
|
print(f"Inserting data: timestamp={timestamp}, gateway_receive_time={gateway_receive_time}, device={device}, value={value}")
|
||||||
|
|
||||||
|
# Execute the query
|
||||||
|
mycursor.execute(insert_query, (timestamp, gateway_receive_time, device, value))
|
||||||
|
|
||||||
|
# Commit the changes
|
||||||
|
mydb.commit()
|
||||||
|
|
||||||
|
# Close cursor and connection
|
||||||
|
mycursor.close()
|
||||||
|
mydb.close()
|
||||||
|
|
||||||
|
print("Data inserted into the database.")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
url = "https://garden.inajar.nl/api/par_events/?format=json"
|
||||||
|
access_token = "33bb3b42452306c58ecedc3c86cfae28ba22329c"
|
||||||
|
# You can change the repeat_count to control how many times you want to repeat the process
|
||||||
|
repeat_count = 10
|
||||||
|
|
||||||
|
fetch_and_display_all(url, access_token, repeat_count)
|
||||||
64
script/relative_humidity_events.py
Normal file
64
script/relative_humidity_events.py
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
import requests
|
||||||
|
import time
|
||||||
|
|
||||||
|
from db_connect import database_connect
|
||||||
|
|
||||||
|
def fetch_and_display_all(url, access_token, repeat_count=5):
|
||||||
|
for _ in range(repeat_count):
|
||||||
|
try:
|
||||||
|
headers = {
|
||||||
|
"Authorization": f"Token {access_token}"
|
||||||
|
}
|
||||||
|
response = requests.get(url, headers=headers)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
print(f"Data from {url}:")
|
||||||
|
print(data)
|
||||||
|
load_data(data)
|
||||||
|
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(f"Error fetching data from {url}: {e}")
|
||||||
|
|
||||||
|
print("Waiting for the next retrieval action...")
|
||||||
|
|
||||||
|
time.sleep(1) # Time here is in seconds.
|
||||||
|
|
||||||
|
def load_data(data):
|
||||||
|
mydb = database_connect()
|
||||||
|
if mydb.is_connected():
|
||||||
|
mycursor = mydb.cursor()
|
||||||
|
|
||||||
|
# Here you need to adjust the correct column names and data formats based on the API response
|
||||||
|
insert_query = """
|
||||||
|
INSERT INTO goodgarden.relative_humidity_events (timestamp, gateway_receive_time, device, value)
|
||||||
|
VALUES (%s, %s, %s, %s)
|
||||||
|
"""
|
||||||
|
for record in data['results']:
|
||||||
|
timestamp = record.get('timestamp', '')
|
||||||
|
gateway_receive_time = record.get('gateway_receive_time', '')
|
||||||
|
device = record.get('device', '')
|
||||||
|
value = record.get('value', '')
|
||||||
|
|
||||||
|
print(f"Inserting data: timestamp={timestamp}, gateway_receive_time={gateway_receive_time}, device={device}, value={value}")
|
||||||
|
|
||||||
|
# Execute the query
|
||||||
|
mycursor.execute(insert_query, (timestamp, gateway_receive_time, device, value))
|
||||||
|
|
||||||
|
# Commit the changes
|
||||||
|
mydb.commit()
|
||||||
|
|
||||||
|
# Close cursor and connection
|
||||||
|
mycursor.close()
|
||||||
|
mydb.close()
|
||||||
|
|
||||||
|
print("Data inserted into the database.")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
url = "https://garden.inajar.nl/api/relative_humidity_events/?format=json"
|
||||||
|
access_token = "33bb3b42452306c58ecedc3c86cfae28ba22329c"
|
||||||
|
|
||||||
|
# You can change the repeat_count to control how many times you want to repeat the process
|
||||||
|
repeat_count = 10
|
||||||
|
|
||||||
|
fetch_and_display_all(url, access_token, repeat_count)
|
||||||
63
script/soil_electric_conductivity_events.py
Normal file
63
script/soil_electric_conductivity_events.py
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import requests
|
||||||
|
import time
|
||||||
|
|
||||||
|
from db_connect import database_connect
|
||||||
|
|
||||||
|
def fetch_and_display_all(url, access_token, repeat_count=5):
|
||||||
|
for _ in range(repeat_count):
|
||||||
|
try:
|
||||||
|
headers = {
|
||||||
|
"Authorization": f"Token {access_token}"
|
||||||
|
}
|
||||||
|
response = requests.get(url, headers=headers)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
print(f"Data from {url}:")
|
||||||
|
print(data)
|
||||||
|
load_data(data)
|
||||||
|
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(f"Error fetching data from {url}: {e}")
|
||||||
|
|
||||||
|
print("Waiting for the next retrieval action...")
|
||||||
|
|
||||||
|
time.sleep(1) # Time here is in seconds.
|
||||||
|
|
||||||
|
def load_data(data):
|
||||||
|
mydb = database_connect()
|
||||||
|
if mydb.is_connected():
|
||||||
|
mycursor = mydb.cursor()
|
||||||
|
|
||||||
|
# Here you need to adjust the correct column names and data formats based on the API response
|
||||||
|
insert_query = """
|
||||||
|
INSERT INTO goodgarden.soil_electric_conductivity_events (timestamp, gateway_receive_time, device, value)
|
||||||
|
VALUES (%s, %s, %s, %s)
|
||||||
|
"""
|
||||||
|
for record in data['results']:
|
||||||
|
timestamp = record.get('timestamp', '')
|
||||||
|
gateway_receive_time = record.get('gateway_receive_time', '')
|
||||||
|
device = record.get('device', '')
|
||||||
|
value = record.get('value', '')
|
||||||
|
|
||||||
|
print(f"Inserting data: timestamp={timestamp}, gateway_receive_time={gateway_receive_time}, device={device}, value={value}")
|
||||||
|
|
||||||
|
# Execute the query
|
||||||
|
mycursor.execute(insert_query, (timestamp, gateway_receive_time, device, value))
|
||||||
|
|
||||||
|
# Commit the changes
|
||||||
|
mydb.commit()
|
||||||
|
|
||||||
|
# Close cursor and connection
|
||||||
|
mycursor.close()
|
||||||
|
mydb.close()
|
||||||
|
|
||||||
|
print("Data inserted into the database.")
|
||||||
|
if __name__ == "__main__":
|
||||||
|
url = "https://garden.inajar.nl/api/soil_electric_conductivity_events/?format=json"
|
||||||
|
access_token = "33bb3b42452306c58ecedc3c86cfae28ba22329c" # Replace this with your actual access token
|
||||||
|
|
||||||
|
# You can change the repeat_count to control how many times you want to repeat the process
|
||||||
|
repeat_count = 10
|
||||||
|
|
||||||
|
fetch_and_display_all(url, access_token, repeat_count)
|
||||||
66
script/soil_relative_permittivity_events.py
Normal file
66
script/soil_relative_permittivity_events.py
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import requests
|
||||||
|
import time
|
||||||
|
|
||||||
|
from db_connect import database_connect
|
||||||
|
|
||||||
|
def fetch_and_display_all(url, access_token, repeat_count=5):
|
||||||
|
for _ in range(repeat_count):
|
||||||
|
try:
|
||||||
|
headers = {
|
||||||
|
"Authorization": f"Token {access_token}"
|
||||||
|
}
|
||||||
|
response = requests.get(url, headers=headers)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
print(f"Data from {url}:")
|
||||||
|
print(data)
|
||||||
|
load_data(data)
|
||||||
|
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(f"Error fetching data from {url}: {e}")
|
||||||
|
|
||||||
|
print("Waiting for the next retrieval action...")
|
||||||
|
|
||||||
|
time.sleep(1) # Time here is in seconds.
|
||||||
|
|
||||||
|
|
||||||
|
def load_data(data):
|
||||||
|
mydb = database_connect()
|
||||||
|
if mydb.is_connected():
|
||||||
|
mycursor = mydb.cursor()
|
||||||
|
|
||||||
|
# Here you need to adjust the correct column names and data formats based on the API response
|
||||||
|
insert_query = """
|
||||||
|
INSERT INTO goodgarden.soil_temperature_events (timestamp, gateway_receive_time, device, value)
|
||||||
|
VALUES (%s, %s, %s, %s)
|
||||||
|
"""
|
||||||
|
for record in data['results']:
|
||||||
|
timestamp = record.get('timestamp', '')
|
||||||
|
gateway_receive_time = record.get('gateway_receive_time', '')
|
||||||
|
device = record.get('device', '')
|
||||||
|
value = record.get('value', '')
|
||||||
|
|
||||||
|
print(f"Inserting data: timestamp={timestamp}, gateway_receive_time={gateway_receive_time}, device={device}, value={value}")
|
||||||
|
|
||||||
|
# Execute the query
|
||||||
|
mycursor.execute(insert_query, (timestamp, gateway_receive_time, device, value))
|
||||||
|
|
||||||
|
# Commit the changes
|
||||||
|
mydb.commit()
|
||||||
|
|
||||||
|
# Close cursor and connection
|
||||||
|
mycursor.close()
|
||||||
|
mydb.close()
|
||||||
|
|
||||||
|
print("Data inserted into the database.")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
url = "https://garden.inajar.nl/api/soil_relative_permittivity_events/?format=json"
|
||||||
|
access_token = "33bb3b42452306c58ecedc3c86cfae28ba22329c"
|
||||||
|
# You can change the repeat_count to control how many times you want to repeat the process
|
||||||
|
repeat_count = 10
|
||||||
|
|
||||||
|
# fetch_and_display_all(urls, access_token)
|
||||||
|
|
||||||
|
fetch_and_display_all(url, access_token, repeat_count)
|
||||||
65
script/soil_temperature_events.py
Normal file
65
script/soil_temperature_events.py
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
import requests
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
from db_connect import database_connect
|
||||||
|
|
||||||
|
def fetch_and_display_all(url, access_token, repeat_count=5):
|
||||||
|
for _ in range(repeat_count):
|
||||||
|
|
||||||
|
try:
|
||||||
|
headers = {
|
||||||
|
"Authorization": f"Token {access_token}"
|
||||||
|
}
|
||||||
|
response = requests.get(url, headers=headers)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
print(f"Data from {url}:")
|
||||||
|
print(data)
|
||||||
|
load_data(data)
|
||||||
|
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(f"Error fetching data from {url}: {e}")
|
||||||
|
|
||||||
|
print("Waiting for the next retrieval action...")
|
||||||
|
|
||||||
|
time.sleep(1) # Time here is in seconds.
|
||||||
|
|
||||||
|
def load_data(data):
|
||||||
|
mydb = database_connect()
|
||||||
|
if mydb.is_connected():
|
||||||
|
mycursor = mydb.cursor()
|
||||||
|
|
||||||
|
# Here you need to adjust the correct column names and data formats based on the API response
|
||||||
|
insert_query = """
|
||||||
|
INSERT INTO goodgarden.soil_temperature_events (timestamp, gateway_receive_time, device, value)
|
||||||
|
VALUES (%s, %s, %s, %s)
|
||||||
|
"""
|
||||||
|
for record in data['results']:
|
||||||
|
timestamp = record.get('timestamp', '')
|
||||||
|
gateway_receive_time = record.get('gateway_receive_time', '')
|
||||||
|
device = record.get('device', '')
|
||||||
|
value = record.get('value', '')
|
||||||
|
|
||||||
|
print(f"Inserting data: timestamp={timestamp}, gateway_receive_time={gateway_receive_time}, device={device}, value={value}")
|
||||||
|
|
||||||
|
# Execute the query
|
||||||
|
mycursor.execute(insert_query, (timestamp, gateway_receive_time, device, value))
|
||||||
|
|
||||||
|
# Commit the changes
|
||||||
|
mydb.commit()
|
||||||
|
|
||||||
|
# Close cursor and connection
|
||||||
|
mycursor.close()
|
||||||
|
mydb.close()
|
||||||
|
|
||||||
|
print("Data inserted into the database.")
|
||||||
|
if __name__ == "__main__":
|
||||||
|
url = "https://garden.inajar.nl/api/soil_temperature_events/?format=json"
|
||||||
|
access_token = "33bb3b42452306c58ecedc3c86cfae28ba22329c" # Replace this with your actual access token
|
||||||
|
|
||||||
|
# You can change the repeat_count to control how many times you want to repeat the process
|
||||||
|
repeat_count = 10
|
||||||
|
|
||||||
|
fetch_and_display_all(url, access_token, repeat_count)
|
||||||
236
src/css/style.css
Normal file
236
src/css/style.css
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
/*default colors*/
|
||||||
|
@import url("https://fonts.googleapis.com/css2?family=Akaya+Kanadaka&display=swap");
|
||||||
|
@import url("https://fonts.googleapis.com/css2?family=Afacad:ital,wght@0,400..700;1,400..700&display=swap");
|
||||||
|
h1, h2, h3, h4, h5 {
|
||||||
|
font-family: "Akaya Kanadaka", system-ui;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p, td {
|
||||||
|
font-family: "Afacad", sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-image: url("../images/achtergrond.png");
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
body .mainContainer {
|
||||||
|
width: 85vw;
|
||||||
|
height: 38rem;
|
||||||
|
background-color: rgba(255, 255, 255, 0.95);
|
||||||
|
border-radius: 40px;
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
|
body .mainContainer .goodgarden-logo {
|
||||||
|
position: absolute;
|
||||||
|
width: 10vw;
|
||||||
|
left: 50%;
|
||||||
|
top: 2.5rem;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
body .mainContainer .informatie-kas-main-container {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 5fr 7fr;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder {
|
||||||
|
padding: 1.25rem 1.5rem;
|
||||||
|
height: 35rem;
|
||||||
|
border: solid 5px rgb(171, 211, 174);
|
||||||
|
border-radius: 40px;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder .pagina-titel {
|
||||||
|
font-size: 2rem;
|
||||||
|
margin-left: 1.5rem;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 0 2.5rem 0 1rem;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .parent-algemeen-overzicht {
|
||||||
|
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
|
||||||
|
border-radius: 40px;
|
||||||
|
padding: 1rem;
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .parent-algemeen-overzicht .algemeen-overzicht {
|
||||||
|
border: solid 2px rgb(171, 211, 174);
|
||||||
|
border-radius: 35px;
|
||||||
|
font-size: 1.25rem;
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .parent-algemeen-overzicht .algemeen-overzicht .table-informatie-kas {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .parent-algemeen-overzicht .algemeen-overzicht .table-informatie-kas .tr-informatie-kas {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .grafiek {
|
||||||
|
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
|
||||||
|
border-radius: 40px;
|
||||||
|
padding: 1rem;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .grafiek .grafiek-innerbox {
|
||||||
|
border: solid 2px rgb(171, 211, 174);
|
||||||
|
border-radius: 35px;
|
||||||
|
font-size: 1.25rem;
|
||||||
|
padding: 0 1rem 2.5rem;
|
||||||
|
height: 225px;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .grafiek .grafiek-innerbox h2 {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .grafiek .grafiek-innerbox canvas {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .content {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 3fr 1fr 3fr;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .content .kant-links {
|
||||||
|
grid-column: 1;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .content .kant-links #planten {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .content .kant-links #planten td article {
|
||||||
|
height: 7rem;
|
||||||
|
width: 10rem;
|
||||||
|
padding: 0.6rem;
|
||||||
|
margin: 0.1rem;
|
||||||
|
margin-left: 2rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
border: solid 3px rgb(171, 211, 174);
|
||||||
|
border-radius: 40px;
|
||||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .content .kant-links #planten td article #toevoegen {
|
||||||
|
height: 5rem;
|
||||||
|
width: 5rem;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .content .kant-links #planten td article h2 {
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .content .kant-links #planten td article:hover {
|
||||||
|
background-color: lightgray;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .content .kant-rechts {
|
||||||
|
grid-column: 3;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .content .kant-rechts #metingen {
|
||||||
|
border: solid 3px rgb(171, 211, 174);
|
||||||
|
border-radius: 40px;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .content .kant-rechts #metingen #main-waardes {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
padding: 0.5rem;
|
||||||
|
padding-bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder #sectie-1 .content .kant-rechts #metingen #main-waardes table {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder .grid-column-2 {
|
||||||
|
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
|
||||||
|
border-radius: 40px;
|
||||||
|
padding: 1rem;
|
||||||
|
margin: 3.25rem 1rem 1.25rem 1rem;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder .grid-column-2 .grid-2-child {
|
||||||
|
border: solid 2px rgb(171, 211, 174);
|
||||||
|
border-radius: 35px;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder .grid-column-2 .grid-2-child .parent-table {
|
||||||
|
padding: 1.5rem 2rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-around;
|
||||||
|
height: 90%;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder .grid-column-2 .grid-2-child .parent-table table tr td {
|
||||||
|
font-size: 1.05rem;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder .grid-column-2 .grid-2-child .parent-table .kas-table-1 tr td {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder .grid-column-2 .grid-2-child .parent-table .kas-table-2 {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder .grid-column-2 .grid-2-child .parent-table .kas-table-2::after, body .mainContainer .mainBorder .grid-column-2 .grid-2-child .parent-table .kas-table-2::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 1px;
|
||||||
|
width: 90%;
|
||||||
|
background: black;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder .grid-column-2 .grid-2-child .parent-table .kas-table-2::after {
|
||||||
|
bottom: -20px;
|
||||||
|
}
|
||||||
|
body .mainContainer .mainBorder .grid-column-2 .grid-2-child .parent-table .kas-table-2::before {
|
||||||
|
top: -20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Divider */
|
||||||
|
.divider {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
border: solid 1px rgb(171, 211, 174);
|
||||||
|
border-radius: 5px;
|
||||||
|
width: 80%;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The Modal (background) */
|
||||||
|
.modal {
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
z-index: 999;
|
||||||
|
left: 50%;
|
||||||
|
top: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
background: white;
|
||||||
|
padding: 1.25rem;
|
||||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
width: 30vw;
|
||||||
|
height: auto;
|
||||||
|
border: solid 2px black;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
.modal .close {
|
||||||
|
color: #aaa;
|
||||||
|
float: right;
|
||||||
|
font-size: 1.75rem;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.modal .close:hover, .modal .close:active {
|
||||||
|
color: black;
|
||||||
|
text-decoration: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}/*# sourceMappingURL=style.css.map */
|
||||||
1
src/css/style.css.map
Normal file
1
src/css/style.css.map
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["style.scss","style.css"],"names":[],"mappings":"AAAA,iBAAA;AAKQ,mFAAA;AACA,2GAAA;AAgCR;EAEI,wCAhCU;EAiCV,SAAA;ACnCJ;;ADsCA;EAEI,iCApCQ;ACAZ;;ADuCA;EAEI,kDAAA;EACA,4BAAA;EACA,sBAAA;EACA,2BAAA;EAEA,aAAA;EACA,uBAAA;EACA,mBAAA;EACA,aAAA;EACA,SAAA;ACtCJ;ADwCI;EAEI,WAAA;EACA,aAAA;EACA,2CAAA;EACA,mBAAA;EACA,aAAA;ACvCR;ADyCQ;EAGI,kBAAA;EACA,WAAA;EACA,SAAA;EACA,WAAA;EACA,2BAAA;ACzCZ;AD4CQ;EAEI,aAAA;EACA,8BAAA;AC3CZ;AD8CQ;EAEI,uBAAA;EACA,aAAA;EACA,oCAAA;EACA,mBAAA;AC7CZ;AD+CY;EAEI,eAAA;EACA,mBAAA;AC9ChB;ADiDY;EAEI,aAAA;EACA,sBAAA;EACA,SAAA;EACA,wBAAA;EACA,kBAAA;AChDhB;ADkDgB;EAlFZ,2CAAA;EAKA,mBAAA;EAiFgB,aAAA;EACA,gBAAA;ACjDpB;ADoDoB;EA/FhB,oCAAA;EAeA,mBAAA;EAoFoB,kBAAA;EACA,oBAAA;ACnDxB;ADsDwB;EAEI,WAAA;ACrD5B;ADuD4B;EAEI,aAAA;EACA,8BAAA;EACA,gBAAA;ACtDhC;AD8DgB;EAlHZ,2CAAA;EAKA,mBAAA;EAiHgB,aAAA;EACA,kBAAA;AC7DpB;AD+DoB;EA9HhB,oCAAA;EAeA,mBAAA;EAmHoB,kBAAA;EACA,sBAAA;EACA,aAAA;AC9DxB;ADiEwB;EAEI,kBAAA;EACA,SAAA;EACA,2BAAA;AChE5B;ADmEwB;EAGI,kBAAA;EACA,QAAA;EACA,SAAA;EACA,gCAAA;ACnE5B;ADwEgB;EAEI,aAAA;EACA,kCAAA;EACA,YAAA;ACvEpB;AD2EwB;EAEI,cAAA;AC1E5B;AD4E4B;EAEI,WAAA;EACA,yBAAA;AC3EhC;AD+EoC;EAEI,YAAA;EACA,YAAA;EACA,eAAA;EACA,cAAA;EACA,iBAAA;EACA,aAAA;EACA,sBAAA;EACA,uBAAA;EACA,mBAAA;EACA,oCAAA;EACA,mBAAA;EACA,wCAAA;AC9ExC;ADgFwC;EAEI,YAAA;EACA,WAAA;AC/E5C;ADkFwC;EAEI,WAAA;ACjF5C;ADoFwC;EAEI,2BAAA;ACnF5C;AD4FwB;EAEI,cAAA;AC3F5B;AD8F4B;EAGI,oCAAA;EACA,mBAAA;AC9FhC;ADgGgC;EAEA,aAAA;EACA,6BAAA;EACA,eAAA;EACA,iBAAA;EACA,WAAA;AC/FhC;ADiGoC;EAEI,aAAA;EACA,6BAAA;AChGxC;AD0GY;EA5OR,2CAAA;EAKA,mBAAA;EA2OY,aAAA;EACA,iCAAA;ACzGhB;AD2GgB;EAxPZ,oCAAA;EAeA,mBAAA;EA6OgB,YAAA;AC1GpB;AD6GoB;EAEI,oBAAA;EACA,aAAA;EACA,sBAAA;EAGA,6BAAA;EACA,WAAA;AC9GxB;ADoHgC;EAEI,kBAAA;ACnHpC;AD4HgC;EAEI,kBAAA;AC3HpC;ADgIwB;EAEI,kBAAA;AC/H5B;ADiI4B;EAGI,WAAA;EACA,kBAAA;EACA,OAAA;EACA,QAAA;EACA,WAAA;EACA,UAAA;EACA,iBAAA;ACjIhC;ADoI4B;EAEI,aAAA;ACnIhC;ADsI4B;EAEI,UAAA;ACrIhC;;ADiJI,YAAA;AACJ;EACI,aAAA;EACA,uBAAA;EACA,oCAAA;EACA,kBAAA;EACA,UAAA;EACA,cAAA;AC9IJ;;ADiJA,2BAAA;AAEA;EAEI,aAAA;EACA,eAAA;EACA,YAAA;EACA,SAAA;EACA,QAAA;EACA,gCAAA;EACA,iBAAA;EACA,gBAAA;EACA,wCAAA;EACA,WAAA;EACA,YAAA;EACA,uBAAA;EACA,mBAAA;AChJJ;ADkJI;EAEI,WAAA;EACA,YAAA;EACA,kBAAA;EACA,iBAAA;ACjJR;ADmJQ;EAGI,YAAA;EACA,qBAAA;EACA,eAAA;ACnJZ","file":"style.css"}
|
||||||
386
src/css/style.scss
Normal file
386
src/css/style.scss
Normal file
@@ -0,0 +1,386 @@
|
|||||||
|
/*default colors*/
|
||||||
|
|
||||||
|
$primary-color: rgb(171, 211, 174);
|
||||||
|
$secondary-color: rgb(143, 188, 143);
|
||||||
|
|
||||||
|
@import url('https://fonts.googleapis.com/css2?family=Akaya+Kanadaka&display=swap');
|
||||||
|
@import url('https://fonts.googleapis.com/css2?family=Afacad:ital,wght@0,400..700;1,400..700&display=swap');
|
||||||
|
|
||||||
|
$font-titels: "Akaya Kanadaka", system-ui;
|
||||||
|
|
||||||
|
$font-text: "Afacad", sans-serif;
|
||||||
|
|
||||||
|
@mixin flexbox
|
||||||
|
{
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin groene-border
|
||||||
|
{
|
||||||
|
border: solid 2px $primary-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin box-shadow
|
||||||
|
{
|
||||||
|
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin border-radius
|
||||||
|
{
|
||||||
|
border-radius: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin inner-border-radius
|
||||||
|
{
|
||||||
|
border-radius: 35px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5
|
||||||
|
{
|
||||||
|
font-family: $font-titels;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p, td
|
||||||
|
{
|
||||||
|
font-family: $font-text;
|
||||||
|
}
|
||||||
|
|
||||||
|
body
|
||||||
|
{
|
||||||
|
background-image: url("../images/achtergrond.png");
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
// font-family: $font-text;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
|
||||||
|
.mainContainer
|
||||||
|
{
|
||||||
|
width: 85vw;
|
||||||
|
height: 38rem;
|
||||||
|
background-color: rgb(255, 255, 255, 95%);
|
||||||
|
border-radius: 40px;
|
||||||
|
padding: 2rem;
|
||||||
|
|
||||||
|
.goodgarden-logo
|
||||||
|
{
|
||||||
|
// z-index: inherit;
|
||||||
|
position: absolute;
|
||||||
|
width: 10vw;
|
||||||
|
left: 50%;
|
||||||
|
top: 2.5rem;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.informatie-kas-main-container
|
||||||
|
{
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 5fr 7fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mainBorder
|
||||||
|
{
|
||||||
|
padding: 1.25rem 1.5rem;
|
||||||
|
height: 35rem;
|
||||||
|
border: solid 5px $primary-color;
|
||||||
|
border-radius: 40px;
|
||||||
|
|
||||||
|
.pagina-titel
|
||||||
|
{
|
||||||
|
font-size: 2rem;
|
||||||
|
margin-left: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sectie-1
|
||||||
|
{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 0 2.5rem 0 1rem;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.parent-algemeen-overzicht
|
||||||
|
{
|
||||||
|
@include box-shadow;
|
||||||
|
@include border-radius;
|
||||||
|
padding: 1rem;
|
||||||
|
margin-top: 1rem;
|
||||||
|
|
||||||
|
|
||||||
|
.algemeen-overzicht
|
||||||
|
{
|
||||||
|
@include groene-border;
|
||||||
|
@include inner-border-radius;
|
||||||
|
font-size: 1.25rem;
|
||||||
|
padding: .5rem 1rem;
|
||||||
|
// background-color: red;
|
||||||
|
|
||||||
|
.table-informatie-kas
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.tr-informatie-kas
|
||||||
|
{
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.grafiek
|
||||||
|
{
|
||||||
|
@include box-shadow;
|
||||||
|
@include border-radius;
|
||||||
|
padding: 1rem;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.grafiek-innerbox
|
||||||
|
{
|
||||||
|
@include groene-border;
|
||||||
|
@include inner-border-radius;
|
||||||
|
font-size: 1.25rem;
|
||||||
|
padding: 0 1rem 2.5rem;
|
||||||
|
height: 225px;
|
||||||
|
// position: relative;
|
||||||
|
|
||||||
|
h2
|
||||||
|
{
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas
|
||||||
|
{
|
||||||
|
// Zorgt ervoor dat de grafiek precies in eht midden komt
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.content
|
||||||
|
{
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 3fr 1fr 3fr;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
.kant
|
||||||
|
{
|
||||||
|
&-links
|
||||||
|
{
|
||||||
|
grid-column: 1;
|
||||||
|
|
||||||
|
#planten
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
|
||||||
|
td
|
||||||
|
{
|
||||||
|
article
|
||||||
|
{
|
||||||
|
height: 7rem;
|
||||||
|
width: 10rem;
|
||||||
|
padding: .6rem;
|
||||||
|
margin: .1rem;
|
||||||
|
margin-left: 2rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
border: solid 3px $primary-color;
|
||||||
|
border-radius: 40px;
|
||||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
|
||||||
|
#toevoegen
|
||||||
|
{
|
||||||
|
height: 5rem;
|
||||||
|
width: 5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2
|
||||||
|
{
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover
|
||||||
|
{
|
||||||
|
background-color: lightgray;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-rechts
|
||||||
|
{
|
||||||
|
grid-column: 3;
|
||||||
|
// margin-right: 2rem;
|
||||||
|
|
||||||
|
#metingen
|
||||||
|
{
|
||||||
|
|
||||||
|
border: solid 3px $primary-color;
|
||||||
|
border-radius: 40px;
|
||||||
|
|
||||||
|
#main-waardes
|
||||||
|
{
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
padding: .5rem;
|
||||||
|
padding-bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
table
|
||||||
|
{
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
// width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-column-2
|
||||||
|
{
|
||||||
|
@include box-shadow;
|
||||||
|
@include border-radius;
|
||||||
|
padding: 1rem;
|
||||||
|
margin: 3.25rem 1rem 1.25rem 1rem;
|
||||||
|
|
||||||
|
.grid-2-child
|
||||||
|
{
|
||||||
|
@include groene-border;
|
||||||
|
@include inner-border-radius;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
|
||||||
|
.parent-table
|
||||||
|
{
|
||||||
|
padding: 1.5rem 2rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
// align-items: stretch;
|
||||||
|
// gap: 2.5rem;
|
||||||
|
justify-content: space-around;
|
||||||
|
height: 90%;
|
||||||
|
|
||||||
|
table
|
||||||
|
{
|
||||||
|
tr
|
||||||
|
{
|
||||||
|
td
|
||||||
|
{
|
||||||
|
font-size: 1.05rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.kas-table-1
|
||||||
|
{
|
||||||
|
tr
|
||||||
|
{
|
||||||
|
td
|
||||||
|
{
|
||||||
|
font-size: 1.25rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.kas-table-2
|
||||||
|
{
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&::after,
|
||||||
|
&::before
|
||||||
|
{
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 1px;
|
||||||
|
width: 90%;
|
||||||
|
background: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::after
|
||||||
|
{
|
||||||
|
bottom: -20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::before
|
||||||
|
{
|
||||||
|
top: -20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Divider */
|
||||||
|
.divider {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
border: solid 1px $primary-color;
|
||||||
|
border-radius: 5px;
|
||||||
|
width: 80%;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The Modal (background) */
|
||||||
|
|
||||||
|
.modal
|
||||||
|
{
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
z-index: 999;
|
||||||
|
left: 50%;
|
||||||
|
top: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
background: white;
|
||||||
|
padding: 1.25rem;
|
||||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
width: 30vw;
|
||||||
|
height: auto;
|
||||||
|
border: solid 2px black;
|
||||||
|
border-radius: 10px;
|
||||||
|
|
||||||
|
.close
|
||||||
|
{
|
||||||
|
color: #aaa;
|
||||||
|
float: right;
|
||||||
|
font-size: 1.75rem;
|
||||||
|
font-weight: bold;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:active
|
||||||
|
{
|
||||||
|
color: black;
|
||||||
|
text-decoration: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
src/images/Icon awesome-apple-alt.png
Normal file
BIN
src/images/Icon awesome-apple-alt.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
src/images/Toevoegen.png
Normal file
BIN
src/images/Toevoegen.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 107 KiB |
BIN
src/images/achtergrond.png
Normal file
BIN
src/images/achtergrond.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 MiB |
BIN
src/images/logo.png
Normal file
BIN
src/images/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
119
src/index.html
Normal file
119
src/index.html
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Document</title>
|
||||||
|
<link rel="stylesheet" href="./css/style.css">
|
||||||
|
<script src="../script/main.js" defer></script>
|
||||||
|
<!-- <script src="../script/main.py"></script> -->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<section class="mainContainer">
|
||||||
|
<section class="mainBorder">
|
||||||
|
<section class="content">
|
||||||
|
<section class="kant-links">
|
||||||
|
<table id="planten">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="../src/kas_informatie.html">
|
||||||
|
<article class="article-1">
|
||||||
|
<img src="images/Icon awesome-apple-alt.png" alt="">
|
||||||
|
<h2>Tomaat</h2>
|
||||||
|
</article>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<article>
|
||||||
|
<img src="images/Icon awesome-apple-alt.png" alt="">
|
||||||
|
<h2>Tomaat</h2>
|
||||||
|
</article>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<!-- Second Row -->
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<article>
|
||||||
|
<img src="images/Icon awesome-apple-alt.png" alt="">
|
||||||
|
<h2>Tomaat</h2>
|
||||||
|
</article>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<article>
|
||||||
|
<img src="images/Icon awesome-apple-alt.png" alt="">
|
||||||
|
<h2>Tomaat</h2>
|
||||||
|
</article>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<!-- Third Row -->
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<article>
|
||||||
|
<img src="images/Icon awesome-apple-alt.png" alt="">
|
||||||
|
<h2>Tomaat</h2>
|
||||||
|
</article>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<article>
|
||||||
|
<img src="images/Icon awesome-apple-alt.png" alt="">
|
||||||
|
<h2>Tomaat</h2>
|
||||||
|
</article>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<!-- Fourth Row -->
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<article>
|
||||||
|
<img src="images/Icon awesome-apple-alt.png" alt="">
|
||||||
|
<h2>Tomaat</h2>
|
||||||
|
</article>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<article id="modalButton" onclick="openModal()">
|
||||||
|
<img id="toevoegen"src="images/Toevoegen.png" alt="">
|
||||||
|
</article>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<div id="myModal" class="modal">
|
||||||
|
<!-- Modal content -->
|
||||||
|
<span class="close">×</span>
|
||||||
|
<form action="http://localhost:3000/submit-form" method="post">
|
||||||
|
<!-- Form content -->
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<!-- White space -->
|
||||||
|
<section>
|
||||||
|
<p>a</p>
|
||||||
|
</section>
|
||||||
|
<section class="kant-rechts">
|
||||||
|
<section id="metingen">
|
||||||
|
<article id="main-waardes">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>Waardes</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>Huidig</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>24u gemiddelde</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</article>
|
||||||
|
<div class="divider">
|
||||||
|
</div>
|
||||||
|
<article>
|
||||||
|
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
124
src/js/main.js
Normal file
124
src/js/main.js
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
const { ipcRenderer } = require("electron");
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', () =>
|
||||||
|
{
|
||||||
|
// Stuur een bericht naar de main process om het Python script uit te voeren
|
||||||
|
// In je renderer.js (geladen met defer in je HTML)
|
||||||
|
ipcRenderer.send('request-update-temp', ['some', 'arguments']);
|
||||||
|
|
||||||
|
ipcRenderer.on('update-temp-result', (event, newTemperature) => {
|
||||||
|
if (newTemperature === 'error') {
|
||||||
|
console.error('Er is een fout opgetreden bij het ophalen van de nieuwe temperatuur');
|
||||||
|
} else {
|
||||||
|
document.getElementById('bodem-temperatuur').textContent = newTemperature;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// function dataTablePython()
|
||||||
|
// {
|
||||||
|
// document.getElementById("")
|
||||||
|
// }
|
||||||
|
|
||||||
|
function openModal()
|
||||||
|
{
|
||||||
|
const modal = document.getElementById("myModal");
|
||||||
|
const button = document.getElementById("modalButton");
|
||||||
|
const close = document.getElementsByClassName("close")[0];
|
||||||
|
|
||||||
|
// Toon de modal wanneer op de knop wordt geklikt
|
||||||
|
button.onclick = function()
|
||||||
|
{
|
||||||
|
modal.style.display = "block";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sluit de modal wanneer op het 'sluiten' icoon wordt geklikt
|
||||||
|
close.onclick = function()
|
||||||
|
{
|
||||||
|
modal.style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sluit de modal wanneer buiten de modal wordt geklikt
|
||||||
|
window.onclick = function(event)
|
||||||
|
{
|
||||||
|
if (event.target == modal)
|
||||||
|
{
|
||||||
|
modal.style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* --- Functie om de grafiek te tekenen. Enigste belangrijke is de eerste 2 "const" arrays "data" & "xLabels".
|
||||||
|
*/
|
||||||
|
function drawLineChart()
|
||||||
|
{
|
||||||
|
/*Dit is de data die getoond wordt als "punt" op de grafiek. 20 = y20 / x20, 50 = y50 / x50 enzovoort... De array "data" & "xLabels" moeten beide evenveel array items hebben!!*/
|
||||||
|
const data = [20, 50, 60, 45, 50, 100, 70, 60, 65, 0, 85, 0];
|
||||||
|
const xLabels = ["", "", "", "", "", 6, "", "", "", "", "", 12];
|
||||||
|
|
||||||
|
// Define Y-axis labels here. The number of labels should match your scale.
|
||||||
|
const yLabels = ["", 20, "", 40, "", 60, "", 80, "", 100]; /*NIET VERANDEREN!!!*/
|
||||||
|
|
||||||
|
const canvas = document.getElementById("myCanvas");
|
||||||
|
const ctx = canvas.getContext("2d");
|
||||||
|
|
||||||
|
ctx.clearRect(0, 0, canvas.width, canvas.height); // Clear the canvas
|
||||||
|
|
||||||
|
const padding = 35; // Increased padding for Y labels
|
||||||
|
const graphWidth = canvas.width - padding * 2;
|
||||||
|
const graphHeight = canvas.height - padding * 2;
|
||||||
|
|
||||||
|
// Draw the axes
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(padding, padding);
|
||||||
|
ctx.lineTo(padding, canvas.height - padding);
|
||||||
|
ctx.lineTo(canvas.width - padding, canvas.height - padding);
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
// Set the color of the line
|
||||||
|
ctx.strokeStyle = "#008000"; // This sets the line color to green
|
||||||
|
|
||||||
|
const xIncrement = graphWidth / (xLabels.length - 1);
|
||||||
|
const yIncrement = graphHeight / (yLabels.length - 1); // Assuming you have labels for each increment
|
||||||
|
|
||||||
|
// Plot the data
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(padding, canvas.height - padding - (data[0] / 100) * graphHeight);
|
||||||
|
|
||||||
|
for (let i = 1; i < data.length; i++)
|
||||||
|
{
|
||||||
|
const xPos = padding + i * xIncrement;
|
||||||
|
const yPos = canvas.height - padding - (data[i] / 100) * graphHeight;
|
||||||
|
ctx.lineTo(xPos, yPos);
|
||||||
|
}
|
||||||
|
ctx.stroke(); // Apply the stroke to the line
|
||||||
|
|
||||||
|
// Draw Y labels
|
||||||
|
ctx.fillStyle = "black";
|
||||||
|
ctx.textAlign = "right"; // Align text to the right
|
||||||
|
ctx.textBaseline = "middle"; // Center vertically
|
||||||
|
|
||||||
|
for (let i = 0; i < yLabels.length; i++)
|
||||||
|
{
|
||||||
|
if (yLabels[i] !== "")
|
||||||
|
{
|
||||||
|
const yPos = canvas.height - padding - i * yIncrement;
|
||||||
|
ctx.fillText(yLabels[i], padding - 10, yPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw X labels
|
||||||
|
ctx.textAlign = "center"; // Center horizontally for X labels
|
||||||
|
for (let i = 0; i < xLabels.length; i++)
|
||||||
|
{
|
||||||
|
if (xLabels[i] !== "")
|
||||||
|
{
|
||||||
|
const xPos = padding + i * xIncrement;
|
||||||
|
ctx.fillText(xLabels[i], xPos, canvas.height - padding + 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
drawLineChart();
|
||||||
111
src/kas_informatie.html
Normal file
111
src/kas_informatie.html
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<link rel="stylesheet" href="../src/css/style.css" />
|
||||||
|
<!-- <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> -->
|
||||||
|
<script src="../src/js/main.js" defer></script>
|
||||||
|
<title>Informatie Kas</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<section class="mainContainer">
|
||||||
|
<article>
|
||||||
|
<img src="../src/images/logo.png" class="goodgarden-logo">
|
||||||
|
</article>
|
||||||
|
<section class="mainBorder informatie-kas-main-container">
|
||||||
|
<article>
|
||||||
|
<h1 class="pagina-titel">Informatie Kas</h1>
|
||||||
|
<section id="sectie-1">
|
||||||
|
<article class="parent-algemeen-overzicht">
|
||||||
|
<article class="algemeen-overzicht">
|
||||||
|
<table class="table-informatie-kas">
|
||||||
|
<tr class="tr-informatie-kas">
|
||||||
|
<td>Dagen tot Oogst</td>
|
||||||
|
<td>12</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="tr-informatie-kas">
|
||||||
|
<td>Dagen in Kas</td>
|
||||||
|
<td>2</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="tr-informatie-kas">
|
||||||
|
<td>Tevredenheid</td>
|
||||||
|
<td>80%</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="tr-informatie-kas">
|
||||||
|
<td>Aandachtspunten</td>
|
||||||
|
<td>1</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</article>
|
||||||
|
</article>
|
||||||
|
<article class="grafiek">
|
||||||
|
<article class="grafiek-innerbox">
|
||||||
|
<h2>Zonlicht</h2>
|
||||||
|
<canvas
|
||||||
|
id="myCanvas" class="canvas-informatie-kas" width="275" height="275"></canvas>
|
||||||
|
</article>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
<!-- <section id="sectie-2"></section> -->
|
||||||
|
</article>
|
||||||
|
<article class="grid-column-2">
|
||||||
|
<article class="grid-2-child">
|
||||||
|
<section class="parent-table">
|
||||||
|
<table class="kas-table-1">
|
||||||
|
<tr>
|
||||||
|
<td>Aantal geplant:</td>
|
||||||
|
<td>2</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Succesvolle Oogst:</td>
|
||||||
|
<td>2</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Gefaalde Oogst:</td>
|
||||||
|
<td>2</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<table class="kas-table-2">
|
||||||
|
<tr>
|
||||||
|
<td>Warmste Maand:</td>
|
||||||
|
<td>n.v.t.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>koudste Maand:</td>
|
||||||
|
<td>December</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Gemiddelde Bodemtemp.:</td>
|
||||||
|
<td id="bodem-temperatuur">2˚C</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Gemiddelde Uren Zonlicht:</td>
|
||||||
|
<td id="battery_voltage">2u</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<table class="kas-table-3">
|
||||||
|
<tr>
|
||||||
|
<td>Laatste Irrigatie:</td>
|
||||||
|
<td>2u</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Aankomende Irrigatie:</td>
|
||||||
|
<td>2u</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Laatste Bemesting</td>
|
||||||
|
<td>2d</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Aankomende Bemesting:</td>
|
||||||
|
<td>2w</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
|
</article>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Document</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>sdgdfsgjindgfvadsiuuiadsiuhdgnhaewgiadsnugaeuigndfogjdfsgdff</h1>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
7
src/py/calculate.py
Normal file
7
src/py/calculate.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# In calculate.py
|
||||||
|
|
||||||
|
# Doe je berekeningen hier, vervang 42 door je berekende waarde
|
||||||
|
calculated_value = 42
|
||||||
|
|
||||||
|
# Print het resultaat, dat zal worden gelezen door de PythonShell.run callback
|
||||||
|
print(calculated_value)
|
||||||
Reference in New Issue
Block a user