mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Index page rendering is now a lot faster
- Hide some elements which are currently very expensive to compute -
This commit is contained in:
parent
90ac3a5a8a
commit
0e55911a6b
@ -494,15 +494,16 @@ class IndexView(TemplateView):
|
||||
|
||||
context = super(TemplateView, self).get_context_data(**kwargs)
|
||||
|
||||
context['starred'] = [star.part for star in self.request.user.starred_parts.all()]
|
||||
# TODO - Re-implement this when a less expensive method is worked out
|
||||
# context['starred'] = [star.part for star in self.request.user.starred_parts.all()]
|
||||
|
||||
# Generate a list of orderable parts which have stock below their minimum values
|
||||
# TODO - Is there a less expensive way to get these from the database
|
||||
context['to_order'] = [part for part in Part.objects.filter(purchaseable=True) if part.need_to_restock()]
|
||||
# context['to_order'] = [part for part in Part.objects.filter(purchaseable=True) if part.need_to_restock()]
|
||||
|
||||
# Generate a list of assembly parts which have stock below their minimum values
|
||||
# TODO - Is there a less expensive way to get these from the database
|
||||
context['to_build'] = [part for part in Part.objects.filter(assembly=True) if part.need_to_restock()]
|
||||
# context['to_build'] = [part for part in Part.objects.filter(assembly=True) if part.need_to_restock()]
|
||||
|
||||
return context
|
||||
|
||||
|
@ -301,7 +301,9 @@ class PartList(generics.ListCreateAPIView):
|
||||
return Response(data)
|
||||
|
||||
def get_queryset(self):
|
||||
|
||||
"""
|
||||
Implement custom filtering for the Part list API
|
||||
"""
|
||||
|
||||
# Start with all objects
|
||||
parts_list = Part.objects.all()
|
||||
|
@ -9,13 +9,7 @@ InvenTree | Index
|
||||
<hr>
|
||||
{% include "InvenTree/starred_parts.html" with collapse_id="starred" %}
|
||||
|
||||
{% if to_order %}
|
||||
{% include "InvenTree/parts_to_order.html" with collapse_id="order" %}
|
||||
{% endif %}
|
||||
|
||||
{% if to_build %}
|
||||
{% include "InvenTree/parts_to_build.html" with collapse_id="build" %}
|
||||
{% endif %}
|
||||
{% include "InvenTree/low_stock.html" with collapse_id="order" %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@ -25,15 +19,31 @@ InvenTree | Index
|
||||
|
||||
{% block js_ready %}
|
||||
|
||||
console.log("abcde?");
|
||||
|
||||
{{ block.super }}
|
||||
|
||||
//TODO: These calls to bootstrapTable() are failing, for some reason?
|
||||
//$("#to-build-table").bootstrapTable();
|
||||
//$("#to-order-table").bootstrapTable();
|
||||
//$("#starred-parts-table").bootstrapTable();
|
||||
loadPartTable("#starred-parts-table", "{% url 'api-part-list' %}", {
|
||||
params: {
|
||||
"starred": true,
|
||||
}
|
||||
});
|
||||
|
||||
loadPartTable("#low-stock-table", "{% url 'api-part-list' %}", {
|
||||
params: {
|
||||
"low_stock": true,
|
||||
}
|
||||
});
|
||||
|
||||
$("#starred-parts-table").on('load-success.bs.table', function() {
|
||||
var count = $("#starred-parts-table").bootstrapTable('getData').length;
|
||||
|
||||
$("#starred-parts-count").html(count);
|
||||
});
|
||||
|
||||
$("#low-stock-table").on('load-success.bs.table', function() {
|
||||
var count = $("#low-stock-table").bootstrapTable('getData').length;
|
||||
|
||||
$("#low-stock-count").html(count);
|
||||
});
|
||||
|
||||
console.log("Got to here...");
|
||||
|
||||
{% endblock %}
|
15
InvenTree/templates/InvenTree/low_stock.html
Normal file
15
InvenTree/templates/InvenTree/low_stock.html
Normal file
@ -0,0 +1,15 @@
|
||||
{% extends "collapse.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block collapse_title %}
|
||||
<span class='fas fa-shopping-cart icon-header'></span>
|
||||
{% trans "Low Stock" %}<span class='badge' id='low-stock-count'>0</span>
|
||||
{% endblock %}
|
||||
|
||||
{% block collapse_content %}
|
||||
|
||||
<table class='table table-striped table-condensed' id='low-stock-table'>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
@ -1,15 +0,0 @@
|
||||
{% extends "collapse.html" %}
|
||||
{% block collapse_title %}
|
||||
<span class='fas fa-shopping-cart icon-header'></span>
|
||||
Parts to Order<span class='badge'>{{ to_order | length }}</span>
|
||||
{% endblock %}
|
||||
|
||||
{% block collapse_heading %}
|
||||
There are {{ to_order | length }} parts which need to be ordered.
|
||||
{% endblock %}
|
||||
|
||||
{% block collapse_content %}
|
||||
|
||||
{% include "required_part_table.html" with parts=to_order table_id="to-order-table" %}
|
||||
|
||||
{% endblock %}
|
@ -1,15 +1,15 @@
|
||||
{% extends "collapse.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block collapse_title %}
|
||||
<span class='fas fa-star icon-header'></span>
|
||||
Starred Parts<span class='badge'>{{ starred | length }}</span>
|
||||
{% endblock %}
|
||||
|
||||
{% block collapse_heading %}
|
||||
You have {{ starred | length }} favourite parts
|
||||
{% trans "Starred Parts" %}<span class='badge' id='starred-parts-count'>0</span>
|
||||
{% endblock %}
|
||||
|
||||
{% block collapse_content %}
|
||||
|
||||
{% include "required_part_table.html" with parts=starred table_id="starred-parts-table" %}
|
||||
<table class='table tabe-striped table-condensed' id='starred-parts-table'>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
@ -102,6 +102,7 @@ InvenTree
|
||||
|
||||
<script type='text/javascript' src="{% static 'script/inventree/inventree.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/api.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/part.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/bom.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/filters.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/tables.js' %}"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user