dodanie navmenu i logout
This commit is contained in:
		
							
								
								
									
										10
									
								
								app.py
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								app.py
									
									
									
									
									
								
							@@ -36,6 +36,16 @@ def login():
 | 
				
			|||||||
            return render_template('index.html', ssh_port=config.webssh_port, machines=machines_all.machines, timezone=config.timezone)
 | 
					            return render_template('index.html', ssh_port=config.webssh_port, machines=machines_all.machines, timezone=config.timezone)
 | 
				
			||||||
    return render_template('login.html')
 | 
					    return render_template('login.html')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@app.route('/logout')
 | 
				
			||||||
 | 
					def logout():
 | 
				
			||||||
 | 
					    auth_token = request.cookies.get('auth_token')
 | 
				
			||||||
 | 
					    if auth_token != "" or auth_token is not None:
 | 
				
			||||||
 | 
					        if db.get_user_bytoken(auth_token) is not None:
 | 
				
			||||||
 | 
					            db.del_auth_token(auth_token)
 | 
				
			||||||
 | 
					            response = make_response(redirect('/'))
 | 
				
			||||||
 | 
					            response.delete_cookie('auth_token')
 | 
				
			||||||
 | 
					            return response
 | 
				
			||||||
 | 
					    return render_template('login.html')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@app.route('/create/conf')
 | 
					@app.route('/create/conf')
 | 
				
			||||||
def create_conf():
 | 
					def create_conf():
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										12
									
								
								db.py
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								db.py
									
									
									
									
									
								
							@@ -138,6 +138,18 @@ def add_auth_token(user_id):
 | 
				
			|||||||
    return token
 | 
					    return token
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def del_auth_token(token):
 | 
				
			||||||
 | 
					    connect()
 | 
				
			||||||
 | 
					    with get_cur() as cur:
 | 
				
			||||||
 | 
					        cur.execute("DELETE FROM auth_tokens WHERE token = %s", (token, ))
 | 
				
			||||||
 | 
					        try:
 | 
				
			||||||
 | 
					            conn.commit()
 | 
				
			||||||
 | 
					            return True
 | 
				
			||||||
 | 
					        except:
 | 
				
			||||||
 | 
					            return None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def login(username, password):
 | 
					def login(username, password):
 | 
				
			||||||
    user_id = get_user_pass(username, password)
 | 
					    user_id = get_user_pass(username, password)
 | 
				
			||||||
    if user_id is not None:
 | 
					    if user_id is not None:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,8 +3,84 @@
 | 
				
			|||||||
<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">
 | 
						<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>
 | 
				
			||||||
 | 
							body {
 | 
				
			||||||
 | 
								font-family: Arial, sans-serif;
 | 
				
			||||||
 | 
								background-color: #f5f5f5;
 | 
				
			||||||
 | 
								margin: 0;
 | 
				
			||||||
 | 
								padding: 0;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							h1 {
 | 
				
			||||||
 | 
								font-size: 32px;
 | 
				
			||||||
 | 
								font-weight: bold;
 | 
				
			||||||
 | 
								color: #333;
 | 
				
			||||||
 | 
								margin: 20px 0;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							table {
 | 
				
			||||||
 | 
								border-collapse: collapse;
 | 
				
			||||||
 | 
								margin: 20px 0;
 | 
				
			||||||
 | 
								width: 100%;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							table th, table td {
 | 
				
			||||||
 | 
								padding: 10px;
 | 
				
			||||||
 | 
								text-align: left;
 | 
				
			||||||
 | 
								vertical-align: middle;
 | 
				
			||||||
 | 
								border: 1px solid #ccc;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							table th {
 | 
				
			||||||
 | 
								background-color: #eee;
 | 
				
			||||||
 | 
								font-weight: bold;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							table tr:hover {
 | 
				
			||||||
 | 
								background-color: #f0f0f0;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							button {
 | 
				
			||||||
 | 
								background-color: #4CAF50;
 | 
				
			||||||
 | 
								border: none;
 | 
				
			||||||
 | 
								color: white;
 | 
				
			||||||
 | 
								padding: 10px 20px;
 | 
				
			||||||
 | 
								text-align: center;
 | 
				
			||||||
 | 
								text-decoration: none;
 | 
				
			||||||
 | 
								display: inline-block;
 | 
				
			||||||
 | 
								font-size: 16px;
 | 
				
			||||||
 | 
								margin: 10px 0;
 | 
				
			||||||
 | 
								cursor: pointer;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							button:hover {
 | 
				
			||||||
 | 
								background-color: #3e8e41;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						</style>
 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
<body>
 | 
					<body>
 | 
				
			||||||
 | 
						<nav class="navbar navbar-expand-lg navbar-light bg-light">
 | 
				
			||||||
 | 
							<div class="container-fluid">
 | 
				
			||||||
 | 
								<a class="navbar-brand" href="#">Panel administracyjny</a>
 | 
				
			||||||
 | 
								<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
 | 
				
			||||||
 | 
									<span class="navbar-toggler-icon"></span>
 | 
				
			||||||
 | 
								</button>
 | 
				
			||||||
 | 
								<div class="collapse navbar-collapse justify-content-end" id="navbarNav" >
 | 
				
			||||||
 | 
									<ul class="navbar-nav">
 | 
				
			||||||
 | 
										<li class="nav-item">
 | 
				
			||||||
 | 
											<a class="nav-link active" aria-current="page" href="/">Lista maszyn</a>
 | 
				
			||||||
 | 
										</li>
 | 
				
			||||||
 | 
										<li class="nav-item">
 | 
				
			||||||
 | 
											<a class="nav-link" href="/create/conf">Tworzenie obrazu</a>
 | 
				
			||||||
 | 
										</li>
 | 
				
			||||||
 | 
										<li class="nav-item">
 | 
				
			||||||
 | 
											<a class="nav-link" href="/logout">Wyloguj</a>
 | 
				
			||||||
 | 
										</li>
 | 
				
			||||||
 | 
									</ul>
 | 
				
			||||||
 | 
								</div>
 | 
				
			||||||
 | 
							</div>
 | 
				
			||||||
 | 
						</nav>
 | 
				
			||||||
	<div class="container">
 | 
						<div class="container">
 | 
				
			||||||
		<h1 class="my-5">Lista maszyn</h1>
 | 
							<h1 class="my-5">Lista maszyn</h1>
 | 
				
			||||||
		<table class="table table-striped table-hover">
 | 
							<table class="table table-striped table-hover">
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user