368 lines
No EOL
12 KiB
HTML
368 lines
No EOL
12 KiB
HTML
{% extends "layout.html" %}
|
|
|
|
{% block content %}
|
|
<div class="container-xl">
|
|
<div class="page-header d-print-none">
|
|
<div class="row align-items-center">
|
|
<div class="col">
|
|
<div class="page-pretitle">
|
|
Server Details
|
|
</div>
|
|
<h2 class="page-title">
|
|
{{ server.hostname }}
|
|
</h2>
|
|
</div>
|
|
<div class="col-auto ms-auto">
|
|
<div class="btn-list">
|
|
<a href="{{ url_for('dashboard.server_edit', server_id=server.id) }}" class="btn btn-primary">
|
|
<span class="ti ti-edit me-2"></span>Edit Server
|
|
</a>
|
|
<button class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#deleteServerModal">
|
|
<span class="ti ti-trash me-2"></span>Delete
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mt-3">
|
|
<div class="col-md-4">
|
|
<!-- Server Information -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h3 class="card-title">Basic Information</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="mb-3">
|
|
<div class="form-label">IP Address</div>
|
|
<div>{{ server.ip_address }}</div>
|
|
</div>
|
|
<div class="mb-3">
|
|
<div class="form-label">Subnet</div>
|
|
<div>
|
|
<a href="{{ url_for('ipam.subnet_view', subnet_id=server.subnet_id) }}">
|
|
{{ server.subnet.cidr }}
|
|
</a>
|
|
({{ server.subnet.location }})
|
|
</div>
|
|
</div>
|
|
<div class="mb-3">
|
|
<div class="form-label">Scan Status</div>
|
|
<div>{{ server.last_scan or 'Not scanned yet' }}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Port Usage Map -->
|
|
<div class="card mb-4">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
<h3 class="card-title">Port Usage</h3>
|
|
<div>
|
|
<button class="btn btn-sm btn-outline-primary" id="get-free-port">Get Free Port</button>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="port-usage-compact">
|
|
<div class="port-legend mb-3">
|
|
<span class="port-indicator port-free me-2"></span> Free
|
|
<span class="port-indicator port-used ms-3 me-2"></span> Used
|
|
</div>
|
|
|
|
<div id="port-ranges" class="port-ranges">
|
|
<!-- Port ranges will be rendered here -->
|
|
</div>
|
|
|
|
<div class="mt-3">
|
|
<h4 class="h5">Used Ports</h4>
|
|
<div id="used-ports-list" class="used-ports-list">
|
|
<!-- Used ports will be listed here -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-8">
|
|
<!-- Documentation section -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h3 class="card-title">Documentation</h3>
|
|
</div>
|
|
<div class="card-body markdown-content">
|
|
{% if server.documentation %}
|
|
{{ server.documentation|markdown|safe }}
|
|
{% else %}
|
|
<div class="empty">
|
|
<div class="empty-icon">
|
|
<span class="ti ti-file-text"></span>
|
|
</div>
|
|
<p class="empty-title">No documentation available</p>
|
|
<p class="empty-subtitle text-muted">
|
|
Add documentation to this server to keep track of important information.
|
|
</p>
|
|
<div class="empty-action">
|
|
<a href="{{ url_for('dashboard.server_edit', server_id=server.id) }}" class="btn btn-primary">
|
|
<span class="ti ti-edit me-2"></span> Add Documentation
|
|
</a>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Applications section with collapsible cards -->
|
|
<div class="card mt-3">
|
|
<div class="card-header">
|
|
<h3 class="card-title">Applications</h3>
|
|
<div class="card-actions">
|
|
<a href="{{ url_for('dashboard.app_new', server_id=server.id) }}" class="btn btn-primary me-2">
|
|
<span class="ti ti-plus me-2"></span> Add Application
|
|
</a>
|
|
<button class="btn btn-outline-primary" id="toggle-all-apps">
|
|
<span class="ti ti-chevrons-down me-1"></span> <span id="toggle-text">Expand All</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
{% if server.apps %}
|
|
<div class="accordion" id="accordionApps">
|
|
{% for app in server.apps %}
|
|
<div class="accordion-item">
|
|
<h2 class="accordion-header" id="heading-{{ app.id }}">
|
|
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
|
|
data-bs-target="#collapse-{{ app.id }}" aria-expanded="false" aria-controls="collapse-{{ app.id }}">
|
|
<div class="d-flex justify-content-between align-items-center w-100 me-2">
|
|
<span>{{ app.name }}</span>
|
|
{% if app.ports %}
|
|
<div>
|
|
{% for port in app.ports %}
|
|
<span class="badge bg-azure me-1">{{ port.port_number }}/{{ port.protocol }}</span>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</button>
|
|
</h2>
|
|
<div id="collapse-{{ app.id }}" class="accordion-collapse collapse" aria-labelledby="heading-{{ app.id }}"
|
|
data-bs-parent="#accordionApps">
|
|
<div class="accordion-body">
|
|
<div class="d-flex justify-content-end mb-3">
|
|
<a href="{{ url_for('dashboard.app_view', app_id=app.id) }}"
|
|
class="btn btn-sm btn-outline-primary me-2">
|
|
<span class="ti ti-eye me-1"></span> View
|
|
</a>
|
|
<a href="{{ url_for('dashboard.app_edit', app_id=app.id) }}"
|
|
class="btn btn-sm btn-outline-primary me-2">
|
|
<span class="ti ti-edit me-1"></span> Edit
|
|
</a>
|
|
<button class="btn btn-sm btn-outline-danger" onclick="deleteApp('{{ app.id }}', '{{ app.name }}')">
|
|
<span class="ti ti-trash me-1"></span> Delete
|
|
</button>
|
|
</div>
|
|
|
|
{% if app.documentation %}
|
|
<div class="markdown-content">
|
|
{{ app.documentation|markdown|safe }}
|
|
</div>
|
|
{% else %}
|
|
<div class="text-muted">No documentation available</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% else %}
|
|
<div class="empty">
|
|
<div class="empty-icon">
|
|
<span class="ti ti-apps"></span>
|
|
</div>
|
|
<p class="empty-title">No applications found</p>
|
|
<p class="empty-subtitle text-muted">
|
|
This server doesn't have any applications yet.
|
|
</p>
|
|
<div class="empty-action">
|
|
<a href="{{ url_for('dashboard.app_new', server_id=server.id) }}" class="btn btn-primary">
|
|
<span class="ti ti-plus me-1"></span> Add Application
|
|
</a>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Delete Server Modal -->
|
|
<div class="modal modal-blur fade" id="deleteServerModal" tabindex="-1">
|
|
<div class="modal-dialog modal-sm modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<div class="modal-body">
|
|
<div class="modal-title">Are you sure?</div>
|
|
<div>This will permanently delete the server "{{ server.hostname }}" and all associated applications and ports.
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
<form method="POST" action="{{ url_for('dashboard.server_delete', server_id=server.id) }}">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<button type="submit" class="btn btn-danger">Delete Server</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Delete App Modal Template - Will be dynamically populated -->
|
|
<div class="modal modal-blur fade" id="deleteAppModal" tabindex="-1">
|
|
<div class="modal-dialog modal-sm modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<div class="modal-body">
|
|
<div class="modal-title">Are you sure?</div>
|
|
<div id="delete-app-message"></div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
<form id="delete-app-form" method="POST" action="">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<button type="submit" class="btn btn-danger">Delete Application</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% block extra_js %}
|
|
<script>
|
|
// Function to handle app deletion modal
|
|
function deleteApp(appId, appName) {
|
|
const modal = document.getElementById('deleteAppModal');
|
|
const message = document.getElementById('delete-app-message');
|
|
const form = document.getElementById('delete-app-form');
|
|
|
|
message.textContent = `This will delete the application "${appName}" and all its ports.`;
|
|
form.action = "{{ url_for('dashboard.app_delete', app_id=0) }}".replace('0', appId);
|
|
|
|
// Show the modal
|
|
new bootstrap.Modal(modal).show();
|
|
}
|
|
|
|
// Toggle expand/collapse all
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const toggleBtn = document.getElementById('toggle-all-apps');
|
|
const toggleText = document.getElementById('toggle-text');
|
|
let isExpanded = false;
|
|
|
|
toggleBtn.addEventListener('click', function () {
|
|
const accordionButtons = document.querySelectorAll('.accordion-button');
|
|
const accordionContents = document.querySelectorAll('.accordion-collapse');
|
|
|
|
isExpanded = !isExpanded;
|
|
|
|
if (isExpanded) {
|
|
// Expand all
|
|
accordionButtons.forEach(button => {
|
|
button.classList.remove('collapsed');
|
|
button.setAttribute('aria-expanded', 'true');
|
|
});
|
|
|
|
accordionContents.forEach(content => {
|
|
content.classList.add('show');
|
|
});
|
|
|
|
toggleText.textContent = 'Collapse All';
|
|
toggleBtn.querySelector('span:first-child').classList.remove('ti-chevrons-down');
|
|
toggleBtn.querySelector('span:first-child').classList.add('ti-chevrons-up');
|
|
} else {
|
|
// Collapse all
|
|
accordionButtons.forEach(button => {
|
|
button.classList.add('collapsed');
|
|
button.setAttribute('aria-expanded', 'false');
|
|
});
|
|
|
|
accordionContents.forEach(content => {
|
|
content.classList.remove('show');
|
|
});
|
|
|
|
toggleText.textContent = 'Expand All';
|
|
toggleBtn.querySelector('span:first-child').classList.remove('ti-chevrons-up');
|
|
toggleBtn.querySelector('span:first-child').classList.add('ti-chevrons-down');
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|
|
{% endblock %}
|
|
|
|
{% block styles %}
|
|
<style>
|
|
.port-usage-compact {
|
|
width: 100%;
|
|
}
|
|
|
|
.port-ranges {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 2px;
|
|
}
|
|
|
|
.port-range {
|
|
height: 12px;
|
|
flex-grow: 1;
|
|
min-width: 3px;
|
|
border-radius: 2px;
|
|
}
|
|
|
|
.port-range-free {
|
|
background-color: rgba(25, 135, 84, 0.4);
|
|
}
|
|
|
|
.port-range-used {
|
|
background-color: rgba(220, 53, 69, 0.6);
|
|
}
|
|
|
|
.port-indicator {
|
|
display: inline-block;
|
|
width: 20px;
|
|
height: 10px;
|
|
border-radius: 2px;
|
|
}
|
|
|
|
.port-free {
|
|
background-color: rgba(25, 135, 84, 0.4);
|
|
}
|
|
|
|
.port-used {
|
|
background-color: rgba(220, 53, 69, 0.6);
|
|
}
|
|
|
|
.used-ports-list {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 8px;
|
|
}
|
|
|
|
.used-port-tag {
|
|
background-color: rgba(220, 53, 69, 0.2);
|
|
border: 1px solid rgba(220, 53, 69, 0.3);
|
|
color: var(--bs-body-color);
|
|
padding: 2px 8px;
|
|
border-radius: 4px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
|
|
.copy-port {
|
|
cursor: pointer;
|
|
opacity: 0.7;
|
|
}
|
|
|
|
.copy-port:hover {
|
|
opacity: 1;
|
|
}
|
|
</style>
|
|
{% endblock %} |