transmit info

This commit is contained in:
2025-06-24 14:11:16 +02:00
parent 912f97490c
commit ca2d2e6587
6 changed files with 71 additions and 23 deletions

Binary file not shown.

View File

@@ -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 ###

View File

@@ -528,6 +528,9 @@ class Instance(db.Model):
status = db.Column(db.String(20), nullable=False, default='inactive') status = db.Column(db.String(20), nullable=False, default='inactive')
status_details = db.Column(db.Text, nullable=True) status_details = db.Column(db.Text, nullable=True)
connection_token = db.Column(db.String(64), unique=True, 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 # Version tracking fields
deployed_version = db.Column(db.String(50), nullable=True) # Current deployed version (commit hash or tag) 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 deployed_branch = db.Column(db.String(100), nullable=True) # Branch that was deployed

View File

@@ -1090,13 +1090,9 @@ def save_instance():
if existing_instance: if existing_instance:
# Update existing instance # Update existing instance
existing_instance.port = data['port'] existing_instance.portainer_stack_id = data['stack_id']
existing_instance.domains = data['domains'] existing_instance.portainer_stack_name = data['stack_name']
existing_instance.stack_id = data['stack_id']
existing_instance.stack_name = data['stack_name']
existing_instance.status = data['status'] 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_version = data.get('deployed_version', 'unknown')
existing_instance.deployed_branch = data.get('deployed_branch', data['branch']) existing_instance.deployed_branch = data.get('deployed_branch', data['branch'])
existing_instance.version_checked_at = datetime.utcnow() existing_instance.version_checked_at = datetime.utcnow()
@@ -1107,13 +1103,9 @@ def save_instance():
'message': 'Instance data updated successfully', 'message': 'Instance data updated successfully',
'data': { 'data': {
'name': existing_instance.name, 'name': existing_instance.name,
'port': existing_instance.port, 'portainer_stack_id': existing_instance.portainer_stack_id,
'domains': existing_instance.domains, 'portainer_stack_name': existing_instance.portainer_stack_name,
'stack_id': existing_instance.stack_id,
'stack_name': existing_instance.stack_name,
'status': existing_instance.status, 'status': existing_instance.status,
'repository': existing_instance.repository,
'branch': existing_instance.branch,
'deployed_version': existing_instance.deployed_version, 'deployed_version': existing_instance.deployed_version,
'deployed_branch': existing_instance.deployed_branch 'deployed_branch': existing_instance.deployed_branch
} }
@@ -1129,11 +1121,8 @@ def save_instance():
payment_plan='Basic', payment_plan='Basic',
main_url=f"https://{data['domains'][0]}" if data['domains'] else f"http://localhost:{data['port']}", main_url=f"https://{data['domains'][0]}" if data['domains'] else f"http://localhost:{data['port']}",
status=data['status'], status=data['status'],
port=data['port'], portainer_stack_id=data['stack_id'],
stack_id=data['stack_id'], portainer_stack_name=data['stack_name'],
stack_name=data['stack_name'],
repository=data['repository'],
branch=data['branch'],
deployed_version=data.get('deployed_version', 'unknown'), deployed_version=data.get('deployed_version', 'unknown'),
deployed_branch=data.get('deployed_branch', data['branch']) deployed_branch=data.get('deployed_branch', data['branch'])
) )
@@ -1145,13 +1134,9 @@ def save_instance():
'message': 'Instance data saved successfully', 'message': 'Instance data saved successfully',
'data': { 'data': {
'name': instance.name, 'name': instance.name,
'port': instance.port, 'portainer_stack_id': instance.portainer_stack_id,
'domains': instance.domains, 'portainer_stack_name': instance.portainer_stack_name,
'stack_id': instance.stack_id,
'stack_name': instance.stack_name,
'status': instance.status, 'status': instance.status,
'repository': instance.repository,
'branch': instance.branch,
'deployed_version': instance.deployed_version, 'deployed_version': instance.deployed_version,
'deployed_branch': instance.deployed_branch 'deployed_branch': instance.deployed_branch
} }

View File

@@ -142,6 +142,21 @@
<div class="company-value" id="instance-payment-plan-value">Loading...</div> <div class="company-value" id="instance-payment-plan-value">Loading...</div>
</div> </div>
</div> </div>
<div class="mb-3">
<div class="d-flex">
<div class="text-muted me-2" style="min-width: 120px;">Portainer Stack:</div>
<div class="company-value">
{% if instance.portainer_stack_name %}
<span class="badge bg-primary">{{ instance.portainer_stack_name }}</span>
{% if instance.portainer_stack_id %}
<small class="text-muted d-block mt-1">ID: {{ instance.portainer_stack_id }}</small>
{% endif %}
{% else %}
<span class="text-muted">Not set</span>
{% endif %}
</div>
</div>
</div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<h5 class="mb-3">Contact Information</h5> <h5 class="mb-3">Contact Information</h5>

View File

@@ -179,6 +179,7 @@
<th>Main URL</th> <th>Main URL</th>
<th>Status</th> <th>Status</th>
<th>Version</th> <th>Version</th>
<th>Portainer Stack</th>
<th>Connection Token</th> <th>Connection Token</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
@@ -220,6 +221,16 @@
<span class="badge bg-secondary version-badge">unknown</span> <span class="badge bg-secondary version-badge">unknown</span>
{% endif %} {% endif %}
</td> </td>
<td>
{% if instance.portainer_stack_name %}
<span class="badge bg-primary" data-bs-toggle="tooltip"
title="Stack ID: {{ instance.portainer_stack_id or 'N/A' }}">
{{ instance.portainer_stack_name }}
</span>
{% else %}
<span class="badge bg-secondary">Not set</span>
{% endif %}
</td>
<td> <td>
{% if instance.connection_token %} {% if instance.connection_token %}
<span class="badge bg-success" data-bs-toggle="tooltip" title="Instance is authenticated"> <span class="badge bg-success" data-bs-toggle="tooltip" title="Instance is authenticated">