Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New homepage layout #982

Merged
merged 6 commits into from
Sep 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion InvenTree/build/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def filter_queryset(self, queryset):
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)
Expand Down
37 changes: 37 additions & 0 deletions InvenTree/part/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,27 @@ def filter_queryset(self, queryset):
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)

Expand Down Expand Up @@ -477,6 +498,22 @@ def filter_queryset(self, queryset):
# 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 = [
Expand Down
15 changes: 15 additions & 0 deletions InvenTree/templates/InvenTree/bom_invalid.html
Original file line number Diff line number Diff line change
@@ -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 %}
15 changes: 15 additions & 0 deletions InvenTree/templates/InvenTree/build_pending.html
Original file line number Diff line number Diff line change
@@ -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 %}
115 changes: 113 additions & 2 deletions InvenTree/templates/InvenTree/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,43 @@
{% 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 %}

Expand All @@ -21,29 +55,106 @@ <h3>InvenTree</h3>

{{ 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 %}
15 changes: 15 additions & 0 deletions InvenTree/templates/InvenTree/latest_parts.html
Original file line number Diff line number Diff line change
@@ -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 %}
2 changes: 1 addition & 1 deletion InvenTree/templates/InvenTree/low_stock.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "collapse.html" %}
{% extends "collapse_index.html" %}

{% load i18n %}

Expand Down
15 changes: 15 additions & 0 deletions InvenTree/templates/InvenTree/po_outstanding.html
Original file line number Diff line number Diff line change
@@ -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 %}
15 changes: 15 additions & 0 deletions InvenTree/templates/InvenTree/required_stock_build.html
Original file line number Diff line number Diff line change
@@ -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 %}
15 changes: 15 additions & 0 deletions InvenTree/templates/InvenTree/so_outstanding.html
Original file line number Diff line number Diff line change
@@ -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 %}
4 changes: 2 additions & 2 deletions InvenTree/templates/InvenTree/starred_parts.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "collapse.html" %}
{% extends "collapse_index.html" %}

{% load i18n %}

Expand All @@ -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 %}
19 changes: 19 additions & 0 deletions InvenTree/templates/collapse_index.html
Original file line number Diff line number Diff line change
@@ -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>
2 changes: 1 addition & 1 deletion InvenTree/templates/js/build.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setupFilterList("build", table);

table.inventreeTable({
$(table).inventreeTable({
method: 'get',
formatNoMatches: function() {
return "{% trans "No builds matching query" %}";
Expand Down