in log4j-catalog/log4j-catalog-editor/src/main/resources/static/js/products.js [17:87]
$(document).ready(function () {
$('#ProductsTableContainer').jtable({
title: 'Table of Products',
paging: true, //Enable paging
pageSize: 25, //Set page size (default: 25)
sorting: true, //Enable sorting
defaultSorting: 'Name ASC', //Set default sorting
actions: {
listAction: 'api/products/list',
},
toolbar: {
items: [{
icon: 'js/jtable.2.4.0/themes/metro/add.png',
text: 'Add new record',
click: () => { addEditProductItem() }
}]
},
fields: {
id: {
key: true,
list: false
},
name: {
title: 'Name',
width: '25%'
},
displayName: {
title: 'Display Name',
width: '25%'
},
description: {
title: 'Description',
width: '50%'
},
edit: {
title: '',
width: '25',
display: function (productData) {
// Store event item data in localStorage
var productDataItem = JSON.stringify(productData.record);
localStorage.setItem('productItem' + productData.record.id, productDataItem);
return '<img class="log4J-action-icon" src="js/jtable.2.4.0/themes/metro/edit.png" onClick="addEditProductItem(' + productData.record.id + ')" />';
}
},
delete: {
title: '',
width: '25',
display: function (productData) {
return '<img class="log4J-action-icon" src="js/jtable.2.4.0/themes/metro/delete.png" onClick="deleteProductItem(' + productData.record.id + ')" />';
}
}
}
});
$.ajax({
type: 'POST',
url: 'api/events/list',
success:function(response){
if (response.Result === 'OK') {
var allEvents = response.Records.map((item) => {
return item.name;
});
localStorage.setItem('allEvents', allEvents);
}
},
error:function(jqXhr, textStatus, errorThrown){
console.error(textStatus + ' - ' + errorThrown);
}
});
//Load products list from server
$('#ProductsTableContainer').jtable('load');
});