From 0595e6dcae584760affd3d4c6f6760d8b211508b Mon Sep 17 00:00:00 2001 From: Jonah Aden <151240959+adenjonah@users.noreply.github.com> Date: Wed, 22 May 2024 08:08:09 -0500 Subject: [PATCH] rocks update --- server/json_databases/DCUUIA.json | 2 +- server/json_databases/geojson/user_pins.json | 48 ++++- server/json_databases/saved_rocks.json | 32 +++ server/server.py | 2 +- src/pages-style/rocks.css | 163 ++++++++++----- src/pages/focus/rocks.js | 208 ++++++++++--------- 6 files changed, 309 insertions(+), 146 deletions(-) diff --git a/server/json_databases/DCUUIA.json b/server/json_databases/DCUUIA.json index 5e352c9..7f1e198 100644 --- a/server/json_databases/DCUUIA.json +++ b/server/json_databases/DCUUIA.json @@ -1 +1 @@ -{"timestamp": "2024-05-22T07:28:53.869186", "dcu": {"eva1": {"batt": false, "oxy": false, "comm": false, "fan": false, "pump": false, "co2": false}, "eva2": {"batt": false, "oxy": false, "comm": false, "fan": false, "pump": false, "co2": false}}, "uia": {"eva1_power": false, "eva1_oxy": false, "eva1_water_supply": false, "eva1_water_waste": false, "eva2_power": false, "eva2_oxy": false, "eva2_water_supply": false, "eva2_water_waste": false, "oxy_vent": false, "depress": false}} \ No newline at end of file +{"timestamp": "2024-05-22T08:08:08.215779", "dcu": {"eva1": {"batt": false, "oxy": false, "comm": false, "fan": false, "pump": false, "co2": false}, "eva2": {"batt": false, "oxy": false, "comm": false, "fan": false, "pump": false, "co2": false}}, "uia": {"eva1_power": false, "eva1_oxy": false, "eva1_water_supply": false, "eva1_water_waste": false, "eva2_power": false, "eva2_oxy": false, "eva2_water_supply": false, "eva2_water_waste": false, "oxy_vent": false, "depress": false}} \ No newline at end of file diff --git a/server/json_databases/geojson/user_pins.json b/server/json_databases/geojson/user_pins.json index 188bb9e..33c08c8 100644 --- a/server/json_databases/geojson/user_pins.json +++ b/server/json_databases/geojson/user_pins.json @@ -1 +1,47 @@ -{"type": "FeatureCollection", "features": []} \ No newline at end of file +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "Name": "Eva1 @ 5126" + }, + "geometry": { + "coordinates": [ + -95.08173200489527, + 29.56480501479513 + ], + "type": "Point" + }, + "id": 5126 + }, + { + "type": "Feature", + "properties": { + "Name": "Eva1 @ 5312" + }, + "geometry": { + "coordinates": [ + -95.08173200489527, + 29.56480501479513 + ], + "type": "Point" + }, + "id": 5312 + }, + { + "type": "Feature", + "properties": { + "Name": "Eva1 @ 5335" + }, + "geometry": { + "coordinates": [ + -95.08173200489527, + 29.56480501479513 + ], + "type": "Point" + }, + "id": 5335 + } + ] +} \ No newline at end of file diff --git a/server/json_databases/saved_rocks.json b/server/json_databases/saved_rocks.json index dbd8b48..b79949a 100644 --- a/server/json_databases/saved_rocks.json +++ b/server/json_databases/saved_rocks.json @@ -1,5 +1,37 @@ { "saved rocks": [ + { + "name": "pigeonite_basalt", + "id": 5, + "data": { + "SiO2": 39.41, + "TiO2": 0.39, + "Al2O3": 1.94, + "FeO": 29.3, + "MnO": 0.71, + "MgO": 19.27, + "CaO": 3.8, + "K2O": 0.12, + "P2O3": 0.3, + "other": 4.76 + } + }, + { + "name": "ilmenite_basalt", + "id": 7, + "data": { + "SiO2": 43.98, + "TiO2": 1.04, + "Al2O3": 5.75, + "FeO": 20.4, + "MnO": 0.51, + "MgO": 6.02, + "CaO": 8.89, + "K2O": 0.71, + "P2O3": 1.09, + "other": 11.61 + } + }, { "name": "ilmenite_basalt", "id": 7, diff --git a/server/server.py b/server/server.py index 857bc5c..b385149 100644 --- a/server/server.py +++ b/server/server.py @@ -155,7 +155,7 @@ async def get_warnings(): raise HTTPException(status_code=404, detail="DATA.json not found") @app.get("/spec_scans") -async def get_warnings(): +async def get_spec_scans(): if os.path.exists(DATA_FILE): with open(DATA_FILE, 'r') as f: data = json.load(f) diff --git a/src/pages-style/rocks.css b/src/pages-style/rocks.css index 6b85392..a3de12b 100644 --- a/src/pages-style/rocks.css +++ b/src/pages-style/rocks.css @@ -1,64 +1,133 @@ -.rocks-container { - display: flex; - height: 90vh; - /*width: 100vw;*/ - background-color: #cce6ff; - } - - .left-section { - width: 60%; - display: flex; - flex-direction: column; - } - - .top-div, .bottom-div { - height: 50%; - padding: 20px; - background-color: #f0f8ff; /* Light blue background */ - border-radius: 10px; - margin: 10px; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); - } - - .right-section { - width: 40%; - padding: 20px; - background-color: rgb(72, 72, 244); /* Blue background */ - border-radius: 10px; - margin: 10px; - display: flex; - justify-content: center; - align-items: center; - color: black; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); - } - /* rocks.css */ -.rocks-container { +#rocks-container { + background-color: #cce6ff; display: flex; flex-direction: row; - height: 100vh; + height: 90vh; + width: 100vw; padding: 20px; + box-sizing: border-box; } -.left-section, .right-section { +#left-section, #right-section { flex: 1; - padding: 20px; - box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); margin: 10px; - border-radius: 8px; + background-color: rgb(72, 72, 244); + display: flex; + flex-direction: column; + justify-content: space-around; + align-items: center; + border-radius: 20px; + padding: 20px; + box-sizing: border-box; +} + +#left-section { + width: 45%; } -.left-section { - background-color: #f9f9f9; +#right-section { + width: 45%; + position: relative; } -.right-section { - background-color: #ffffff; +#left-section > div, #right-section > div { + width: 100%; + height: 50%; + background-color: lightblue; + color: black; display: flex; - flex-direction: column; justify-content: center; + align-items: center; + border-radius: 5px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); + padding: 20px; + box-sizing: border-box; +} + +#right-section pre, #left-section .bottom-div pre { + width: 100%; + height: 100%; + background-color: #f0f8ff; + border-radius: 4px; + padding: 10px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + box-sizing: border-box; + overflow: auto; } -.top-div, .bottom-div { +#left-section .top-div, #left-section .bottom-div { margin-bottom: 20px; } + +#left-section .top-div:last-child, #left-section .bottom-div:last-child { + margin-bottom: 0; +} + +.data-container { + display: flex; + flex-direction: row; + justify-content: space-between; + width: 100%; +} + +.ev1-data { + width: 30%; +} + +.significant-info { + width: 70%; + scale: 80%; +} + +.significant-info { + background-color: #f0f8ff; + border-radius: 4px; + padding: 10px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); +} + +.significant-info h3 { + margin: 0; + padding-bottom: 10px; +} + +.significant-info ul { + list-style-type: none; + padding: 0; +} + +.significant-info ul li { + margin: 5px 0; +} + +.button-container { + display: flex; + flex-direction: row; + justify-content: space-between; + width: 100%; + margin-top: 30px; +} + +#save-button, #drop-pin-button { + text-align: center; + width: 48%; + height: 30%; + background-color: rgb(73, 209, 254); + color: white; + display: flex; + justify-content: center; + align-items: center; + border-radius: 5px; + cursor: pointer; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); + transition: background-color 0.3s; +} + +#save-button:hover, #drop-pin-button:hover { + background-color: darkblue; +} + +#right-section p { + margin-top: 10px; + color: white; +} diff --git a/src/pages/focus/rocks.js b/src/pages/focus/rocks.js index f59521f..2ba02e5 100644 --- a/src/pages/focus/rocks.js +++ b/src/pages/focus/rocks.js @@ -1,114 +1,130 @@ import React, { useEffect, useState } from 'react'; import '../../pages-style/rocks.css'; -import '../../pages-style/page.css'; -import styled from 'styled-components'; +import Map from "../../components/Map"; -const Table = styled.table` - width: 100%; - border-collapse: collapse; - margin: 20px 0; - font-size: 16px; -`; - -const TableHead = styled.thead` - background-color: #4CAF50; - color: white; -`; - -const TableHeader = styled.th` - padding: 12px; - text-align: left; - border-bottom: 1px solid #ddd; -`; - -const TableRow = styled.tr` - &:nth-child(even) { - background-color: #f2f2f2; - } - &:hover { - background-color: #ddd; - } -`; - -const TableCell = styled.td` - padding: 12px; - border-bottom: 1px solid #ddd; - text-align: left; -`; +function Rocks() { + const [eva1Data, setEva1Data] = useState(null); + const [savedRocks, setSavedRocks] = useState(null); + const [message, setMessage] = useState(null); + const [pinMessage, setPinMessage] = useState(null); -const InnerTable = styled.table` - width: 100%; - border-collapse: collapse; - margin: 0; -`; + const fetchData = async () => { + try { + const eva1Response = await fetch('http://localhost:8000/spec_scans', { + headers: { + 'Accept': 'application/json' + } + }); + if (!eva1Response.ok) { + throw new Error(`HTTP error! status: ${eva1Response.status}`); + } + const eva1Data = await eva1Response.json(); + setEva1Data(eva1Data.spec.eva1); -const InnerTableCell = styled.td` - padding: 8px; - border: none; -`; + const savedRocksResponse = await fetch('http://localhost:8000/get_spec', { + headers: { + 'Accept': 'application/json' + } + }); + if (!savedRocksResponse.ok) { + throw new Error(`HTTP error! status: ${savedRocksResponse.status}`); + } + const savedRocksData = await savedRocksResponse.json(); + setSavedRocks(savedRocksData['saved rocks']); + } catch (error) { + console.error('Error fetching data:', error); + } + }; -function Rocks() { - const [rocksData, setRocksData] = useState(null); + const handleSaveSpec = async () => { + try { + const response = await fetch('http://localhost:8000/save_spec', { + method: 'POST', + headers: { + 'Accept': 'application/json' + } + }); + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + const result = await response.json(); + setMessage(result.message); + } catch (error) { + console.error('Error saving spec:', error); + } + }; - useEffect(() => { - const fetchData = async () => { - try { - const response = await fetch('http://localhost:8000/get_rover_spec_scan'); - if (!response.ok) { - throw new Error(`HTTP error! status: ${response.status}`); + const handleDropPin = async () => { + try { + const response = await fetch('http://localhost:8000/drop_pin_here/1', { + method: 'POST', + headers: { + 'Accept': 'application/json' } - const data = await response.json(); - console.log('Fetched data:', data); - setRocksData([data]); - } catch (error) { - console.error('Error fetching rocks data:', error); + }); + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); } - }; + const result = await response.json(); + setPinMessage(result.message); + } catch (error) { + console.error('Error dropping pin:', error); + } + }; - // Fetch data initially + useEffect(() => { fetchData(); + const interval = setInterval(fetchData, 3000); + return () => clearInterval(interval); }, []); return ( -
-
-
Top Div Content
-
Bottom Div Content
+
+
+
+
+ +
+
+
+ {savedRocks ? ( +
{JSON.stringify(savedRocks, null, 2)}
+ ) : ( + 'Loading...' + )} +
-
- {rocksData ? ( - - - - Name - ID - Data - - - - {rocksData.map((rock) => ( - - {rock.name} - {rock.id} - - - - {Object.entries(rock.data).map(([key, value]) => ( - - {key} - {value} - - ))} - - - - - ))} - -
- ) : ( - 'Loading...' - )} +
+
+
+ {eva1Data ? ( +
{JSON.stringify(eva1Data, null, 2)}
+ ) : ( + 'Loading...' + )} +
+
+

Samples are considered scientifically significant if:

+
    +
  • SiO2 < 10%
  • +
  • TiO2 > 1%
  • +
  • Al2O3 > 10%
  • +
  • FeO-T > 29%
  • +
  • MnO > 1%
  • +
  • MgO > 20%
  • +
  • CaO > 10%
  • +
  • K2O > 1%
  • +
  • P2O5 > 1.5%
  • +
  • other > 50%
  • +
+
+
+
+ + +
+ {message &&

{message}

} + {pinMessage &&

{pinMessage}

}
);