Skip to content

Commit

Permalink
#4 Display datatypes
Browse files Browse the repository at this point in the history
  • Loading branch information
pepegiallo committed Apr 9, 2024
1 parent 5f8e68e commit 5e14173
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 4 deletions.
11 changes: 9 additions & 2 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,20 @@ def class_list():
interface.cursor.execute("SELECT id FROM structure_class ORDER BY id")
return render_template('class_list.html', classes=[interface.get_class(row['id']) for row in interface.cursor.fetchall()])

@app.route('/datatype/<int:datatype_id>')
def show_datatype(datatype_id: int):
with get_interface() as interface:

# Klasse ermitteln
datatype = interface.get_datatype(datatype_id)
return render_template('show_datatype.html', datatype=datatype)

@app.route('/class/<int:class_id>')
def show_class(class_id: int):
with get_interface() as interface:

# Klasse und alle Children ermitteln
# Klasse ermitteln
class_ = interface.get_class(class_id)
valid_classes = [class_, *class_.get_children(True)]

# Attribute ermitteln
all_attributes = [aa.get_attribute() for aa in class_.get_attribute_assignments(True)]
Expand Down
11 changes: 9 additions & 2 deletions gui/templates/show_class.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,21 @@ <h2>Attributes</h2>
<thead>
<tr>
<th>Name</th>
<th>Datatype</th>
</tr>
</thead>
<tbody>
{% for attribute in class_attributes %}
<tr><td style="font-weight: bold"><a href="{{ url_for('show_attribute_assignment', class_id=class_.id, attribute_id=attribute.id) }}">{{ attribute.name }}</a></td></tr>
<tr>
<td style="font-weight: bold"><a href="{{ url_for('show_attribute_assignment', class_id=class_.id, attribute_id=attribute.id) }}">{{ attribute.name }}</a></td>
<td><a href="{{ url_for('show_datatype', datatype_id=attribute.get_datatype().id) }}">{{ attribute.get_datatype().name }}</a></td>
</tr>
{% endfor %}
{% for attribute in inherited_attributes %}
<tr><td><a href="{{ url_for('show_attribute_assignment', class_id=class_.id, attribute_id=attribute.id) }}">{{ attribute.name }}</a></td></tr>
<tr>
<td><a href="{{ url_for('show_attribute_assignment', class_id=class_.id, attribute_id=attribute.id) }}">{{ attribute.name }}</a></td>
<td><a href="{{ url_for('show_datatype', datatype_id=attribute.get_datatype().id) }}">{{ attribute.get_datatype().name }}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
Expand Down
48 changes: 48 additions & 0 deletions gui/templates/show_datatype.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% extends 'base.html' %}

{% block content %}
<h1>{% block title %} Datatype {{ datatype.name }} {% endblock %}</h1>

<!-- General information -->
<hr>
<h2>General</h2>
<div class="row mb-2">
<div class="col-2">
<label for="identifier" class="form-label">Identifier</label>
<input type="text" class="form-control" id="identifier" value="{{ datatype.id }}" disabled>
</div>
<div class="col-5">
<label for="datatype_name" class="form-label">Name</label>
<input type="text" class="form-control" id="datatype_name" value="{{ datatype.name }}" disabled>
</div>
<div class="col-5">
<label for="parent_name" class="form-label">Parent</label>
<input type="text" class="form-control" id="parent_name" value="{{ datatype.get_parent().name }}" disabled>
</div>
<!--<div class="col-1">
<a href="{{ url_for('show_datatype', datatype_id=datatype.get_parent().id) }}"><button class="btn btn-primary">Show</button></a>
</div>-->
</div>
<div class="row mb-2">
<div class="col-12">
<label for="generator" class="form-label">Generator</label>
<input type="text" class="form-control" id="generator" value="{{ datatype.get_generator() }}" disabled>
</div>
</div>

<!-- Transformer -->
<hr>
<h2>Transformer</h2>
<div class="row">
<div class="col-12 mb-2">
<label for="read_transformer" class="form-label">Read</label>
<textarea class="form-control" id="read_transformer" rows="10" disabled>{{ datatype.read_transformer_source }}</textarea>
</div>
</div>
<div class="row">
<div class="col-12 mb-2">
<label for="write_transformer" class="form-label">Write</label>
<textarea class="form-control" id="write_transformer" rows="10" disabled>{{ datatype.write_transformer_source }}</textarea>
</div>
</div>
{% endblock %}

0 comments on commit 5e14173

Please sign in to comment.