Skip to content

Commit

Permalink
added legend and test for network view
Browse files Browse the repository at this point in the history
  • Loading branch information
csae8092 committed Mar 1, 2024
1 parent 6d0aaa7 commit b07c78d
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 9 deletions.
19 changes: 18 additions & 1 deletion dumper/templates/dumper/network.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,24 @@ <h1 class="display-3 text-center">Netzwerk aller Verbindungen</h1>
<span class="visually-hidden">Lade die Netzwerkdaten...</span>
</div>
</div>
<div class="row">
<div class="col-2" >
<div class="p2" style="visibility: hidden;" id="legend">
<ul>
{% for x in model_list %}
<li>
<i class="{{ x.icon }}"></i> {{ x.name }}
</li>
{% endfor %}
</ul>
</div>
</div>
<div class="col-10">
<div id="app"></div>

<div id="app"></div>
</div>
</div>


</div>
{% endblock %}
5 changes: 5 additions & 0 deletions dumper/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,8 @@ def test_09_imprint(self):
url = reverse("dumper:export")
response = client.get(url)
self.assertEqual(response.status_code, 200)

def test_10_network(self):
url = reverse("dumper:network")
response = client.get(url)
self.assertEqual(response.status_code, 200)
19 changes: 19 additions & 0 deletions dumper/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Any
from django.apps import apps
from django.contrib.auth import authenticate, login, logout
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
Expand Down Expand Up @@ -29,6 +31,23 @@ class ExportView(TemplateView):
class NetworkView(TemplateView):
template_name = "dumper/network.html"

def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
context = super().get_context_data(**kwargs)
MODELS = list(apps.all_models["apis_entities"].values())
model_list = []
for x in MODELS:
try:
item = {
"color": x.get_color(),
"icon": x.get_icon(),
"name": x._meta.verbose_name,
}
except AttributeError:
continue
model_list.append(item)
context["model_list"] = model_list
return context


class ImprintView(TemplateView):
template_name = "dumper/imprint.html"
Expand Down
4 changes: 3 additions & 1 deletion pmb/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
)

if settings.DEBUG:
urlpatterns = urlpatterns + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns = urlpatterns + static(
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
)
2 changes: 2 additions & 0 deletions static/src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const node_csv = "/media/nodes.csv";
const edge_promis = d3.csv(edge_csv);
const node_promis = d3.csv(node_csv);
const spinnerNode = document.getElementById("spinner");
const legendNode = document.getElementById("legend");
const canvas = document.createElement("div");
canvas.style.height = "800px"

Expand All @@ -27,6 +28,7 @@ Promise.all([edge_promis, node_promis]).then(([edge_data, node_data]) => {

// remove spinner
spinnerNode.style.visibility = "hidden";
legendNode.style.visibility = "visible";
appNode.appendChild(canvas);
const searchContainer = document.createElement('div')
appNode.appendChild(searchContainer);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions static/vite/main-BgjuSik3.js → static/vite/main-CE-ujooY.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions static/vite/manifest.info
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"_browser-Co2CjrBv.js": {
"file": "browser-Co2CjrBv.js",
"_browser-C1tfp1OT.js": {
"file": "browser-C1tfp1OT.js",
"isDynamicEntry": true,
"imports": [
"js/main.js"
]
},
"js/main.js": {
"file": "main-BgjuSik3.js",
"file": "main-CE-ujooY.js",
"src": "js/main.js",
"isEntry": true,
"dynamicImports": [
"_browser-Co2CjrBv.js"
"_browser-C1tfp1OT.js"
]
}
}

0 comments on commit b07c78d

Please sign in to comment.