diff --git a/InvenTree/InvenTree/static/script/inventree/notification.js b/InvenTree/InvenTree/static/script/inventree/notification.js
index dc346e6f92..399ba1d359 100644
--- a/InvenTree/InvenTree/static/script/inventree/notification.js
+++ b/InvenTree/InvenTree/static/script/inventree/notification.js
@@ -75,6 +75,12 @@ function showMessage(message, options={}) {
var timeout = options.timeout || 5000;
+ var details = '';
+
+ if (options.details) {
+ details = `
${options.details}
`;
+ }
+
// Hacky function to get the next available ID
var id = 1;
@@ -85,14 +91,15 @@ function showMessage(message, options={}) {
var icon = '';
if (options.icon) {
- icon = ` `;
}
// Construct the alert
var html = `
${icon}
- ${message}
+ ${message}
+ ${details}
`;
diff --git a/InvenTree/templates/js/translated/api.js b/InvenTree/templates/js/translated/api.js
index 841cf467ba..cdd59a7fe5 100644
--- a/InvenTree/templates/js/translated/api.js
+++ b/InvenTree/templates/js/translated/api.js
@@ -163,7 +163,7 @@ function inventreeDelete(url, options={}) {
}
-function showApiError(xhr) {
+function showApiError(xhr, url) {
var title = null;
var message = null;
@@ -208,7 +208,11 @@ function showApiError(xhr) {
}
message += ' ';
- message += renderErrorMessage(xhr);
+ message += `URL: ${url}`;
- showAlertDialog(title, message);
+ showMessage(title, {
+ style: 'danger',
+ icon: 'fas fa-server icon-red',
+ details: message,
+ });
}
diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js
index dec9a4aaf7..499fde9bec 100644
--- a/InvenTree/templates/js/translated/build.js
+++ b/InvenTree/templates/js/translated/build.js
@@ -339,7 +339,7 @@ function completeBuildOutputs(build_id, outputs, options={}) {
break;
default:
$(opts.modal).modal('hide');
- showApiError(xhr);
+ showApiError(xhr, opts.url);
break;
}
}
@@ -1527,7 +1527,7 @@ function allocateStockToBuild(build_id, part_id, bom_items, options={}) {
break;
default:
$(opts.modal).modal('hide');
- showApiError(xhr);
+ showApiError(xhr, opts.url);
break;
}
}
diff --git a/InvenTree/templates/js/translated/forms.js b/InvenTree/templates/js/translated/forms.js
index be202183ff..7ca2e77a3f 100644
--- a/InvenTree/templates/js/translated/forms.js
+++ b/InvenTree/templates/js/translated/forms.js
@@ -123,9 +123,10 @@ function getApiEndpointOptions(url, callback) {
json: 'application/json',
},
success: callback,
- error: function() {
+ error: function(xhr) {
// TODO: Handle error
console.log(`ERROR in getApiEndpointOptions at '${url}'`);
+ showApiError(xhr, url);
}
});
}
@@ -199,12 +200,14 @@ function constructChangeForm(fields, options) {
// Store the entire data object
options.instance = data;
-
+
constructFormBody(fields, options);
},
- error: function() {
+ error: function(xhr) {
// TODO: Handle error here
console.log(`ERROR in constructChangeForm at '${options.url}'`);
+
+ showApiError(xhr, options.url);
}
});
}
@@ -241,9 +244,11 @@ function constructDeleteForm(fields, options) {
constructFormBody(fields, options);
},
- error: function() {
+ error: function(xhr) {
// TODO: Handle error here
console.log(`ERROR in constructDeleteForm at '${options.url}`);
+
+ showApiError(xhr, options.url);
}
});
}
@@ -708,7 +713,7 @@ function submitFormData(fields, options) {
break;
default:
$(options.modal).modal('hide');
- showApiError(xhr);
+ showApiError(xhr, options.url);
break;
}
}
diff --git a/InvenTree/templates/js/translated/order.js b/InvenTree/templates/js/translated/order.js
index 1008c77909..b0e3009720 100644
--- a/InvenTree/templates/js/translated/order.js
+++ b/InvenTree/templates/js/translated/order.js
@@ -555,7 +555,7 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) {
break;
default:
$(opts.modal).modal('hide');
- showApiError(xhr);
+ showApiError(xhr, opts.url);
break;
}
}
diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js
index 261cb4d1d6..07689b7638 100644
--- a/InvenTree/templates/js/translated/stock.js
+++ b/InvenTree/templates/js/translated/stock.js
@@ -427,7 +427,7 @@ function adjustStock(action, items, options={}) {
break;
default:
$(opts.modal).modal('hide');
- showApiError(xhr);
+ showApiError(xhr, opts.url);
break;
}
}