Improved javascript log / warn / error messages

This commit is contained in:
Oliver Walters 2022-05-03 12:00:28 +10:00
parent 4732efb330
commit d69b5811b1
8 changed files with 18 additions and 19 deletions

View File

@ -105,7 +105,7 @@ function inventreeFormDataUpload(url, data, options={}) {
}
},
error: function(xhr, status, error) {
console.log('Form data upload failure: ' + status);
console.error('Form data upload failure: ' + status);
if (options.error) {
options.error(xhr, status, error);

View File

@ -86,7 +86,6 @@ function onCameraAvailable(hasCamera, options) {
function onBarcodeScanCompleted(result, options) {
if (result.data == '') return;
console.log('decoded qr code:', result.data);
stopQrScanner();
postBarcodeData(result.data, options);
}

View File

@ -1061,7 +1061,7 @@ function loadBomTable(table, options={}) {
table.bootstrapTable('append', response);
},
error: function(xhr) {
console.log('Error requesting BOM for part=' + part_pk);
console.error('Error requesting BOM for part=' + part_pk);
showApiError(xhr);
}
}

View File

@ -62,7 +62,7 @@ function loadTableFilters(tableKey) {
if (f.length == 2) {
filters[f[0]] = f[1];
} else {
console.log(`Improperly formatted filter: ${item}`);
console.warn(`Improperly formatted filter: ${item}`);
}
}
});
@ -274,7 +274,7 @@ function setupFilterList(tableKey, table, target, options={}) {
var element = $(target);
if (!element || !element.exists()) {
console.log(`WARNING: setupFilterList could not find target '${target}'`);
console.warn(`setupFilterList could not find target '${target}'`);
return;
}

View File

@ -274,7 +274,7 @@ function reloadFieldOptions(fieldName, options) {
setFieldOptions(fieldName, opts);
},
error: function() {
console.log('Error GETting field options');
console.error('Error GETting field options');
}
});
}
@ -842,7 +842,7 @@ function attachFieldCallback(modal, callback) {
// Run the callback function with the new value of the field!
callback.action(field.val(), field);
} else {
console.log(`Value changed for field ${callback.field} - ${field.val()}`);
console.info(`Value changed for field ${callback.field} - ${field.val()} (no callback attached)`);
}
});
}
@ -1085,8 +1085,8 @@ function launchModalForm(url, options = {}) {
showAlertDialog('{% trans "Error requesting form data" %}', renderErrorMessage(xhr));
}
console.log('Modal form error: ' + xhr.status);
console.log('Message: ' + xhr.responseText);
console.error('Modal form error: ' + xhr.status);
console.info('Message: ' + xhr.responseText);
}
};

View File

@ -1403,7 +1403,7 @@ function loadPurchaseOrderLineItemTable(table, options={}) {
var line_item = $(table).bootstrapTable('getRowByUniqueId', pk);
if (!line_item) {
console.log('WARNING: getRowByUniqueId returned null');
console.warn('getRowByUniqueId returned null');
return;
}
@ -1662,12 +1662,12 @@ function loadPurchaseOrderExtraLineTable(table, options={}) {
options.params = options.params || {};
if (!options.order) {
console.log('ERROR: function called without order ID');
console.error('function called without order ID');
return;
}
if (!options.status) {
console.log('ERROR: function called without order status');
console.error('function called without order status');
return;
}
@ -2789,12 +2789,12 @@ function loadSalesOrderLineItemTable(table, options={}) {
options.params = options.params || {};
if (!options.order) {
console.log('ERROR: function called without order ID');
console.error('function called without order ID');
return;
}
if (!options.status) {
console.log('ERROR: function called without order status');
console.error('function called without order status');
return;
}
@ -3297,12 +3297,12 @@ function loadSalesOrderExtraLineTable(table, options={}) {
options.params = options.params || {};
if (!options.order) {
console.log('ERROR: function called without order ID');
console.error('function called without order ID');
return;
}
if (!options.status) {
console.log('ERROR: function called without order status');
console.error('function called without order status');
return;
}

View File

@ -876,7 +876,7 @@ function loadPartPurchaseOrderTable(table, part_id, options={}) {
var line_item = $(table).bootstrapTable('getRowByUniqueId', pk);
if (!line_item) {
console.log('WARNING: getRowByUniqueId returned null');
console.warn('getRowByUniqueId returned null');
return;
}

View File

@ -39,7 +39,7 @@ function downloadTableData(table, opts={}) {
var url = table_options.url;
if (!url) {
console.log('Error: downloadTableData could not find "url" parameter.');
console.error('downloadTableData could not find "url" parameter.');
}
var query_params = table_options.query_params || {};
@ -343,7 +343,7 @@ $.fn.inventreeTable = function(options) {
}
});
} else {
console.log(`Could not get list of visible columns for table '${tableName}'`);
console.error(`Could not get list of visible columns for table '${tableName}'`);
}
}