Base html

[FR] Notification centre
Fixes #2279
This commit is contained in:
Matthias 2021-11-27 02:22:39 +01:00
parent 82d5952ddd
commit 6b53fd2bd4
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
6 changed files with 204 additions and 0 deletions

View File

@ -41,6 +41,7 @@ from .views import SettingsView, EditUserView, SetPasswordView, CustomEmailView,
from .views import CurrencyRefreshView from .views import CurrencyRefreshView
from .views import AppearanceSelectView, SettingCategorySelectView from .views import AppearanceSelectView, SettingCategorySelectView
from .views import DynamicJsView from .views import DynamicJsView
from .views import NotificationsView
from .api import InfoView, NotFoundView from .api import InfoView, NotFoundView
from .api import ActionPluginView from .api import ActionPluginView
@ -87,6 +88,12 @@ settings_urls = [
url(r'^.*$', SettingsView.as_view(template_name='InvenTree/settings/settings.html'), name='settings'), 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 # These javascript files are served "dynamically" - i.e. rendered on demand
dynamic_javascript_urls = [ dynamic_javascript_urls = [
url(r'^calendar.js', DynamicJsView.as_view(template_name='js/dynamic/calendar.js'), name='calendar.js'), 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'^settings/', include(settings_urls)),
url(r'^notifications/', include(notifications_urls)),
url(r'^edit-user/', EditUserView.as_view(), name='edit-user'), url(r'^edit-user/', EditUserView.as_view(), name='edit-user'),
url(r'^set-password/', SetPasswordView.as_view(), name='set-password'), url(r'^set-password/', SetPasswordView.as_view(), name='set-password'),

View File

@ -884,3 +884,18 @@ class DatabaseStatsView(AjaxView):
""" """
return ctx 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

View File

@ -0,0 +1,25 @@
{% extends "panel.html" %}
{% load i18n %}
{% load inventree_extras %}
{% block label %}history{% endblock %}
{% block heading %}
{% trans "History" %}
{% endblock %}
{% block actions %}
<div class='btn btn-secondary' type='button' id='history-refresh' title='{% trans "Refresh History" %}'>
<span class='fa fa-sync'></span> {% trans "Refresh History" %}
</div>
{% endblock %}
{% block content %}
<div class='row'>
<table class='table table-striped table-condensed' id='history-table'>
</table>
</div>
{% endblock %}

View File

@ -0,0 +1,25 @@
{% extends "panel.html" %}
{% load i18n %}
{% load inventree_extras %}
{% block label %}inbox{% endblock %}
{% block heading %}
{% trans "Inbox" %}
{% endblock %}
{% block actions %}
<div class='btn btn-secondary' type='button' id='inbox-refresh' title='{% trans "Refresh Inbox" %}'>
<span class='fa fa-sync'></span> {% trans "Refresh Inbox" %}
</div>
{% endblock %}
{% block content %}
<div class='row'>
<table class='table table-striped table-condensed' id='inbox-table'>
</table>
</div>
{% endblock %}

View File

@ -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 = "<button title='{% trans "Edit Template" %}' class='template-edit btn btn-outline-secondary' type='button' pk='" + row.pk + "'><span class='fas fa-edit'></span></button>";
var bDel = "<button title='{% trans "Delete Template" %}' class='template-delete btn btn-outline-secondary' type='button' pk='" + row.pk + "'><span class='fas fa-trash-alt icon-red'></span></button>";
var html = "<div class='btn-group float-right' role='group'>" + bEdit + bDel + "</div>";
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 = "<button title='{% trans "Edit Template" %}' class='template-edit btn btn-outline-secondary' type='button' pk='" + row.pk + "'><span class='fas fa-edit'></span></button>";
var bDel = "<button title='{% trans "Delete Template" %}' class='template-delete btn btn-outline-secondary' type='button' pk='" + row.pk + "'><span class='fas fa-trash-alt icon-red'></span></button>";
var html = "<div class='btn-group float-right' role='group'>" + bEdit + bDel + "</div>";
return html;
}
}
]
});
$("#history-refresh").on('click', function() {
$("#history-table").bootstrapTable('refresh');
});
enableSidebar('notifications');
{% endblock %}

View File

@ -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" %}