MGMT
parent
277041d50d
commit
366ff7c78a
|
|
@ -1,6 +1,16 @@
|
|||
from app import db
|
||||
|
||||
# Existing models…
|
||||
|
||||
client_domains = db.Table('client_domains',
|
||||
db.Column('client_id', db.Integer, db.ForeignKey('client.id', ondelete="CASCADE")),
|
||||
db.Column('domain_id', db.Integer, db.ForeignKey('domain.id'))
|
||||
)
|
||||
|
||||
client_ssl = db.Table('client_ssl',
|
||||
db.Column('client_id', db.Integer, db.ForeignKey('client.id', ondelete="CASCADE")),
|
||||
db.Column('domain_id', db.Integer, db.ForeignKey('domain.id'))
|
||||
)
|
||||
|
||||
class Domain(db.Model):
|
||||
__tablename__ = 'domain'
|
||||
__table_args__ = {'extend_existing': True}
|
||||
|
|
@ -18,18 +28,21 @@ class Client(db.Model):
|
|||
name = db.Column(db.String(255), nullable=False)
|
||||
phone = db.Column(db.String(255))
|
||||
address = db.Column(db.String(255))
|
||||
ip_address = db.Column(db.String(255))
|
||||
subnet_mask = db.Column(db.String(255))
|
||||
gateway = db.Column(db.String(255))
|
||||
passwords = db.relationship('ClientPassword', backref='client', lazy=True,
|
||||
cascade="all, delete-orphan")
|
||||
domains = db.relationship('Domain', secondary='client_domains',
|
||||
domains = db.relationship('Domain', secondary=client_domains,
|
||||
backref=db.backref('clients', lazy='dynamic'))
|
||||
ssl_domains = db.relationship('Domain', secondary='client_ssl',
|
||||
ssl_domains = db.relationship('Domain', secondary=client_ssl,
|
||||
backref=db.backref('ssl_clients', lazy='dynamic'))
|
||||
# New relationship for remotes
|
||||
remotes = db.relationship('ClientRemote', backref='client', lazy=True,
|
||||
cascade="all, delete-orphan")
|
||||
def __repr__(self):
|
||||
return f"<Client {self.name}>"
|
||||
|
||||
|
||||
class ClientPassword(db.Model):
|
||||
__tablename__ = 'client_password'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
|
|
@ -75,14 +88,3 @@ class ClientRemote(db.Model):
|
|||
remote_category = db.relationship('RemoteCategory')
|
||||
def __repr__(self):
|
||||
return f"<ClientRemote {self.id} in {self.remote_category.name}>"
|
||||
|
||||
# Association tables for domains remain unchanged.
|
||||
client_domains = db.Table('client_domains',
|
||||
db.Column('client_id', db.Integer, db.ForeignKey('client.id', ondelete="CASCADE")),
|
||||
db.Column('domain_id', db.Integer, db.ForeignKey('domain.id'))
|
||||
)
|
||||
|
||||
client_ssl = db.Table('client_ssl',
|
||||
db.Column('client_id', db.Integer, db.ForeignKey('client.id', ondelete="CASCADE")),
|
||||
db.Column('domain_id', db.Integer, db.ForeignKey('domain.id'))
|
||||
)
|
||||
|
|
|
|||
|
|
@ -56,9 +56,13 @@ def update_client_details(client_id):
|
|||
client = Client.query.get_or_404(client_id)
|
||||
client.phone = request.form.get('phone')
|
||||
client.address = request.form.get('address')
|
||||
client.ip_address = request.form.get('ip_address')
|
||||
client.subnet_mask = request.form.get('subnet_mask')
|
||||
client.gateway = request.form.get('gateway')
|
||||
db.session.commit()
|
||||
return redirect(url_for('clients.client_detail', client_id=client.id))
|
||||
|
||||
|
||||
@clients_bp.route('/clients/<int:client_id>/add_password', methods=['POST'])
|
||||
def add_client_password(client_id):
|
||||
client = Client.query.get_or_404(client_id)
|
||||
|
|
|
|||
|
|
@ -7,10 +7,25 @@
|
|||
|
||||
<!-- Section 1: Details -->
|
||||
<div class="mt-4">
|
||||
<div id="detailsDisplay" class="text-center">
|
||||
{% if client.phone or client.address %}
|
||||
<h2>Phone: {{ client.phone or "N/A" }} | Address: {{ client.address or "N/A" }}</h2>
|
||||
{% else %}
|
||||
<div class="text-center">
|
||||
<ul class="list-unstyled">
|
||||
{% if client.phone %}
|
||||
<li><strong>Phone:</strong> {{ client.phone }}</li>
|
||||
{% endif %}
|
||||
{% if client.address %}
|
||||
<li><strong>Address:</strong> {{ client.address }}</li>
|
||||
{% endif %}
|
||||
{% if client.ip_address %}
|
||||
<li><strong>IP Address:</strong> {{ client.ip_address }}</li>
|
||||
{% endif %}
|
||||
{% if client.subnet_mask %}
|
||||
<li><strong>Subnet Mask:</strong> {{ client.subnet_mask }}</li>
|
||||
{% endif %}
|
||||
{% if client.gateway %}
|
||||
<li><strong>Gateway:</strong> {{ client.gateway }}</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% if client.phone is none and client.address is none and client.ip_address is none and client.subnet_mask is none and client.gateway is none %}
|
||||
<p>No details available.</p>
|
||||
{% endif %}
|
||||
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#detailsForm" aria-expanded="false" aria-controls="detailsForm">
|
||||
|
|
@ -28,12 +43,25 @@
|
|||
<label for="address">Address:</label>
|
||||
<input type="text" class="form-control" name="address" value="{{ client.address or '' }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="ip_address">IP Address:</label>
|
||||
<input type="text" class="form-control" name="ip_address" value="{{ client.ip_address or '' }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="subnet_mask">Subnet Mask:</label>
|
||||
<input type="text" class="form-control" name="subnet_mask" value="{{ client.subnet_mask or '' }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="gateway">Gateway:</label>
|
||||
<input type="text" class="form-control" name="gateway" value="{{ client.gateway or '' }}">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">Update Details</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
<!-- Section: Remote -->
|
||||
|
|
|
|||
|
|
@ -8,9 +8,27 @@
|
|||
|
||||
<!-- Details Section -->
|
||||
<div class="mt-4">
|
||||
<h2 class="text-center">Details</h2>
|
||||
<div class="text-center">
|
||||
<h2>Phone: {{ client.phone or "N/A" }} | Address: {{ client.address or "N/A" }}</h2>
|
||||
<ul class="list-unstyled">
|
||||
{% if client.phone %}
|
||||
<li><strong>Phone:</strong> {{ client.phone }}</li>
|
||||
{% endif %}
|
||||
{% if client.address %}
|
||||
<li><strong>Address:</strong> {{ client.address }}</li>
|
||||
{% endif %}
|
||||
{% if client.ip_address %}
|
||||
<li><strong>IP Address:</strong> {{ client.ip_address }}</li>
|
||||
{% endif %}
|
||||
{% if client.subnet_mask %}
|
||||
<li><strong>Subnet Mask:</strong> {{ client.subnet_mask }}</li>
|
||||
{% endif %}
|
||||
{% if client.gateway %}
|
||||
<li><strong>Gateway:</strong> {{ client.gateway }}</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% if client.phone is none and client.address is none and client.ip_address is none and client.subnet_mask is none and client.gateway is none %}
|
||||
<p>No details available.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -92,6 +110,7 @@
|
|||
<th>Item</th>
|
||||
<th>Username</th>
|
||||
<th>Password</th>
|
||||
<th>IP Address</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
@ -100,6 +119,7 @@
|
|||
<td>{{ p.item }}</td>
|
||||
<td>{{ p.username }}</td>
|
||||
<td>{{ p.password }}</td>
|
||||
<td>{{ p.ip_address }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
@ -161,8 +181,5 @@
|
|||
<p>No SSL associations.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- You can include a print CSS or a Print button that calls window.print() if desired -->
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
<tr>
|
||||
<th>Domain</th>
|
||||
<th>WHOIS Expiration</th>
|
||||
<th>SSL Expiration</th>
|
||||
<th>Refresh</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
|
|
@ -21,7 +20,6 @@
|
|||
<tr>
|
||||
<td>{{ domain.domain }}</td>
|
||||
<td>{{ domain.expiration_date }}</td>
|
||||
<td>{{ domain.ssl_expiration_date }}</td>
|
||||
<td>
|
||||
<a href="{{ url_for('domain.refresh_individual', domain_id=domain.id) }}" class="btn btn-sm btn-primary">Refresh</a>
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>Domain</th>
|
||||
<th>WHOIS Expiration</th>
|
||||
<th>SSL Expiration</th>
|
||||
<th>Type</th>
|
||||
<th>Refresh</th>
|
||||
|
|
@ -21,11 +20,10 @@
|
|||
{% for d in domains %}
|
||||
<tr>
|
||||
<td>{{ d.domain }}</td>
|
||||
<td>{{ d.expiration_date }}</td>
|
||||
<td>{{ d.ssl_expiration_date }}</td>
|
||||
<td>
|
||||
{% if d.ssl_only %}
|
||||
<span class="badge badge-info">Email</span>
|
||||
<span class="badge badge-info">App Cert</span>
|
||||
{% else %}
|
||||
<span class="badge badge-secondary">Domain</span>
|
||||
{% endif %}
|
||||
|
|
|
|||
Loading…
Reference in New Issue