Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 35168e5f

Přidáno uživatelem Matěj Zeman před téměř 3 roky(ů)

Fixed minor issues. View on keyman devices changed. Changed database for new keyman x license connection.

Zobrazit rozdíly:

server/sql_app/api/devices_web.py
8 8
from pydantic import BaseModel
9 9
from sqlalchemy.orm import Session
10 10
from sql_app.api.auth import fake_users_db
11
from sql_app import crud, models
11
from sql_app import crud, models, schemas
12 12
from ..database import SessionLocal, engine
13 13

  
14 14
models.Base.metadata.create_all(bind=engine)
......
38 38
    Authorize.jwt_optional()
39 39
    current_user = Authorize.get_jwt_subject()
40 40

  
41
    device_dict = []
41 42
    devices = crud.get_devices(db, skip=skip, limit=limit)
42
    statuses = []
43
    # adding state for each device in list
44
    for i in range(0, len(devices)):
45
        statuses.append(devices[i].logs[len(devices[i].logs) - 1].status)
43
    teams = crud.get_teams(db, skip=skip, limit=limit)
44
    # adding dictionary entry with all inforamtions needed in template
45
    for dev in devices:
46
        if len(dev.licenses) > 0:
47
            for lic in dev.licenses:
48
                device_dict.append({"device": dev, "license": lic.licenses, "log": dev.logs[len(dev.logs) - 1]})
49
        else:
50
            device_dict.append({"device": dev, "license": dev.licenses, "log": dev.logs[len(dev.logs) - 1]})
46 51
    licenses = crud.get_licenses(db, skip=skip, limit=limit)
47 52
    if current_user == "admin":
48
        return templates.TemplateResponse("devices.html", {"request": request, "devs": len(devices), "devices": devices,
49
                                                           "statuses": statuses, "licenses": licenses, "user": current_user})
53
        return templates.TemplateResponse("devices.html", {"request": request, "devices": device_dict,
54
                                                           "licenses": licenses, "devs": devices,
55
                                                           "teams": teams, "user": current_user})
50 56
    else:
51 57
        current_user = "guest"
52
        return templates.TemplateResponse("devices_normal.html", {"request": request, "devs": len(devices), "devices": devices,
53
                                                                  "statuses": statuses, "licenses": licenses, "user": current_user})
58
        return templates.TemplateResponse("devices_normal.html", {"request": request, "devices": device_dict,
59
                                                                  "licenses": licenses, "user": current_user})
54 60

  
55 61

  
56 62
@device_web.post("/devices-web", response_class=HTMLResponse)
57
async def filter_devices(request: Request, skip: int = 0, limit: int = 100, lic: str = Form("all"),
63
async def filter_devices(request: Request, skip: int = 0, limit: int = 100,
64
                         keyman_id: str = Form("all"), lic_name: str = Form("all"),
65
                         lic_id: str = Form("all"), team: str = Form("all"),
58 66
                         db: Session = Depends(get_db), Authorize: AuthJWT = Depends()):
59 67
    """
60 68
    Endpoint used for filtering devices by license. returns html template with only
......
62 70
    """
63 71
    Authorize.jwt_optional()
64 72
    current_user = Authorize.get_jwt_subject()
65
    devices = crud.get_devices(db, skip=skip, limit=limit)
66
    def_devices = []
73
    device_dict = []
74
    devices_f = crud.get_filtered_devices(db, keyman_id, lic_name, lic_id, team)
75
    ids = []
76
    for d in devices_f:
77
        ids.append(d[0])
78
    devices = crud.get_devices_with_ids(db, ids)
79
    teams = crud.get_teams(db, skip=skip, limit=limit)
80
    # adding dictionary entry with all inforamtions needed in template
67 81
    for dev in devices:
68
        for l in dev.licenses:
69
            if dev not in def_devices and l.licenses.name == lic:
70
                def_devices.append(dev)
71
    # if input was default all
72
    if lic == "all":
73
        def_devices = devices
74
    statuses = []
75
    for i in range(0, len(def_devices)):
76
        statuses.append(def_devices[i].logs[len(def_devices[i].logs) - 1].status)
82
        if len(dev.licenses) > 0:
83
            for lic in dev.licenses:
84
                device_dict.append({"device": dev, "license": lic.licenses, "log": dev.logs[len(dev.logs) - 1]})
85
        else:
86
            device_dict.append({"device": dev, "license": dev.licenses, "log": dev.logs[len(dev.logs) - 1]})
77 87
    licenses = crud.get_licenses(db, skip=skip, limit=limit)
78 88
    if current_user == "admin":
79
        return templates.TemplateResponse("devices.html",
80
                                          {"request": request, "devs": len(def_devices), "devices": def_devices,
81
                                           "statuses": statuses, "licenses": licenses, "user": current_user})
89
        return templates.TemplateResponse("devices.html", {"request": request, "devices": device_dict,
90
                                                           "licenses": licenses, "devs": devices,
91
                                                           "teams": teams, "user": current_user})
82 92
    else:
83 93
        current_user = "guest"
84
        return templates.TemplateResponse("devices_normal.html",
85
                                          {"request": request, "devs": len(def_devices), "devices": def_devices,
86
                                           "statuses": statuses, "licenses": licenses, "user": current_user})
94
        return templates.TemplateResponse("devices_normal.html", {"request": request, "devices": device_dict,
95
                                                                  "licenses": licenses, "user": current_user})
87 96

  
88 97

  
89 98
@device_web.get("/device-license/{device_id}", response_class=HTMLResponse)
......
98 107
        return RedirectResponse(url=f"/logs-web", status_code=303)
99 108
    device = crud.get_device(db, device_id)
100 109
    dev_licenses = crud.get_device_licenses(db, device_id)
101
    lic_names = []
110
    lic_ids = []
102 111
    dev_lics = []
103 112
    for dev_lic in dev_licenses:
104 113
        dev_lics.append(dev_lic.licenses)
105 114
    for dev_lic in dev_licenses:
106
        lic_names.append(dev_lic.licenses.name)
115
        lic_ids.append(dev_lic.licenses.license_id)
107 116
    licenses = crud.get_licenses(db, 0, 100)
108 117
    lic_left = []
109 118
    for lic in licenses:
110
        if lic.name not in lic_names and lic not in lic_left:
119
        if lic.license_id not in lic_ids and lic not in lic_left:
111 120
            lic_left.append(lic)
121
    teams = crud.get_teams(db, 0, 100)
112 122
    return templates.TemplateResponse("devicelicense.html",
113
                                      {"request": request, "device": device, "licenses": lic_left, "dev_lic": dev_lics})
123
                                      {"request": request, "device": device, "licenses": lic_left, "dev_lic": dev_lics,
124
                                       "teams": teams})
114 125

  
115 126

  
116 127
@device_web.post("/devices-web/{device_id}")
......
141 152
        return RedirectResponse(url=f"/logs-web", status_code=303)
142 153
    crud.delete_device_license(db, device_id, int(lic_del))
143 154
    return RedirectResponse(url=f"/devices-web", status_code=303)
155

  
156
@device_web.post("/devices-web-team/{device_id}")
157
async def dev_team_con(device_id: int, team_con: str = Form(...), db: Session = Depends(get_db),
158
                      Authorize: AuthJWT = Depends()):
159
    """
160
    Endpoint called from template for deleting device-license connection. Adds entry to bodydevices_licenses
161
    table and redirects to devices-web endpoint
162
    """
163
    Authorize.jwt_optional()
164
    current_user = Authorize.get_jwt_subject()
165
    if current_user != "admin":
166
        return RedirectResponse(url=f"/logs-web", status_code=303)
167
    crud.update_device(db, device_id, team_con)
168
    return RedirectResponse(url=f"/devices-web", status_code=303)
169

  
170
@device_web.post("/devices-web-inv/{device_id}")
171
async def dev_inv_new(device_id: int, dev_inv: str = Form(...), db: Session = Depends(get_db),
172
                      Authorize: AuthJWT = Depends()):
173
    """
174
    Endpoint called from template for deleting device-license connection. Adds entry to bodydevices_licenses
175
    table and redirects to devices-web endpoint
176
    """
177
    Authorize.jwt_optional()
178
    current_user = Authorize.get_jwt_subject()
179
    if current_user != "admin":
180
        return RedirectResponse(url=f"/logs-web", status_code=303)
181
    crud.update_device_inv(db, device_id, dev_inv)
182
    return RedirectResponse(url=f"/devices-web", status_code=303)
183

  
184
@device_web.post("/devices-web-comment/{device_id}")
185
async def dev_comm_new(device_id: int, dev_com: str = Form(...), db: Session = Depends(get_db),
186
                      Authorize: AuthJWT = Depends()):
187
    """
188
    Endpoint called from template for deleting device-license connection. Adds entry to bodydevices_licenses
189
    table and redirects to devices-web endpoint
190
    """
191
    Authorize.jwt_optional()
192
    current_user = Authorize.get_jwt_subject()
193
    if current_user != "admin":
194
        return RedirectResponse(url=f"/logs-web", status_code=303)
195
    crud.update_device_com(db, device_id, dev_com)
196
    return RedirectResponse(url=f"/devices-web", status_code=303)
server/sql_app/api/licenses_web.py
1 1
from typing import List
2

  
2
from typing import Optional
3 3
from fastapi import Depends, FastAPI, HTTPException, APIRouter, Form
4 4
from sqlalchemy.orm import Session
5 5
from datetime import date
......
60 60
                                                            "user": current_user})
61 61

  
62 62
@licenses_web.post("/licenses-web")
63
def create_license(name: str = Form(...), expdate: date = Form(...), db: Session = Depends(get_db),
64
                   Authorize: AuthJWT = Depends()):
63
def create_license(name: str = Form(...), lic_id: str = Form(...), expdate: Optional[date] = Form(None),
64
                   db: Session = Depends(get_db), Authorize: AuthJWT = Depends()):
65 65
    """
66 66
    Endpoint called from create license form. Creates new license and redirects to devices-web endpoint
67 67
    """
......
70 70
    if current_user != "admin":
71 71
        return RedirectResponse(url=f"/logs-web", status_code=303)
72 72
    licenses = crud.get_licenses(db, 0, 100)
73
    licenses_names = []
73
    licenses_ids = []
74 74
    for l in licenses:
75
        licenses_names.append(l.name)
76
    if name not in licenses_names:
77
        db_license = crud.create_license(db, name, expdate)
75
        licenses_ids.append(l.license_id)
76
    if lic_id not in licenses_ids:
77
        db_license = crud.create_license(db, name, lic_id, expdate)
78 78
        if db_license is None:
79 79
            print("something went wrong")
80
    return RedirectResponse(url=f"/devices-web", status_code=303)
80
    return RedirectResponse(url=f"/licenses-web", status_code=303)
server/sql_app/api/pcs_web.py
42 42
        current_user = "guest"
43 43
        return templates.TemplateResponse("pcs_normal.html", {"request": request, "pcs": pcs, "user": current_user})
44 44

  
45

  
46
@pcs_web.get("/pc-team/{pc_id}", response_class=HTMLResponse)
47
async def connect_pc_team(request: Request, pc_id: int, db: Session = Depends(get_db),
48
                          Authorize: AuthJWT = Depends()):
49
    """
50
    Returns template with Form for connecting pc with team
51
    """
52
    Authorize.jwt_optional()
53
    current_user = Authorize.get_jwt_subject()
54
    if current_user != "admin":
55
        return RedirectResponse(url=f"/logs-web", status_code=303)
56
    pc = crud.get_pc(db, pc_id)
57
    teams = crud.get_teams(db, 0, 100)
58
    return templates.TemplateResponse("pcteam.html",
59
                                      {"request": request, "pc": pc, "teams": teams})
60

  
61

  
62
@pcs_web.post("/pcs-web/{pc_id}")
63
async def connect_post(pc_id: int, team: str = Form(...), db: Session = Depends(get_db),
64
                       Authorize: AuthJWT = Depends()):
65
    """
66
    Endpoint called from within form for connecting pc with team. Updates certain pc with new team.
67
    """
68
    Authorize.jwt_optional()
69
    current_user = Authorize.get_jwt_subject()
70
    if current_user != "admin":
71
        return RedirectResponse(url=f"/logs-web", status_code=303)
72
    old_pc = crud.update_pc(db, pc_id, team)
73
    return RedirectResponse(url=f"/pcs-web", status_code=303)
server/sql_app/api/teams_web.py
59 59
@teams_web.post("/teams-web-con")
60 60
def create_team(name: str = Form(...), db: Session = Depends(get_db), Authorize: AuthJWT = Depends()):
61 61
    """
62
    Endpoint called from within form for creating new team. Creates new team and returns all teams in database
62
    Endpoint called from within form for creating new team. Creates new team and redirects to view with all teams
63 63
    """
64 64
    Authorize.jwt_optional()
65 65
    current_user = Authorize.get_jwt_subject()
......
74 74
        if team is None:
75 75
            print("something went wrong")
76 76
    return RedirectResponse(url=f"/teams-web", status_code=303)
77

  
78

  
79
@teams_web.get("/team-change/{team_id}", response_class=HTMLResponse)
80
async def team_change_web(request: Request, team_id: int, db: Session = Depends(get_db),
81
                          Authorize: AuthJWT = Depends()):
82
    """
83
    Returns template with form for changing teams name
84
    """
85
    Authorize.jwt_optional()
86
    current_user = Authorize.get_jwt_subject()
87
    if current_user != "admin":
88
        return RedirectResponse(url=f"/logs-web", status_code=303)
89
    team = crud.get_team(db, team_id)
90
    return templates.TemplateResponse("team_change.html", {"request": request, "team": team})
91

  
92
@teams_web.post("/teams-change-process/{team_id}")
93
async def team_change_process(team_id: int, db:Session = Depends(get_db), name: str = Form(...),
94
                              Authorize: AuthJWT = Depends()):
95
    """
96
    Changes teams name to a new one given by user
97
    """
98
    Authorize.jwt_optional()
99
    current_user = Authorize.get_jwt_subject()
100
    if current_user != "admin":
101
        return RedirectResponse(url=f"/logs-web", status_code=303)
102
    team = crud.change_team(db, team_id, name)
103
    return RedirectResponse(url=f"/teams-web", status_code=303)
server/sql_app/crud.py
19 19
    return db.query(models.Device).offset(skip).limit(limit).all()
20 20

  
21 21

  
22
def find_device(db: Session, device: schemas.DeviceBase):
22
def find_device(db: Session, device: schemas.DeviceTemp):
23 23
    """
24
    finds one device with product_id, vendor_id and serial_number same as in given DeviceBase object
24
    finds one device with  serial_number same as in given DeviceBase object
25 25
    """
26
    return db.query(models.Device).filter(and_(models.Device.product_id == device.product_id,
27
                                               models.Device.vendor_id == device.vendor_id,
28
                                               models.Device.serial_number == device.serial_number)).first()
26
    return db.query(models.Device).filter(and_(models.Device.serial_number == device.serial_number)).first()
29 27

  
30 28

  
31
def create_device(db: Session, device: schemas.DeviceBase):
29
def find_device_by_serial(db: Session, ser: str):
30
    """
31
    finds one device with serial_number same as in given DeviceBase object
32
    """
33
    return db.query(models.Device).filter(and_(models.Device.serial_number == ser)).first()
34

  
35
def get_devices_with_ids(db: Session, ids: []):
36
    """
37
    returns all devices with given ids
38
    """
39
    return db.query(models.Device).filter(models.Device.id.in_(ids)).all()
40

  
41
def get_devices_by_team(db: Session, team: int):
42
    """
43
    returns all devices with same team
44
    """
45
    return db.query(models.Device).filter(models.Device.team_id == team).all()
46

  
47
def create_device(db: Session, device: schemas.DeviceTemp):
32 48
    """
33 49
    creates new device with data from given DeviceBase object
34 50
    """
35 51
    db_device = models.Device(vendor_id=device.vendor_id, product_id=device.product_id,
36
                              serial_number=device.serial_number, assigned=False)
52
                              serial_number=device.serial_number, inventory_number="", comment="")
37 53
    db.add(db_device)
38 54
    db.commit()
39 55
    db.refresh(db_device)
......
58 74
    """
59 75
    finds one license by given string name
60 76
    """
61
    return db.query(models.License).filter(models.License.name == name).first()
77
    return db.query(models.License).filter(models.License.license_id == name).first()
78

  
62 79

  
80
def get_licenses_by_name(db: Session, name: str):
81
    return db.query(models.License).filter(models.License.name == name).all()
63 82

  
64
def create_license(db: Session, name: str, expdate: date):
83

  
84
def create_license(db: Session, name: str, lic_id: str, expdate: date):
65 85
    """
66 86
    creates new license with given name and expiration date
67 87
    """
68
    db_license = models.License(name=name, expiration_date=expdate)
88
    db_license = models.License(name=name, license_id=lic_id, expiration_date=expdate)
69 89
    db.add(db_license)
70 90
    db.commit()
71 91
    db.refresh(db_license)
......
79 99
    return db.query(models.DeviceLicense).filter(models.DeviceLicense.license_id == license_id).all()
80 100

  
81 101

  
102
def find_devicelicenses_by_licid_array(db: Session, lcs: []):
103
    """
104
    Finds all device_licenses with license_id in given id array
105
    """
106
    return db.query(models.DeviceLicense).filter(models.DeviceLicense.license_id.in_(lcs)).all()
107

  
108

  
82 109
def get_device_licenses(db: Session, device_id: int):
83 110
    """
84
    returns all entries in devices_licenses table with given license_id
111
    returns all entries in devices_licenses table with given device_id
85 112
    """
86 113
    return db.query(models.DeviceLicense).filter(models.DeviceLicense.device_id == device_id).all()
87 114

  
......
174 201
    return db.query(models.PC).filter(models.PC.id == pc_id).first()
175 202

  
176 203

  
177
def update_pc(db: Session, pc_id: int, team: str):
204
def update_device(db: Session, device_id: int, team: str):
178 205
    """
179 206
    Updates team of one specific pc
180 207
    """
181
    old_pc = get_pc(db, pc_id)
208
    old_dev = get_device(db, device_id)
182 209
    team = get_team(db, int(team))
183
    new = {'id': old_pc.id, 'username': old_pc.username, 'hostname': old_pc.hostname, 'assigned': True,
184
           'team_id': team.id}
210
    new = {'id': old_dev.id, 'vendor_id': old_dev.vendor_id, 'product_id': old_dev.product_id,
211
           'serial_number': old_dev.serial_number, 'inventory_number': old_dev.inventory_number,
212
           'comment': old_dev.comment, 'team_id': team.id}
213
    for key, value in new.items():
214
        setattr(old_dev, key, value)
215
    db.commit()
216
    db.refresh(old_dev)
217
    return old_dev
218

  
219

  
220
def update_device_inv(db: Session, device_id: int, inv: str):
221
    """
222
    Updates inventory number of one specific pc
223
    """
224
    old_dev = get_device(db, device_id)
225
    if old_dev.team_id != None:
226
        team = get_team(db, int(old_dev.team_id))
227
        teamid = team.id
228
    else:
229
        teamid = None
230
    new = {'id': old_dev.id, 'vendor_id': old_dev.vendor_id, 'product_id': old_dev.product_id,
231
           'serial_number': old_dev.serial_number, 'inventory_number': inv,
232
           'comment': old_dev.comment, 'team_id': teamid}
233
    for key, value in new.items():
234
        setattr(old_dev, key, value)
235
    db.commit()
236
    db.refresh(old_dev)
237
    return old_dev
238

  
239

  
240
def update_device_com(db: Session, device_id: int, comm: str):
241
    """
242
    Updates team of one specific pc
243
    """
244
    old_dev = get_device(db, device_id)
245
    if old_dev.team_id != None:
246
        team = get_team(db, int(old_dev.team_id))
247
        teamid = team.id
248
    else:
249
        teamid = None
250
    new = {'id': old_dev.id, 'vendor_id': old_dev.vendor_id, 'product_id': old_dev.product_id,
251
           'serial_number': old_dev.serial_number, 'inventory_number': old_dev.inventory_number,
252
           'comment': comm, 'team_id': teamid}
185 253
    for key, value in new.items():
186
        setattr(old_pc, key, value)
254
        setattr(old_dev, key, value)
187 255
    db.commit()
188
    db.refresh(old_pc)
189
    return old_pc
256
    db.refresh(old_dev)
257
    return old_dev
258

  
190 259

  
191 260
def change_role(db: Session, usr_id: int, role: str):
192 261
    """
......
237 306
    return db.query(models.PC).filter(models.PC.id.in_(pcs)).all()
238 307

  
239 308

  
240
def get_pcs_by_team(db: Session, team_id: int):
241
    """
242
    returns all pcs in given team by team id
243
    """
244
    return db.query(models.PC).filter(models.PC.team_id == team_id).all()
245

  
246

  
247 309
def create_pc(db: Session, user: str, host: str):
248 310
    """
249 311
    creates new pc with given username and hostname
250 312
    """
251
    db_pc = models.PC(username=user, hostname=host, assigned=False)
313
    db_pc = models.PC(username=user, hostname=host)
252 314
    db.add(db_pc)
253 315
    db.commit()
254 316
    db.refresh(db_pc)
......
287 349
    return db_team
288 350

  
289 351

  
352
def change_team(db: Session, team_id: int, name: str):
353
    """
354
    Updates name of one specific team
355
    """
356
    old_team = get_team(db, team_id)
357
    new = {'id': old_team.id, 'name': name}
358
    for key, value in new.items():
359
        setattr(old_team, key, value)
360
    db.commit()
361
    db.refresh(old_team)
362
    return old_team
363

  
364

  
290 365
def get_head_device(db: Session, head_id: int):
291 366
    """
292 367
    Returns one specific head device by given id
......
410 485
    if tema != "all":
411 486
        team = find_team(db, tema)
412 487
        if team is not None:
413
            pcst = get_pcs_by_team(db, team.id)
414
            pc_ids = "("
415
            for p in pcst:
416
                pc_ids += str(p.id) + ", "
417
            def_pc_ids = pc_ids[:-2] + ")"
488
            devs = get_devices_by_team(db, team.id)
489
            d_ids = "("
490
            for p in devs:
491
                d_ids += str(p.id) + ", "
492
            def_d_ids = d_ids[:-2] + ")"
418 493
            if pc != "all" and pcs is not None:
419
                if len(def_pc_ids) > 1:
420
                    execute_string += " AND logs.pc_id IN " + def_pc_ids
494
                if len(def_d_ids) > 1:
495
                    execute_string += " AND logs.device_id IN " + def_d_ids
421 496
            else:
422
                if len(def_pc_ids) > 1:
423
                    execute_string += " WHERE logs.pc_id IN " + def_pc_ids
497
                if len(def_d_ids) > 1:
498
                    execute_string += " WHERE logs.device_id IN " + def_d_ids
424 499
    if lic != "all":
425
        license = find_license(db, lic)
500
        license = get_licenses_by_name(db, lic)
426 501
        if license is not None:
427 502
            device_licenses = get_license_bodydevice(db, license.id)
428 503
            dev_ids = "("
......
454 529
    if tema != "all":
455 530
        team = find_team(db, tema)
456 531
        if team is not None:
457
            pcst = get_pcs_by_team(db, team.id)
458
            pc_ids = "("
459
            for p in pcst:
460
                pc_ids += str(p.id) + ", "
461
            def_pc_ids = pc_ids[:-2] + ")"
532
            devs = get_devices_by_team(db, team.id)
533
            d_ids = "("
534
            for p in devs:
535
                d_ids += str(p.id) + ", "
536
            def_d_ids = d_ids[:-2] + ")"
462 537
            if pc != "all" and pcs is not None:
463
                if len(def_pc_ids) > 1:
464
                    execute_string += " AND logs.pc_id IN " + def_pc_ids
538
                if len(def_d_ids) > 1:
539
                    execute_string += " AND logs.device_id IN " + def_d_ids
465 540
            else:
466
                if len(def_pc_ids) > 1:
467
                    execute_string += " WHERE logs.pc_id IN " + def_pc_ids
541
                if len(def_d_ids) > 1:
542
                    execute_string += " WHERE logs.device_id IN " + def_d_ids
468 543
    if lic != "all":
469
        license = find_license(db, lic)
544
        license = get_licenses_by_name(db, lic)
470 545
        if license is not None:
471 546
            device_licenses = get_license_devices(db, license.id)
472 547
            dev_ids = "("
......
485 560
    return result
486 561

  
487 562

  
563
def get_filtered_devices(db: Session, keyman_id: str, license_name: str, license_id: str, team: str):
564
    """
565
    returns filtered devices based on given atributes
566
    """
567
    execute_string = "SELECT * FROM devices AS device WHERE"
568
    before_me = False
569
    all_all = True
570
    if keyman_id != "all":
571
        all_all = False
572
        keyman_dev = find_device_by_serial(db, keyman_id)
573
        if keyman_dev != None:
574
            if before_me:
575
                execute_string += " AND device.id = " + str(keyman_dev.id)
576
            else:
577
                before_me = True
578
                execute_string += " device.id = " + str(keyman_dev.id)
579
    if license_name != "all":
580
        all_all = False
581
        license = get_licenses_by_name(db, license_name)
582
        if len(license) > 0:
583
            lic_ids = []
584
            for l in license:
585
                lic_ids.append(l.id)
586
            dev_lics = find_devicelicenses_by_licid_array(db, lic_ids)
587
            lic_ids = "("
588
            for l in dev_lics:
589
                lic_ids += str(l.device_id) + ", "
590
            def_lic_ids = lic_ids[:-2] + ")"
591
            if before_me:
592
                execute_string += " AND device.id IN " + def_lic_ids
593
            else:
594
                before_me = True
595
                execute_string += " device.id IN " + def_lic_ids
596
    if license_id != "all":
597
        all_all = False
598
        license = find_license(db, license_id)
599
        licen_devs = get_license_devices(db, license.id)
600
        ids = "("
601
        for lic in licen_devs:
602
            ids += str(lic.device_id) + ", "
603
        def_ids = ids[:-2] + ")"
604
        if license != None:
605
            if before_me:
606
                execute_string += " AND device.id IN " + def_ids
607
            else:
608
                before_me = True
609
                execute_string += " device.id IN " + def_ids
610
    if team != "all":
611
        all_all = False
612
        tem = find_team(db, team)
613
        if tem != None:
614
            if before_me:
615
                execute_string += " AND device.team_id = " + str(tem.id)
616
            else:
617
                before_me = True
618
                execute_string += " device.team_id = " + str(tem.id)
619
    if all_all:
620
        before_me = True
621
        execute_string = "SELECT * FROM devices AS devices"
622

  
623
    if not before_me:
624
        execute_string = "SELECT * FROM devices AS devices WHERE devices.id = -1"
625
    result = db.execute(execute_string)
626
    return result
627

  
628

  
488 629
def create_device_logs(db: Session, item: schemas.USBTempBase, dev_id: int, pc_id: int, date: datetime):
489 630
    """
490 631
    Creates new USB log for usb_logs database table
server/sql_app/main.py
38 38

  
39 39
'''
40 40
if __name__ == "__main__":
41
    uvicorn.run(app, host="192.168.0.22", port=8000)
41
    uvicorn.run(app, host="192.168.64.1", port=8000)
42 42
'''
server/sql_app/models.py
14 14
    vendor_id = Column(String, index=True, nullable=False)
15 15
    product_id = Column(String, index=True, nullable=False)
16 16
    serial_number = Column(String, index=True, nullable=False)
17
    assigned = Column(Boolean, index=True, nullable=False)
17
    inventory_number = Column(String, index=True, nullable=True)
18
    comment = Column(String, index=True, nullable=True)
19

  
20
    team_id = Column(Integer, ForeignKey("teams.id"))
18 21

  
19 22
    # relationships for foreign keys, thus connecting table with usb_logs and licenses
20 23
    # tables
21 24
    logs = relationship("USBLog", back_populates="device")
22 25
    licenses = relationship("DeviceLicense", back_populates="device_lic")
23

  
26
    team = relationship("Team", back_populates="devices")
24 27

  
25 28
class USBLog(Base):
26 29
    """
......
48 51

  
49 52
    id = Column(Integer, primary_key=True, index=True)
50 53
    name = Column(String, index=True, nullable=False)
51
    expiration_date = Column(DateTime(timezone=True), server_default=func.now())
54
    license_id = Column(String, index=True, nullable=False)
55
    expiration_date = Column(DateTime(timezone=True), nullable=True)
52 56

  
53 57
    # relationships for foreign keys, thus connecting table with devices table
54 58
    devices = relationship("DeviceLicense", back_populates="licenses")
......
97 101
    id = Column(Integer, primary_key=True, index=True)
98 102
    username = Column(String, index=True, nullable=False)
99 103
    hostname = Column(String, index=True, nullable=False)
100
    assigned = Column(Boolean, index=True, nullable=False)
101
    team_id = Column(Integer, ForeignKey("teams.id"))
102 104

  
103 105
    # relationships for foreign keys, thus connecting table with teams, usb_logs and ld_logs
104 106
    # tables
105
    team = relationship("Team", back_populates="pcs")
106 107
    logs_pc = relationship("USBLog", back_populates="pc")
107 108
    ld_pc = relationship("LDLog", back_populates="ldpc")
108 109

  
......
116 117
    id = Column(Integer, primary_key=True, index=True)
117 118
    name = Column(String, index=True, nullable=False)
118 119

  
119
    # relationships for foreign keys, thus connecting table with pc table
120
    pcs = relationship("PC", back_populates="team")
121

  
120
    devices = relationship("Device", back_populates="team")
122 121

  
123 122
class HeadDevice(Base):
124 123
    """
server/sql_app/schemas.py
48 48
    vendor_id: str
49 49
    product_id: str
50 50
    serial_number: str
51
    inventory_number: str
52
    comment: str
51 53

  
52 54

  
53 55
class DeviceCreate(DeviceBase):
......
59 61
    Class used for creating and reading devices entries
60 62
    """
61 63
    id: int
62
    assigned: bool
63 64
    logs: List[USBLog] = []
64 65
    licenses: List[DeviceLicense] = []
65 66

  
......
67 68
        orm_mode = True
68 69

  
69 70

  
71
class DeviceTemp(BaseModel):
72
    vendor_id: str
73
    product_id: str
74
    serial_number: str
75

  
76

  
70 77
class LDLogBase(BaseModel):
71 78
    timestamp: datetime
72 79
    status: str
......
140 147
    Class used for creating and reading pc entries
141 148
    """
142 149
    id: int
143
    assigned: bool
144 150
    logs_pc: List[USBLog] = []
151
    logs_ld: List[LDLog] = []
145 152

  
146 153
    class Config:
147 154
        orm_mode = True
......
160 167
    Class used for creating and reading team entries
161 168
    """
162 169
    id: int
163
    pcs: List[PC] = []
170
    devices: List[Device] = []
164 171

  
165 172
    class Config:
166 173
        orm_mode = True
......
168 175

  
169 176
class LicenseBase(BaseModel):
170 177
    name: str
178
    license_id: str
171 179
    expiration_date: date
172 180

  
173 181

  
......
193 201
    username: str
194 202
    hostname: str
195 203
    timestamp: str
196
    device: DeviceBase
204
    device: DeviceTemp
197 205
    status: str
198 206

  
199 207

  
......
242 250
    password: str
243 251
    role: str
244 252

  
253

  
245 254
class UserCreate(UserBase):
246 255
    pass
247 256

  
......
251 260

  
252 261
    class Config:
253 262
        orm_mode = True
263

  
server/templates/body-devices/body_devices.html
22 22
<form action="" method="get">
23 23
  <label for="view">Choose view:</label>
24 24
  <select id="view" name="view" onchange="this.form.action=this.value;">
25
      <option value=""></option>
26
      <option value="/logs-web">Logs</option>
27
      <option value="/ldlogs-web">LD Logs</option>
25
      <option value="/logs-web">Vector Logs</option>
26
      <option value="/ldlogs-web">Lauterbach Logs</option>
28 27
      <option value="/devices-web">Devices</option>
29
      <option value="/body-devices-web">Body Devices</option>
28
      <option value="/body-devices-web" selected>Body Devices</option>
30 29
      <option value="/teams-web">Teams</option>
31 30
      <option value="/pcs-web">PCs</option>
32 31
      <option value="/licenses-web">Licenses</option>
......
47 46
<table>
48 47
    <TR>
49 48
        <TH>ID</TH>
50
        <TH>Serial Number</TH>
49
        <TH>Lauterbach Body ID</TH>
51 50
        <TH>Licenses</TH>
52 51
        <TH>Status</TH>
53 52
    </TR>
server/templates/body-devices/body_devices_normal.html
22 22
<form action="" method="get">
23 23
  <label for="view">Choose view:</label>
24 24
  <select id="view" name="view" onchange="this.form.action=this.value;">
25
      <option value=""></option>
26
      <option value="/logs-web">Logs</option>
27
      <option value="/ldlogs-web">LD Logs</option>
25
      <option value="/logs-web">Vector Logs</option>
26
      <option value="/ldlogs-web">Lauterbach Logs</option>
28 27
      <option value="/devices-web">Devices</option>
29
      <option value="/body-devices-web">Body Devices</option>
28
      <option value="/body-devices-web" selected>Body Devices</option>
30 29
      <option value="/teams-web">Teams</option>
31 30
      <option value="/pcs-web">PCs</option>
32 31
      <option value="/licenses-web">Licenses</option>
......
46 45
<table>
47 46
    <TR>
48 47
        <TH>ID</TH>
49
        <TH>Serial Number</TH>
48
        <TH>Lauterbach Body ID</TH>
50 49
        <TH>Licenses</TH>
51 50
        <TH>Status</TH>
52 51
    </TR>
server/templates/devices/devicelicense.html
7 7
<body>
8 8
<h6><p>Vendor ID: {{device.vendor_id}}</p>
9 9
    <p>Product ID: {{device.product_id}}</p>
10
    <p>Serial Number: {{device.serial_number}}</p>
11 10
</h6>
11
<h4>Serial Number: {{device.serial_number}}</h4>
12 12
<form action="/devices-web/{{device.id}}" method="post">
13 13
  <label for="lic">Licenses:</label>
14 14
  <select id="lic" name="lic">
15 15
      {% for license in licenses %}
16
    <option value={{license.id}}>{{license.name}}</option>
16
    <option value={{license.id}}>{{license.name}} : {{license.license_id}}</option>
17 17
      {% endfor %}
18 18
  </select>
19 19
  <input type="submit" value="Connect">
20 20
</form>
21
<div style='padding-top:20px'>
21 22
<form action="/devices-web-del/{{device.id}}" method="post">
22 23
  <label for="lic_del">Licenses:</label>
23 24
  <select id="lic_del" name="lic_del">
24 25
      {% for license in dev_lic %}
25
    <option value={{license.id}}>{{license.name}}</option>
26
    <option value={{license.id}}>{{license.name}} : {{license.license_id}}</option>
26 27
      {% endfor %}
27 28
  </select>
28 29
  <input type="submit" value="Delete">
29 30
</form>
31
</div>
32
<div style='padding-top:20px'>
33
<form action="/devices-web-team/{{device.id}}" method="post">
34
  <label for="team_con">Teams:</label>
35
  <select id="team_con" name="team_con">
36
      {% for team in teams %}
37
    <option value={{team.id}}>{{team.name}}</option>
38
      {% endfor %}
39
  </select>
40
  <input type="submit" value="Connect">
41
</form>
42
</div>
43
<div style='padding-top:20px'>
44
<form action="/devices-web-inv/{{device.id}}" method="post">
45
  <label for="dev_inv">Inventory Number:</label><br>
46
  <input type="text" id="dev_inv" name="dev_inv" value="{{device.inventory_number}}">
47
  <input type="submit" value="Submit">
48
</form>
49
</div>
50
<div style='padding-top:20px'>
51
<form action="/devices-web-comment/{{device.id}}" method="post">
52
  <label for="dev_com">Comment:</label><br>
53
  <input type="text" id="dev_com" name="dev_com" value="{{device.comment}}">
54
  <input type="submit" value="Submit">
55
</form>
56
</div>
30 57
</body>
31 58
</html>
server/templates/devices/devices.html
1 1
<html>
2 2
<head>
3
    <style>
4
        #devices {
5
  font-family: Arial, Helvetica, sans-serif;
6
  border-collapse: collapse;
7
  width: 100%;
8
}
9

  
10
#devices td, #devices th {
11
  border: 1px solid #ddd;
12
  padding: 8px;
13
}
14

  
15
#devices tr:nth-child(even){background-color: #f2f2f2;}
16

  
17
#devices tr:hover {background-color: #ddd;}
18

  
19
#devices th {
20
  padding-top: 12px;
21
  padding-bottom: 12px;
22
  text-align: left;
23
  background-color: #47BBF5;
24
  color: black;
25
}
26
    </style>
3 27
    <title>Devices Details</title>
4 28
</head>
5 29
<body>
......
22 46
<form action="" method="get">
23 47
  <label for="view">Choose view:</label>
24 48
  <select id="view" name="view" onchange="this.form.action=this.value;">
25
      <option value=""></option>
26
      <option value="/logs-web">Logs</option>
27
      <option value="/ldlogs-web">LD Logs</option>
28
      <option value="/devices-web">Devices</option>
49
      <option value="/logs-web">Vector Logs</option>
50
      <option value="/ldlogs-web">Lauterbach Logs</option>
51
      <option value="/devices-web" selected>Devices</option>
29 52
      <option value="/body-devices-web">Body Devices</option>
30 53
      <option value="/teams-web">Teams</option>
31 54
      <option value="/pcs-web">PCs</option>
......
35 58
  <input type="submit" value="OK">
36 59
</form>
37 60
<form action="/devices-web" method="post">
38
    <label for="lic">License:</label>
39
    <input id="lic" name="lic" type="text" list="licenses" value="" placeholder="all">
40
    <datalist id="licenses">
61
    <label for="keyman_id">Keyman ID:</label>
62
    <input id="keyman_id" name="keyman_id" type="text" list="keyman_ids" value="" placeholder="all">
63
    <datalist id="keyman_ids">
64
        {% for dev in devs %}
65
        <option value="{{dev.serial_number}}"></option>
66
        {% endfor %}
67
    </datalist>
68
    <label for="lic_name">License Name:</label>
69
    <input id="lic_name" name="lic_name" type="text" list="licenses_names" value="" placeholder="all">
70
    <datalist id="licenses_names">
41 71
        {% for license in licenses %}
42 72
        <option value="{{license.name}}"></option>
43 73
        {% endfor %}
44 74
    </datalist>
75
    <label for="lic_id">License ID:</label>
76
    <input id="lic_id" name="lic_id" type="text" list="licenses_ids" value="" placeholder="all">
77
    <datalist id="licenses_ids">
78
        {% for license in licenses %}
79
        <option value="{{license.license_id}}"></option>
80
        {% endfor %}
81
    </datalist>
82
    <label for="team">Team:</label>
83
    <input id="team" name="team" type="text" list="teams" value="" placeholder="all">
84
    <datalist id="teams">
85
        {% for team in teams %}
86
        <option value="{{team.name}}">{{team.name}}</option>
87
        {% endfor %}
88
    </datalist>
45 89
  <input type="submit" value="Filter">
46 90
</form>
47
<table>
91
<table id="devices">
48 92
    <TR>
49 93
        <TH>ID</TH>
50
        <TH>Vendor ID</TH>
51
        <TH>Product ID</TH>
52
        <TH>Serial Number</TH>
53
        <TH>Licenses</TH>
94
        <TH>Keyman ID</TH>
95
        <TH>License Type</TH>
96
        <TH>License ID</TH>
97
        <TH>Inventory Number</TH>
98
        <TH>Team</TH>
99
        <TH>Last Username</TH>
100
        <TH>Last Hostname</TH>
101
        <TH>Last Detection</TH>
54 102
        <TH>Status</TH>
103
        <TH>Comment</TH>
55 104
    </TR>
56
    {% for i in range(devs) %}
105
    {% for dev in devices %}
57 106
    <TR>
58
        <TD class="ID"><a href="/device-license/{{devices[i].id}}">{{devices[i].id}}</a></TD>
59
        <TD class="Vendor ID">{{devices[i].vendor_id}}</TD>
60
        <TD class="Product ID">{{devices[i].product_id}}</TD>
61
        <TD class="Serial Number">{{devices[i].serial_number}}</TD>
62
        <TD class="License">
63
            {% for lic in devices[i].licenses %}
64
                {{lic.licenses.name}}<BR>
65
            {% endfor %}
66
        </TD>
67
        <TD class="Status">{{statuses[i]}}</TD>
107
        <TD class="ID"><a href="/device-license/{{dev['device'].id}}">{{dev['device'].id}}</a></TD>
108
        <TD class="Serial Number">{{dev['device'].serial_number}}</TD>
109
        <TD class="License">{{dev['license'].name}}</TD>
110
        <TD class="License ID">{{dev['license'].license_id}}</TD>
111
        <TD class="Inventory Number">{{dev['device'].inventory_number}}</TD>
112
        <TD class="Team">{{dev['device'].team.name}}</TD>
113
        <TD class="Last Username">{{dev['log'].pc.username}}</TD>
114
        <TD class="Last Hostname">{{dev['log'].pc.hostname}}</TD>
115
        <TD class="Last Detection">{{dev['log'].timestamp}}</TD>
116
        <TD class="Status">{{dev['log'].status}}</TD>
117
        <TD class="Comment">{{dev['device'].comment}}</TD>
68 118
    </TR>
69 119
    {% endfor %}
70
    <TR>
71
        <TD class="ID"></TD>
72
        <TD class="Vendor ID"></TD>
73
        <TD class="Product ID"></TD>
74
        <TD class="Serial Number"></TD>
75
        <TD class="License">
76
            <form action="/license-create" method="get">
77
                <input type="submit" value="Add">
78
            </form>
79
        </TD>
80
    </TR>
81 120
</table>
82 121
</body>
83 122
</html>
server/templates/devices/devices_normal.html
1 1
<html>
2 2
<head>
3
    <style>
4
        #devices {
5
  font-family: Arial, Helvetica, sans-serif;
6
  border-collapse: collapse;
7
  width: 100%;
8
}
9

  
10
#devices td, #devices th {
11
  border: 1px solid #ddd;
12
  padding: 8px;
13
}
14

  
15
#devices tr:nth-child(even){background-color: #f2f2f2;}
16

  
17
#devices tr:hover {background-color: #ddd;}
18

  
19
#devices th {
20
  padding-top: 12px;
21
  padding-bottom: 12px;
22
  text-align: left;
23
  background-color: #47BBF5;
24
  color: black;
25
}
26
    </style>
3 27
    <title>Devices Details</title>
4 28
</head>
5 29
<body>
......
22 46
<form action="" method="get">
23 47
  <label for="view">Choose view:</label>
24 48
  <select id="view" name="view" onchange="this.form.action=this.value;">
25
      <option value=""></option>
26
      <option value="/logs-web">Logs</option>
27
      <option value="/ldlogs-web">LD Logs</option>
28
      <option value="/devices-web">Devices</option>
49
      <option value="/logs-web">Vector Logs</option>
50
      <option value="/ldlogs-web">Lauterbach Logs</option>
51
      <option value="/devices-web" selected>Devices</option>
29 52
      <option value="/body-devices-web">Body Devices</option>
30 53
      <option value="/teams-web">Teams</option>
31 54
      <option value="/pcs-web">PCs</option>
......
43 66
    </datalist>
44 67
  <input type="submit" value="Filter">
45 68
</form>
46
<table>
69
<table id="devices">
47 70
    <TR>
48 71
        <TH>ID</TH>
49
        <TH>Vendor ID</TH>
50
        <TH>Product ID</TH>
51
        <TH>Serial Number</TH>
52
        <TH>Licenses</TH>
72
        <TH>Keyman ID</TH>
73
        <TH>License Type</TH>
74
        <TH>License ID</TH>
75
        <TH>Inventory Number</TH>
76
        <TH>Team</TH>
77
        <TH>Last Username</TH>
78
        <TH>Last Hostname</TH>
79
        <TH>Last Detection</TH>
53 80
        <TH>Status</TH>
81
        <TH>Comment</TH>
54 82
    </TR>
55
    {% for i in range(devs) %}
83
    {% for dev in devices %}
56 84
    <TR>
57
        <TD class="ID">{{devices[i].id}}</TD>
58
        <TD class="Vendor ID">{{devices[i].vendor_id}}</TD>
59
        <TD class="Product ID">{{devices[i].product_id}}</TD>
60
        <TD class="Serial Number">{{devices[i].serial_number}}</TD>
61
        <TD class="License">
62
            {% for lic in devices[i].licenses %}
63
                {{lic.licenses.name}}<BR>
64
            {% endfor %}
65
        </TD>
66
        <TD class="Status">{{statuses[i]}}</TD>
85
        <TD class="ID">{{dev['device'].id}}</TD>
86
        <TD class="Serial Number">{{dev['device'].serial_number}}</TD>
87
        <TD class="License">{{dev['license'].name}}</TD>
88
        <TD class="License ID">{{dev['license'].license_id}}</TD>
89
        <TD class="Inventory Number">{{dev['device'].inventory_number}}</TD>
90
        <TD class="Team">{{dev['device'].team.name}}</TD>
91
        <TD class="Last Username">{{dev['log'].pc.username}}</TD>
92
        <TD class="Last Hostname">{{dev['log'].pc.hostname}}</TD>
93
        <TD class="Last Detection">{{dev['log'].timestamp}}</TD>
94
        <TD class="Status">{{dev['log'].status}}</TD>
95
        <TD class="Comment">{{dev['device'].comment}}</TD>
67 96
    </TR>
68 97
    {% endfor %}
69 98
</table>
server/templates/ld-logs/ldlogs.html
22 22
<form action="" method="get">
23 23
  <label for="view">Choose view:</label>
24 24
  <select id="view" name="view" onchange="this.form.action=this.value;">
25
      <option value=""></option>
26
      <option value="/logs-web">Logs</option>
27
      <option value="/ldlogs-web">LD Logs</option>
25
      <option value="/logs-web">Vector Logs</option>
26
      <option value="/ldlogs-web" selected>Lauterbach Logs</option>
28 27
      <option value="/devices-web">Devices</option>
29 28
      <option value="/body-devices-web">Body Devices</option>
30 29
      <option value="/teams-web">Teams</option>
......
66 65
        <TH>Team</TH>
67 66
        <TH>Timestamp</TH>
68 67
        <TH>Status</TH>
69
        <TH>Head Device Serial Number</TH>
70
        <TH>Body Device Serial Number</TH>
68
        <TH>Lauterbach Head ID</TH>
69
        <TH>Lauterbach Body ID</TH>
71 70
    </TR>
72 71
    {% for log in logs %}
73 72
    <TR>
server/templates/ld-logs/ldlogs_normal.html
22 22
<form action="" method="get">
23 23
  <label for="view">Choose view:</label>
24 24
  <select id="view" name="view" onchange="this.form.action=this.value;">
25
      <option value=""></option>
26
      <option value="/logs-web">Logs</option>
27
      <option value="/ldlogs-web">LD Logs</option>
25
      <option value="/logs-web">Vector Logs</option>
26
      <option value="/ldlogs-web" selected>Lauterbach Logs</option>
28 27
      <option value="/devices-web">Devices</option>
29 28
      <option value="/body-devices-web">Body Devices</option>
30 29
      <option value="/teams-web">Teams</option>
......
65 64
        <TH>Team</TH>
66 65
        <TH>Timestamp</TH>
67 66
        <TH>Status</TH>
68
        <TH>Head Device Serial Number</TH>
69
        <TH>Body Device Serial Number</TH>
67
        <TH>Lauterbach Head ID</TH>
68
        <TH>Lauterbach Body ID</TH>
70 69
    </TR>
71 70
    {% for log in logs %}
72 71
    <TR>
server/templates/licenses/license_create.html
8 8
<form action="/licenses-web" method="post">
9 9
  <label for="name">Name:</label><br>
10 10
  <input type="text" id="name" name="name"><br><br>
11
    <label for="lic_id">License ID:</label><br>
12
  <input type="text" id="lic_id" name="lic_id"><br><br>
11 13
    <label for="expdate">Expiration Date</label>
12 14
  <input type="date" id="expdate" name="expdate" min={{minimum_date}}>
13 15
  <input type="submit" value="Submit">
server/templates/licenses/licenses.html
22 22
<form action="" method="get">
23 23
  <label for="view">Choose view:</label>
24 24
  <select id="view" name="view" onchange="this.form.action=this.value;">
25
      <option value=""></option>
26
      <option value="/logs-web">Logs</option>
27
      <option value="/ldlogs-web">LD Logs</option>
25
      <option value="/logs-web">Vector Logs</option>
26
      <option value="/ldlogs-web">Lauterbach Logs</option>
28 27
      <option value="/devices-web">Devices</option>
29 28
      <option value="/body-devices-web">Body Devices</option>
30 29
      <option value="/teams-web">Teams</option>
31 30
      <option value="/pcs-web">PCs</option>
32
      <option value="/licenses-web">Licenses</option>
31
      <option value="/licenses-web" selected>Licenses</option>
33 32
      <option value="/users-web">Users</option>
34 33
  </select>
35 34
  <input type="submit" value="OK">
......
37 36
<table>
38 37
    <TR>
39 38
        <TH>ID</TH>
40
        <TH>Name</TH>
39
        <TH>License Type</TH>
40
        <TH>License ID</TH>
41 41
        <TH>Expiration Date</TH>
42 42
    </TR>
43 43
    {% for license in licenses %}
44 44
    <TR>
45 45
        <TD class="ID">{{license.id}}</TD>
46
        <TD class="Vendor ID">{{license.name}}</TD>
47
        <TD class="Product ID">{{license.expiration_date}}</TD>
46
        <TD class="License Type">{{license.name}}</TD>
47
        <TD class="License ID">{{license.license_id}}</TD>
48
        <TD class="Expiration Date">{{license.expiration_date}}</TD>
48 49
    </TR>
49 50
    {% endfor %}
50 51
</table>
server/templates/licenses/licenses_normal.html
22 22
<form action="" method="get">
23 23
  <label for="view">Choose view:</label>
24 24
  <select id="view" name="view" onchange="this.form.action=this.value;">
25
      <option value=""></option>
26
      <option value="/logs-web">Logs</option>
27
      <option value="/ldlogs-web">LD Logs</option>
25
      <option value="/logs-web">Vector Logs</option>
26
      <option value="/ldlogs-web">Lauterbach Logs</option>
28 27
      <option value="/devices-web">Devices</option>
29 28
      <option value="/body-devices-web">Body Devices</option>
30 29
      <option value="/teams-web">Teams</option>
31 30
      <option value="/pcs-web">PCs</option>
32
      <option value="/licenses-web">Licenses</option>
31
      <option value="/licenses-web" selected>Licenses</option>
33 32
  </select>
34 33
  <input type="submit" value="OK">
35 34
</form>
......
37 36
    <TR>
38 37
        <TH>ID</TH>
39 38
        <TH>Name</TH>
39
        <TH>License ID</TH>
40 40
        <TH>Expiration Date</TH>
41 41
    </TR>
42 42
    {% for license in licenses %}
43 43
    <TR>
44 44
        <TD class="ID">{{license.id}}</TD>
45 45
        <TD class="Vendor ID">{{license.name}}</TD>
46
        <TD class="License ID">{{license.license_id}}</TD>
46 47
        <TD class="Product ID">{{license.expiration_date}}</TD>
47 48
    </TR>
48 49
    {% endfor %}
server/templates/pcs/pcs.html
22 22
<form action="" method="get">
23 23
  <label for="view">Choose view:</label>
24 24
  <select id="view" name="view" onchange="this.form.action=this.value;">
25
      <option value=""></option>
26
      <option value="/logs-web">Logs</option>
27
      <option value="/ldlogs-web">LD Logs</option>
25
      <option value="/logs-web">Vector Logs</option>
26
      <option value="/ldlogs-web">Lauterbach Logs</option>
28 27
      <option value="/devices-web">Devices</option>
29 28
      <option value="/body-devices-web">Body Devices</option>
30 29
      <option value="/teams-web">Teams</option>
31
      <option value="/pcs-web">PCs</option>
30
      <option value="/pcs-web" selected>PCs</option>
32 31
      <option value="/licenses-web">Licenses</option>
33 32
      <option value="/users-web">Users</option>
34 33
  </select>
......
39 38
        <TH>ID</TH>
40 39
        <TH>Username</TH>
41 40
        <TH>Hostname</TH>
42
        <TH>Team</TH>
43 41
    </TR>
44 42
    {% for pc in pcs %}
45 43
    <TR>
46
        <TD class="ID"><a href="/pc-team/{{pc.id}}">{{pc.id}}</a></TD>
47
        <TD class="Vendor ID">{{pc.username}}</TD>
48
        <TD class="Product ID">{{pc.hostname}}</TD>
49
        {% if pc.team == None %}
50
            <TD class="Team">NONE</TD>
51
        {% else %}
52
            <TD class="Team">{{pc.team.name}}</TD>
53
        {% endif %}
44
        <TD class="ID">{{pc.id}}</TD>
45
        <TD class="Username">{{pc.username}}</TD>
46
        <TD class="Hostname">{{pc.hostname}}</TD>
54 47
    </TR>
55 48
    {% endfor %}
56 49
</table>
server/templates/pcs/pcs_normal.html
22 22
<form action="" method="get">
23 23
  <label for="view">Choose view:</label>
24 24
  <select id="view" name="view" onchange="this.form.action=this.value;">
25
      <option value=""></option>
26
      <option value="/logs-web">Logs</option>
27
      <option value="/ldlogs-web">LD Logs</option>
25
      <option value="/logs-web">Vector Logs</option>
26
      <option value="/ldlogs-web">Lauterbach Logs</option>
28 27
      <option value="/devices-web">Devices</option>
29 28
      <option value="/body-devices-web">Body Devices</option>
30 29
      <option value="/teams-web">Teams</option>
31
      <option value="/pcs-web">PCs</option>
30
      <option value="/pcs-web" selected>PCs</option>
32 31
      <option value="/licenses-web">Licenses</option>
33 32
  </select>
34 33
  <input type="submit" value="OK">
......
38 37
        <TH>ID</TH>
39 38
        <TH>Username</TH>
40 39
        <TH>Hostname</TH>
41
        <TH>Team</TH>
42 40
    </TR>
43 41
    {% for pc in pcs %}
44 42
    <TR>
45 43
        <TD class="ID">{{pc.id}}</TD>
46
        <TD class="Vendor ID">{{pc.username}}</TD>
47
        <TD class="Product ID">{{pc.hostname}}</TD>
48
        {% if pc.team == None %}
49
            <TD class="Team">NONE</TD>
50
        {% else %}
51
            <TD class="Team">{{pc.team.name}}</TD>
52
        {% endif %}
44
        <TD class="Username">{{pc.username}}</TD>
45
        <TD class="Hostname">{{pc.hostname}}</TD>
53 46
    </TR>
54 47
    {% endfor %}
55 48
</table>
server/templates/teams/team_change.html
1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
    <meta charset="UTF-8">
5
    <title>Change team name</title>
6
</head>
7
<body>
8
<h4>Team: {{team.name}}</h4>
9
<form action="/teams-change-process/{{team.id}}" method="post">
10
  <label for="name">Name:</label><br>
11
  <input type="text" id="name" name="name"><br><br>
12
  <input type="submit" value="Submit">
13
</form>
14
</body>
15
</html>
server/templates/teams/teams.html
22 22
<form action="" method="get">
23 23
  <label for="view">Choose view:</label>
24 24
  <select id="view" name="view" onchange="this.form.action=this.value;">
25
      <option value=""></option>
26
      <option value="/logs-web">Logs</option>
27
      <option value="/ldlogs-web">LD Logs</option>
25
      <option value="/logs-web">Vector Logs</option>
26
      <option value="/ldlogs-web">Lauterbach Logs</option>
28 27
      <option value="/devices-web">Devices</option>
29 28
      <option value="/body-devices-web">Body Devices</option>
30
      <option value="/teams-web">Teams</option>
29
      <option value="/teams-web" selected>Teams</option>
31 30
      <option value="/pcs-web">PCs</option>
32 31
      <option value="/licenses-web">Licenses</option>
33 32
      <option value="/users-web">Users</option>
......
38 37
    <TR>
39 38
        <TH>ID</TH>
40 39
        <TH>Name</TH>
41
        <TH>Members</TH>
42 40
    </TR>
43 41
    {% for team in teams %}
44 42
    <TR>
45
        <TD class="ID">{{team.id}}</TD>
43
        <TD class="ID"><a href="/team-change/{{team.id}}">{{team.id}}</a></TD>
46 44
        <TD class="Name">{{team.name}}</TD>
47
        <TD class="Members">
48
        {% for ppl in team.pcs %}
49
            {{ppl.username}}<BR>
50
        {% endfor %}
51
        </TD>
52 45
    </TR>
53 46
    {% endfor %}
54 47
</table>
server/templates/teams/teams_normal.html
22 22
<form action="" method="get">
23 23
  <label for="view">Choose view:</label>
24 24
  <select id="view" name="view" onchange="this.form.action=this.value;">
25
      <option value=""></option>
26
      <option value="/logs-web">Logs</option>
27
      <option value="/ldlogs-web">LD Logs</option>
25
      <option value="/logs-web">Vector Logs</option>
26
      <option value="/ldlogs-web">Lauterbach Logs</option>
28 27
      <option value="/devices-web">Devices</option>
29 28
      <option value="/body-devices-web">Body Devices</option>
30
      <option value="/teams-web">Teams</option>
29
      <option value="/teams-web" selected>Teams</option>
31 30
      <option value="/pcs-web">PCs</option>
32 31
      <option value="/licenses-web">Licenses</option>
33 32
  </select>
......
37 36
    <TR>
38 37
        <TH>ID</TH>
39 38
        <TH>Name</TH>
40
        <TH>Members</TH>
41 39
    </TR>
42 40
    {% for team in teams %}
43 41
    <TR>
44 42
        <TD class="ID">{{team.id}}</TD>
45 43
        <TD class="Vendor ID">{{team.name}}</TD>
46
        <TD class="Members">
47
        {% for ppl in team.pcs %}
48
            {{ppl.username}}<BR>
49
        {% endfor %}
50
        </TD>
51 44
    </TR>
52 45
    {% endfor %}
53 46
</table>
server/templates/usb-logs/logs.html
22 22
<form action="" method="get">
23 23
  <label for="view">Choose view:</label>
24 24
  <select id="view" name="view" onchange="this.form.action=this.value;">
25
      <option value=""></option>
26
      <option value="/logs-web">Logs</option>
27
      <option value="/ldlogs-web">LD Logs</option>
25
      <option value="/logs-web" selected>Vector Logs</option>
26
      <option value="/ldlogs-web">Lauterbach Logs</option>
28 27
      <option value="/devices-web">Devices</option>
29 28
      <option value="/body-devices-web">Body Devices</option>
30 29
      <option value="/teams-web">Teams</option>
......
66 65
        <TH>Team</TH>
67 66
        <TH>Timestamp</TH>
68 67
        <TH>Status</TH>
69
        <TH>Device Product ID</TH>
70
        <TH>Device Serial Number</TH>
68
        <TH>Keyman ID</TH>
71 69
    </TR>
72 70
    {% for log in logs %}
73 71
    <TR>
......
77 75
        {% if log.pc.team == None %}
78 76
            <TD class="Team">NONE</TD>
79 77
        {% else %}
... Rozdílový soubor je zkrácen, protože jeho délka přesahuje max. limit.

Také k dispozici: Unified diff