UI: Add basic support for displaying records from ara_record
Change-Id: I7bbf12266586e547ad2d6ff4d1d4a3cf4334cd31
This commit is contained in:
parent
3062eafef6
commit
de360a0d41
|
@ -18,7 +18,7 @@ class Command(BaseCommand):
|
|||
os.mkdir(path)
|
||||
|
||||
# create subdirs
|
||||
dirs = ["playbook", "file", "host", "result"]
|
||||
dirs = ["playbook", "file", "host", "result", "record"]
|
||||
for dir in dirs:
|
||||
if not os.path.exists(os.path.join(path, dir)):
|
||||
os.mkdir(os.path.join(path, dir))
|
||||
|
@ -89,4 +89,13 @@ class Command(BaseCommand):
|
|||
data = {"result": detailed_result, "static_generation": True}
|
||||
self.render("result.html", destination, **data)
|
||||
|
||||
for record in detailed_playbook["records"]:
|
||||
# Retrieve record details
|
||||
detailed_record = client.get("/api/v1/records/%s" % record["id"])
|
||||
|
||||
# Generate record page
|
||||
destination = os.path.join(path, "record/%s.html" % record["id"])
|
||||
data = {"record": detailed_record, "static_generation": True}
|
||||
self.render("record.html", destination, **data)
|
||||
|
||||
print("[ara] %s files generated." % self.rendered)
|
||||
|
|
|
@ -17,12 +17,24 @@
|
|||
{% for arg, value in playbook.arguments.items %}
|
||||
<tr>
|
||||
<td>{{ arg }}</td>
|
||||
<td>{{ value | safe }}</td>
|
||||
<td>{% autoescape on %}{{ value }}{% endautoescape %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</details>
|
||||
<details id="records">
|
||||
<summary>Records</summary>
|
||||
{% if playbook.items.records %}
|
||||
<ul class="pf-c-list">
|
||||
{% for record in playbook.records %}
|
||||
<li><a href="../record/{{ record.id }}.html">{{ record.key }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
No records have been saved with <a href="https://ara.readthedocs.io/en/latest/ara-record.html" target="_blank">ara_record</a> for this playbook.
|
||||
{% endif %}
|
||||
</details>
|
||||
<details id="files">
|
||||
<summary>Files</summary>
|
||||
<ul class="pf-c-list">
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
{% extends "base.html" %}
|
||||
{% block body %}
|
||||
{% include "partials/playbook_card.html" with playbook=record.playbook %}
|
||||
|
||||
<div class="pf-c-card" style="margin: 1em 0;">
|
||||
<div class="pf-c-card__header pf-c-title pf-m-md">
|
||||
Record: {{ record.key }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="pf-c-card" style="margin: 1em 0;">
|
||||
<div class="pf-c-card__body">
|
||||
<pre>{% autoescape on %}{{ record.value }}{% endautoescape %}</pre>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -9,4 +9,5 @@ urlpatterns = [
|
|||
path("result/<int:result_id>.html", views.result, name="result"),
|
||||
path("file/<int:file_id>.html", views.file, name="file"),
|
||||
path("host/<int:host_id>.html", views.host, name="host"),
|
||||
path("record/<int:record_id>.html", views.record, name="record"),
|
||||
]
|
||||
|
|
|
@ -28,3 +28,8 @@ def file(request, file_id):
|
|||
def result(request, result_id):
|
||||
result = client.get("/api/v1/results/%s" % result_id)
|
||||
return render(request, "result.html", {"result": result})
|
||||
|
||||
|
||||
def record(request, record_id):
|
||||
record = client.get("/api/v1/records/%s" % record_id)
|
||||
return render(request, "record.html", {"record": record})
|
||||
|
|
Loading…
Reference in New Issue