diff --git a/borgweb/borg/static/borg/js/index.js b/borgweb/borg/static/borg/js/index.js index 1892d35..e9543e4 100644 --- a/borgweb/borg/static/borg/js/index.js +++ b/borgweb/borg/static/borg/js/index.js @@ -1,11 +1,11 @@ function inflateRepo(repo_json, label, template_id, container_id) { - const template_copy = $(template_id).clone(); - $(template_copy).find(".repo-label").html(label); - $(template_copy).find(".repo-location").html(repo_json.location); - $(template_copy).find(".repo-latest-backup").html(repo_json.latest_backup); - $(template_copy).find(".repo-size").html(repo_json.size); - $(template_copy).find(".repo-recent-errors").html(repo_json.recent_errors); - $(template_copy).find(".repo-size-graph").prop("id", `repo-${label}-size-graph`); + const repoLabel = `#repo-${label}` + + $(container_id).find(repoLabel).find(".repo-latest-backup").html(repo_json.latest_backup); + $(container_id).find(repoLabel).find(".repo-size").html(repo_json.size); + $(container_id).find(repoLabel).find(".repo-recent-errors").html(repo_json.recent_errors); + + $(container_id).find(repoLabel).removeClass("bg-primary"); let bg_class = "bg-primary"; if (repo_json.error) { @@ -13,9 +13,7 @@ function inflateRepo(repo_json, label, template_id, container_id) { } else if (repo_json.warning) { bg_class = "bg-warning"; } - $(template_copy).addClass(bg_class); - - $(container_id).append(template_copy); + $(container_id).find(repoLabel).addClass(bg_class); } diff --git a/borgweb/borg/templates/borg/index.html b/borgweb/borg/templates/borg/index.html index e1b4e16..e0b936a 100644 --- a/borgweb/borg/templates/borg/index.html +++ b/borgweb/borg/templates/borg/index.html @@ -15,29 +15,68 @@ {% block style %} {{ block.super }} .repo-container { - padding: 8px; - margin: 8px; + padding: 8px; + margin: 8px; } .att-label { - margin-top: 4px; - margin-bottom: 4px; + margin-top: 4px; + margin-bottom: 4px; } {% endblock %} {% block body %} -
-{#
#} -{# #} -{#
#} -{#
#} -{# #} -{#
#} -{#
#} -{#
#} -{#

No repositories found

#} -{#
#} -
+ {% if repo_list %} +
+ {% for repo in repo_list %} +
+
+

{{ repo.label }} + {{ repo.location }} +

+
+
+
Latest backup:
+
+
+
+
Size:
+
+
+
+
Recent errors:
+
+
+ + +
+ {% endfor %} +{#
#} +{# #} +{#
#} +{#
#} +{# #} +{#
#} + {% else %} +
+
+

No repositories found

+
+
+ {% endif %}
+ {#
#} + {#
#} + {# #} + {#
#} + {#
#} + {# #} + {#
#} + {#
#} + {#
#} + {#

No repositories found

#} + {#
#} + {#
#} + {#
#} {% endblock %} diff --git a/borgweb/borg/views/views.py b/borgweb/borg/views/views.py index 9537ec4..085f79c 100644 --- a/borgweb/borg/views/views.py +++ b/borgweb/borg/views/views.py @@ -3,7 +3,12 @@ from ..models import Repo def index(request): - return render(request, 'borg/index.html', {}) + repo_list = Repo.objects.all() + + context = { + 'repo_list': repo_list, + } + return render(request, 'borg/index.html', context) def repo(request, repo_label: str):