Skip to content
Snippets Groups Projects
Commit 3375ec28 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

More mobile friendly index page and tables

/close #36
/close #28
parent 81461b83
No related branches found
No related tags found
No related merge requests found
...@@ -114,7 +114,7 @@ def merge_todos(): ...@@ -114,7 +114,7 @@ def merge_todos():
@manager.command @manager.command
def runserver(): def runserver():
app.run() app.run(host="192.168.0.13")
make_scheduler() make_scheduler()
# cause uwsgi currently has a bug # cause uwsgi currently has a bug
...@@ -430,7 +430,7 @@ def list_protocols(): ...@@ -430,7 +430,7 @@ def list_protocols():
"<b>{}</b>".format(text) if matched else text "<b>{}</b>".format(text) if matched else text
for text, matched in parts for text, matched in parts
])) ]))
search_results[protocol] = "<br />\n".join(formatted_lines) search_results[protocol] = "<br />\n".join(formatted_lines)
protocols = sorted(protocols, key=lambda protocol: protocol.date, reverse=True) protocols = sorted(protocols, key=lambda protocol: protocol.date, reverse=True)
page = _get_page() page = _get_page()
page_count = int(math.ceil(len(protocols) / config.PAGE_LENGTH)) page_count = int(math.ceil(len(protocols) / config.PAGE_LENGTH))
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
{% block title %}Startseite{% endblock %} {% block title %}Startseite{% endblock %}
{% block content %} {% block content %}
{% if protocol is not none %} {% if check_login() %}
<div class="row"> <div class="row">
<div id="left-column" class="col-lg-6"> <div id="left-column" class="col-lg-6">
{% endif %} {% endif %}
...@@ -25,21 +25,7 @@ ...@@ -25,21 +25,7 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
</ul> </ul>
{% if check_login() %}
<h3>Offene Todos <a href="{{url_for("list_todos")}}">Alle</a></h3>
<ul>
{% if todos|length > 0 %}
{% for todo in todos %}
<li>{{todo.render_html()|safe}} ({{todo.protocoltype.name}})</li>
{% endfor %}
{% else %}
<li>Keine Todos</li>
{% endif %}
</ul>
{% endif %}
{% if protocol is not none %} {% if protocol is not none %}
</div>
<div id="right-column" class="col-lg-6">
<h3>Letztes Protokoll</h3> <h3>Letztes Protokoll</h3>
<div class="well"> <div class="well">
<div class="btn-group"> <div class="btn-group">
...@@ -75,6 +61,20 @@ ...@@ -75,6 +61,20 @@
{% endif %} {% endif %}
</ul> </ul>
</div> </div>
{% endif %}
{% if check_login() %}
</div>
<div id="right-column" class="col-lg-6">
<h3>Offene Todos <a href="{{url_for("list_todos")}}">Alle</a></h3>
<ul>
{% if todos|length > 0 %}
{% for todo in todos %}
<li>{{todo.render_html()|safe}} ({{todo.protocoltype.name}})</li>
{% endfor %}
{% else %}
<li>Keine Todos</li>
{% endif %}
</ul>
</div> </div>
</div> </div>
{% endif %} {% endif %}
......
...@@ -109,6 +109,7 @@ to not render a label for the CRSFTokenField --> ...@@ -109,6 +109,7 @@ to not render a label for the CRSFTokenField -->
{%- endmacro %} {%- endmacro %}
{% macro render_table(table) -%} {% macro render_table(table) -%}
{% set classes = table.classes() %}
<h3> <h3>
{{table.title}} {{table.title}}
{% if table.newlink is not none %} {% if table.newlink is not none %}
...@@ -118,16 +119,16 @@ to not render a label for the CRSFTokenField --> ...@@ -118,16 +119,16 @@ to not render a label for the CRSFTokenField -->
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
{% for header in table.headers() %} {% for (header, class) in zip(table.headers(), classes) %}
<th>{{header}}</th> <th{% if class is not none %} class="{{class}}"{% endif %}>{{header}}</th>
{% endfor %} {% endfor %}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for row in table.rows() %} {% for row in table.rows() %}
<tr> <tr>
{% for entry in row %} {% for (entry, class) in zip(row, classes) %}
<td>{{entry}}</td> <td{% if class is not none %} class="{{class}}"{% endif %}>{{entry}}</td>
{% endfor %} {% endfor %}
</tr> </tr>
{% endfor %} {% endfor %}
......
...@@ -15,6 +15,9 @@ class Table: ...@@ -15,6 +15,9 @@ class Table:
def rows(self): def rows(self):
return [row for row in [self.row(value) for value in self.values] if row is not None] return [row for row in [self.row(value) for value in self.values] if row is not None]
def classes(self):
return [None for header in self.headers()]
@staticmethod @staticmethod
def link(target, text, confirm=None): def link(target, text, confirm=None):
confirmation = "" confirmation = ""
...@@ -55,7 +58,7 @@ class ProtocolsTable(Table): ...@@ -55,7 +58,7 @@ class ProtocolsTable(Table):
self.search_results = search_results self.search_results = search_results
def headers(self): def headers(self):
result = ["ID", "Sitzung", "Datum"] result = ["ID", "Sitzung", "Sitzung", "Datum"]
state_part = ["Status"] state_part = ["Status"]
search_part = ["Suchergebnis"] search_part = ["Suchergebnis"]
login_part = ["Typ", "Löschen"] login_part = ["Typ", "Löschen"]
...@@ -67,11 +70,22 @@ class ProtocolsTable(Table): ...@@ -67,11 +70,22 @@ class ProtocolsTable(Table):
result.extend(login_part) result.extend(login_part)
return result return result
def classes(self):
state_or_search_class = "hidden-xs" if self.search_results is None else None
result = ["hidden-xs", "hidden-sm hidden-md hidden-lg", "hidden-xs", "hidden-xs", None]
#result.append(state_or_search_class)
login_part = ["hidden-xs", "hidden-xs"]
if check_login():
result.extend(login_part)
return result
def row(self, protocol): def row(self, protocol):
user = current_user() user = current_user()
protocol_link = url_for("show_protocol", protocol_id=protocol.id)
result = [ result = [
Table.link(url_for("show_protocol", protocol_id=protocol.id), str(protocol.id)), Table.link(protocol_link, str(protocol.id)),
Table.link(url_for("show_protocol", protocol_id=protocol.id), protocol.protocoltype.name), Markup("<br>").join([Table.link(protocol_link, protocol.protocoltype.name), date_filter(protocol.date)]),
Table.link(protocol_link, protocol.protocoltype.name),
date_filter(protocol.date), date_filter(protocol.date),
] ]
if self.search_results is None: if self.search_results is None:
...@@ -92,19 +106,41 @@ class ProtocolTypesTable(Table): ...@@ -92,19 +106,41 @@ class ProtocolTypesTable(Table):
super().__init__("Protokolltypen", types, newlink=url_for("new_type")) super().__init__("Protokolltypen", types, newlink=url_for("new_type"))
def headers(self): def headers(self):
return ["Typ", "Name", "Neuestes Protokoll", ""] return [
"Typ", "Protokoll",
"Typ", "Name", "Neuestes Protokoll", ""
]
def classes(self):
return [
"hidden-sm hidden-md hidden-lg", "hidden-sm hidden-md hidden-lg",
"hidden-xs", "hidden-xs", "hidden-xs", "hidden-xs"
]
def row(self, protocoltype): def row(self, protocoltype):
protocol = protocoltype.get_latest_protocol() protocol = protocoltype.get_latest_protocol()
user = current_user() user = current_user()
has_private_view_right = protocoltype.has_private_view_right(user)
has_modify_right = protocoltype.has_modify_right(user) has_modify_right = protocoltype.has_modify_right(user)
return [ protocoltype_link = url_for("show_type", protocoltype_id=protocoltype.id)
Table.link(url_for("show_type", protocoltype_id=protocoltype.id), protocoltype.short_name) if has_modify_right else protocoltype.short_name, protocol_link = url_for("show_protocol", protocol_id=protocol.id)
new_protocol_link = url_for("new_protocol", type_id=protocoltype.id)
mobile_name = "{} ({})".format(protocoltype.name, protocoltype.short_name)
mobile_links = [Table.link(protocol_link, protocol.get_identifier())]
if has_modify_right:
mobile_links.append(Table.link(new_protocol_link, "Neues Protokoll"))
mobile_part = [
Table.link(protocoltype_link, mobile_name) if has_private_view_right else mobile_name,
Markup("<br>".join(mobile_links))
]
desktop_part = [
Table.link(protocoltype_link, protocoltype.short_name) if has_private_view_right else protocoltype.short_name,
protocoltype.name, protocoltype.name,
Table.link(url_for("show_protocol", protocol_id=protocol.id), protocol.get_identifier()) if protocol is not None else "Noch kein Protokoll", Table.link(protocol_link, protocol.get_identifier()) if protocol is not None else "Noch kein Protokoll",
Table.link(url_for("new_protocol", type_id=protocoltype.id), "Neues Protokoll") if has_modify_right else "" Table.link(new_protocol_link, "Neues Protokoll") if has_modify_right else ""
"" # TODO: add link for modify, delete "" # TODO: add link for modify, delete
] ]
return mobile_part + desktop_part
class ProtocolTypeTable(SingleValueTable): class ProtocolTypeTable(SingleValueTable):
def __init__(self, protocoltype): def __init__(self, protocoltype):
...@@ -229,6 +265,9 @@ class ErrorsTable(Table): ...@@ -229,6 +265,9 @@ class ErrorsTable(Table):
def headers(self): def headers(self):
return ["Protokoll", "Aktion", "Fehler", "Zeitpunkt", "Beschreibung", ""] return ["Protokoll", "Aktion", "Fehler", "Zeitpunkt", "Beschreibung", ""]
def classes(self):
return [None, None, None, None, "hidden-xs"]
def row(self, error): def row(self, error):
return [ return [
Table.link(url_for("show_protocol", protocol_id=error.protocol.id), error.protocol.get_identifier()), Table.link(url_for("show_protocol", protocol_id=error.protocol.id), error.protocol.get_identifier()),
...@@ -260,12 +299,20 @@ class TodosTable(Table): ...@@ -260,12 +299,20 @@ class TodosTable(Table):
super().__init__("Todos", todos, newlink=url_for("new_todo")) super().__init__("Todos", todos, newlink=url_for("new_todo"))
def headers(self): def headers(self):
return ["ID", "Status", "Sitzung", "Name", "Aufgabe", ""] return ["Todo", "ID", "Status", "Sitzung", "Name", "Aufgabe", ""]
def classes(self):
return ["hidden-sm hidden-md hidden-lg", "hidden-xs", "hidden-xs", "hidden-xs", "hidden-xs", None, "hidden-xs"]
def row(self, todo): def row(self, todo):
user = current_user() user = current_user()
protocol = todo.get_first_protocol() protocol = todo.get_first_protocol()
row = [ row = [
Markup("<br>").join([
Table.link(url_for("show_todo", todo_id=todo.id), todo.get_state()),
Table.link(url_for("show_protocol", protocol_id=protocol.id), todo.protocoltype.short_name),
todo.who
]),
Table.link(url_for("show_todo", todo_id=todo.id), todo.get_id()), Table.link(url_for("show_todo", todo_id=todo.id), todo.get_id()),
todo.get_state(), todo.get_state(),
Table.link(url_for("show_protocol", protocol_id=protocol.id), protocol.get_identifier()) Table.link(url_for("show_protocol", protocol_id=protocol.id), protocol.get_identifier())
...@@ -338,6 +385,9 @@ class DocumentsTable(Table): ...@@ -338,6 +385,9 @@ class DocumentsTable(Table):
def headers(self): def headers(self):
return ["ID", "Name", ""] return ["ID", "Name", ""]
def classes(self):
return [None, None, "hidden-xs"]
def row(self, document): def row(self, document):
user = current_user() user = current_user()
links = [] links = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment