Retrieve repo info with individual requests

This commit is contained in:
George Lacey 2022-04-11 07:55:19 +01:00
parent 7a12406e60
commit 4c3bafdcca
2 changed files with 11 additions and 28 deletions

View File

@ -1,10 +1,6 @@
function inflateRepo(repo_json, label, template_id, container_id) {
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";
@ -22,25 +18,9 @@ window.addEventListener("DOMContentLoaded", function () {
const template = $('#repo-template').html();
const container = $('#repo-container');
$.getJSON(`/repo_list.json`, function (repo_list) {
repo_list.labels.forEach(function (repo_label) {
$.getJSON(`/repo/${repo_label}.json`, function (repo_json) {
inflateRepo(repo_json, repo_label, template, container);
$('[data-json-string-request]').each(function (index, element) {
$.getJSON($(this).attr("data-json-string-request"), function (data) {
$(element).html(data['data']);
})
$.getJSON(`/repo/${repo_label}/monthly-size.json`, function (repo_size_json) {
draw_time_series_graph(`repo-${repo_label}-size-graph`, repo_size_json.repo,
repo_size_json.dates, repo_size_json.units);
})
});
})
// $.getJSON("repo_daily.json", function (json) {
// draw_time_graph("daily_backup_size", json.repos, json.dates, json.units);
// });
// $.getJSON("repo_monthly.json", function (json) {
// draw_time_graph("monthly_backup_size", json.repos, json.dates, json.units);
// });
}, false);

View File

@ -36,21 +36,24 @@
</div>
<dl class="att-label row ps-3">
<dt class="col-4">Latest backup:</dt>
<dd class="repo-latest-backup col-8">
<dd class="repo-latest-backup col-8"
data-json-string-request="/repo/{{ repo.label }}/latest-backup.json">
<div class="spinner-border" role="status">
</div>
</dd>
</dl>
<dl class="att-label row ps-3">
<dt class="col-4">Size:</dt>
<dd class="repo-size col-8">
<dd class="repo-size col-8"
data-json-string-request="/repo/{{ repo.label }}/size.json">
<div class="spinner-border" role="status">
</div>
</dd>
</dl>
<dl class="att-label row ps-3">
<dt class="col-4">Recent errors:</dt>
<dd class="repo-recent-errors col-8">
<dd class="repo-recent-errors col-8"
data-json-string-request="/repo/{{ repo.label }}/recent-errors.json">
<div class="spinner-border" role="status">
</div>
</dd>