started
This commit is contained in:
parent
5bb69eef31
commit
536a0b2f6d
|
|
@ -0,0 +1,7 @@
|
||||||
|
FROM python
|
||||||
|
COPY ./certs /certs
|
||||||
|
|
||||||
|
COPY ./ /app
|
||||||
|
RUN pip install -r /app/requirements.txt
|
||||||
|
|
||||||
|
CMD python /app/run.py
|
||||||
|
|
@ -1 +1,7 @@
|
||||||
BioSys
|
BioSys
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Notes
|
||||||
|
|
||||||
|
FingerprintID: 0 is the left pinky 9 is the right pinky, people with more than 10 fingers may use another system.
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,21 @@
|
||||||
|
from flask import Flask, request, g, render_template
|
||||||
|
from flask_restful import Resource, reqparse
|
||||||
|
from flask_restful_swagger_3 import Api
|
||||||
|
from flask_cors import CORS
|
||||||
|
import os
|
||||||
|
from json import dumps
|
||||||
|
import application.endpoints as endpoints
|
||||||
|
import application.config as config
|
||||||
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
api = Api(app, version='1', contact={"name":""}, license={"name":"Online Dienst Dokumentation"}, api_spec_url='/api/swagger')
|
||||||
|
|
||||||
|
|
||||||
|
api.add_resource(endpoints.PersonList,'/api/v1/person/<string:id>')
|
||||||
|
|
||||||
|
@app.route("/")
|
||||||
|
def index():
|
||||||
|
"""serve the ui"""
|
||||||
|
return render_template("index.html")
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
debug = True
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
import sqlalchemy as db
|
||||||
|
from sqlalchemy import Column, String, Integer, Numeric, Table, DateTime, ARRAY, ForeignKey, create_engine, LargeBinary, Enum
|
||||||
|
from sqlalchemy.orm import sessionmaker, relationship, column_property
|
||||||
|
from datetime import datetime
|
||||||
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
import enum
|
||||||
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
engine = db.create_engine('sqlite:///./test.sqlite', echo=True)
|
||||||
|
connection = engine.connect()
|
||||||
|
Base = declarative_base()
|
||||||
|
Session = sessionmaker(bind=engine)
|
||||||
|
|
||||||
|
class Gender(enum.Enum):
|
||||||
|
other = "other"
|
||||||
|
male = "male"
|
||||||
|
female = "female"
|
||||||
|
|
||||||
|
class Person(Base):
|
||||||
|
__tablename__ = "person"
|
||||||
|
person_id = Column('person_id', Integer, primary_key=True, autoincrement=True)
|
||||||
|
timestamp = Column('timestamp', DateTime, default=datetime.utcnow)
|
||||||
|
fname = Column('fname', String(50))
|
||||||
|
lname = Column('lname', String(50))
|
||||||
|
yob = Column('yob', Integer)
|
||||||
|
gender = Column('gender', Enum(Gender))
|
||||||
|
face = Column('face', LargeBinary)
|
||||||
|
fingerprints = relationship("Fingerprint", foreign_keys='Fingerprint.person_id')
|
||||||
|
|
||||||
|
class Fingerprint(Base):
|
||||||
|
__tablename__ = "fingerprint"
|
||||||
|
person_id = Column('person_id', Integer, ForeignKey('person.person_id'), primary_key=True)
|
||||||
|
|
||||||
|
fingerprint_id = Column('fingerprint_id', Integer, primary_key=True) # 0: left pinky; 9: right pinky
|
||||||
|
timestamp = Column('timestamp', DateTime, default=datetime.utcnow)
|
||||||
|
fingerprint = Column('fingerprint', LargeBinary)
|
||||||
|
|
||||||
|
Base.metadata.create_all(engine)
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
from flask_restful import Resource, reqparse
|
||||||
|
import flask
|
||||||
|
import requests
|
||||||
|
import application.config as config
|
||||||
|
import json
|
||||||
|
from application.db import Session, Person
|
||||||
|
|
||||||
|
class PersonList(Resource):
|
||||||
|
def post(self, id):
|
||||||
|
""" """
|
||||||
|
try:
|
||||||
|
data = ""
|
||||||
|
return flask.make_response(flask.jsonify({'data': data}), 201)
|
||||||
|
except Exception as e:
|
||||||
|
print("error: -", e)
|
||||||
|
return flask.make_response(flask.jsonify({'error': str(e)}), 400)
|
||||||
|
|
||||||
|
def get(self, id):
|
||||||
|
""" """
|
||||||
|
try:
|
||||||
|
session = Session()
|
||||||
|
person = Person(fname="hi")
|
||||||
|
session.add(person)
|
||||||
|
session.commit()
|
||||||
|
|
||||||
|
data = list(session.query(Person).all())
|
||||||
|
arr = []
|
||||||
|
for x in data:
|
||||||
|
arr.append(json.loads(x))
|
||||||
|
|
||||||
|
print(arr)
|
||||||
|
return flask.make_response(flask.jsonify({'data': arr}), 200)
|
||||||
|
except Exception as e:
|
||||||
|
print("error: -", e)
|
||||||
|
return flask.make_response(flask.jsonify({'error': str(e)}), 400)
|
||||||
|
|
||||||
|
def put(self, id):
|
||||||
|
""" """
|
||||||
|
try:
|
||||||
|
data = ""
|
||||||
|
return flask.make_response(flask.jsonify({'data': data}), 200)
|
||||||
|
except Exception as e:
|
||||||
|
print("error: -", e)
|
||||||
|
return flask.make_response(flask.jsonify({'error': str(e)}), 400)
|
||||||
|
|
||||||
|
def delete(self, id):
|
||||||
|
""" """
|
||||||
|
try:
|
||||||
|
data = ""
|
||||||
|
return flask.make_response(flask.jsonify({'data': data}), 204)
|
||||||
|
except Exception as e:
|
||||||
|
print("error: -", e)
|
||||||
|
return flask.make_response(flask.jsonify({'error': str(e)}), 400)
|
||||||
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
.demo{
|
||||||
|
max-width: 60%;
|
||||||
|
min-width: 100px;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container{
|
||||||
|
padding:0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.demo2{
|
||||||
|
margin-left: -10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg-primary1{
|
||||||
|
background-color: rgb(255, 230, 183) !important;
|
||||||
|
}
|
||||||
|
.bg-warning1{
|
||||||
|
background-color: rgb(255, 250, 175)!important;
|
||||||
|
}
|
||||||
|
.bg-info1{
|
||||||
|
background-color: rgb(210, 253, 193)!important;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,137 @@
|
||||||
|
var rootKontext = "/od1";
|
||||||
|
//var rootKontext = "";
|
||||||
|
var customeStyle = false;
|
||||||
|
|
||||||
|
function loadOD1(){
|
||||||
|
try{
|
||||||
|
let ksession = $.cookie("KSESSIONID");
|
||||||
|
var xmlHttp = new XMLHttpRequest();
|
||||||
|
xmlHttp.open( "GET", rootKontext, false );
|
||||||
|
xmlHttp.send();
|
||||||
|
document.getElementById("od1").innerHTML = xmlHttp.responseText;
|
||||||
|
|
||||||
|
$('link[title="custom"]').prop('disabled', true);
|
||||||
|
|
||||||
|
loadData();
|
||||||
|
}
|
||||||
|
catch(e){
|
||||||
|
document.getElementById("od1").innerHTML = "Ein Fehler ist beim Laden des Dienstes aufgetreten, bitte versuchen Sie es später erneut.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function nextTab(){
|
||||||
|
$('#navMenu1 a').removeClass("disabled");
|
||||||
|
$('#navMenu1 a').tab('show');
|
||||||
|
}
|
||||||
|
|
||||||
|
function getJSON (url, callback) {
|
||||||
|
let ksession = $.cookie("KSESSIONID");
|
||||||
|
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('GET', url + "?session_id=" + ksession, true);
|
||||||
|
xhr.responseType = 'json';
|
||||||
|
xhr.onload = function() {
|
||||||
|
var status = xhr.status;
|
||||||
|
if (status < 400) {
|
||||||
|
callback(null, xhr.response);
|
||||||
|
} else {
|
||||||
|
console.log("failed getting");
|
||||||
|
console.log(status);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.send();
|
||||||
|
};
|
||||||
|
|
||||||
|
function putJSON (url, data, callback) {
|
||||||
|
let ksession = $.cookie("KSESSIONID");
|
||||||
|
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('PUT', url + "?session_id=" + ksession, true);
|
||||||
|
xhr.responseType = 'json';
|
||||||
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||||
|
xhr.onload = function() {
|
||||||
|
var status = xhr.status;
|
||||||
|
if (status < 400) {
|
||||||
|
callback(null, xhr.response);
|
||||||
|
} else {
|
||||||
|
console.log("failed posting");
|
||||||
|
console.log(status);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.send(data);
|
||||||
|
};
|
||||||
|
|
||||||
|
function sendVorhaben(){
|
||||||
|
let data = document.getElementById("form1");
|
||||||
|
|
||||||
|
data = {};
|
||||||
|
data["name"] = document.getElementById("form1")["name"].value;
|
||||||
|
data["reason"] = document.getElementById("form1")["reason"].value;
|
||||||
|
data["note"] = document.getElementById("form1")["note"].value;
|
||||||
|
data["partial_application_id"] = document.getElementById("form1")["partial_application_id"].value;
|
||||||
|
|
||||||
|
putJSON(rootKontext + "/api/v1/vorhaben/" + data["partial_application_id"], JSON.stringify(data), function(error, data){
|
||||||
|
document.getElementById("status").innerHTML = "Daten erfolgreich erneuert";
|
||||||
|
loadData();
|
||||||
|
nextTab();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function queryString(string)
|
||||||
|
{
|
||||||
|
let queryString = window.location.search;
|
||||||
|
let varArray = queryString.split("&");
|
||||||
|
for (let i=0;i<varArray.length;i++) {
|
||||||
|
let param = varArray[i].split("=");
|
||||||
|
if(param[0] == string ){
|
||||||
|
return param[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadData(){
|
||||||
|
let encodedID = queryString("?partialApplicationId");
|
||||||
|
//encodedID = "d05e6d3a-1774-46a0-abb0-89abfe2ff5a3";
|
||||||
|
getJSON(rootKontext + "/api/v1/vorhaben/" + encodedID,
|
||||||
|
function(error, data){
|
||||||
|
console.log(data)
|
||||||
|
populateForm(data["data"], "form1")
|
||||||
|
populateForm(data["data"], "form2")
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function populateForm(data, formId){
|
||||||
|
console.log(data)
|
||||||
|
inputs = document.forms[formId];
|
||||||
|
|
||||||
|
for(var i = 0; i < 8; i++){
|
||||||
|
if(inputs[i] !== undefined && data[inputs[i].name] !== undefined){
|
||||||
|
inputs[i].value = data[inputs[i].name];
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
console.log(inputs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadNewStyle(){
|
||||||
|
customeStyle = !customeStyle;
|
||||||
|
|
||||||
|
if(customeStyle){
|
||||||
|
$('link[title="custom"]').prop('disabled', false);
|
||||||
|
$('link[title="default"]').prop('disabled', true);
|
||||||
|
|
||||||
|
console.log("StyleSheet: Custom");
|
||||||
|
alert("StyleSheet: Custom");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$('link[title="default"]').prop('disabled', false);
|
||||||
|
$('link[title="custom"]').prop('disabled', true);
|
||||||
|
|
||||||
|
console.log("StyleSheet: Default");
|
||||||
|
alert("StyleSheet: Default");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<!--Bootstrap-->
|
||||||
|
<!-- Latest compiled and minified CSS -->
|
||||||
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||||
|
<link rel="stylesheet" title="default" href="/od1/static/main.css">
|
||||||
|
<link rel="stylesheet" title="default" href="/static/main.css">
|
||||||
|
|
||||||
|
<link rel="stylesheet" title="custom" href="/static/main2.css">
|
||||||
|
<link rel="stylesheet" title="custom" href="/od1/static/main2.css">
|
||||||
|
<!-- jQuery library -->
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Popper JS -->
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Latest compiled JavaScript -->
|
||||||
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>
|
||||||
|
|
||||||
|
<script src="/od1/static/main.js"></script>
|
||||||
|
<script src="/static/main.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<h2>Online Dienst 1</h2>
|
||||||
|
<ul class="nav nav-tabs">
|
||||||
|
<li id="navMenu0" class="nav-item">
|
||||||
|
<a data-toggle="tab" class="nav-link active" href="#home">Eingabe</a>
|
||||||
|
</li>
|
||||||
|
<li id="navMenu1" class="nav-item ">
|
||||||
|
<a href="#menu1" data-toggle="tab" class="nav-link disabled">Übersicht</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="tab-content">
|
||||||
|
<div id="home" class="tab-pane container active">
|
||||||
|
<div id="header">
|
||||||
|
<input type="button" value="Aussehen ändern" class="btn btn-dark float-right" onclick="loadNewStyle()">
|
||||||
|
</div>
|
||||||
|
<form id="form1">
|
||||||
|
<div class="bg-info1 demo">
|
||||||
|
<div class="demo2">eAst POST zu OD</div>
|
||||||
|
partial_application_id:<br>
|
||||||
|
|
||||||
|
<input type="text" class="form-control" name="partial_application_id" placeholder="partial_application_id" readonly><br>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bg-warning1 demo">
|
||||||
|
<div class="demo2">OD GET an eAst</div>
|
||||||
|
sent_date:<br>
|
||||||
|
<input type="text" class="form-control" name="sent_date" placeholder="sent_date" readonly><br>
|
||||||
|
application_id:<br>
|
||||||
|
<input type="text" class="form-control" name="application_id" placeholder="application_id" readonly><br>
|
||||||
|
official_letter_required:<br>
|
||||||
|
<input type="text" class="form-control" name="official_letter_required" placeholder="official_letter_required"
|
||||||
|
readonly><br>
|
||||||
|
name:<br>
|
||||||
|
<input type="text" class="form-control" name="name" placeholder="name"><br>
|
||||||
|
status:<br>
|
||||||
|
<input type="text" class="form-control" name="status" placeholder="status" readonly><br><br>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bg-primary1 demo">
|
||||||
|
<div class="demo2">Daten des OD</div>
|
||||||
|
Grund:<br>
|
||||||
|
<input type="text" class="form-control" name="reason" placeholder="Grund"><br>
|
||||||
|
Notiz:<br>
|
||||||
|
<input type="text" class="form-control" name="note" placeholder="Notitz"><br>
|
||||||
|
</div>
|
||||||
|
<input type="button" value="Speichern" class="btn btn-dark float-right" onclick="sendVorhaben()">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div id="menu1" class="tab-pane container">
|
||||||
|
<h2 id="status"></h2>
|
||||||
|
<form id="form2">
|
||||||
|
<div class="demo">
|
||||||
|
|
||||||
|
partial_application_id:<br>
|
||||||
|
<input type="text" class="form-control" name="partial_application_id" placeholder="partial_application_id" readonly><br>
|
||||||
|
sent_date:<br>
|
||||||
|
<input type="text" class="form-control" name="sent_date" placeholder="sent_date" readonly><br>
|
||||||
|
application_id:<br>
|
||||||
|
<input type="text" class="form-control" name="application_id" placeholder="application_id" readonly><br>
|
||||||
|
official_letter_required:<br>
|
||||||
|
<input type="text" class="form-control" name="official_letter_required" placeholder="official_letter_required"
|
||||||
|
readonly><br>
|
||||||
|
name:<br>
|
||||||
|
<input type="text" class="form-control" name="name" placeholder="name" readonly><br>
|
||||||
|
status:<br>
|
||||||
|
<input type="text" class="form-control" name="status" placeholder="status" readonly><br><br>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bg-primary1 demo">
|
||||||
|
<div class="demo2">Geänderte Daten</div>
|
||||||
|
Grund:<br>
|
||||||
|
<input type="text" class="form-control" name="reason" placeholder="Grund" readonly><br>
|
||||||
|
Notiz:<br>
|
||||||
|
<input type="text" class="form-control" name="note" placeholder="Notitz" readonly><br>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>loadData();</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
flask
|
||||||
|
flask_restful
|
||||||
|
sqlalchemy
|
||||||
|
requests
|
||||||
|
flask-restful-swagger-3
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
from application import app
|
||||||
|
|
||||||
|
app.run(host="0.0.0.0",port='10024', debug=True)
|
||||||
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue