mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 04:26:44 +00:00
More fixes:
- Add "back to site" button on logout screen - Add favicon to account pages - Refactor notifications / alerts / caching
This commit is contained in:
parent
4e7825df13
commit
df30a85c03
@ -28,9 +28,8 @@
|
|||||||
padding: 20px;
|
padding: 20px;
|
||||||
padding-bottom: 35px;
|
padding-bottom: 35px;
|
||||||
background-color: rgba(50, 50, 50, 0.75);
|
background-color: rgba(50, 50, 50, 0.75);
|
||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 330px;
|
max-width: 550px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,6 +202,9 @@ function inventreeDocReady() {
|
|||||||
|
|
||||||
location.href = url;
|
location.href = url;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Display any cached alert messages
|
||||||
|
showCachedAlerts();
|
||||||
}
|
}
|
||||||
|
|
||||||
function isFileTransfer(transfer) {
|
function isFileTransfer(transfer) {
|
||||||
|
@ -1,12 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Add a cached alert message to sesion storage
|
||||||
|
*/
|
||||||
|
function addCachedAlert(message, style) {
|
||||||
|
|
||||||
function showAlertOrCache(alertType, message, cache, timeout=5000) {
|
var alerts = sessionStorage.getItem('inventree-alerts');
|
||||||
if (cache) {
|
|
||||||
sessionStorage.setItem(`inventree-${alertType}`, message);
|
if (alerts) {
|
||||||
|
alerts = JSON.parse(alerts);
|
||||||
|
} else {
|
||||||
|
alerts = [];
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
showMessage('#' + alertType, message, timeout);
|
|
||||||
|
|
||||||
sessionStorage.removeItem(`inventree-${alertType}`);
|
alerts.push({
|
||||||
|
message: message,
|
||||||
|
style: style
|
||||||
|
});
|
||||||
|
|
||||||
|
sessionStorage.setItem('inventree-alerts', JSON.stringify(alerts));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Remove all cached alert messages
|
||||||
|
*/
|
||||||
|
function clearCachedAlerts() {
|
||||||
|
sessionStorage.removeItem('inventree-alerts');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display an alert, or cache to display on reload
|
||||||
|
*/
|
||||||
|
function showAlertOrCache(message, style, cache=false) {
|
||||||
|
|
||||||
|
if (cache) {
|
||||||
|
addCachedAlert(message, style);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
showMessage(message, {style: style});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,25 +47,13 @@ function showAlertOrCache(alertType, message, cache, timeout=5000) {
|
|||||||
*/
|
*/
|
||||||
function showCachedAlerts() {
|
function showCachedAlerts() {
|
||||||
|
|
||||||
var styles = [
|
var alerts = JSON.parse(sessionStorage.getItem('inventree-alerts')) || [];
|
||||||
'primary',
|
|
||||||
'secondary',
|
|
||||||
'success',
|
|
||||||
'info',
|
|
||||||
'warning',
|
|
||||||
'danger',
|
|
||||||
];
|
|
||||||
|
|
||||||
styles.forEach(function(style) {
|
alerts.forEach(function(alert) {
|
||||||
|
showMessage(alert.message, {style: alert.style});
|
||||||
var msg = sessionStorage.getItem(`inventree-alert-${style}`);
|
|
||||||
|
|
||||||
if (msg) {
|
|
||||||
showMessage(msg, {
|
|
||||||
style: style,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
clearCachedAlerts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,26 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
|
||||||
|
<!-- Favicon -->
|
||||||
|
<link rel="apple-touch-icon" sizes="57x57" href="{% static 'img/favicon/apple-icon-57x57.png' %}">
|
||||||
|
<link rel="apple-touch-icon" sizes="60x60" href="{% static 'img/favicon/apple-icon-60x60.png' %}">
|
||||||
|
<link rel="apple-touch-icon" sizes="72x72" href="{% static 'img/favicon/apple-icon-72x72.png' %}">
|
||||||
|
<link rel="apple-touch-icon" sizes="76x76" href="{% static 'img/favicon/apple-icon-76x76.png' %}">
|
||||||
|
<link rel="apple-touch-icon" sizes="114x114" href="{% static 'img/favicon/apple-icon-114x114.png' %}">
|
||||||
|
<link rel="apple-touch-icon" sizes="120x120" href="{% static 'img/favicon/apple-icon-120x120.png' %}">
|
||||||
|
<link rel="apple-touch-icon" sizes="144x144" href="{% static 'img/favicon/apple-icon-144x144.png' %}">
|
||||||
|
<link rel="apple-touch-icon" sizes="152x152" href="{% static 'img/favicon/apple-icon-152x152.png' %}">
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="{% static 'img/favicon/apple-icon-180x180.png' %}">
|
||||||
|
<link rel="icon" type="image/png" sizes="192x192" href="{% static 'img/favicon/android-icon-192x192.png' %}">
|
||||||
|
<link rel="icon" type="image/png" sizes="32x32" href="{% static 'img/favicon/favicon-32x32.png' %}">
|
||||||
|
<link rel="icon" type="image/png" sizes="96x96" href="{% static 'img/favicon/favicon-96x96.png' %}">
|
||||||
|
<link rel="icon" type="image/png" sizes="16x16" href="{% static 'img/favicon/favicon-16x16.png' %}">
|
||||||
|
<link rel="manifest" href="{% static 'img/favicon/manifest.json' %}">
|
||||||
|
<meta name="msapplication-TileColor" content="#ffffff">
|
||||||
|
<meta name="msapplication-TileImage" content="{% static 'img/favicon/ms-icon-144x144.png' %}">
|
||||||
|
<meta name="theme-color" content="#ffffff">
|
||||||
|
|
||||||
|
|
||||||
<!-- CSS -->
|
<!-- CSS -->
|
||||||
<link rel="stylesheet" href="{% static 'fontawesome/css/brands.css' %}">
|
<link rel="stylesheet" href="{% static 'fontawesome/css/brands.css' %}">
|
||||||
<link rel="stylesheet" href="{% static 'fontawesome/css/solid.css' %}">
|
<link rel="stylesheet" href="{% static 'fontawesome/css/solid.css' %}">
|
||||||
@ -46,9 +66,10 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class='container-fluid'>
|
<div class='container-fluid'>
|
||||||
|
|
||||||
<div class='clearfix content-heading login-header'>
|
<div class='clearfix content-heading login-header d-flex flex-wrap'>
|
||||||
<img class="pull-left" src="{% static 'img/inventree.png' %}" width="60" height="60"/>
|
<img class="pull-left" src="{% static 'img/inventree.png' %}" width="60" height="60"/>
|
||||||
<span><h3>{% inventree_title %}</h3></span>
|
{% include "spacer.html" %}
|
||||||
|
<span class='float-right'><h3>{% inventree_title %}</h3></span>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class='container-fluid'>{% block content %}{% endblock %}</div>
|
<div class='container-fluid'>{% block content %}{% endblock %}</div>
|
||||||
@ -90,12 +111,10 @@ $(document).ready(function () {
|
|||||||
// notifications
|
// notifications
|
||||||
{% if messages %}
|
{% if messages %}
|
||||||
{% for message in messages %}
|
{% for message in messages %}
|
||||||
showAlertOrCache('alert-info', '{{message}}', true);
|
showAlertOrCache('{{ message }}', 'info', true);
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
showCachedAlerts();
|
|
||||||
|
|
||||||
inventreeDocReady();
|
inventreeDocReady();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -32,12 +32,12 @@ for a account and sign in below:{% endblocktrans %}</p>
|
|||||||
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
|
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="btn-toolbar">
|
<div class="btn-group float-right" role="group">
|
||||||
<button class="btn btn-primary col-md-8" type="submit">{% trans "Sign In" %}</button>
|
<button class="btn btn-success" type="submit">{% trans "Sign In" %}</button>
|
||||||
{% if mail_conf and enable_pwd_forgot %}
|
</div>
|
||||||
<a class="btn btn-primary" href="{% url 'account_reset_password' %}">{% trans "Forgot Password?" %}</a>
|
{% if mail_conf and enable_pwd_forgot %}
|
||||||
{% endif %}
|
<a class="" href="{% url 'account_reset_password' %}"><small>{% trans "Forgot Password?" %}</small></a>
|
||||||
</div>
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% if enable_sso %}
|
{% if enable_sso %}
|
||||||
|
@ -14,7 +14,10 @@
|
|||||||
{% if redirect_field_value %}
|
{% if redirect_field_value %}
|
||||||
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}"/>
|
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}"/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<button type="submit" class="btn btn-primary btn-block">{% trans 'Sign Out' %}</button>
|
<div class='btn-group float-right' role='group'>
|
||||||
|
<a type='button' class='btn btn-secondary' href='{% url "index" %}'><span class='fas fa-undo-alt'></span> {% trans "Back to Site" %}</a>
|
||||||
|
<button type="submit" class="btn btn-danger btn-block">{% trans 'Sign Out' %}</button>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,15 +183,13 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
inventreeDocReady();
|
inventreeDocReady();
|
||||||
|
|
||||||
showCachedAlerts();
|
|
||||||
|
|
||||||
{% if barcodes %}
|
{% if barcodes %}
|
||||||
$('#barcode-scan').click(function() {
|
$('#barcode-scan').click(function() {
|
||||||
barcodeScanDialog();
|
barcodeScanDialog();
|
||||||
});
|
});
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
moment.locale('{{request.LANGUAGE_CODE}}');
|
moment.locale('{{ request.LANGUAGE_CODE }}');
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -480,10 +480,10 @@ function barcodeCheckIn(location_id) {
|
|||||||
$(modal).modal('hide');
|
$(modal).modal('hide');
|
||||||
if (status == 'success' && 'success' in response) {
|
if (status == 'success' && 'success' in response) {
|
||||||
|
|
||||||
showAlertOrCache('alert-success', response.success, true);
|
showAlertOrCache(response.success, 'success', true);
|
||||||
location.reload();
|
location.reload();
|
||||||
} else {
|
} else {
|
||||||
showAlertOrCache('alert-success', '{% trans "Error transferring stock" %}', false);
|
showAlertOrCache('{% trans "Error transferring stock" %}', 'danger', false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -604,10 +604,10 @@ function scanItemsIntoLocation(item_id_list, options={}) {
|
|||||||
$(modal).modal('hide');
|
$(modal).modal('hide');
|
||||||
|
|
||||||
if (status == 'success' && 'success' in response) {
|
if (status == 'success' && 'success' in response) {
|
||||||
showAlertOrCache('alert-success', response.success, true);
|
showAlertOrCache(response.success, 'success', true);
|
||||||
location.reload();
|
location.reload();
|
||||||
} else {
|
} else {
|
||||||
showAlertOrCache('alert-danger', '{% trans "Error transferring stock" %}', false);
|
showAlertOrCache('{% trans "Error transferring stock" %}', 'danger', false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -885,19 +885,19 @@ function handleFormSuccess(response, options) {
|
|||||||
|
|
||||||
// Display any messages
|
// Display any messages
|
||||||
if (response && response.success) {
|
if (response && response.success) {
|
||||||
showAlertOrCache('alert-success', response.success, cache);
|
showAlertOrCache(response.success, 'success', cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response && response.info) {
|
if (response && response.info) {
|
||||||
showAlertOrCache('alert-info', response.info, cache);
|
showAlertOrCache(response.info, 'info', cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response && response.warning) {
|
if (response && response.warning) {
|
||||||
showAlertOrCache('alert-warning', response.warning, cache);
|
showAlertOrCache(response.warning, 'warning', cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response && response.danger) {
|
if (response && response.danger) {
|
||||||
showAlertOrCache('alert-danger', response.danger, cache);
|
showAlertOrCache(response.danger, 'dagner', cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.onSuccess) {
|
if (options.onSuccess) {
|
||||||
|
@ -399,19 +399,19 @@ function afterForm(response, options) {
|
|||||||
|
|
||||||
// Display any messages
|
// Display any messages
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
showAlertOrCache('alert-success', response.success, cache);
|
showAlertOrCache(response.success, 'success', cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.info) {
|
if (response.info) {
|
||||||
showAlertOrCache('alert-info', response.info, cache);
|
showAlertOrCache(response.info, 'info', cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.warning) {
|
if (response.warning) {
|
||||||
showAlertOrCache('alert-warning', response.warning, cache);
|
showAlertOrCache(response.warning, 'warning', cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.danger) {
|
if (response.danger) {
|
||||||
showAlertOrCache('alert-danger', response.danger, cache);
|
showAlertOrCache(response.danger, 'danger', cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Was a callback provided?
|
// Was a callback provided?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user