Load daily repo graph separately
This commit is contained in:
parent
a3c48a35b9
commit
2705641d0d
|
@ -1,6 +1,7 @@
|
|||
window.addEventListener("DOMContentLoaded", function () {
|
||||
// const repoDict = JSON.parse(document.getElementById('hour_list').textContent);
|
||||
// set_daily_graph(repoDict)
|
||||
$.getJSON( "repo_daily.json", function( json ) {
|
||||
set_daily_graph(json);
|
||||
});
|
||||
}, false);
|
||||
|
||||
function set_daily_graph(repoDict) {
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
<link type="text/x-scss" href="{% static 'theme.scss' %}" rel="stylesheet" media="screen">
|
||||
{% endcompress %}
|
||||
|
||||
{% block script %}
|
||||
{% endblock %}
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
{% block script %}{% endblock %}
|
||||
|
||||
<style>{% block style %}{% endblock %}</style>
|
||||
<title>{% block title %}Title{% endblock %}</title>
|
||||
|
|
|
@ -5,6 +5,7 @@ from . import views
|
|||
|
||||
urlpatterns = [
|
||||
path('', cache_page(60)(views.index), name='index'),
|
||||
path('repo_daily.json', views.repo_daily_json, name='repo json'),
|
||||
path('repo/<str:repo_label>', views.repo, name='repo'),
|
||||
path('post/repo', views.post_repo, name='post repo'),
|
||||
path('post/archive', views.post_archive, name='post archive'),
|
||||
|
|
|
@ -2,23 +2,21 @@ from django.shortcuts import render, get_object_or_404
|
|||
from django.http import HttpResponseRedirect
|
||||
|
||||
from django.urls import reverse
|
||||
from django.contrib.auth.decorators import permission_required
|
||||
from django.core.cache import cache
|
||||
from django.http import JsonResponse
|
||||
from .models import Repo, Label, Archive, Cache, Error, Location
|
||||
from .forms import RepoForm, ArchiveForm, ErrorForm, LocationForm
|
||||
from django.contrib.auth.decorators import permission_required
|
||||
from .utility import data
|
||||
from datetime import datetime, timedelta
|
||||
from django.core.cache import cache
|
||||
from .utility import data
|
||||
|
||||
|
||||
def index(request):
|
||||
repo_list = Repo.objects.all()
|
||||
location_list = Location.objects.all()
|
||||
|
||||
# repo_dict = repo_daily_dict(repo_list, 8)
|
||||
|
||||
context = {
|
||||
'repo_list': repo_list,
|
||||
# 'hour_list': repo_dict,
|
||||
'location_list': location_list,
|
||||
}
|
||||
return render(request, 'borg/index.html', context)
|
||||
|
@ -38,6 +36,11 @@ def repo_daily_dict(repo_list, n_days=14):
|
|||
}
|
||||
|
||||
|
||||
def repo_daily_json(request):
|
||||
repo_list = Repo.objects.all()
|
||||
return JsonResponse(repo_daily_dict(repo_list, 31))
|
||||
|
||||
|
||||
def repo(request, repo_label: str):
|
||||
s_repo = get_object_or_404(Repo, label__label=repo_label)
|
||||
return render(request, 'borg/repo.html', {'repo': s_repo})
|
||||
|
|
Loading…
Reference in New Issue
Block a user