diff --git a/__pycache__/models.cpython-313.pyc b/__pycache__/models.cpython-313.pyc index 5ad7012..c577fe6 100644 Binary files a/__pycache__/models.cpython-313.pyc and b/__pycache__/models.cpython-313.pyc differ diff --git a/migrations/versions/9206bf87bb8e_add_portainer_stack_fields_to_instances.py b/migrations/versions/9206bf87bb8e_add_portainer_stack_fields_to_instances.py new file mode 100644 index 0000000..ca5027f --- /dev/null +++ b/migrations/versions/9206bf87bb8e_add_portainer_stack_fields_to_instances.py @@ -0,0 +1,34 @@ +"""add portainer stack fields to instances + +Revision ID: 9206bf87bb8e +Revises: add_quota_fields +Create Date: 2025-06-24 14:02:17.375785 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '9206bf87bb8e' +down_revision = 'add_quota_fields' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('instances', schema=None) as batch_op: + batch_op.add_column(sa.Column('portainer_stack_id', sa.String(length=100), nullable=True)) + batch_op.add_column(sa.Column('portainer_stack_name', sa.String(length=100), nullable=True)) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('instances', schema=None) as batch_op: + batch_op.drop_column('portainer_stack_name') + batch_op.drop_column('portainer_stack_id') + + # ### end Alembic commands ### diff --git a/models.py b/models.py index fff20a6..3a96298 100644 --- a/models.py +++ b/models.py @@ -528,6 +528,9 @@ class Instance(db.Model): status = db.Column(db.String(20), nullable=False, default='inactive') status_details = db.Column(db.Text, nullable=True) connection_token = db.Column(db.String(64), unique=True, nullable=True) + # Portainer integration fields + portainer_stack_id = db.Column(db.String(100), nullable=True) # Portainer stack ID + portainer_stack_name = db.Column(db.String(100), nullable=True) # Portainer stack name # Version tracking fields deployed_version = db.Column(db.String(50), nullable=True) # Current deployed version (commit hash or tag) deployed_branch = db.Column(db.String(100), nullable=True) # Branch that was deployed diff --git a/routes/launch_api.py b/routes/launch_api.py index 46303ce..5d44e28 100644 --- a/routes/launch_api.py +++ b/routes/launch_api.py @@ -1090,13 +1090,9 @@ def save_instance(): if existing_instance: # Update existing instance - existing_instance.port = data['port'] - existing_instance.domains = data['domains'] - existing_instance.stack_id = data['stack_id'] - existing_instance.stack_name = data['stack_name'] + existing_instance.portainer_stack_id = data['stack_id'] + existing_instance.portainer_stack_name = data['stack_name'] existing_instance.status = data['status'] - existing_instance.repository = data['repository'] - existing_instance.branch = data['branch'] existing_instance.deployed_version = data.get('deployed_version', 'unknown') existing_instance.deployed_branch = data.get('deployed_branch', data['branch']) existing_instance.version_checked_at = datetime.utcnow() @@ -1107,13 +1103,9 @@ def save_instance(): 'message': 'Instance data updated successfully', 'data': { 'name': existing_instance.name, - 'port': existing_instance.port, - 'domains': existing_instance.domains, - 'stack_id': existing_instance.stack_id, - 'stack_name': existing_instance.stack_name, + 'portainer_stack_id': existing_instance.portainer_stack_id, + 'portainer_stack_name': existing_instance.portainer_stack_name, 'status': existing_instance.status, - 'repository': existing_instance.repository, - 'branch': existing_instance.branch, 'deployed_version': existing_instance.deployed_version, 'deployed_branch': existing_instance.deployed_branch } @@ -1129,11 +1121,8 @@ def save_instance(): payment_plan='Basic', main_url=f"https://{data['domains'][0]}" if data['domains'] else f"http://localhost:{data['port']}", status=data['status'], - port=data['port'], - stack_id=data['stack_id'], - stack_name=data['stack_name'], - repository=data['repository'], - branch=data['branch'], + portainer_stack_id=data['stack_id'], + portainer_stack_name=data['stack_name'], deployed_version=data.get('deployed_version', 'unknown'), deployed_branch=data.get('deployed_branch', data['branch']) ) @@ -1145,13 +1134,9 @@ def save_instance(): 'message': 'Instance data saved successfully', 'data': { 'name': instance.name, - 'port': instance.port, - 'domains': instance.domains, - 'stack_id': instance.stack_id, - 'stack_name': instance.stack_name, + 'portainer_stack_id': instance.portainer_stack_id, + 'portainer_stack_name': instance.portainer_stack_name, 'status': instance.status, - 'repository': instance.repository, - 'branch': instance.branch, 'deployed_version': instance.deployed_version, 'deployed_branch': instance.deployed_branch } diff --git a/templates/main/instance_detail.html b/templates/main/instance_detail.html index c29d307..34be9de 100644 --- a/templates/main/instance_detail.html +++ b/templates/main/instance_detail.html @@ -142,6 +142,21 @@