wip
This commit is contained in:
parent
6dd38036e7
commit
097b3dbf09
34 changed files with 1719 additions and 520 deletions
|
@ -5,55 +5,129 @@
|
|||
<div class="page-header d-print-none">
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<div class="page-pretitle">
|
||||
Subnet Details
|
||||
</div>
|
||||
<h2 class="page-title">
|
||||
{{ subnet.cidr }}
|
||||
{{ subnet.cidr }} - {{ subnet.location }}
|
||||
</h2>
|
||||
<div class="text-muted mt-1">{{ subnet.location }}</div>
|
||||
</div>
|
||||
<div class="col-auto ms-auto d-print-none">
|
||||
<div class="btn-list">
|
||||
<a href="{{ url_for('ipam.subnet_scan', subnet_id=subnet.id) }}" class="btn btn-outline-primary">
|
||||
<i class="fas fa-search me-2"></i> Scan Subnet
|
||||
</a>
|
||||
<a href="{{ url_for('ipam.subnet_visualize', subnet_id=subnet.id) }}" class="btn btn-outline-primary">
|
||||
<i class="fas fa-chart-network me-2"></i> Visualize
|
||||
</a>
|
||||
<a href="{{ url_for('ipam.ipam_home') }}" class="btn btn-link">
|
||||
Back to IPAM
|
||||
<a href="{{ url_for('ipam.subnet_edit', subnet_id=subnet.id) }}" class="btn btn-primary">
|
||||
<i class="ti ti-edit me-1"></i> Edit
|
||||
</a>
|
||||
<form method="POST" action="{{ url_for('ipam.subnet_scan', subnet_id=subnet.id) }}" class="d-inline">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<button type="submit" class="btn btn-warning">
|
||||
<i class="ti ti-search me-1"></i> Scan Now
|
||||
</button>
|
||||
</form>
|
||||
<button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#deleteSubnetModal">
|
||||
<i class="ti ti-trash me-1"></i> Delete
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
{% for category, message in messages %}
|
||||
<div class="alert alert-{{ category }} alert-dismissible fade show mt-3" role="alert">
|
||||
{{ message }}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
<div class="row mt-3">
|
||||
<div class="col-md-8">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Registered Hosts</h3>
|
||||
<h3 class="card-title">Subnet Information</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if servers %}
|
||||
<table class="table table-vcenter">
|
||||
<tr>
|
||||
<td><strong>CIDR Notation</strong></td>
|
||||
<td>{{ subnet.cidr }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Location</strong></td>
|
||||
<td>{{ subnet.location }}</td>
|
||||
</tr>
|
||||
{% set network = get_ip_network(subnet.cidr) %}
|
||||
{% if network %}
|
||||
<tr>
|
||||
<td><strong>Network Address</strong></td>
|
||||
<td>{{ network.network_address }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Broadcast Address</strong></td>
|
||||
<td>{{ network.broadcast_address if network.prefixlen < 31 else 'N/A' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Netmask</strong></td>
|
||||
<td>{{ network.netmask }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Host Range</strong></td>
|
||||
<td>
|
||||
{% if network.prefixlen < 31 %} {{ network.network_address + 1 }} - {{ network.broadcast_address - 1 }}
|
||||
{% else %} {{ network.network_address }} - {{ network.broadcast_address }} {% endif %} </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Total Hosts</strong></td>
|
||||
<td>
|
||||
{% if network.prefixlen < 31 %} {{ network.num_addresses - 2 }} {% else %} {{ network.num_addresses }}
|
||||
{% endif %} </td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td><strong>Auto Scan</strong></td>
|
||||
<td>{{ 'Yes' if subnet.auto_scan else 'No' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Last Scanned</strong></td>
|
||||
<td>{{ subnet.last_scanned|default('Never', true) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Created</strong></td>
|
||||
<td>{{ subnet.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Servers in Subnet</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if subnet.servers %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-vcenter">
|
||||
<table class="table table-vcenter card-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Hostname</th>
|
||||
<th>IP Address</th>
|
||||
<th>Created</th>
|
||||
<th class="w-1"></th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for server in servers %}
|
||||
{% for server in subnet.servers %}
|
||||
<tr>
|
||||
<td>{{ server.hostname }}</td>
|
||||
<td><a href="{{ url_for('dashboard.server_view', server_id=server.id) }}">{{ server.hostname }}</a>
|
||||
</td>
|
||||
<td>{{ server.ip_address }}</td>
|
||||
<td>{{ server.created_at.strftime('%Y-%m-%d') }}</td>
|
||||
<td>
|
||||
<a href="{{ url_for('dashboard.server_view', server_id=server.id) }}"
|
||||
class="btn btn-sm btn-primary">
|
||||
View
|
||||
<i class="ti ti-eye"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -62,69 +136,51 @@
|
|||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="text-center py-3">
|
||||
<div class="mb-3">No hosts registered in this subnet</div>
|
||||
<a href="{{ url_for('dashboard.server_new') }}" class="btn btn-outline-primary">
|
||||
Add New Server
|
||||
</a>
|
||||
<a href="{{ url_for('ipam.subnet_scan', subnet_id=subnet.id) }}" class="btn btn-outline-primary ms-2">
|
||||
Scan Subnet
|
||||
</a>
|
||||
<div class="empty">
|
||||
<div class="empty-icon">
|
||||
<i class="ti ti-server"></i>
|
||||
</div>
|
||||
<p class="empty-title">No servers in this subnet</p>
|
||||
<p class="empty-subtitle text-muted">
|
||||
You can add a new server to this subnet from the dashboard
|
||||
</p>
|
||||
<div class="empty-action">
|
||||
<a href="{{ url_for('dashboard.server_new') }}" class="btn btn-primary">
|
||||
<i class="ti ti-plus me-2"></i> Add New Server
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Subnet Information</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-2">
|
||||
<strong>Network:</strong> {{ subnet.cidr }}
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<strong>Location:</strong> {{ subnet.location }}
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<strong>Total IPs:</strong> {{ total_ips }}
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<strong>Used IPs:</strong> {{ used_ips }} ({{ '%.1f'|format(usage_percent) }}%)
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<strong>Available IPs:</strong> {{ total_ips - used_ips }}
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<strong>Auto Scan:</strong>
|
||||
{% if subnet.auto_scan %}
|
||||
<span class="badge bg-success">Enabled</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">Disabled</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<strong>Created:</strong> {{ subnet.created_at.strftime('%Y-%m-%d') }}
|
||||
</div>
|
||||
</div>
|
||||
<!-- Delete Confirmation Modal -->
|
||||
<div class="modal fade" id="deleteSubnetModal" tabindex="-1" aria-labelledby="deleteSubnetModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="deleteSubnetModalLabel">Confirm Deletion</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<div class="card mt-3">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Actions</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="d-grid gap-2">
|
||||
<a href="{{ url_for('ipam.subnet_scan', subnet_id=subnet.id) }}" class="btn btn-outline-primary">
|
||||
<i class="fas fa-search me-2"></i> Scan Now
|
||||
</a>
|
||||
<a href="{{ url_for('ipam.subnet_visualize', subnet_id=subnet.id) }}" class="btn btn-outline-primary">
|
||||
<i class="fas fa-chart-network me-2"></i> IP Visualization
|
||||
</a>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Are you sure you want to delete the subnet {{ subnet.cidr }}?</p>
|
||||
{% if subnet.servers %}
|
||||
<div class="alert alert-danger">
|
||||
<strong>Warning:</strong> This subnet has {{ subnet.servers|length }} servers assigned to it.
|
||||
You must delete or reassign these servers before deleting the subnet.
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<form method="POST" action="{{ url_for('ipam.subnet_delete', subnet_id=subnet.id) }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<button type="submit" class="btn btn-danger" {{ 'disabled' if subnet.servers }}>Delete Subnet</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue