From aa210efad668d86711f1894bb24a5b79e315331b Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 2 Feb 2020 22:03:31 +1100 Subject: [PATCH] Simple skelton for database stats view --- InvenTree/InvenTree/static/script/inventree/inventree.js | 6 ++++++ InvenTree/InvenTree/urls.py | 4 +++- InvenTree/InvenTree/views.py | 8 ++++++++ InvenTree/templates/stats.html | 5 +++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 InvenTree/templates/stats.html diff --git a/InvenTree/InvenTree/static/script/inventree/inventree.js b/InvenTree/InvenTree/static/script/inventree/inventree.js index 90dbacbe35..4f119b6118 100644 --- a/InvenTree/InvenTree/static/script/inventree/inventree.js +++ b/InvenTree/InvenTree/static/script/inventree/inventree.js @@ -41,6 +41,12 @@ function inventreeDocReady() { modal.modal('show'); }); + + // Callback to launch the 'Database Stats' window + $('#launch-stats').click(function() { + launchModalForm("/stats/", { + }); + }); } function isFileTransfer(transfer) { diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index 31b498ea2b..4b18916828 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -33,7 +33,8 @@ from django.conf.urls.static import static from django.views.generic.base import RedirectView from rest_framework.documentation import include_docs_urls -from .views import IndexView, SearchView, SettingsView, EditUserView, SetPasswordView +from .views import IndexView, SearchView, DatabaseStatsView +from .views import SettingsView, EditUserView, SetPasswordView from .views import InfoView from users.urls import user_urls @@ -97,6 +98,7 @@ urlpatterns = [ url(r'^index/', IndexView.as_view(), name='index'), url(r'^search/', SearchView.as_view(), name='search'), + url(r'^stats/', DatabaseStatsView.as_view(), name='stats'), url(r'^api/', include(apipatterns)), url(r'^api-doc/', include_docs_urls(title='InvenTree API')), diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index 95ad33cba1..2fcef3b76a 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -8,6 +8,7 @@ as JSON objects and passing them to modal forms (using jQuery / bootstrap). # -*- coding: utf-8 -*- from __future__ import unicode_literals +from django.utils.translation import gettext_lazy as _ from django.template.loader import render_to_string from django.http import JsonResponse, HttpResponseRedirect @@ -537,3 +538,10 @@ class SettingsView(TemplateView): ctx['settings'] = InvenTreeSetting.objects.all().order_by('key') return ctx + + +class DatabaseStatsView(AjaxView): + """ View for displaying database statistics """ + + ajax_template_name = "stats.html" + ajax_form_title = _("Database Statistics") \ No newline at end of file diff --git a/InvenTree/templates/stats.html b/InvenTree/templates/stats.html new file mode 100644 index 0000000000..38520bfb01 --- /dev/null +++ b/InvenTree/templates/stats.html @@ -0,0 +1,5 @@ +{% load static %} +{% load inventree_extras %} +{% load i18n %} + +HELLO WORLD \ No newline at end of file