diff --git a/gui.py b/gui.py index fc6ddc2..9e15a64 100644 --- a/gui.py +++ b/gui.py @@ -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)] diff --git a/gui/templates/show_class.html b/gui/templates/show_class.html index 6dc5355..e60442d 100644 --- a/gui/templates/show_class.html +++ b/gui/templates/show_class.html @@ -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> diff --git a/gui/templates/show_datatype.html b/gui/templates/show_datatype.html new file mode 100644 index 0000000..3e48b2f --- /dev/null +++ b/gui/templates/show_datatype.html @@ -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 %} \ No newline at end of file