refactor
This commit is contained in:
@@ -1,160 +1,111 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Remote server management</title>
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Hosty - /etc/hosts Manager{% endblock %}
|
||||
{% block extra_css %}
|
||||
{{ super() }}
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; background: #f1f1f1; margin: 0; padding: 0; }
|
||||
.container { max-width: 800px; margin: 40px auto; background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 0 10px #ccc; }
|
||||
h1 { text-align: center; margin-bottom: 1em; }
|
||||
table { width: 100%; border-collapse: collapse; margin-bottom: 1em; }
|
||||
table th, table td { border: 1px solid #ccc; padding: 8px; text-align: left; }
|
||||
table th { background: #f7f7f7; }
|
||||
.form-section { margin-bottom: 20px; background: #fafafa; padding: 10px; border: 1px solid #ddd; border-radius: 4px; }
|
||||
label { display: block; margin-top: 1em; }
|
||||
input[type="text"], input[type="password"], textarea { width: 100%; padding: 8px; margin-top: 4px; box-sizing: border-box; }
|
||||
button { margin-top: 1em; padding: 10px 20px; background: #007bff; border: none; color: #fff; cursor: pointer; border-radius: 4px; }
|
||||
button:hover { background: #0056b3; }
|
||||
.delete-btn { background: #dc3545; margin-top: 0; }
|
||||
.delete-btn:hover { background: #c82333; }
|
||||
.links { text-align: center; margin-top: 10px; }
|
||||
.links a { color: #007bff; text-decoration: none; margin: 0 10px; }
|
||||
.links a:hover { text-decoration: underline; }
|
||||
.flash-messages { margin-top: 10px; color: #b30000; text-align: center; }
|
||||
.btn {
|
||||
display: inline-block;
|
||||
padding: 4px 10px;
|
||||
margin: 0 3px;
|
||||
border-radius: 4px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
color: #fff;
|
||||
font-size: 0.85em;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* Kolorowe warianty */
|
||||
.btn-primary {
|
||||
background-color: #007bff;
|
||||
}
|
||||
.btn-primary:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
.btn-info {
|
||||
background-color: #17a2b8;
|
||||
}
|
||||
.btn-info:hover {
|
||||
background-color: #138496;
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
background-color: #28a745;
|
||||
}
|
||||
.btn-success:hover {
|
||||
background-color: #218838;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background-color: #dc3545;
|
||||
}
|
||||
.btn-danger:hover {
|
||||
background-color: #c82333;
|
||||
}
|
||||
.resolved-hostname {
|
||||
display: none;
|
||||
font-size: 0.7em;
|
||||
color: #777;
|
||||
}
|
||||
td:hover .resolved-hostname {
|
||||
display: block;
|
||||
/* Dodatkowy styl, np. modyfikacja wyglądu tooltipów */
|
||||
.tooltip-inner {
|
||||
max-width: 300px;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Remote server management</h1>
|
||||
{% with messages = get_flashed_messages(category_filter=["danger","success","info"]) %}
|
||||
{% if messages %}
|
||||
<div class="flash-messages">
|
||||
{% for message in messages %}
|
||||
<p>{{ message }}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
<div class="form-section">
|
||||
<h2>Add new server</h2>
|
||||
<form method="POST" action="{{ url_for('manage_hosts') }}">
|
||||
<label for="hostname">Hostname (IP or domain):</label>
|
||||
<input type="text" name="hostname" id="hostname" required />
|
||||
<label for="username">SSH Username:</label>
|
||||
<input type="text" name="username" id="username" required />
|
||||
<label for="password">SSH Password:</label>
|
||||
<input type="password" name="password" id="password" />
|
||||
<label for="port">SSH Port:</label>
|
||||
<input type="text" name="port" id="port" value="22" />
|
||||
<label for="host_type">Type:</label>
|
||||
<select name="host_type" id="host_type" required>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<h2>Dodaj nowy serwer</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ url_for('manage_hosts') }}">
|
||||
<div class="mb-3">
|
||||
<label for="hostname" class="form-label">Nazwa hosta (IP lub domena)</label>
|
||||
<input type="text" name="hostname" id="hostname" class="form-control" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="username" class="form-label">Użytkownik SSH</label>
|
||||
<input type="text" name="username" id="username" class="form-control" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">Hasło SSH</label>
|
||||
<input type="password" name="password" id="password" class="form-control">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="port" class="form-label">Port SSH</label>
|
||||
<input type="text" name="port" id="port" class="form-control" value="22">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="host_type" class="form-label">Typ</label>
|
||||
<select name="host_type" id="host_type" class="form-select" required>
|
||||
<option value="linux">Linux</option>
|
||||
<option value="mikrotik">Mikrotik</option>
|
||||
</select>
|
||||
<label for="auth_method">Authentication Method:</label>
|
||||
<select name="auth_method" id="auth_method">
|
||||
<option value="password">Password</option>
|
||||
<option value="ssh_key">SSH Key</option>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="auth_method" class="form-label">Metoda uwierzytelniania</label>
|
||||
<select name="auth_method" id="auth_method" class="form-select">
|
||||
<option value="password">Hasło</option>
|
||||
<option value="ssh_key">Klucz SSH</option>
|
||||
</select>
|
||||
<label for="private_key">Private Key (if using SSH Key):</label>
|
||||
<textarea name="private_key" id="private_key" rows="5"></textarea>
|
||||
<label for="key_passphrase">Key Passphrase (if encrypted key):</label>
|
||||
<input type="password" name="key_passphrase" id="key_passphrase" />
|
||||
<button type="submit">Add Host</button>
|
||||
</form>
|
||||
</div>
|
||||
<table>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="private_key" class="form-label">Klucz prywatny (jeśli używasz klucza SSH)</label>
|
||||
<textarea name="private_key" id="private_key" rows="4" class="form-control"></textarea>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="key_passphrase" class="form-label">Hasło do klucza (jeśli klucz jest zaszyfrowany)</label>
|
||||
<input type="password" name="key_passphrase" id="key_passphrase" class="form-control">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Dodaj hosta</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>Lista hostów</h2>
|
||||
</div>
|
||||
<div class="card-body table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Hostname</th>
|
||||
<th>SSH User</th>
|
||||
<th>Nazwa hosta</th>
|
||||
<th>Użytkownik SSH</th>
|
||||
<th>Port</th>
|
||||
<th>Type</th>
|
||||
<th>Auth Method</th>
|
||||
<th>Actions</th>
|
||||
<th>Typ</th>
|
||||
<th>Metoda uwierzytelniania</th>
|
||||
<th>Akcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for h in hosts %}
|
||||
<tr>
|
||||
<td>{{ h.id }}</td>
|
||||
<td>
|
||||
<span class="primary-hostname">{{ h.hostname }}</span>
|
||||
<br>
|
||||
<span class="resolved-hostname">{{ h.resolved_hostname }}</span>
|
||||
<td data-bs-toggle="tooltip" data-bs-placement="top" title="{{ h.resolved_hostname }}">
|
||||
{{ h.hostname }}
|
||||
</td>
|
||||
|
||||
<td>{{ h.username }}</td>
|
||||
<td>{{ h.port }}</td>
|
||||
<td>{{ h.type }}</td>
|
||||
<td>{{ h.auth_method }}</td>
|
||||
<td>
|
||||
<a href="{{ url_for('edit_host', id=h.id) }}" class="btn btn-primary">Edit</a>
|
||||
<a href="{{ url_for('test_host', id=h.id) }}" class="btn btn-info">Test</a>
|
||||
<a href="{{ url_for('backup_host', host_id=h.id) }}" class="btn btn-success">Backup</a>
|
||||
<a href="{{ url_for('edit_host', id=h.id) }}" class="btn btn-primary btn-sm">Edytuj</a>
|
||||
<a href="{{ url_for('test_host', id=h.id) }}" class="btn btn-info btn-sm">Testuj</a>
|
||||
<a href="{{ url_for('backup_host', host_id=h.id) }}" class="btn btn-success btn-sm">Backup</a>
|
||||
<form method="GET" action="{{ url_for('delete_host', id=h.id) }}" style="display:inline;">
|
||||
<button type="submit" class="btn btn-danger">Delete</button>
|
||||
<button type="submit" class="btn btn-danger btn-sm">Usuń</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="links">
|
||||
<a href="{{ url_for('import_hosts') }}">Import Servers from CSV</a> |
|
||||
<a href="{{ url_for('export_hosts') }}">Export Servers to CSV</a> |
|
||||
<a href="{{ url_for('dashboard') }}">Go to Dashboard</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 text-center">
|
||||
<a href="{{ url_for('import_hosts') }}" class="btn btn-secondary">Importuj serwery z CSV</a>
|
||||
<a href="{{ url_for('export_hosts') }}" class="btn btn-secondary">Eksportuj serwery do CSV</a>
|
||||
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary">Przejdź do pulpitu</a>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user