zmiana wygladu strony

This commit is contained in:
Mateusz779 2023-04-19 12:12:38 +02:00
parent 5c7bb023c0
commit 32d044c721
3 changed files with 32 additions and 33 deletions

View File

@ -4,4 +4,5 @@ user="praktyki"
password="2a7driUITXFy73tO" password="2a7driUITXFy73tO"
port="5432" port="5432"
default_file = "default.squashfs" default_file = "default.squashfs"
webssh_port = "8000" webssh_port = "8000"
timezone = "UTC"

2
db.py
View File

@ -17,7 +17,7 @@ def connect():
cur = conn.cursor() cur = conn.cursor()
with conn.cursor() as cur: with conn.cursor() as cur:
cur.execute("SET TIMEZONE='UTC';") cur.execute("SET TIMEZONE='%s'",(config.timezone,))
conn.commit() conn.commit()
cur.execute(""" cur.execute("""
CREATE TABLE IF NOT EXISTS image ( CREATE TABLE IF NOT EXISTS image (

View File

@ -2,6 +2,7 @@
<html> <html>
<head> <head>
<title>Panel administracyjny</title> <title>Panel administracyjny</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<style> <style>
body { body {
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
@ -59,42 +60,39 @@
</style> </style>
</head> </head>
<body> <body>
<h1>Lista maszyn</h1> <div class="container">
<table> <h1 class="my-5">Lista maszyn</h1>
<thead> <table class="table table-striped table-hover">
<tr> <thead>
<th>Nazwa maszyny</th>
<th>Obraz</th>
<th>Czas uruchomienia</th>
<th>IP uVPN</th>
<th>IP lokalne</th>
<th></th>
</tr>
</thead>
<tbody>
{% for machine in machines %}
<tr> <tr>
<td>{{ machine.name }}</td> <th>Nazwa maszyny</th>
<td>{{ machine.image_name }}</td> <th>Obraz</th>
<td>{{ machine.start_time }}</td> <th>Czas uruchomienia</th>
<td>{{ machine.ipvpn }}</td> <th>IP uVPN</th>
<td>{{ machine.iplocal }}</td> <th>IP lokalne</th>
<td><button onclick="ssh('{{ machine.ipvpn }}', '{{ machine.username }}', '{{ machine.password }}')">SSH</button></td> <th></th>
</tr> </tr>
{% endfor %} </thead>
</tbody> <tbody>
</table> {% for machine in machines %}
<tr>
<td>{{ machine.name }}</td>
<td>{{ machine.image_name }}</td>
<td>{{ machine.start_time }}</td>
<td>{{ machine.ipvpn }}</td>
<td>{{ machine.iplocal }}</td>
<td><button class="btn btn-primary" onclick="ssh('{{ machine.ipvpn }}', '{{ machine.username }}', '{{ machine.password }}')">SSH</button></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<script> <script>
function ssh(ipvpn, username, password) { function ssh(ipvpn, username, password) {
const currentLocation = window.location;
const currentLocation = window.location; const newUrl = currentLocation.protocol + '//' + currentLocation.hostname + ':' + {{ ssh_port }} + "/?hostname="+ipvpn+"&username="+username+"&password="+btoa(password);
// budowanie nowego URL window.open(newUrl,"_blank");
const newUrl = currentLocation.protocol + '//' + currentLocation.hostname + ':' + {{ ssh_port }} + "/?hostname="+ipvpn+"&username="+username+"&password="+btoa(password);
console.log(newUrl);
// przekierowanie na nowy URL
window.open(newUrl,"_blank");
} }
</script> </script>
</body> </body>