109 lines
No EOL
3.9 KiB
HTML
109 lines
No EOL
3.9 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">
|
|
<h2 class="page-title">
|
|
{% if app %}Edit Application{% else %}Add New Application{% endif %}
|
|
</h2>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card mt-3">
|
|
<div class="card-body">
|
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
|
{% if messages %}
|
|
{% for category, message in messages %}
|
|
<div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
|
|
{{ message }}
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
</div>
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endwith %}
|
|
|
|
<form method="POST"
|
|
action="{% if app %}{{ url_for('dashboard.app_edit', app_id=app.id) }}{% else %}{{ url_for('dashboard.app_new') }}{% endif %}">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<div class="mb-3">
|
|
<label class="form-label required">Application Name</label>
|
|
<input type="text" class="form-control" name="name" required value="{% if app %}{{ app.name }}{% endif %}">
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label required">Server</label>
|
|
<select class="form-select" name="server_id" required>
|
|
<option value="">Select a server</option>
|
|
{% for server in servers %}
|
|
<option value="{{ server.id }}" {% if app and app.server_id==server.id %}selected {% elif server_id and
|
|
server.id|string==server_id|string %}selected{% endif %}>
|
|
{{ server.hostname }} ({{ server.ip_address }})
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label">Documentation</label>
|
|
<textarea class="form-control" name="documentation"
|
|
rows="10">{% if app %}{{ app.documentation }}{% endif %}</textarea>
|
|
<div class="form-text">Markdown is supported</div>
|
|
</div>
|
|
<div class="form-footer">
|
|
<button type="submit" class="btn btn-primary">Save</button>
|
|
{% if app %}
|
|
<a href="{{ url_for('dashboard.app_view', app_id=app.id) }}" class="btn btn-outline-secondary ms-2">Cancel</a>
|
|
{% else %}
|
|
<a href="{% if server_id %}{{ url_for('dashboard.server_view', server_id=server_id) }}{% else %}{{ url_for('dashboard.dashboard_home') }}{% endif %}"
|
|
class="btn btn-outline-secondary ms-2">Cancel</a>
|
|
{% endif %}
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% block extra_js %}
|
|
<script>
|
|
let portRowIndex = 1;
|
|
|
|
function addPortRow() {
|
|
const tbody = document.querySelector('#ports-table tbody');
|
|
const tr = document.createElement('tr');
|
|
tr.classList.add('port-row');
|
|
tr.innerHTML = `
|
|
<td>
|
|
<input type="number" name="port_number_${portRowIndex}" class="form-control"
|
|
min="1" max="65535" placeholder="Port number">
|
|
</td>
|
|
<td>
|
|
<select name="protocol_${portRowIndex}" class="form-select">
|
|
<option value="TCP">TCP</option>
|
|
<option value="UDP">UDP</option>
|
|
<option value="SCTP">SCTP</option>
|
|
<option value="OTHER">OTHER</option>
|
|
</select>
|
|
</td>
|
|
<td>
|
|
<input type="text" name="description_${portRowIndex}" class="form-control"
|
|
placeholder="Description">
|
|
</td>
|
|
<td>
|
|
<button type="button" class="btn btn-sm btn-ghost-danger" onclick="removePortRow(this)">
|
|
<span class="ti ti-trash"></span>
|
|
</button>
|
|
</td>
|
|
`;
|
|
tbody.appendChild(tr);
|
|
portRowIndex++;
|
|
}
|
|
|
|
function removePortRow(button) {
|
|
const row = button.closest('tr');
|
|
row.remove();
|
|
}
|
|
</script>
|
|
{% endblock %}
|
|
|
|
{% endblock %} |