mirror of
https://github.com/TakeusV1/flask_ipam.git
synced 2026-10-14 01:15:33 +02:00
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
from flask import Blueprint, render_template, redirect, url_for
|
|
from flask_login import login_required, current_user
|
|
|
|
from app._config import app_version
|
|
|
|
from app.extensions import *
|
|
from app.models import *
|
|
|
|
base = Blueprint('base', __name__)
|
|
|
|
@base.route('/')
|
|
def home():
|
|
if current_user.is_authenticated:
|
|
return redirect(url_for('base.dashboard'))
|
|
else:
|
|
return redirect(url_for('auth.login'))
|
|
|
|
@base.route('/dashboard')
|
|
@login_required
|
|
def dashboard():
|
|
|
|
db_networks = Network.query.count()
|
|
db_allocations = Allocation.query.filter_by(is_used=True).count()
|
|
db_inventory = Inventory.query.count()
|
|
db_users = User.query.count()
|
|
available_alloc = 0
|
|
|
|
for available_ip in Network.query.all():
|
|
available_alloc += int(available_ip.hosts)
|
|
|
|
return render_template(
|
|
'panel/dashboard.html',
|
|
title="Dashboard",
|
|
is_dash=True,
|
|
app_version=app_version,
|
|
## Variables
|
|
db_networks=db_networks,
|
|
db_allocations=db_allocations,
|
|
db_inventory=db_inventory,
|
|
available_alloc=available_alloc,
|
|
db_users=db_users,
|
|
Inventory=Inventory,
|
|
navcolor='dark'
|
|
) |