Merge pull request #982 from eeintech/new_homepage_layout

New homepage layout
This commit is contained in:
Oliver 2020-09-19 20:04:23 +10:00 committed by GitHub
commit a218b6b351
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 267 additions and 7 deletions

View File

@ -59,7 +59,10 @@ class BuildList(generics.ListCreateAPIView):
status = self.request.query_params.get('status', None)
if status is not None:
queryset = queryset.filter(status=status)
# Get status codes
codes = status.split('-')
# Filter by codes
queryset = queryset.filter(status__in=codes)
# Filter by associated part?
part = self.request.query_params.get('part', None)

View File

@ -405,6 +405,27 @@ class PartList(generics.ListCreateAPIView):
except (ValueError, Part.DoesNotExist):
pass
# Filter by latest part creation date
latest_parts = params.get('latest_parts', None)
if latest_parts is not None:
# Get the last 5 created parts
queryset = queryset.order_by('-creation_date')[:5]
# Filter invalid BOMs
bom_invalid = params.get('bom_invalid', None)
if bom_invalid is not None:
# Get assemblies with invalid BOMs
assemblies = queryset.filter(active=True).filter(assembly=True)
valid_boms = []
for part in assemblies:
if part.is_bom_valid:
valid_boms.append(part.pk)
queryset = assemblies.exclude(pk__in=valid_boms)
# Filter by 'starred' parts?
starred = params.get('starred', None)
@ -477,6 +498,22 @@ class PartList(generics.ListCreateAPIView):
# Filter items which have an 'in_stock' level higher than 'minimum_stock'
queryset = queryset.filter(Q(in_stock__gte=F('minimum_stock')))
# Filter by "parts which need stock to complete build"
stock_to_build = params.get('stock_to_build', None)
if stock_to_build is not None:
# Filter only active parts
queryset = queryset.filter(active=True)
parts_need_stock = []
# Find parts with active builds
# where any subpart's stock is lower than quantity being built
for part in queryset:
if part.active_builds and part.can_build < part.quantity_being_built:
parts_need_stock.append(part.pk)
queryset = queryset.filter(pk__in=parts_need_stock)
return queryset
permission_classes = [

View File

@ -0,0 +1,15 @@
{% extends "collapse_index.html" %}
{% load i18n %}
{% block collapse_title %}
<span class='fas fa-times-circle icon-header'></span>
{% trans "BOM Waiting Validation" %}<span class='badge' id='bom-invalid-count'>0</span>
{% endblock %}
{% block collapse_content %}
<table class='table table-striped table-condensed' id='bom-invalid-table'>
</table>
{% endblock %}

View File

@ -0,0 +1,15 @@
{% extends "collapse_index.html" %}
{% load i18n %}
{% block collapse_title %}
<span class='fas fa-cogs icon-header'></span>
{% trans "Pending Builds" %}<span class='badge' id='build-pending-count'>0</span>
{% endblock %}
{% block collapse_content %}
<table class='table table-striped table-condensed' id='build-pending-table'>
</table>
{% endblock %}

View File

@ -7,9 +7,43 @@ InvenTree | Index
{% block content %}
<h3>InvenTree</h3>
<hr>
{% include "InvenTree/starred_parts.html" with collapse_id="starred" %}
{% include "InvenTree/low_stock.html" with collapse_id="order" %}
<div class="row">
<div class="col-sm-6">
{% include "InvenTree/latest_parts.html" with collapse_id="latest_parts" %}
</div>
<div class="col-sm-6">
{% include "InvenTree/starred_parts.html" with collapse_id="starred" %}
</div>
</div>
<div class="row">
<div class="col-sm-6">
{% include "InvenTree/bom_invalid.html" with collapse_id="bom_invalid" %}
</div>
<div class="col-sm-6">
{% include "InvenTree/build_pending.html" with collapse_id="build_pending" %}
</div>
</div>
<div class="row">
<div class="col-sm-6">
{% include "InvenTree/low_stock.html" with collapse_id="order" %}
</div>
<div class="col-sm-6">
{% include "InvenTree/required_stock_build.html" with collapse_id="stock_to_build" %}
</div>
</div>
<div class="row">
<div class="col-sm-6">
{% include "InvenTree/po_outstanding.html" with collapse_id="po_outstanding" %}
</div>
<div class="col-sm-6">
{% include "InvenTree/so_outstanding.html" with collapse_id="so_outstanding" %}
</div>
</div>
{% endblock %}
@ -21,29 +55,106 @@ InvenTree | Index
{{ block.super }}
loadPartTable("#latest-parts-table", "{% url 'api-part-list' %}", {
params: {
"latest_parts": true,
}
});
loadPartTable("#starred-parts-table", "{% url 'api-part-list' %}", {
params: {
"starred": true,
}
});
loadPartTable("#bom-invalid-table", "{% url 'api-part-list' %}", {
params: {
"bom_invalid": true,
}
});
loadBuildTable("#build-pending-table", {
url: "{% url 'api-build-list' %}",
params: {
"part_detail": true,
"status": "10-20",
}
});
loadPartTable("#low-stock-table", "{% url 'api-part-list' %}", {
params: {
"low_stock": true,
}
});
loadPartTable("#stock-to-build-table", "{% url 'api-part-list' %}", {
params: {
"stock_to_build": true,
}
});
loadPurchaseOrderTable("#po-outstanding-table", {
url: "{% url 'api-po-list' %}",
params: {
"supplier_detail": true,
"oustanding": true,
}
});
loadSalesOrderTable("#so-outstanding-table", {
url: "{% url 'api-so-list' %}",
params: {
"customer_detail": true,
"oustanding": true,
}
});
$("#latest-parts-table").on('load-success.bs.table', function() {
var count = $("#latest-parts-table").bootstrapTable('getData').length;
$("#latest-parts-count").html(count);
});
$("#starred-parts-table").on('load-success.bs.table', function() {
var count = $("#starred-parts-table").bootstrapTable('getData').length;
$("#starred-parts-count").html(count);
});
$("#bom-invalid-table").on('load-success.bs.table', function() {
var count = $("#bom-invalid-table").bootstrapTable('getData').length;
$("#bom-invalid-count").html(count);
});
$("#build-pending-table").on('load-success.bs.table', function() {
var count = $("#build-pending-table").bootstrapTable('getData').length;
$("#build-pending-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);
});
$("#stock-to-build-table").on('load-success.bs.table', function() {
var count = $("#stock-to-build-table").bootstrapTable('getData').length;
$("#stock-to-build-count").html(count);
});
$("#po-outstanding-table").on('load-success.bs.table', function() {
var count = $("#po-outstanding-table").bootstrapTable('getData').length;
$("#po-outstanding-count").html(count);
});
$("#so-outstanding-table").on('load-success.bs.table', function() {
var count = $("#so-outstanding-table").bootstrapTable('getData').length;
$("#so-outstanding-count").html(count);
});
{% endblock %}

View File

@ -0,0 +1,15 @@
{% extends "collapse_index.html" %}
{% load i18n %}
{% block collapse_title %}
<span class='fas fa-newspaper icon-header'></span>
{% trans "Latest Parts" %}<span class='badge' id='latest-parts-count'>0</span>
{% endblock %}
{% block collapse_content %}
<table class='table table-striped table-condensed' id='latest-parts-table'>
</table>
{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "collapse.html" %}
{% extends "collapse_index.html" %}
{% load i18n %}

View File

@ -0,0 +1,15 @@
{% extends "collapse_index.html" %}
{% load i18n %}
{% block collapse_title %}
<span class='fas fa-sign-in-alt icon-header'></span>
{% trans "Outstanding Purchase Orders" %}<span class='badge' id='po-outstanding-count'>0</span>
{% endblock %}
{% block collapse_content %}
<table class='table table-striped table-condensed' id='po-outstanding-table'>
</table>
{% endblock %}

View File

@ -0,0 +1,15 @@
{% extends "collapse_index.html" %}
{% load i18n %}
{% block collapse_title %}
<span class='fas fa-bullhorn icon-header'></span>
{% trans "Require Stock To Complete Build" %}<span class='badge' id='stock-to-build-count'>0</span>
{% endblock %}
{% block collapse_content %}
<table class='table table-striped table-condensed' id='stock-to-build-table'>
</table>
{% endblock %}

View File

@ -0,0 +1,15 @@
{% extends "collapse_index.html" %}
{% load i18n %}
{% block collapse_title %}
<span class='fas fa-sign-out-alt icon-header'></span>
{% trans "Outstanding Sales Orders" %}<span class='badge' id='so-outstanding-count'>0</span>
{% endblock %}
{% block collapse_content %}
<table class='table table-striped table-condensed' id='so-outstanding-table'>
</table>
{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "collapse.html" %}
{% extends "collapse_index.html" %}
{% load i18n %}
@ -9,7 +9,7 @@
{% block collapse_content %}
<table class='table tabe-striped table-condensed' id='starred-parts-table'>
<table class='table table-striped table-condensed' id='starred-parts-table'>
</table>
{% endblock %}

View File

@ -0,0 +1,19 @@
{% block collapse_preamble %}
{% endblock %}
<div class='panel-group'>
<div class='panel panel-default'>
<div {% block collapse_panel_setup %}class='panel panel-heading'{% endblock %}>
<div class='panel-title'>
<a data-toggle='collapse' href="#collapse-item-{{ collapse_id }}">{% block collapse_title %}Title{% endblock %}</a>
</div>
{% block collapse_heading %}
{% endblock %}
</div>
<div class='panel-collapse collapse' id='collapse-item-{{ collapse_id }}'>
<div class='panel-body'>
{% block collapse_content %}
{% endblock %}
</div>
</div>
</div>
</div>

View File

@ -13,7 +13,7 @@ function loadBuildTable(table, options) {
setupFilterList("build", table);
table.inventreeTable({
$(table).inventreeTable({
method: 'get',
formatNoMatches: function() {
return "{% trans "No builds matching query" %}";