mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-09-19 18:31:16 +00:00
52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
def navbarItems(activePage):
|
|
pages = ["Students", "Assistants", "Experiments", "Appointments", "Groups", "Users"]
|
|
items = ""
|
|
for page in pages:
|
|
active = ""
|
|
lowerPage = page.lower().replace(" ", "_")
|
|
if lowerPage == activePage:
|
|
active = " active"
|
|
items += '<a class="nav-link' + active + '" href="' + lowerPage + '">' + page + '</a>'
|
|
return items
|
|
|
|
def makeTable(headerAndDataList, rows):
|
|
def cellString(cell):
|
|
return str(cell).replace("<", " ").replace(">", " ")
|
|
|
|
def td(cell):
|
|
return "<td>" + cellString(cell) + "</td>"
|
|
|
|
def th(cell):
|
|
return '<th data-sortable="true">' + cellString(cell) + '</th>'
|
|
|
|
table = '''<table
|
|
data-classes="table table-bordered table-striped"
|
|
data-toggle="table"
|
|
data-thead-classes="table-dark"
|
|
data-search="true"
|
|
data-show-toggle="true"
|
|
data-show-columns="true"
|
|
data-show-export="true"
|
|
data-export-types="['json', 'xml', 'csv', 'txt', 'sql', 'pdf']">
|
|
<thead>
|
|
<tr>'''
|
|
for i in headerAndDataList:
|
|
table += th(i[0])
|
|
table += '''</tr>
|
|
</thead>
|
|
<tbody>\n'''
|
|
|
|
for row in rows:
|
|
table += '<tr>'
|
|
|
|
for i in headerAndDataList:
|
|
table += td(eval(i[1]))
|
|
|
|
table += '</tr>\n'
|
|
|
|
table += '''</tbody>
|
|
</table>
|
|
<br>
|
|
<hr>
|
|
<br>'''
|
|
return table
|