commit 7fe7be79d4da62e8ab89c487ae57e8d6e0991f7a
Author: zemanm98@students.zcu.cz <Farnhait123*>
Date:   Sun May 8 10:09:26 2022 +0200

    Added views for LD logs and forms for connecting body devices with licenses.

diff --git a/server/sql_app/api/auth.py b/server/sql_app/api/auth.py
index 8178130..069d27c 100644
--- a/server/sql_app/api/auth.py
+++ b/server/sql_app/api/auth.py
@@ -1,14 +1,10 @@
-
-
 from fastapi import Depends, APIRouter, Form
 from fastapi import Request
 from fastapi.responses import HTMLResponse
 from fastapi.templating import Jinja2Templates
-from fastapi.responses import HTMLResponse
 from fastapi_jwt_auth import AuthJWT
 from pydantic import BaseModel
 
-
 # Path to html templates used in this file
 templates = Jinja2Templates(directory="templates/auth")
 
@@ -29,7 +25,7 @@ class Settings(BaseModel):
 def get_config():
     return Settings()
 
-
+# admin username and password
 fake_users_db = {
     "admin": {
         "username": "admin",
@@ -40,13 +36,19 @@ fake_users_db = {
 
 @auth.get("/login", response_class=HTMLResponse)
 async def login_get(request: Request):
+    """
+    return html template for login
+    """
     return templates.TemplateResponse("login.html", {"request": request})
 
 
 @auth.post("/login", response_class=HTMLResponse)
 async def login(username: str = Form(...), password: str = Form(...), Authorize: AuthJWT = Depends()):
+    """
+    Endpoint called from login template. Checks if given username and password aligns with admin
+    username and password and returns token for browser according to given username and password
+    """
     user_dict = fake_users_db.get(username)
-
     if user_dict != None:
         if user_dict["username"] == username and user_dict["password"] == password:
             access_token = Authorize.create_access_token(subject="admin", expires_time=False)
@@ -78,8 +80,11 @@ async def login(username: str = Form(...), password: str = Form(...), Authorize:
 
 @auth.post('/refresh')
 def refresh(Authorize: AuthJWT = Depends()):
+    """
+    endpoint for refreshing browser token. Not used at the moment since lifetime of given tokens are
+    unlimited.
+    """
     Authorize.jwt_refresh_token_required()
-
     current_user = Authorize.get_jwt_subject()
     new_access_token = Authorize.create_access_token(subject=current_user)
     # Set the JWT cookies in the response
@@ -90,9 +95,7 @@ def refresh(Authorize: AuthJWT = Depends()):
 @auth.get('/logout', response_class=HTMLResponse)
 def logout(Authorize: AuthJWT = Depends()):
     """
-    Because the JWT are stored in an httponly cookie now, we cannot
-    log the user out by simply deleting the cookies in the frontend.
-    We need the backend to send us a response to delete the cookies.
+    Endpoint for deleting cookie token with acces role.
     """
     Authorize.jwt_optional()
 
diff --git a/server/sql_app/api/bodydevices_web.py b/server/sql_app/api/bodydevices_web.py
new file mode 100644
index 0000000..9b13bb7
--- /dev/null
+++ b/server/sql_app/api/bodydevices_web.py
@@ -0,0 +1,128 @@
+from datetime import datetime
+
+from fastapi import Depends, APIRouter, Form
+from fastapi import Request
+from fastapi.responses import HTMLResponse, RedirectResponse
+from fastapi.templating import Jinja2Templates
+from fastapi_jwt_auth import AuthJWT
+from pydantic import BaseModel
+from sqlalchemy.orm import Session
+from sql_app.api.auth import fake_users_db
+from sql_app import crud, models
+from ..database import SessionLocal, engine
+
+models.Base.metadata.create_all(bind=engine)
+
+# Path to html templates used in this file
+templates = Jinja2Templates(directory="templates/body-devices")
+
+# prefix used for all endpoints in this file
+body_device_web = APIRouter(prefix="")
+
+
+# Dependency
+def get_db():
+    db = SessionLocal()
+    try:
+        yield db
+    finally:
+        db.close()
+
+
+@body_device_web.get("/body-devices-web", response_class=HTMLResponse)
+async def read_devices(request: Request, skip: int = 0, limit: int = 100, db: Session = Depends(get_db),
+                       Authorize: AuthJWT = Depends()):
+    """
+    Returns template with all body devices and its current states
+    """
+    Authorize.jwt_optional()
+    current_user = Authorize.get_jwt_subject()
+
+    devices = crud.get_body_devices(db, skip=skip, limit=limit)
+    statuses = []
+    # adding state for each device in list
+    for i in range(0, len(devices)):
+        statuses.append(devices[i].b_logs[len(devices[i].b_logs) - 1].status)
+    licenses = crud.get_licenses(db, skip=skip, limit=limit)
+    if current_user == "admin":
+        return templates.TemplateResponse("body_devices.html", {"request": request, "devs": len(devices), "devices": devices,
+                                                           "statuses": statuses, "licenses": licenses, "user": current_user})
+    else:
+        current_user = "guest"
+        return templates.TemplateResponse("body_devices_normal.html", {"request": request, "devs": len(devices), "devices": devices,
+                                                           "statuses": statuses, "licenses": licenses, "user": current_user})
+
+
+@body_device_web.post("/body-devices-web", response_class=HTMLResponse)
+async def filter_devices(request: Request, skip: int = 0, limit: int = 100, lic: str = Form("all"),
+                         db: Session = Depends(get_db), Authorize: AuthJWT = Depends()):
+    """
+    Endpoint used for filtering body devices by license. returns html template with only
+    body devices that has assigned license defined by user input
+    """
+    Authorize.jwt_optional()
+    current_user = Authorize.get_jwt_subject()
+    devices = crud.get_body_devices(db, skip=skip, limit=limit)
+    def_devices = []
+    for dev in devices:
+        for l in dev.debug_licenses:
+            if dev not in def_devices and l.b_licenses.name == lic:
+                def_devices.append(dev)
+    # if input was default all
+    if lic == "all":
+        def_devices = devices
+    statuses = []
+    for i in range(0, len(def_devices)):
+        statuses.append(def_devices[i].b_logs[len(def_devices[i].b_logs) - 1].status)
+    licenses = crud.get_licenses(db, skip=skip, limit=limit)
+    if current_user == "admin":
+        return templates.TemplateResponse("body_devices.html",
+                                          {"request": request, "devs": len(def_devices), "devices": def_devices,
+                                           "statuses": statuses, "licenses": licenses, "user": current_user})
+    else:
+        current_user = "guest"
+        return templates.TemplateResponse("body_devices_normal.html",
+                                          {"request": request, "devs": len(def_devices), "devices": def_devices,
+                                           "statuses": statuses, "licenses": licenses, "user": current_user})
+
+
+@body_device_web.get("/body-device-license/{device_id}", response_class=HTMLResponse)
+async def connect_dev_lic(request: Request, device_id: int, db: Session = Depends(get_db)):
+    """
+    Returns template with one body device and all available licenses that can be assigned to it.
+    """
+    device = crud.get_body_device(db, device_id)
+    dev_licenses = crud.get_bodydevice_license(db, device_id)
+    lic_names = []
+    dev_lics = []
+    for dev_lic in dev_licenses:
+        dev_lics.append(dev_lic.b_licenses)
+    for dev_lic in dev_licenses:
+        lic_names.append(dev_lic.b_licenses.name)
+    licenses = crud.get_licenses(db, 0, 100)
+    lic_left = []
+    for lic in licenses:
+        if lic.name not in lic_names and lic not in lic_left:
+            lic_left.append(lic)
+    return templates.TemplateResponse("body_device_license.html",
+                                      {"request": request, "device": device, "licenses": lic_left, "dev_lic": dev_lics})
+
+
+@body_device_web.post("/body-devices-web/{device_id}")
+async def connect_post(device_id: int, lic: str = Form(...), db: Session = Depends(get_db)):
+    """
+    Endpoint called from template for connecting body device with license. Adds entry to bodydevices_licenses
+    table and redirects to body-devices-web endpoint
+    """
+    crud.create_body_device_license(db, device_id, int(lic), datetime.now())
+    return RedirectResponse(url=f"/body-devices-web", status_code=303)
+
+
+@body_device_web.post("/body-devices-web-del/{device_id}")
+async def delete_post(device_id: int, b_lic: str = Form(...), db: Session = Depends(get_db)):
+    """
+    Endpoint called from template for connecting body device with license. Adds entry to devices_licenses
+    table and redirects to body-devices-web endpoint
+    """
+    crud.delete_bodydevice_license(db, device_id, int(b_lic))
+    return RedirectResponse(url=f"/body-devices-web", status_code=303)
\ No newline at end of file
diff --git a/server/sql_app/api/devices_web.py b/server/sql_app/api/devices_web.py
index f10de1b..97c38a5 100644
--- a/server/sql_app/api/devices_web.py
+++ b/server/sql_app/api/devices_web.py
@@ -46,19 +46,22 @@ async def read_devices(request: Request, skip: int = 0, limit: int = 100, db: Se
     licenses = crud.get_licenses(db, skip=skip, limit=limit)
     if current_user == "admin":
         return templates.TemplateResponse("devices.html", {"request": request, "devs": len(devices), "devices": devices,
-                                                           "statuses": statuses, "licenses": licenses})
+                                                           "statuses": statuses, "licenses": licenses, "user": current_user})
     else:
+        current_user = "guest"
         return templates.TemplateResponse("devices_normal.html", {"request": request, "devs": len(devices), "devices": devices,
-                                                           "statuses": statuses, "licenses": licenses})
+                                                                  "statuses": statuses, "licenses": licenses, "user": current_user})
 
 
 @device_web.post("/devices-web", response_class=HTMLResponse)
 async def filter_devices(request: Request, skip: int = 0, limit: int = 100, lic: str = Form("all"),
-                         db: Session = Depends(get_db)):
+                         db: Session = Depends(get_db), Authorize: AuthJWT = Depends()):
     """
     Endpoint used for filtering devices by license. returns html template with only
     devices that has assigned license defined by user input
     """
+    Authorize.jwt_optional()
+    current_user = Authorize.get_jwt_subject()
     devices = crud.get_devices(db, skip=skip, limit=limit)
     def_devices = []
     for dev in devices:
@@ -72,9 +75,15 @@ async def filter_devices(request: Request, skip: int = 0, limit: int = 100, lic:
     for i in range(0, len(def_devices)):
         statuses.append(def_devices[i].logs[len(def_devices[i].logs) - 1].status)
     licenses = crud.get_licenses(db, skip=skip, limit=limit)
-    return templates.TemplateResponse("devices.html",
-                                      {"request": request, "devs": len(def_devices), "devices": def_devices,
-                                       "statuses": statuses, "licenses": licenses})
+    if current_user == "admin":
+        return templates.TemplateResponse("devices.html",
+                                          {"request": request, "devs": len(def_devices), "devices": def_devices,
+                                           "statuses": statuses, "licenses": licenses, "user": current_user})
+    else:
+        current_user = "guest"
+        return templates.TemplateResponse("devices_normal.html",
+                                          {"request": request, "devs": len(def_devices), "devices": def_devices,
+                                           "statuses": statuses, "licenses": licenses, "user": current_user})
 
 
 @device_web.get("/device-license/{device_id}", response_class=HTMLResponse)
@@ -83,16 +92,37 @@ async def connect_dev_lic(request: Request, device_id: int, db: Session = Depend
     Returns template with one device and all available licenses that can be assigned to it.
     """
     device = crud.get_device(db, device_id)
+    dev_licenses = crud.get_device_licenses(db, device_id)
+    lic_names = []
+    dev_lics = []
+    for dev_lic in dev_licenses:
+        dev_lics.append(dev_lic.licenses)
+    for dev_lic in dev_licenses:
+        lic_names.append(dev_lic.licenses.name)
     licenses = crud.get_licenses(db, 0, 100)
+    lic_left = []
+    for lic in licenses:
+        if lic.name not in lic_names and lic not in lic_left:
+            lic_left.append(lic)
     return templates.TemplateResponse("devicelicense.html",
-                                      {"request": request, "device": device, "licenses": licenses})
+                                      {"request": request, "device": device, "licenses": lic_left, "dev_lic": dev_lics})
 
 
-@device_web.post("/devices-web/{device_id}", response_class=HTMLResponse)
+@device_web.post("/devices-web/{device_id}")
 async def connect_post(device_id: int, lic: str = Form(...), db: Session = Depends(get_db)):
     """
     Endpoint called from template for connecting device with license. Adds entry to devices_licenses
-    table and returns template with all devices in database
+    table and redirects to devices-web endpoint
     """
     crud.create_device_license(db, device_id, int(lic), datetime.now())
-    return RedirectResponse("/devices-web")
+    return RedirectResponse(url=f"/devices-web", status_code=303)
+
+
+@device_web.post("/devices-web-del/{device_id}")
+async def delete_post(device_id: int, lic_del: str = Form(...), db: Session = Depends(get_db)):
+    """
+    Endpoint called from template for deleting device-license connection. Adds entry to bodydevices_licenses
+    table and redirects to devices-web endpoint
+    """
+    crud.delete_device_license(db, device_id, int(lic_del))
+    return RedirectResponse(url=f"/devices-web", status_code=303)
diff --git a/server/sql_app/api/ld_logs_web.py b/server/sql_app/api/ld_logs_web.py
index e69de29..fbebfec 100644
--- a/server/sql_app/api/ld_logs_web.py
+++ b/server/sql_app/api/ld_logs_web.py
@@ -0,0 +1,73 @@
+from typing import List
+from fastapi import Depends, FastAPI, HTTPException, APIRouter, Form
+from datetime import datetime
+from sqlalchemy.orm import Session
+from sql_app import crud, models, schemas
+from ..database import SessionLocal, engine
+from fastapi import FastAPI, Request
+from fastapi.responses import HTMLResponse
+from fastapi_jwt_auth import AuthJWT
+from fastapi.staticfiles import StaticFiles
+from fastapi.templating import Jinja2Templates
+
+models.Base.metadata.create_all(bind=engine)
+
+# Path to html templates used in this file
+templates = Jinja2Templates(directory="templates/ld-logs")
+
+# prefix used for all endpoints in this file
+ldlogs_web = APIRouter(prefix="")
+
+
+# Dependency
+def get_db():
+    db = SessionLocal()
+    try:
+        yield db
+    finally:
+        db.close()
+
+
+@ldlogs_web.get("/ldlogs-web", response_class=HTMLResponse)
+async def read_logs(request: Request, skip: int = 0, limit: int = 100, db: Session = Depends(get_db),
+                    Authorize: AuthJWT = Depends()):
+    """
+    Returns template with all usb logs currently saved in database with its pcs, teams and licenses.
+    """
+    Authorize.jwt_optional()
+    current_user = Authorize.get_jwt_subject()
+    logs = crud.get_ld_logs(db, skip=skip, limit=limit)
+    pcs = []
+    for log in logs:
+        if log.pc_id not in pcs:
+            pcs.append(log.pc_id)
+    pc_obj = crud.find_pcs(db, pcs)
+    teams = crud.get_teams(db, skip=skip, limit=limit)
+    licenses = crud.get_licenses(db, skip=skip, limit=limit)
+    if current_user != "admin":
+        current_user = "guest"
+    return templates.TemplateResponse("ldlogs.html", {"request": request, "logs": logs, "pcs": pc_obj, "teams": teams,
+                                                      "licenses": licenses, "user": current_user})
+
+
+@ldlogs_web.post("/ldlogs-web", response_class=HTMLResponse)
+async def filter_logs(request: Request, pc: str = Form("all"), team: str = Form("all"), lic: str = Form("all"),
+                      skip: int = 0, limit: int = 100,
+                      db: Session = Depends(get_db), Authorize: AuthJWT = Depends()):
+    """
+    Endpoint used for filtering ld logs by user given form inputs.
+    """
+    Authorize.jwt_optional()
+    current_user = Authorize.get_jwt_subject()
+    log = crud.get_filtered_ldlogs(db, pc, team, lic)
+    logs_ids = []
+    for l in log:
+        logs_ids.append(l[0])
+    logs = crud.find_filtered_ldlogs(db, logs_ids)
+    pc_obj = crud.get_pcs(db, skip=skip, limit=limit)
+    teams = crud.get_teams(db, skip=skip, limit=limit)
+    licenses = crud.get_licenses(db, skip=skip, limit=limit)
+    if current_user != "admin":
+        current_user = "guest"
+    return templates.TemplateResponse("ldlogs.html", {"request": request, "logs": logs, "pcs": pc_obj, "teams": teams,
+                                                      "licenses": licenses, "user": current_user})
diff --git a/server/sql_app/api/licenses_web.py b/server/sql_app/api/licenses_web.py
index cebf250..24de037 100644
--- a/server/sql_app/api/licenses_web.py
+++ b/server/sql_app/api/licenses_web.py
@@ -46,12 +46,12 @@ async def read_licenses_web(request: Request, skip: int = 0, limit: int = 100, d
     return templates.TemplateResponse("licenses.html", {"request": request, "licenses": licenses})
 
 
-@licenses_web.post("/licenses-web", response_class=HTMLResponse)
+@licenses_web.post("/licenses-web")
 def create_license(name: str = Form(...), expdate: date = Form(...), db: Session = Depends(get_db)):
     """
-    Endpoint called from create license form. Creates new license and returns template with all licenses in database
+    Endpoint called from create license form. Creates new license and redirects to devices-web endpoint
     """
     db_license = crud.create_license(db, name, expdate)
     if db_license is None:
         print("something went wrong")
-    return RedirectResponse("/devices-web")
+    return RedirectResponse(url=f"/devices-web", status_code=303)
diff --git a/server/sql_app/api/pcs_web.py b/server/sql_app/api/pcs_web.py
index 3a5d66f..02303ab 100644
--- a/server/sql_app/api/pcs_web.py
+++ b/server/sql_app/api/pcs_web.py
@@ -37,9 +37,10 @@ async def read_pcs(request: Request, skip: int = 0, limit: int = 100, db: Sessio
     current_user = Authorize.get_jwt_subject()
     pcs = crud.get_pcs(db, skip=skip, limit=limit)
     if current_user == "admin":
-        return templates.TemplateResponse("pcs.html", {"request": request, "pcs": pcs})
+        return templates.TemplateResponse("pcs.html", {"request": request, "pcs": pcs, "user": current_user})
     else:
-        return templates.TemplateResponse("pcs_normal.html", {"request": request, "pcs": pcs})
+        current_user = "guest"
+        return templates.TemplateResponse("pcs_normal.html", {"request": request, "pcs": pcs, "user": current_user})
 
 
 @pcs_web.get("/pc-team/{pc_id}", response_class=HTMLResponse)
@@ -53,10 +54,10 @@ async def connect_pc_team(request: Request, pc_id: int, db: Session = Depends(ge
                                       {"request": request, "pc": pc, "teams": teams})
 
 
-@pcs_web.post("/pcs-web/{pc_id}", response_class=HTMLResponse)
+@pcs_web.post("/pcs-web/{pc_id}")
 async def connect_post(pc_id: int, team: str = Form(...), db: Session = Depends(get_db)):
     """
     Endpoint called from within form for connecting pc with team. Updates certain pc with new team.
     """
     old_pc = crud.update_pc(db, pc_id, team)
-    RedirectResponse("/pcs-web")
+    return RedirectResponse(url=f"/pcs-web", status_code=303)
diff --git a/server/sql_app/api/teams_web.py b/server/sql_app/api/teams_web.py
index 3d9cfd6..c1752a1 100644
--- a/server/sql_app/api/teams_web.py
+++ b/server/sql_app/api/teams_web.py
@@ -38,9 +38,10 @@ async def read_devices(request: Request, skip: int = 0, limit: int = 100, db: Se
     current_user = Authorize.get_jwt_subject()
     teams = crud.get_teams(db, skip=skip, limit=limit)
     if current_user == "admin":
-        return templates.TemplateResponse("teams.html", {"request": request, "teams": teams})
+        return templates.TemplateResponse("teams.html", {"request": request, "teams": teams, "user": current_user})
     else:
-        return templates.TemplateResponse("teams_normal.html", {"request": request, "teams": teams})
+        current_user = "guest"
+        return templates.TemplateResponse("teams_normal.html", {"request": request, "teams": teams, "user": current_user})
 
 
 @teams_web.get("/team-create", response_class=HTMLResponse)
@@ -51,7 +52,7 @@ async def team_create_web(request: Request):
     return templates.TemplateResponse("team_create.html", {"request": request})
 
 
-@teams_web.post("/teams-web", response_class=HTMLResponse)
+@teams_web.post("/teams-web-con")
 def create_team(name: str = Form(...), db: Session = Depends(get_db)):
     """
     Endpoint called from within form for creating new team. Creates new team and returns all teams in database
@@ -59,4 +60,4 @@ def create_team(name: str = Form(...), db: Session = Depends(get_db)):
     team = crud.create_team(db, name)
     if team is None:
         print("something went wrong")
-    RedirectResponse("/teams-web")
+    return RedirectResponse(url=f"/teams-web", status_code=303)
diff --git a/server/sql_app/api/usb_logs_web.py b/server/sql_app/api/usb_logs_web.py
index 0559e59..cb83443 100644
--- a/server/sql_app/api/usb_logs_web.py
+++ b/server/sql_app/api/usb_logs_web.py
@@ -6,6 +6,7 @@ from sql_app import crud, models, schemas
 from ..database import SessionLocal, engine
 from fastapi import FastAPI, Request
 from fastapi.responses import HTMLResponse
+from fastapi_jwt_auth import AuthJWT
 from fastapi.staticfiles import StaticFiles
 from fastapi.templating import Jinja2Templates
 
@@ -28,10 +29,13 @@ def get_db():
 
 
 @usblogs_web.get("/logs-web", response_class=HTMLResponse)
-async def read_logs(request: Request, skip: int = 0, limit: int = 100, db: Session = Depends(get_db)):
+async def read_logs(request: Request, skip: int = 0, limit: int = 100, db: Session = Depends(get_db),
+                    Authorize: AuthJWT = Depends()):
     """
     Returns template with all usb logs currently saved in database with its pcs, teams and licenses.
     """
+    Authorize.jwt_optional()
+    current_user = Authorize.get_jwt_subject()
     logs = crud.get_logs(db, skip=skip, limit=limit)
     pcs = []
     for log in logs:
@@ -40,8 +44,10 @@ async def read_logs(request: Request, skip: int = 0, limit: int = 100, db: Sessi
     pc_obj = crud.find_pcs(db, pcs)
     teams = crud.get_teams(db, skip=skip, limit=limit)
     licenses = crud.get_licenses(db, skip=skip, limit=limit)
+    if current_user != "admin":
+        current_user = "guest"
     return templates.TemplateResponse("logs.html", {"request": request, "logs": logs, "pcs": pc_obj, "teams": teams,
-                                                    "licenses": licenses})
+                                                    "licenses": licenses, "user": current_user})
 
 
 @usblogs_web.post("/logs-web", response_class=HTMLResponse)
diff --git a/server/sql_app/crud.py b/server/sql_app/crud.py
index eb3b7f8..cc20541 100644
--- a/server/sql_app/crud.py
+++ b/server/sql_app/crud.py
@@ -74,11 +74,48 @@ def create_license(db: Session, name: str, expdate: date):
 
 def get_license_devices(db: Session, license_id: int):
     """
-    returns all entries in devices_licenses table
+    returns all entries in devices_licenses table with given license_id
     """
     return db.query(models.DeviceLicense).filter(models.DeviceLicense.license_id == license_id).all()
 
 
+def get_device_licenses(db: Session, device_id: int):
+    """
+    returns all entries in devices_licenses table with given license_id
+    """
+    return db.query(models.DeviceLicense).filter(models.DeviceLicense.device_id == device_id).all()
+
+
+def get_devicelicense_by_devicelicense(db: Session, device_id: int, license_id: int):
+    """
+    returns entry in devices_licenses table with given device id and license id
+    """
+    return db.query(models.DeviceLicense).filter(and_(models.DeviceLicense.device_id == device_id,
+                                                      models.DeviceLicense.license_id == license_id)).first()
+
+
+def get_bodydevicelicense_by_bodydevicelicense(db: Session, device_id: int, license_id: int):
+    """
+    returns entry in bodydevices_licenses table with given body device id and license id
+    """
+    return db.query(models.BodyDeviceLicense).filter(and_(models.BodyDeviceLicense.bodydevice_id == device_id,
+                                                      models.BodyDeviceLicense.license_id == license_id)).first()
+
+
+def get_license_bodydevice(db: Session, license_id: int):
+    """
+    returns all entries in bodydevices_licenses with given license_id
+    """
+    return db.query(models.BodyDeviceLicense).filter(models.BodyDeviceLicense.license_id == license_id).all()
+
+
+def get_bodydevice_license(db: Session, device_id: int):
+    """
+    returns all entries in bodydevices_licenses with given license_id
+    """
+    return db.query(models.BodyDeviceLicense).filter(models.BodyDeviceLicense.bodydevice_id == device_id).all()
+
+
 def create_device_license(db: Session, device: int, license: int, time: datetime):
     """
     creates new entry in devices_licenses table with device id, license id and time.
@@ -91,6 +128,38 @@ def create_device_license(db: Session, device: int, license: int, time: datetime
     return db_device_license
 
 
+def delete_device_license(db: Session, device: int, license: int):
+    """
+    deletes entry in devices_licenses table with device id, license id and time.
+    """
+    db_device_license = get_devicelicense_by_devicelicense(db, device, license)
+    db_lic = db.delete(db_device_license)
+    db.commit()
+    return db_lic
+
+
+def delete_bodydevice_license(db: Session, device: int, license: int):
+    """
+    deletes entry in devices_licenses table with device id, license id and time.
+    """
+    db_device_license = get_bodydevicelicense_by_bodydevicelicense(db, device, license)
+    db_lic = db.delete(db_device_license)
+    db.commit()
+    return db_lic
+
+
+def create_body_device_license(db: Session, device: int, license: int, time: datetime):
+    """
+    creates new entry in devices_licenses table with device id, license id and time.
+    """
+    db_device_license = models.BodyDeviceLicense(bodydevice_id=device, license_id=license,
+                                                 assigned_datetime=time)
+    db.add(db_device_license)
+    db.commit()
+    db.refresh(db_device_license)
+    return db_device_license
+
+
 def find_pc_by_username(db: Session, name: str):
     """
     Finds one pc by given username
@@ -107,7 +176,7 @@ def get_pc(db: Session, pc_id: int):
 
 def update_pc(db: Session, pc_id: int, team: str):
     """
-    Function updates team of one specific pc
+    Updates team of one specific pc
     """
     old_pc = get_pc(db, pc_id)
     team = get_team(db, int(team))
@@ -274,7 +343,7 @@ def get_ld_logs(db: Session, skip: int = 0, limit: int = 100):
     """
     Returns all ld debugger logs in database
     """
-    return db.query(models.LDLog).offset(skip).limit(limit).all()
+    return db.query(models.LDLog).order_by(desc(models.LDLog.timestamp)).offset(skip).limit(limit).all()
 
 
 def create_ld_logs(db: Session, item: schemas.LDTempBase, head_id: int, body_id: int, pc_id: int, date: datetime):
@@ -309,37 +378,95 @@ def find_filtered_logs(db: Session, logs: []):
     return db.query(models.USBLog).filter(models.USBLog.id.in_(logs)).order_by(desc(models.USBLog.timestamp)).all()
 
 
+def find_filtered_ldlogs(db: Session, logs: []):
+    """
+    Returns all ld logs with ids in given id array.
+    """
+    return db.query(models.LDLog).filter(models.LDLog.id.in_(logs)).order_by(desc(models.LDLog.timestamp)).all()
+
+
+def get_filtered_ldlogs(db: Session, pc: str, tema: str, lic: str):
+    """
+    Function creates query string used for filtering by pc username, team name and license name.
+    Depending on selected filters assembles query string for database
+    """
+    execute_string = "SELECT * FROM ld_logs AS logs"
+    pcs = find_pc_by_username(db, pc)
+    if pc != "all":
+        if pcs is not None:
+            execute_string += "  WHERE logs.pc_id = " + str(pcs.id)
+    if tema != "all":
+        team = find_team(db, tema)
+        if team is not None:
+            pcst = get_pcs_by_team(db, team.id)
+            pc_ids = "("
+            for p in pcst:
+                pc_ids += str(p.id) + ", "
+            def_pc_ids = pc_ids[:-2] + ")"
+            if pc != "all" and pcs is not None:
+                if len(def_pc_ids) > 1:
+                    execute_string += " AND logs.pc_id IN " + def_pc_ids
+            else:
+                if len(def_pc_ids) > 1:
+                    execute_string += " WHERE logs.pc_id IN " + def_pc_ids
+    if lic != "all":
+        license = find_license(db, lic)
+        if license is not None:
+            device_licenses = get_license_bodydevice(db, license.id)
+            dev_ids = "("
+            for dev in device_licenses:
+                dev_ids += str(dev.bodydevice_id) + ", "
+            defin_ids = dev_ids[:-2] + ")"
+            if pc != "all" or tema != "all":
+                if len(defin_ids) > 1:
+                    execute_string += " AND logs.body_id IN " + defin_ids
+            else:
+                if len(defin_ids) > 1:
+                    execute_string += " WHERE logs.body_id IN " + defin_ids
+
+    # executing assembled query string
+    result = db.execute(execute_string)
+    return result
+
+
 def get_filtered_logs(db: Session, pc: str, tema: str, lic: str):
     """
     Function creates query string used for filtering by pc username, team name and license name.
     Depending on selected filters assembles query string for database
     """
     execute_string = "SELECT * FROM usb_logs AS logs"
+    pcs = find_pc_by_username(db, pc)
     if pc != "all":
-        pcs = find_pc_by_username(db, pc)
-        execute_string += "  WHERE logs.pc_id = " + str(pcs.id)
+        if pcs is not None:
+            execute_string += "  WHERE logs.pc_id = " + str(pcs.id)
     if tema != "all":
         team = find_team(db, tema)
-        pcs = get_pcs_by_team(db, team.id)
-        pc_ids = "("
-        for p in pcs:
-            pc_ids += str(p.id) + ", "
-        def_pc_ids = pc_ids[:-2] + ")"
-        if pc != "all":
-            execute_string += " AND logs.pc_id IN " + def_pc_ids
-        else:
-            execute_string += " WHERE logs.pc_id IN " + def_pc_ids
+        if team is not None:
+            pcst = get_pcs_by_team(db, team.id)
+            pc_ids = "("
+            for p in pcst:
+                pc_ids += str(p.id) + ", "
+            def_pc_ids = pc_ids[:-2] + ")"
+            if pc != "all" and pcs is not None:
+                if len(def_pc_ids) > 1:
+                    execute_string += " AND logs.pc_id IN " + def_pc_ids
+            else:
+                if len(def_pc_ids) > 1:
+                    execute_string += " WHERE logs.pc_id IN " + def_pc_ids
     if lic != "all":
         license = find_license(db, lic)
-        device_licenses = get_license_devices(db, license.id)
-        dev_ids = "("
-        for dev in device_licenses:
-            dev_ids += str(dev.device_id) + ", "
-        defin_ids = dev_ids[:-2] + ")"
-        if pc != "all" or tema != "all":
-            execute_string += " AND logs.device_id IN " + defin_ids
-        else:
-            execute_string += " WHERE logs.device_id IN " + defin_ids
+        if license is not None:
+            device_licenses = get_license_devices(db, license.id)
+            dev_ids = "("
+            for dev in device_licenses:
+                dev_ids += str(dev.device_id) + ", "
+            defin_ids = dev_ids[:-2] + ")"
+            if pc != "all" or tema != "all":
+                if len(defin_ids) > 1:
+                    execute_string += " AND logs.device_id IN " + defin_ids
+            else:
+                if len(defin_ids) > 1:
+                    execute_string += " WHERE logs.device_id IN " + defin_ids
 
     # executing assembled query string
     result = db.execute(execute_string)
diff --git a/server/sql_app/main.py b/server/sql_app/main.py
index 774d8eb..a77e626 100644
--- a/server/sql_app/main.py
+++ b/server/sql_app/main.py
@@ -10,6 +10,8 @@ from sql_app.api.usb_logs_web import usblogs_web
 from sql_app.api.teams import teams
 from sql_app.api.teams_web import teams_web
 from sql_app.api.auth import auth
+from sql_app.api.ld_logs_web import ldlogs_web
+from sql_app.api.bodydevices_web import body_device_web
 from fastapi import FastAPI
 
 
@@ -28,9 +30,11 @@ app.include_router(licenses_web)
 app.include_router(pcs_web)
 app.include_router(teams_web)
 app.include_router(usblogs_web)
+app.include_router(ldlogs_web)
+app.include_router(body_device_web)
 app.include_router(auth)
 
 '''
 if __name__ == "__main__":
-    uvicorn.run(app, host="192.168.0.22", port=8000)
+    uvicorn.run(app, host="192.168.176.1", port=8000)
 '''
diff --git a/server/sql_app/models.py b/server/sql_app/models.py
index 1040967..8d62fe9 100644
--- a/server/sql_app/models.py
+++ b/server/sql_app/models.py
@@ -52,7 +52,7 @@ class License(Base):
 
     # relationships for foreign keys, thus connecting table with devices table
     devices = relationship("DeviceLicense", back_populates="licenses")
-
+    body_devices = relationship("BodyDeviceLicense", back_populates="b_licenses")
 
 class DeviceLicense(Base):
     """
@@ -71,6 +71,23 @@ class DeviceLicense(Base):
     licenses = relationship("License", back_populates="devices")
 
 
+class BodyDeviceLicense(Base):
+    """
+    Class defining database table bodydevices_licenses
+    """
+    __tablename__ = "bodydevices_licenses"
+
+    id = Column(Integer, primary_key=True, index=True)
+    bodydevice_id = Column(Integer, ForeignKey("body_devices.id"))
+    license_id = Column(Integer, ForeignKey("licenses.id"))
+    assigned_datetime = Column(String, index=True, nullable=False)
+
+    # relationships for foreign keys, thus connecting table with devices and licenses
+    # tables
+    bodydevice_lic = relationship("BodyDevice", back_populates="debug_licenses")
+    b_licenses = relationship("License", back_populates="body_devices")
+
+
 class PC(Base):
     """
     Class defining database table pc
@@ -127,6 +144,7 @@ class BodyDevice(Base):
 
     # relationships for foreign keys, thus connecting table with ld_logs table
     b_logs = relationship("LDLog", back_populates="body_device")
+    debug_licenses = relationship("BodyDeviceLicense", back_populates="bodydevice_lic")
 
 
 class LDLog(Base):
diff --git a/server/templates/body-devices/body_device_license.html b/server/templates/body-devices/body_device_license.html
new file mode 100644
index 0000000..9c9dee5
--- /dev/null
+++ b/server/templates/body-devices/body_device_license.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Body Device License Connect</title>
+</head>
+<body>
+<h6><p>Vendor ID: {{device.vendor_id}}</p>
+    <p>Serial Number: {{device.serial_number}}</p>
+</h6>
+<form action="/body-devices-web/{{device.id}}" method="post">
+  <label for="lic">Licenses:</label>
+  <select id="lic" name="lic">
+      {% for license in licenses %}
+    <option value={{license.id}}>{{license.name}}</option>
+      {% endfor %}
+  </select>
+  <input type="submit" value="Connect">
+</form>
+<form action="/body-devices-web-del/{{device.id}}" method="post">
+  <label for="b_lic">Licenses:</label>
+  <select id="b_lic" name="b_lic">
+      {% for license in dev_lic %}
+    <option value={{license.id}}>{{license.name}}</option>
+      {% endfor %}
+  </select>
+  <input type="submit" value="Delete">
+</form>
+</body>
+</html>
\ No newline at end of file
diff --git a/server/templates/body-devices/body_devices.html b/server/templates/body-devices/body_devices.html
new file mode 100644
index 0000000..eb02d61
--- /dev/null
+++ b/server/templates/body-devices/body_devices.html
@@ -0,0 +1,72 @@
+<html>
+<head>
+    <title>Devices Details</title>
+</head>
+<body>
+<div style='float:left'>
+<form action="" method="get">
+  <label for="view">Choose view:</label>
+  <select id="view" name="view" onchange="this.form.action=this.value;">
+      <option value=""></option>
+      <option value="/logs-web">Logs</option>
+      <option value="/ldlogs-web">LD Logs</option>
+      <option value="/devices-web">Devices</option>
+      <option value="/body-devices-web">Body Devices</option>
+      <option value="/teams-web">Teams</option>
+      <option value="/pcs-web">PCs</option>
+  </select>
+  <input type="submit" value="OK">
+</form>
+</div>
+<div style='float:left'>
+<form action="/login" method="get">
+    <input type="submit" value="Login" />
+</form>
+</div>
+<div style='float:left'>
+<form action="/logout" method="get">
+    <input type="submit" value="Logout" />
+</form>
+</div>
+<h4>{{user}}</h4>
+<form action="/body-devices-web" method="post">
+    <label for="lic">License:</label>
+    <input id="lic" name="lic" type="text" list="licenses" value="" placeholder="all">
+    <datalist id="licenses">
+        {% for license in licenses %}
+        <option value="{{license.name}}"></option>
+        {% endfor %}
+    </datalist>
+  <input type="submit" value="Filter">
+</form>
+<table>
+    <TR>
+        <TH>ID</TH>
+        <TH>Serial Number</TH>
+        <TH>Licenses</TH>
+        <TH>Status</TH>
+    </TR>
+    {% for i in range(devs) %}
+    <TR>
+        <TD class="ID"><a href="/body-device-license/{{devices[i].id}}">{{devices[i].id}}</a></TD>
+        <TD class="Serial Number">{{devices[i].serial_number}}</TD>
+        <TD class="License">
+            {% for lic in devices[i].debug_licenses %}
+                {{lic.b_licenses.name}}<BR>
+            {% endfor %}
+        </TD>
+        <TD class="Status">{{statuses[i]}}</TD>
+    </TR>
+    {% endfor %}
+    <TR>
+        <TD class="ID"></TD>
+        <TD class="Serial Number"></TD>
+        <TD class="License">
+            <form action="/license-create" method="get">
+                <input type="submit" value="Add">
+            </form>
+        </TD>
+    </TR>
+</table>
+</body>
+</html>
\ No newline at end of file
diff --git a/server/templates/body-devices/body_devices_normal.html b/server/templates/body-devices/body_devices_normal.html
new file mode 100644
index 0000000..a2c3da2
--- /dev/null
+++ b/server/templates/body-devices/body_devices_normal.html
@@ -0,0 +1,63 @@
+<html>
+<head>
+    <title>Devices Details</title>
+</head>
+<body>
+<div style='float:left'>
+<form action="" method="get">
+  <label for="view">Choose view:</label>
+  <select id="view" name="view" onchange="this.form.action=this.value;">
+      <option value=""></option>
+      <option value="/logs-web">Logs</option>
+      <option value="/ldlogs-web">LD Logs</option>
+      <option value="/devices-web">Devices</option>
+      <option value="/body-devices-web">Body Devices</option>
+      <option value="/teams-web">Teams</option>
+      <option value="/pcs-web">PCs</option>
+  </select>
+  <input type="submit" value="OK">
+</form>
+</div>
+<div style='float:left'>
+<form action="/login" method="get">
+    <input type="submit" value="Login" />
+</form>
+</div>
+<div style='float:left'>
+<form action="/logout" method="get">
+    <input type="submit" value="Logout" />
+</form>
+</div>
+<h4>{{user}}</h4>
+<form action="/body-devices-web" method="post">
+    <label for="lic">License:</label>
+    <input id="lic" name="lic" type="text" list="licenses" value="" placeholder="all">
+    <datalist id="licenses">
+        {% for license in licenses %}
+        <option value="{{license.name}}"></option>
+        {% endfor %}
+    </datalist>
+  <input type="submit" value="Filter">
+</form>
+<table>
+    <TR>
+        <TH>ID</TH>
+        <TH>Serial Number</TH>
+        <TH>Licenses</TH>
+        <TH>Status</TH>
+    </TR>
+    {% for i in range(devs) %}
+    <TR>
+        <TD class="ID">{{devices[i].id}}</TD>
+        <TD class="Serial Number">{{devices[i].serial_number}}</TD>
+        <TD class="License">
+            {% for lic in devices[i].debug_licenses %}
+                {{lic.b_licenses.name}}<BR>
+            {% endfor %}
+        </TD>
+        <TD class="Status">{{statuses[i]}}</TD>
+    </TR>
+    {% endfor %}
+</table>
+</body>
+</html>
\ No newline at end of file
diff --git a/server/templates/devices/devicelicense.html b/server/templates/devices/devicelicense.html
index f3780b1..b8f8833 100644
--- a/server/templates/devices/devicelicense.html
+++ b/server/templates/devices/devicelicense.html
@@ -18,5 +18,14 @@
   </select>
   <input type="submit" value="Connect">
 </form>
+<form action="/devices-web-del/{{device.id}}" method="post">
+  <label for="lic_del">Licenses:</label>
+  <select id="lic_del" name="lic_del">
+      {% for license in dev_lic %}
+    <option value={{license.id}}>{{license.name}}</option>
+      {% endfor %}
+  </select>
+  <input type="submit" value="Delete">
+</form>
 </body>
 </html>
\ No newline at end of file
diff --git a/server/templates/devices/devices.html b/server/templates/devices/devices.html
index c1abf2d..93dee09 100644
--- a/server/templates/devices/devices.html
+++ b/server/templates/devices/devices.html
@@ -9,7 +9,9 @@
   <select id="view" name="view" onchange="this.form.action=this.value;">
       <option value=""></option>
       <option value="/logs-web">Logs</option>
+      <option value="/ldlogs-web">LD Logs</option>
       <option value="/devices-web">Devices</option>
+      <option value="/body-devices-web">Body Devices</option>
       <option value="/teams-web">Teams</option>
       <option value="/pcs-web">PCs</option>
   </select>
@@ -21,9 +23,12 @@
     <input type="submit" value="Login" />
 </form>
 </div>
+<div style='float:left'>
 <form action="/logout" method="get">
     <input type="submit" value="Logout" />
 </form>
+</div>
+<h4>{{user}}</h4>
 <form action="/devices-web" method="post">
     <label for="lic">License:</label>
     <input id="lic" name="lic" type="text" list="licenses" value="" placeholder="all">
diff --git a/server/templates/devices/devices_normal.html b/server/templates/devices/devices_normal.html
index 18b21a4..a87c3b2 100644
--- a/server/templates/devices/devices_normal.html
+++ b/server/templates/devices/devices_normal.html
@@ -9,7 +9,9 @@
   <select id="view" name="view" onchange="this.form.action=this.value;">
       <option value=""></option>
       <option value="/logs-web">Logs</option>
+      <option value="/ldlogs-web">LD Logs</option>
       <option value="/devices-web">Devices</option>
+      <option value="/body-devices-web">Body Devices</option>
       <option value="/teams-web">Teams</option>
       <option value="/pcs-web">PCs</option>
   </select>
@@ -21,9 +23,12 @@
     <input type="submit" value="Login" />
 </form>
 </div>
+<div style='float:left'>
 <form action="/logout" method="get">
     <input type="submit" value="Logout" />
 </form>
+</div>
+<h4>{{user}}</h4>
 <form action="/devices-web" method="post">
     <label for="lic">License:</label>
     <input id="lic" name="lic" type="text" list="licenses" value="" placeholder="all">
diff --git a/server/templates/ld-logs/ldlogs.html b/server/templates/ld-logs/ldlogs.html
new file mode 100644
index 0000000..e6f6c27
--- /dev/null
+++ b/server/templates/ld-logs/ldlogs.html
@@ -0,0 +1,85 @@
+<html>
+<head>
+    <title> LD Logs Details</title>
+</head>
+<body>
+<div style='float:left'>
+<form action="" method="get">
+  <label for="view">Choose view:</label>
+  <select id="view" name="view" onchange="this.form.action=this.value;">
+      <option value=""></option>
+      <option value="/logs-web">Logs</option>
+      <option value="/ldlogs-web">LD Logs</option>
+      <option value="/devices-web">Devices</option>
+      <option value="/body-devices-web">Body Devices</option>
+      <option value="/teams-web">Teams</option>
+      <option value="/pcs-web">PCs</option>
+  </select>
+  <input type="submit" value="OK">
+</form>
+</div>
+<div style='float:left'>
+<form action="/login" method="get">
+    <input type="submit" value="Login" />
+</form>
+</div>
+<div style='float:left'>
+<form action="/logout" method="get">
+    <input type="submit" value="Logout" />
+</form>
+</div>
+<h4>{{user}}</h4>
+<form action="/ldlogs-web" method="post">
+  <label for="pc">PC:</label>
+  <input id="pc" name="pc" type="text" list="pcs" value="" placeholder="all">
+    <datalist id="pcs">
+        {% for pc in pcs %}
+        <option value="{{pc.username}}"></option>
+        {% endfor %}
+    </datalist>
+    <label for="team">Team:</label>
+  <input id="team" name="team" type="text" list="teams" value="" placeholder="all">
+    <datalist id="teams">
+        {% for team in teams %}
+        <option value="{{team.name}}"></option>
+        {% endfor %}
+    </datalist>
+    <label for="lic">License:</label>
+    <input id="lic" name="lic" type="text" list="licenses" value="" placeholder="all">
+    <datalist id="licenses">
+        {% for license in licenses %}
+        <option value="{{license.name}}"></option>
+        {% endfor %}
+    </datalist>
+  <input type="submit" value="Filter">
+</form>
+    <table>
+    <TR>
+        <TH>ID</TH>
+        <TH>PC Username</TH>
+        <TH>PC Hostname</TH>
+        <TH>Team</TH>
+        <TH>Timestamp</TH>
+        <TH>Status</TH>
+        <TH>Head Device Serial Number</TH>
+        <TH>Body Device Serial Number</TH>
+    </TR>
+    {% for log in logs %}
+    <TR>
+        <TD class="ID">{{log.id}}</TD>
+        <TD class="Username">{{log.ldpc.username}}</TD>
+        <TD class="Hostname">{{log.ldpc.hostname}}</TD>
+        {% if log.ldpc.team == None %}
+            <TD class="Team">NONE</TD>
+        {% else %}
+            <TD class="Team">{{log.ldpc.team.name}}</TD>
+        {% endif %}
+        <TD class="Timestamp">{{log.timestamp}}</TD>
+        <TD class="Status">{{log.status}}</TD>
+        <TD class="HeadDeviceSerialNumber">{{log.head_device.serial_number}}</TD>
+        <TD class="BodyDeviceSerialNumber">{{log.body_device.serial_number}}</TD>
+    </TR>
+    {% endfor %}
+</table>
+</body>
+</html>
\ No newline at end of file
diff --git a/server/templates/licenses/licenses.html b/server/templates/licenses/licenses.html
index 8e5ab8e..d9faf97 100644
--- a/server/templates/licenses/licenses.html
+++ b/server/templates/licenses/licenses.html
@@ -9,7 +9,9 @@
   <select id="view" name="view" onchange="this.form.action=this.value;">
       <option value=""></option>
       <option value="/logs-web">Logs</option>
+      <option value="/ldlogs-web">LD Logs</option>
       <option value="/devices-web">Devices</option>
+      <option value="/body-devices-web">Body Devices</option>
       <option value="/teams-web">Teams</option>
       <option value="/pcs-web">PCs</option>
   </select>
diff --git a/server/templates/pcs/pcs.html b/server/templates/pcs/pcs.html
index 6532f24..fa268a5 100644
--- a/server/templates/pcs/pcs.html
+++ b/server/templates/pcs/pcs.html
@@ -9,7 +9,9 @@
   <select id="view" name="view" onchange="this.form.action=this.value;">
       <option value=""></option>
       <option value="/logs-web">Logs</option>
+      <option value="/ldlogs-web">LD Logs</option>
       <option value="/devices-web">Devices</option>
+      <option value="/body-devices-web">Body Devices</option>
       <option value="/teams-web">Teams</option>
       <option value="/pcs-web">PCs</option>
   </select>
@@ -21,9 +23,12 @@
     <input type="submit" value="Login" />
 </form>
 </div>
+<div style='float:left'>
 <form action="/logout" method="get">
     <input type="submit" value="Logout" />
 </form>
+</div>
+<h4>{{user}}</h4>
 <table>
     <TR>
         <TH>ID</TH>
diff --git a/server/templates/pcs/pcs_normal.html b/server/templates/pcs/pcs_normal.html
index bee77d2..a17833a 100644
--- a/server/templates/pcs/pcs_normal.html
+++ b/server/templates/pcs/pcs_normal.html
@@ -9,7 +9,9 @@
   <select id="view" name="view" onchange="this.form.action=this.value;">
       <option value=""></option>
       <option value="/logs-web">Logs</option>
+      <option value="/ldlogs-web">LD Logs</option>
       <option value="/devices-web">Devices</option>
+      <option value="/body-devices-web">Body Devices</option>
       <option value="/teams-web">Teams</option>
       <option value="/pcs-web">PCs</option>
   </select>
@@ -21,9 +23,12 @@
     <input type="submit" value="Login" />
 </form>
 </div>
+<div style='float:left'>
 <form action="/logout" method="get">
     <input type="submit" value="Logout" />
 </form>
+</div>
+<h4>{{user}}</h4>
 <table>
     <TR>
         <TH>ID</TH>
diff --git a/server/templates/teams/team_create.html b/server/templates/teams/team_create.html
index 16dcc0a..28fb63d 100644
--- a/server/templates/teams/team_create.html
+++ b/server/templates/teams/team_create.html
@@ -5,7 +5,7 @@
     <title>Create a Team</title>
 </head>
 <body>
-<form action="/teams-web" method="post">
+<form action="/teams-web-con" method="post">
   <label for="name">Name:</label><br>
   <input type="text" id="name" name="name"><br><br>
   <input type="submit" value="Submit">
diff --git a/server/templates/teams/teams.html b/server/templates/teams/teams.html
index 77e5052..f9889f0 100644
--- a/server/templates/teams/teams.html
+++ b/server/templates/teams/teams.html
@@ -9,7 +9,9 @@
   <select id="view" name="view" onchange="this.form.action=this.value;">
       <option value=""></option>
       <option value="/logs-web">Logs</option>
+      <option value="/ldlogs-web">LD Logs</option>
       <option value="/devices-web">Devices</option>
+      <option value="/body-devices-web">Body Devices</option>
       <option value="/teams-web">Teams</option>
       <option value="/pcs-web">PCs</option>
   </select>
@@ -21,9 +23,12 @@
     <input type="submit" value="Login" />
 </form>
 </div>
+<div style='float:left'>
 <form action="/logout" method="get">
     <input type="submit" value="Logout" />
 </form>
+</div>
+<h4>{{user}}</h4>
 <table>
     <TR>
         <TH>ID</TH>
diff --git a/server/templates/teams/teams_normal.html b/server/templates/teams/teams_normal.html
index f1a5fc1..1e3c70c 100644
--- a/server/templates/teams/teams_normal.html
+++ b/server/templates/teams/teams_normal.html
@@ -9,7 +9,9 @@
   <select id="view" name="view" onchange="this.form.action=this.value;">
       <option value=""></option>
       <option value="/logs-web">Logs</option>
+      <option value="/ldlogs-web">LD Logs</option>
       <option value="/devices-web">Devices</option>
+      <option value="/body-devices-web">Body Devices</option>
       <option value="/teams-web">Teams</option>
       <option value="/pcs-web">PCs</option>
   </select>
@@ -21,9 +23,12 @@
     <input type="submit" value="Login" />
 </form>
 </div>
+<div style='float:left'>
 <form action="/logout" method="get">
     <input type="submit" value="Logout" />
 </form>
+</div>
+<h4>{{user}}</h4>
 <table>
     <TR>
         <TH>ID</TH>
diff --git a/server/templates/usb-logs/logs.html b/server/templates/usb-logs/logs.html
index 7e7e4be..dc83324 100644
--- a/server/templates/usb-logs/logs.html
+++ b/server/templates/usb-logs/logs.html
@@ -9,7 +9,9 @@
   <select id="view" name="view" onchange="this.form.action=this.value;">
       <option value=""></option>
       <option value="/logs-web">Logs</option>
+      <option value="/ldlogs-web">LD Logs</option>
       <option value="/devices-web">Devices</option>
+      <option value="/body-devices-web">Body Devices</option>
       <option value="/teams-web">Teams</option>
       <option value="/pcs-web">PCs</option>
   </select>
@@ -21,9 +23,12 @@
     <input type="submit" value="Login" />
 </form>
 </div>
+<div style='float:left'>
 <form action="/logout" method="get">
     <input type="submit" value="Logout" />
 </form>
+</div>
+<h4>{{user}}</h4>
 <form action="/logs-web" method="post">
   <label for="pc">PC:</label>
   <input id="pc" name="pc" type="text" list="pcs" value="" placeholder="all">
