Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b8c3686
Minor style changes
kreydev Jan 15, 2025
7af8256
Merge branch 'james-dev'
kreydev Jan 28, 2025
c66246e
Cycle 1 navbar changes
kreydev Feb 2, 2025
aa97b8c
Fixed nits from PR:
kreydev Feb 4, 2025
b421bbb
fix the bugs that somehow I didn't catch before
kreydev Feb 5, 2025
6e87c3e
Merge NavBar and AuthNavBar :)
kreydev Feb 5, 2025
1e73d89
changes to MyForge table
kreydev Feb 15, 2025
d9a8c77
Merge github.com:BreadInvasion/forge-new-website into table
kreydev Feb 15, 2025
c0dede8
Various changes to table and avatar icon
kreydev Feb 22, 2025
dd57b29
made edit and delete buttons only show when the row is hovered over
kreydev Mar 1, 2025
fd2bd9e
Merge branch 'master' into table
kreydev Mar 1, 2025
2d859c4
Merge branch 'master' into table
kreydev Mar 18, 2025
d2b46b7
Various changes to MyForge table & sidebar
kreydev Mar 19, 2025
3fc13b8
Fix typos on MachineTypes tab
kreydev Mar 19, 2025
7b9aebd
various usermenu fixes
kreydev Mar 19, 2025
041bea0
cleaned up table code
kreydev Mar 19, 2025
1d3e2d8
Merge remote-tracking branch 'origin/master' into table
kreydev Mar 21, 2025
9ea1c96
Merge remote-tracking branch 'origin/master' into table
kreydev Apr 1, 2025
509982a
resources + resourceslots add menu works
kreydev Apr 22, 2025
b41706d
Merge remote-tracking branch 'origin/master' into table
kreydev Apr 25, 2025
da965ad
update table to work with new structure
kreydev Apr 25, 2025
3043165
machine type add works
kreydev Apr 27, 2025
f4f5a9d
adding machinegroups works. also changed backend a bit because the cr…
kreydev Apr 27, 2025
5770b3b
all add endpoints are set in the frontend wooooo
kreydev Apr 27, 2025
a983d12
Merge branch 'master' into table
kreydev Sep 23, 2025
e02a9fd
update packages
kreydev Sep 30, 2025
14534c2
make table not go off the page
kreydev Sep 30, 2025
5baa538
add/edit menu works for machines tab
kreydev Oct 10, 2025
2f247b6
add machine type add/edit menus; still need to do backend changes
kreydev Oct 14, 2025
c283959
upgrade packages, again
kreydev Oct 24, 2025
75c6844
Merge remote-tracking branch 'origin' into table
kreydev Oct 24, 2025
07ef5cb
got edit menu for machine types working
kreydev Oct 28, 2025
f0c06c5
fixed loading the machines on the machine group page
kreydev Nov 12, 2025
cd94182
finished edit menu for machine groups; made omniapi throw errors on r…
kreydev Nov 16, 2025
b3490ae
Resources CRUD fixed
kreydev Dec 7, 2025
fc529d0
ResourceSlots CRUD fixed
kreydev Dec 7, 2025
305c1e8
Merge remote-tracking branch 'origin' into table
kreydev Dec 7, 2025
02628db
fixed the lack of useeffects on machinetypes.tsx
kreydev Dec 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions backend/api/routes/machine_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,18 @@ async def create_machine_group(
status_code=status.HTTP_409_CONFLICT,
detail="A machine group with that name already exists",
)
machines = (
await session.scalars(
select(Machine).where(Machine.id.in_(request.machine_ids))
)
).all()
if len(machines) != len(request.machine_ids):
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="One or more of the provided machine IDs is invalid",
)

new_machine_group = MachineGroup(name=request.name, machines=[])
new_machine_group = MachineGroup(name=request.name, machines=machines)
session.add(new_machine_group)
await session.commit()
await session.refresh(new_machine_group)
Expand Down Expand Up @@ -171,7 +181,7 @@ async def edit_machine_group(
differences = {
"name": request.name if machine_group.name != request.name else None,
"machine_ids": (
request.machine_ids
[str(x) for x in request.machine_ids]
if set(machine_group.machines) != set(machines)
else None
),
Expand All @@ -181,7 +191,7 @@ async def edit_machine_group(
machine_group.machines = list(machines)

audit_log = AuditLog(
type=LogType.MACHINE_GROUP_DELETED,
type=LogType.MACHINE_GROUP_EDITED,
content={
"machine_group_id": str(machine_group.id),
"user_rcsid": current_user.RCSID,
Expand Down
8 changes: 5 additions & 3 deletions backend/api/routes/machine_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from uuid import UUID
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy import and_, func, ScalarSelect, select
from decimal import Decimal
from sqlalchemy.orm import InstrumentedAttribute, joinedload, selectinload

from models.audit_log import AuditLog
Expand Down Expand Up @@ -249,19 +250,20 @@ async def edit_machine_type(
differences = {
"name": request.name if machine_type.name != request.name else None,
"resource_slots": (
request.resource_slot_ids
[str(x) for x in request.resource_slot_ids]
if set(machine_type.resource_slots) != set(resource_slots)
else None
),
"cost_per_hour": (
request.cost_per_hour
if machine_type.cost_per_hour != request.cost_per_hour
float(request.cost_per_hour)
if float(machine_type.cost_per_hour) != float(request.cost_per_hour)
else None
),
}

machine_type.name = request.name
machine_type.resource_slots = list(resource_slots)
machine_type.cost_per_hour = Decimal(request.cost_per_hour)

audit_log = AuditLog(
type=LogType.MACHINE_TYPE_EDITED,
Expand Down
13 changes: 11 additions & 2 deletions backend/api/routes/resource_slots.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from models.audit_log import AuditLog
from models.resource import Resource
from models.resource_slot import ResourceSlot
from models.machine_type import MachineType, MachineTypeSlotAssociation
from models.resource_usage_quantity import ResourceUsageQuantity
from schemas.requests import ResourceSlotCreateRequest, ResourceSlotEditRequest
from schemas.responses import (
Expand Down Expand Up @@ -207,8 +208,8 @@ async def edit_resource_slot(
if resource_slot.display_name != request.display_name
else None
),
"valid_resource_ids": (
request.resource_ids
"resource_ids": (
[str(r) for r in request.resource_ids]
if set(resource_slot.valid_resources) != set(valid_resources)
else None
),
Expand Down Expand Up @@ -262,6 +263,14 @@ async def delete_resource_slot(
detail="Resource Slot with provided ID not found",
)

slotAcc: MachineTypeSlotAssociation = await session.scalar(select(MachineTypeSlotAssociation).where(MachineTypeSlotAssociation.resource_slot_id == resource_slot_id))
if slotAcc:
mtypeWith: MachineType = await session.get(MachineType, slotAcc.machine_type_id)
raise HTTPException(
status_code=status.HTTP_406_NOT_ACCEPTABLE,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an incorrect use of HTTP 406 - 406 is used for mismatch with the http "accept: " header. You're looking for HTTP 409: Conflict.

detail=f"One or more machine types is using this resource slot: {mtypeWith.name})"
)

await session.delete(resource_slot)

audit_log = AuditLog(
Expand Down
13 changes: 12 additions & 1 deletion backend/api/routes/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from models.audit_log import AuditLog
from models.resource import Resource
from models.resource_slot import ResourceSlot, ResourceSlotAssociation
from schemas.requests import ResourceCreateRequest, ResourceEditRequest
from schemas.responses import (
AuditLogModel,
Expand Down Expand Up @@ -50,7 +51,7 @@ async def create_resource(
)

new_resource = Resource(
name=request.name, brand=request.brand, units=request.units, cost=request.cost
name=request.name, color=request.color, brand=request.brand, units=request.units, cost=request.cost
)
session.add(new_resource)
await session.commit()
Expand Down Expand Up @@ -166,12 +167,14 @@ async def edit_resource(
differences = {
"name": request.name if resource.name != request.name else None,
"brand": request.brand if resource.brand != request.brand else None,
"color": request.color if resource.color != request.color else None,
"units": request.units if resource.units != request.units else None,
"cost": request.cost if resource.cost != request.cost else None,
}

resource.name = request.name
resource.brand = request.brand
resource.color = request.color
resource.units = request.units
resource.cost = request.cost

Expand Down Expand Up @@ -204,6 +207,14 @@ async def delete_resource(
status_code=status.HTTP_404_NOT_FOUND,
detail="Resource with provided ID not found",
)

slotAcc: ResourceSlotAssociation = await session.scalar(select(ResourceSlotAssociation).where(ResourceSlotAssociation.resource_id == resource_id))
if slotAcc:
slotWith: ResourceSlot = await session.get(ResourceSlot, slotAcc.resource_slot_id)
raise HTTPException(
status_code=status.HTTP_406_NOT_ACCEPTABLE,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See other comment about 406

detail=f"One or more resource slots is using this resource: {slotWith.display_name})"
)

await session.delete(resource)

Expand Down
1 change: 1 addition & 0 deletions backend/schemas/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class UserChangeRCSIDRequest(BaseRequest):

class MachineGroupCreateRequest(BaseRequest):
name: str
machine_ids: list[UUID4]


class MachineGroupEditRequest(BaseRequest):
Expand Down
2 changes: 1 addition & 1 deletion frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
content="RPI Makerspace in CII 2037A"
/>
<link rel="apple-touch-icon" href="/logo192.png" />
<link rel="manifest" href="/manifest.json" />
Expand Down
Loading