mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Make further use of notification messages
This commit is contained in:
parent
df30a85c03
commit
b6d48cab2a
@ -75,6 +75,12 @@ function showMessage(message, options={}) {
|
|||||||
|
|
||||||
var timeout = options.timeout || 5000;
|
var timeout = options.timeout || 5000;
|
||||||
|
|
||||||
|
var details = '';
|
||||||
|
|
||||||
|
if (options.details) {
|
||||||
|
details = `<p><small>${options.details}</p></small>`;
|
||||||
|
}
|
||||||
|
|
||||||
// Hacky function to get the next available ID
|
// Hacky function to get the next available ID
|
||||||
var id = 1;
|
var id = 1;
|
||||||
|
|
||||||
@ -85,14 +91,15 @@ function showMessage(message, options={}) {
|
|||||||
var icon = '';
|
var icon = '';
|
||||||
|
|
||||||
if (options.icon) {
|
if (options.icon) {
|
||||||
icon = `<span class='${options.icon}></span>`;
|
icon = `<span class='${options.icon}'></span>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the alert
|
// Construct the alert
|
||||||
var html = `
|
var html = `
|
||||||
<div id='alert-${id}' class='alert alert-${style} alert-dismissible fade show' role='alert'>
|
<div id='alert-${id}' class='alert alert-${style} alert-dismissible fade show' role='alert'>
|
||||||
${icon}
|
${icon}
|
||||||
${message}
|
<b>${message}</b>
|
||||||
|
${details}
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
@ -163,7 +163,7 @@ function inventreeDelete(url, options={}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function showApiError(xhr) {
|
function showApiError(xhr, url) {
|
||||||
|
|
||||||
var title = null;
|
var title = null;
|
||||||
var message = null;
|
var message = null;
|
||||||
@ -208,7 +208,11 @@ function showApiError(xhr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message += '<hr>';
|
message += '<hr>';
|
||||||
message += renderErrorMessage(xhr);
|
message += `URL: ${url}`;
|
||||||
|
|
||||||
showAlertDialog(title, message);
|
showMessage(title, {
|
||||||
|
style: 'danger',
|
||||||
|
icon: 'fas fa-server icon-red',
|
||||||
|
details: message,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -339,7 +339,7 @@ function completeBuildOutputs(build_id, outputs, options={}) {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$(opts.modal).modal('hide');
|
$(opts.modal).modal('hide');
|
||||||
showApiError(xhr);
|
showApiError(xhr, opts.url);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1527,7 +1527,7 @@ function allocateStockToBuild(build_id, part_id, bom_items, options={}) {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$(opts.modal).modal('hide');
|
$(opts.modal).modal('hide');
|
||||||
showApiError(xhr);
|
showApiError(xhr, opts.url);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,9 +123,10 @@ function getApiEndpointOptions(url, callback) {
|
|||||||
json: 'application/json',
|
json: 'application/json',
|
||||||
},
|
},
|
||||||
success: callback,
|
success: callback,
|
||||||
error: function() {
|
error: function(xhr) {
|
||||||
// TODO: Handle error
|
// TODO: Handle error
|
||||||
console.log(`ERROR in getApiEndpointOptions at '${url}'`);
|
console.log(`ERROR in getApiEndpointOptions at '${url}'`);
|
||||||
|
showApiError(xhr, url);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -202,9 +203,11 @@ function constructChangeForm(fields, options) {
|
|||||||
|
|
||||||
constructFormBody(fields, options);
|
constructFormBody(fields, options);
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function(xhr) {
|
||||||
// TODO: Handle error here
|
// TODO: Handle error here
|
||||||
console.log(`ERROR in constructChangeForm at '${options.url}'`);
|
console.log(`ERROR in constructChangeForm at '${options.url}'`);
|
||||||
|
|
||||||
|
showApiError(xhr, options.url);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -241,9 +244,11 @@ function constructDeleteForm(fields, options) {
|
|||||||
|
|
||||||
constructFormBody(fields, options);
|
constructFormBody(fields, options);
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function(xhr) {
|
||||||
// TODO: Handle error here
|
// TODO: Handle error here
|
||||||
console.log(`ERROR in constructDeleteForm at '${options.url}`);
|
console.log(`ERROR in constructDeleteForm at '${options.url}`);
|
||||||
|
|
||||||
|
showApiError(xhr, options.url);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -708,7 +713,7 @@ function submitFormData(fields, options) {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$(options.modal).modal('hide');
|
$(options.modal).modal('hide');
|
||||||
showApiError(xhr);
|
showApiError(xhr, options.url);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -555,7 +555,7 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$(opts.modal).modal('hide');
|
$(opts.modal).modal('hide');
|
||||||
showApiError(xhr);
|
showApiError(xhr, opts.url);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -427,7 +427,7 @@ function adjustStock(action, items, options={}) {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$(opts.modal).modal('hide');
|
$(opts.modal).modal('hide');
|
||||||
showApiError(xhr);
|
showApiError(xhr, opts.url);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user