From c9fc1b9c8b9e0da3177de82b9edc7cf6ed6a9352 Mon Sep 17 00:00:00 2001 From: vik378 Date: Wed, 28 Feb 2024 21:37:29 +0100 Subject: [PATCH] demo template improvements --- .gitignore | 2 ++ capella_model_explorer/explorer.py | 3 ++- templates/system_capability.j2.html | 23 +++++++++++++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 6dddc2e..8fa212c 100644 --- a/.gitignore +++ b/.gitignore @@ -156,3 +156,5 @@ dmypy.json # Cython debug symbols cython_debug/ + +node_modules/ diff --git a/capella_model_explorer/explorer.py b/capella_model_explorer/explorer.py index ff37956..3d1741d 100644 --- a/capella_model_explorer/explorer.py +++ b/capella_model_explorer/explorer.py @@ -1,5 +1,6 @@ import click from fastapi import FastAPI +from fastapi.responses import HTMLResponse import uvicorn import capellambse from pathlib import Path @@ -76,7 +77,7 @@ def render_template(template_name: str, object_id: str): object = app.model.by_uuid(object_id) # render the template with the object rendered = template.render(object=object) - return rendered + return HTMLResponse(content=rendered, status_code=200) if __name__ == "__main__": diff --git a/templates/system_capability.j2.html b/templates/system_capability.j2.html index f106b7e..14f85d0 100644 --- a/templates/system_capability.j2.html +++ b/templates/system_capability.j2.html @@ -1,6 +1,25 @@ -

{{ object.name }}

+

{{ object.name | capitalize }}

{% if object.description %}

{{ object.description }}

{% else %} -

No description available.

+

No description available.

{% endif %} + +Pre-condition: +{% if object.precondition %} +{{ object.precondition.specification['capella:linkedText']|safe }} +{% else %} +

No pre-condition defined

+{% endif %} + +Post-condition: +{% if object.postcondition %} +{{ object.postcondition.specification['capella:linkedText']|safe }} +{% else %} +

No post-condition defined

+{% endif %} + +

Context Diagram

+

The diagram below provides an overview over the entities immediately involved in the Capability and related Capabilities.

+ +{{ object.context_diagram.as_svg|safe}} \ No newline at end of file