diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index 584403fc84..c6bdf9dfcc 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -41,6 +41,7 @@ from .views import SettingsView, EditUserView, SetPasswordView, CustomEmailView, from .views import CurrencyRefreshView from .views import AppearanceSelectView, SettingCategorySelectView from .views import DynamicJsView +from .views import NotificationsView from .api import InfoView, NotFoundView from .api import ActionPluginView @@ -87,6 +88,12 @@ settings_urls = [ url(r'^.*$', SettingsView.as_view(template_name='InvenTree/settings/settings.html'), name='settings'), ] +notifications_urls = [ + + # Catch any other urls + url(r'^.*$', NotificationsView.as_view(), name='notifications'), +] + # These javascript files are served "dynamically" - i.e. rendered on demand dynamic_javascript_urls = [ url(r'^calendar.js', DynamicJsView.as_view(template_name='js/dynamic/calendar.js'), name='calendar.js'), @@ -138,6 +145,8 @@ urlpatterns = [ url(r'^settings/', include(settings_urls)), + url(r'^notifications/', include(notifications_urls)), + url(r'^edit-user/', EditUserView.as_view(), name='edit-user'), url(r'^set-password/', SetPasswordView.as_view(), name='set-password'), diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index 989fb1bc9d..6eb9fb7462 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -884,3 +884,18 @@ class DatabaseStatsView(AjaxView): """ return ctx + + +class NotificationsView(TemplateView): + """ View for showing notifications + """ + + template_name = "InvenTree/notifications/notifications.html" + + def get_context_data(self, **kwargs): + + ctx = super().get_context_data(**kwargs).copy() + + # ctx['settings'] = InvenTreeSetting.objects.all().order_by('key') + + return ctx diff --git a/InvenTree/templates/InvenTree/notifications/history.html b/InvenTree/templates/InvenTree/notifications/history.html new file mode 100644 index 0000000000..a3c4ffdc0e --- /dev/null +++ b/InvenTree/templates/InvenTree/notifications/history.html @@ -0,0 +1,25 @@ +{% extends "panel.html" %} + +{% load i18n %} +{% load inventree_extras %} + +{% block label %}history{% endblock %} + +{% block heading %} +{% trans "History" %} +{% endblock %} + +{% block actions %} +
+ {% trans "Refresh History" %} +
+{% endblock %} + +{% block content %} + +
+ +
+
+ +{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/notifications/inbox.html b/InvenTree/templates/InvenTree/notifications/inbox.html new file mode 100644 index 0000000000..92c4a56339 --- /dev/null +++ b/InvenTree/templates/InvenTree/notifications/inbox.html @@ -0,0 +1,25 @@ +{% extends "panel.html" %} + +{% load i18n %} +{% load inventree_extras %} + +{% block label %}inbox{% endblock %} + +{% block heading %} +{% trans "Inbox" %} +{% endblock %} + +{% block actions %} +
+ {% trans "Refresh Inbox" %} +
+{% endblock %} + +{% block content %} + +
+ +
+
+ +{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/notifications/notifications.html b/InvenTree/templates/InvenTree/notifications/notifications.html new file mode 100644 index 0000000000..d10c1dcf7b --- /dev/null +++ b/InvenTree/templates/InvenTree/notifications/notifications.html @@ -0,0 +1,119 @@ +{% extends "base.html" %} + +{% load i18n %} +{% load inventree_extras %} + +{% block breadcrumb_list %} +{% endblock %} + +{% block page_title %} +{% inventree_title %} | {% trans "Notifications" %} +{% endblock %} + +{% block sidebar %} + {% include "InvenTree/notifications/sidebar.html" %} +{% endblock %} + +{% block content %} + {% include "InvenTree/notifications/inbox.html" %} + {% include "InvenTree/notifications/history.html" %} +{% endblock %} + +{% block js_ready %} +{{ block.super }} + +$("#inbox-table").inventreeTable({ + url: "{% url 'api-part-parameter-template-list' %}", + queryParams: { + ordering: 'name', + }, + formatNoMatches: function() { return '{% trans "No part parameter templates found" %}'; }, + columns: [ + { + field: 'pk', + title: '{% trans "ID" %}', + visible: false, + switchable: false, + }, + { + field: 'name', + title: '{% trans "Name" %}', + sortable: 'true', + }, + { + field: 'units', + title: '{% trans "Units" %}', + sortable: 'true', + }, + { + formatter: function(value, row, index, field) { + var bEdit = ""; + var bDel = ""; + + var html = "
" + bEdit + bDel + "
"; + + return html; + } + } + ] +}); + +$("#inbox-table").on('click', '.template-edit', function() { + var button = $(this); + + var url = "/part/parameter/template/" + button.attr('pk') + "/edit/"; + + launchModalForm(url, { + success: function() { + $("#inbox-table").bootstrapTable('refresh'); + } + }); +}); + +$("#inbox-refresh").on('click', function() { + $("#inbox-table").bootstrapTable('refresh'); +}); + + +$("#history-table").inventreeTable({ + url: "{% url 'api-part-parameter-template-list' %}", + queryParams: { + ordering: 'name', + }, + formatNoMatches: function() { return '{% trans "No part parameter templates found" %}'; }, + columns: [ + { + field: 'pk', + title: '{% trans "ID" %}', + visible: false, + switchable: false, + }, + { + field: 'name', + title: '{% trans "Name" %}', + sortable: 'true', + }, + { + field: 'units', + title: '{% trans "Units" %}', + sortable: 'true', + }, + { + formatter: function(value, row, index, field) { + var bEdit = ""; + var bDel = ""; + + var html = "
" + bEdit + bDel + "
"; + + return html; + } + } + ] +}); + +$("#history-refresh").on('click', function() { + $("#history-table").bootstrapTable('refresh'); +}); + +enableSidebar('notifications'); +{% endblock %} diff --git a/InvenTree/templates/InvenTree/notifications/sidebar.html b/InvenTree/templates/InvenTree/notifications/sidebar.html new file mode 100644 index 0000000000..aec7af1983 --- /dev/null +++ b/InvenTree/templates/InvenTree/notifications/sidebar.html @@ -0,0 +1,11 @@ +{% load i18n %} +{% load static %} +{% load inventree_extras %} + +{% trans "Notifications" as text %} +{% include "sidebar_header.html" with text=text icon='fa-user' %} + +{% trans "Inbox" as text %} +{% include "sidebar_item.html" with label='inbox' text=text icon="fa-cog" %} +{% trans "History" as text %} +{% include "sidebar_item.html" with label='history' text=text icon="fa-desktop" %}