Skip to content

Commit

Permalink
Merge pull request #22 from columbiaspace/equipmentcards
Browse files Browse the repository at this point in the history
Equipmentcards
  • Loading branch information
adenjonah committed May 17, 2024
2 parents ce1e7d1 + fd96a55 commit 4d6f544
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 164 deletions.
139 changes: 0 additions & 139 deletions server/json_databases/equipment_repair.json
Original file line number Diff line number Diff line change
@@ -1,128 +1,5 @@
{
"procedures": [
{
"id": 1,
"title": "Structural Damage Repair",
"steps": [
{
"step": "Comm Tower Base 1",
"role": "EV1",
"description": "Collect structural repair materials including metal patches, welding tools, and adhesives."
},
{
"step": "Comm Tower Base 2",
"role": "EV2",
"description": "Assemble safety gear for climbing and securing both crew members."
},
{
"step": "Comm Tower 3",
"role": "EV1",
"description": "Assess tower for visible structural damage."
},
{
"step": "Comm Tower 4",
"role": "EV2",
"description": "Assist in removing debris and damaged components."
},
{
"step": "Comm Tower 5",
"role": "EV1",
"description": "Apply metal patches over holes or tears using welding tools."
},
{
"step": "Comm Tower 6",
"role": "EV2",
"description": "Provide support in applying patches or adhesives."
},
{
"step": "Comm Tower 7",
"role": "EV1",
"description": "Secure larger structural issues with adhesives and temporary supports."
},
{
"step": "Comm Tower 8",
"role": "EV2",
"description": "Ensure safety protocols are followed during high or difficult access points."
}
]
},
{
"id": 2,
"title": "Power System Troubleshooting and Repair",
"steps": [
{
"step": "Tower Base PSU 1",
"role": "EV1",
"description": "Assemble diagnostic kit, spare batteries, solar cells, and electrical repair tools."
},
{
"step": "Tower Base PSU 2",
"role": "EV2",
"description": "Carry additional spare parts and protective equipment."
},
{
"step": "Tower Base PSU 3",
"role": "EV1",
"description": "Perform diagnostics to identify power supply issues."
},
{
"step": "Tower Base PSU 4",
"role": "EV2",
"description": "Assist in identifying damaged components."
},
{
"step": "Tower Base PSU 5",
"role": "EV1",
"description": "Replace faulty batteries or solar cells."
},
{
"step": "Tower Base PSU 6",
"role": "EV2",
"description": "Help in repairing or replacing wiring, ensuring secure connections."
},
{
"step": "Tower Base PSU 7",
"role": "EV1",
"description": "Verify power system functionality post-repair."
}
]
},
{
"id": 3,
"title": "Antenna Alignment and Calibration",
"steps": [
{
"step": "Comm Tower Antenna 1",
"role": "EV1",
"description": "Prepare alignment tools and calibration software on a portable device."
},
{
"step": "Comm Tower Antenna 2",
"role": "EV2",
"description": "Assemble securing gear and safety equipment for both crew members."
},
{
"step": "Comm Tower Antenna 3",
"role": "EV1",
"description": "Adjust the antenna to correct orientation using tools."
},
{
"step": "Comm Tower Antenna 4",
"role": "EV2",
"description": "Assist in antenna inspection for misalignment or damage."
},
{
"step": "Comm Tower Antenna 5",
"role": "EV1",
"description": "Secure antenna position; perform calibration test."
},
{
"step": "Comm Tower Antenna 6",
"role": "EV2",
"description": "Support in adjustment and calibration process; maintain communication with mission control."
}
]
},
{
"id": 4,
"title": "Transceiver Module Replacement",
Expand Down Expand Up @@ -158,22 +35,6 @@
"description": "Ensure module installation is correctly performed; conduct systems check to verify functionality."
}
]
},
{
"id": 80,
"title": "Dance",
"steps": [
{
"step": "left foot forward",
"role": "you",
"description": "yea get it"
},
{
"step": "dougie",
"role": "me",
"description": "ill teach you"
}
]
}
]
}
44 changes: 44 additions & 0 deletions server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,47 @@ async def add_procedure(procedure: Procedure):
json.dump(data, file, indent=4)

return procedure

@app.delete("/delete_procedure/{id}", response_model=dict)
async def delete_procedure(id: int):
if os.path.exists(EQUIPMENT_REPAIR_FILE):
with open(EQUIPMENT_REPAIR_FILE, 'r') as file:
data = json.load(file)
else:
raise HTTPException(status_code=404, detail=f"{EQUIPMENT_REPAIR_FILE} not found")

procedures = data.get("procedures", [])
updated_procedures = [procedure for procedure in procedures if procedure["id"] != id]

if len(procedures) == len(updated_procedures):
raise HTTPException(status_code=404, detail="Procedure not found")

data["procedures"] = updated_procedures

with open(EQUIPMENT_REPAIR_FILE, 'w') as file:
json.dump(data, file, indent=4)

return {"message": "Procedure deleted successfully"}

@app.put("/update_procedure/{id}", response_model=Procedure)
async def update_procedure(id: int, updated_procedure: Procedure):
if os.path.exists(EQUIPMENT_REPAIR_FILE):
with open(EQUIPMENT_REPAIR_FILE, 'r') as file:
data = json.load(file)
else:
raise HTTPException(status_code=404, detail=f"{EQUIPMENT_REPAIR_FILE} not found")

procedures = data.get("procedures", [])
for index, procedure in enumerate(procedures):
if procedure["id"] == id:
procedures[index] = updated_procedure.dict()
break
else:
raise HTTPException(status_code=404, detail="Procedure not found")

data["procedures"] = procedures

with open(EQUIPMENT_REPAIR_FILE, 'w') as file:
json.dump(data, file, indent=4)

return updated_procedure
48 changes: 47 additions & 1 deletion src/pages-style/equipment.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@
margin: 20px;
display: flex;
flex-direction: column;
align-items: center;
font-family: Arial, sans-serif;
color: #333;
}

h2, h3 {
color: #333;
border-bottom: 2px solid #ddd;
padding-bottom: 5px;
margin-bottom: 15px;
}

ul {
list-style-type: none;
padding: 0;
margin-bottom: 50px;
}

li {
Expand Down Expand Up @@ -130,16 +131,61 @@ button:hover {
border-radius: 10px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
position: relative;
cursor: pointer;
width: 50%;
}

.procedure-card:hover {
background-color: #d9dfe4;
}

.procedure-header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 5px;
}

.procedure-header h4 {
margin: 0;
font-size: 1.2em;
color: #666;
}

.procedure-header.expanded h2 {
border-bottom: 2px solid #ddd;
}

.delete-button {
background-color: #ff4d4d;
color: white;
border: none;
border-radius: 5px;
padding: 5px 10px;
cursor: pointer;
transition: background-color 0.3s ease;
position: absolute;
bottom: 15px;
right: 15px;
}

.delete-button:hover {
background-color: #cc0000;
}

.edit-button {
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
padding: 5px 10px;
cursor: pointer;
transition: background-color 0.3s ease;
position: absolute;
bottom: 15px;
right: 90px;
}

.edit-button:hover {
background-color: #45a049;
}
Loading

0 comments on commit 4d6f544

Please sign in to comment.