Skip to content

Commit 1573ca7

Browse files
authored
Merge pull request #154 from equinor/feat-add-height-width-in-nodes
added width and heigh ion node style
2 parents be71a95 + 742fd71 commit 1573ca7

7 files changed

Lines changed: 239 additions & 225 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""Added height and width in nodestyle
2+
3+
Revision ID: 4fcae4b62683
4+
Revises: e915e38cedc2
5+
Create Date: 2025-10-17 12:55:10.801087
6+
7+
"""
8+
from typing import Sequence, Union
9+
10+
from alembic import op
11+
import sqlalchemy as sa
12+
13+
14+
# revision identifiers, used by Alembic.
15+
revision: str = '4fcae4b62683'
16+
down_revision: Union[str, None] = 'e915e38cedc2'
17+
branch_labels: Union[str, Sequence[str], None] = None
18+
depends_on: Union[str, Sequence[str], None] = None
19+
20+
21+
def upgrade() -> None:
22+
"""Upgrade schema."""
23+
# ### commands auto generated by Alembic - please adjust! ###
24+
op.add_column('node_style', sa.Column('width', sa.INTEGER(), nullable=False,server_default=sa.text('200')))
25+
op.add_column('node_style', sa.Column('height', sa.INTEGER(), nullable=False,server_default=sa.text('150')))
26+
# ### end Alembic commands ###
27+
28+
29+
def downgrade() -> None:
30+
"""Downgrade schema."""
31+
# ### commands auto generated by Alembic - please adjust! ###
32+
op.drop_column('node_style', 'height')
33+
op.drop_column('node_style', 'width')
34+
# ### end Alembic commands ###

src/dtos/node_style_dtos.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class NodeStyleDto(BaseModel):
99
node_id: uuid.UUID
1010
x_position: int = 0
1111
y_position: int = 0
12+
width: int = 200
13+
height: int = 150
1214

1315

1416
class NodeStyleIncomingDto(NodeStyleDto):
@@ -27,6 +29,8 @@ def to_outgoing_dto(entity: NodeStyle) -> NodeStyleOutgoingDto:
2729
node_id=entity.node_id,
2830
x_position=entity.x_position,
2931
y_position=entity.y_position,
32+
width=entity.width,
33+
height=entity.height,
3034
)
3135

3236
@staticmethod
@@ -36,6 +40,8 @@ def to_entity(dto: NodeStyleIncomingDto) -> NodeStyle:
3640
node_id=dto.node_id if dto.node_id else None,
3741
x_position=dto.x_position,
3842
y_position=dto.y_position,
43+
width=dto.width,
44+
height=dto.height,
3945
)
4046

4147
@staticmethod

src/models/node_style.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class NodeStyle(Base, BaseEntity):
2121

2222
x_position: Mapped[int] = mapped_column(INT)
2323
y_position: Mapped[int] = mapped_column(INT)
24+
width: Mapped[int] = mapped_column(INT)
25+
height: Mapped[int] = mapped_column(INT)
2426

2527
node: Mapped["Node"] = relationship("Node", back_populates="node_style")
2628

@@ -30,9 +32,13 @@ def __init__(
3032
node_id: Optional[uuid.UUID],
3133
x_position: int = 0,
3234
y_position: int = 0,
35+
width: int = 200,
36+
height: int = 150,
3337
):
3438
self.id = id
3539
if node_id:
3640
self.node_id = node_id
3741
self.x_position = x_position
3842
self.y_position = y_position
43+
self.width = width
44+
self.height = height

src/repositories/node_style_repository.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ async def update(self, entities: list[NodeStyle]) -> list[NodeStyle]:
2222
entity = entities[n]
2323
entity_to_update.x_position = entity.x_position
2424
entity_to_update.y_position = entity.y_position
25+
entity_to_update.width = entity.width
26+
entity_to_update.height = entity.height
2527
if entity.node_id:
2628
entity_to_update = entity.node_id
2729

0 commit comments

Comments
 (0)