feat(webapi): add api packages and base files

This commit is contained in:
Julian Lobbes 2022-11-21 20:32:07 +01:00
parent 0bb678acc0
commit 413dedd29e
8 changed files with 37 additions and 9 deletions

View File

@ -12,6 +12,7 @@ services:
- ./lumi2/exceptions.py:/app/lumi2/exceptions.py:ro
- ./lumi2/ldap.py:/app/lumi2/ldap.py:ro
- ./lumi2/usermodel.py:/app/lumi2/usermodel.py:ro
- ./lumi2/webapi.py:/app/lumi2/webapi.py:ro
- ./lumi2/usermanager.py:/app/lumi2/usermanager.py:ro
- ./lumi2/static/js:/app/lumi2/static/js:ro
- ./lumi2/static/css:/app/lumi2/static/css:ro

View File

@ -1,6 +1,10 @@
import os
from flask import Flask
from flask_restful import Api
api = Api()
def create_app(test_config=None):
@ -44,6 +48,10 @@ def create_app(test_config=None):
app.register_blueprint(usermanager.bp)
app.add_url_rule('/', endpoint='index')
from . import webapi
api.add_resource(webapi.HelloWorld, '/api/hello')
api.init_app(app)
# TODO create OUs
return app

10
lumi2/static/js/tables.js Normal file
View File

@ -0,0 +1,10 @@
$(function() {
$("table").tablesorter({
theme: 'bootstrap',
headerTemplate: '{content} {icon}',
cssIcon: 'bi-arrow-down-up',
cssIconNone: '',
cssIconAsc: 'bi-arrow-up',
cssIconDesc: 'bi-arrow-down',
});
});

View File

@ -20,9 +20,13 @@
<!--<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">-->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.2/font/bootstrap-icons.css">
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.1/dist/jquery.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/tablesorter@2.31.3/dist/js/jquery.tablesorter.combined.min.js" integrity="sha256-ounC3wWwZ9iBUyF8x1+X+REppGjK+p6/+w+ky1MGoMM=" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-lg bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="{{ url_for('index') }}">
@ -38,6 +42,9 @@
<li class="nav-item">
<a class="nav-link" href="{{ url_for('usermanager.user_list') }}">Users</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('usermanager.group_list') }}">Groups</a>
</li>
</ul>
<div class="d-flex"">
<a class="btn btn-primary"
@ -59,6 +66,5 @@
{% block content %}
{% endblock content %}
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>
</body>
</html>

View File

@ -8,10 +8,7 @@
<a class="btn btn-primary"
href="{{ url_for('usermanager.group_create') }}"
role="button"
>
<img src="{{ url_for('static', filename='/images/base/plus.png') }}" alt="Plus-Icon" width="16" height="16">
Create a new group
</a>
><i class="bi-people"></i> Create a new group</a>
</div>
{% if groups %}
<div class="table-responsive">

View File

@ -8,10 +8,7 @@
<a class="btn btn-primary"
href="{{ url_for('usermanager.user_create') }}"
role="button"
>
<img src="{{ url_for('static', filename='/images/base/plus.png') }}" alt="Plus-Icon" width="16" height="16">
Create a new user
</a>
><i class="bi-person-plus"></i> Create a new user</a>
</div>
{% if users %}
<div class="table-responsive">
@ -53,4 +50,5 @@
<p class="text-muted">There are currently no users.</p>
</div>
{% endif %}
<script src="{{ url_for('static', filename='js/tables.js') }}"></script>
{% endblock content %}

7
lumi2/webapi.py Normal file
View File

@ -0,0 +1,7 @@
from flask import Blueprint
from flask_restful import Resource
class HelloWorld(Resource):
def get(self):
return {'hello': 'world'}

View File

@ -6,3 +6,4 @@ Pillow==9.3.0
WTForms==3.0.1
wtforms[email]==3.0.1
Flask-WTF==1.0.1
Flask-RESTful==0.3.9