Complete version of the manager

This commit is contained in:
Kumi 2018-11-26 08:23:33 +01:00
parent 4c3b316430
commit eefaaabc8c
10 changed files with 231 additions and 2 deletions

View file

@ -0,0 +1,18 @@
# Generated by Django 2.1.3 on 2018-11-25 17:01
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('manager', '0002_auto_20181125_1457'),
]
operations = [
migrations.AddField(
model_name='device',
name='name',
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Common Name'),
),
]

View file

@ -0,0 +1,18 @@
# Generated by Django 2.1.3 on 2018-11-25 17:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('manager', '0003_device_name'),
]
operations = [
migrations.AddField(
model_name='network',
name='organizations',
field=models.ManyToManyField(to='manager.Organization'),
),
]

View file

@ -0,0 +1,18 @@
# Generated by Django 2.1.3 on 2018-11-25 20:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('manager', '0004_network_organizations'),
]
operations = [
migrations.AddField(
model_name='device',
name='lasttime',
field=models.DateTimeField(blank=True, null=True, verbose_name='Last Received Heartbeat'),
),
]

View file

@ -0,0 +1,65 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>VPN360 Device Administration</title>
<!-- Bootstrap core CSS -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark static-top">
<div class="container">
<a class="navbar-brand" href="/">VPN360 Device Administration</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
{% if user.is_authenticated %}
<li class="nav-item">
<a class="nav-link" href="/devices">Devices</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/accounts/logout">Logout</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="/accounts/login">Login</a>
</li>
{% endif %}
</ul>
</div>
</div>
</nav>
<!-- Page Content -->
<div class="container">
<div class="row">
<div class="col-lg-12">
<br/>
<h1>{{ title }}</h1>
{% block content %}
{% endblock %}
</div>
</div>
</div>
<!-- Bootstrap core JavaScript -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js"></script>
</body>
</html>

View file

@ -0,0 +1,26 @@
{% extends "base.html" %}
{% block content %}
<form action="#" method="post">
{% csrf_token %}
<div class="form-group">
<label for="serial">Serial Number</label>
<input type="text" class="form-control" id="serial" disabled="disabled" value="{{ device.serial }}"></input>
</div>
<div class="form-group">
<label for="name">Device Name</label>
<input type="text" class="form-control" name="name" id="name" placeholder="Enter Device Name (Optional)"></input>
</div>
<div class="form-group">
<label for="subnet">Assigned Network</label>
<select class="custom-select mr-sm-2" id="subnet" name="subnet">
{% for choice in subnets %}
<option {% if choice.intip == device.network.intip %} selected {% endif %} value="{{ choice.intip }}">{{ choice.intip}} ({{ choice.extip }})</option>
{% endfor %}
</select>
</div>
<button type="submit" class="btn btn-primary">Apply Changes</button>
</form>
{% endblock %}

View file

@ -0,0 +1,35 @@
{% extends "base.html" %}
{% block content %}
<p><b>Organization:</b> {{ organization }}</p>
<p><b>User:</b> {{ user.firstname }} {{ user.lastname }} ({{ user.username }})</p>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Device ID</th>
<th>Common Name</th>
<th>Network</th>
<th>Latest IP</th>
<th>Secret</th>
<th>Options</th>
</tr>
</thead>
{% for device in devices %}
<tr>
<td>{{ device.serial }}</td>
<td>{% if device.name %}{{ device.name }}{% endif %}</td>
<td>{{ device.network }}</td>
<td>{% if device.curip %}{{ device.curip }} (at {{ device.lasttime }}){% endif %}</td>
<td>{{ device.secret }}</td>
<td><a href="/devices/{{ device.id }}"><i class="fas fa-edit"></i></a></td>
</tr>
{% endfor %}
</table>
</div>
{% endblock %}

View file

@ -0,0 +1,38 @@
{% extends "base.html" %}
{% block content %}
{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
{% if next %}
{% if user.is_authenticated %}
<p>Your account doesn't have access to this page. To proceed,
please login with an account that has access.</p>
{% else %}
<p>Please login to see this page.</p>
{% endif %}
{% endif %}
<form method="post" action="{% url 'login' %}">
{% csrf_token %}
<table>
<tr>
<td>{{ form.username.label_tag }}</td>
<td>{{ form.username }}</td>
</tr>
<tr>
<td>{{ form.password.label_tag }}</td>
<td>{{ form.password }}</td>
</tr>
</table>
<input type="submit" value="login">
<input type="hidden" name="next" value="{{ next }}">
</form>
{# Assumes you setup the password_reset view in your URLconf #}
<p><a href="{% url 'password_reset' %}">Lost password?</a></p>
{% endblock %}

2
uwsgi.sh Executable file
View file

@ -0,0 +1,2 @@
#!/bin/bash
uwsgi --socket 127.0.0.1:9360 --module vpnmanager.wsgi --uid 1001

10
vpnmanager.service Normal file
View file

@ -0,0 +1,10 @@
[Unit]
Description = VPNManager
After = network.target
[Service]
WorkingDirectory = /opt/vpnmanager/
ExecStart=/opt/vpnmanager/uwsgi.sh
[Install]
WantedBy=multi-user.target

View file

@ -25,14 +25,13 @@ SECRET_KEY = '=go8&h#^kh6ksr11e2z-@4qqd6t%63$x#-!s#l_yhw@oyanrys'
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
ALLOWED_HOSTS = [] ALLOWED_HOSTS = ["admin360.kumi.host"]
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'manager.apps.ManagerConfig', 'manager.apps.ManagerConfig',
'bootstrap3',
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',