$()

in log4j-catalog/log4j-catalog-editor/src/main/resources/static/js/categories.js [17:87]


$(document).ready(function () {
    $('#CategoriesTableContainer').jtable({
        title: 'Table of categories',
        paging: true, //Enable paging
        pageSize: 25, //Set page size (default: 25)
        sorting: true, //Enable sorting
        defaultSorting: 'Name ASC', //Set default sorting
        actions: {
            listAction: 'api/categories/list',
        },
        toolbar: {
            items: [{
                icon: 'js/jtable.2.4.0/themes/metro/add.png',
                text: 'Add new record',
                click: () => { addEditCategoryItem() }
            }]
        },
        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 (categoryData) {
                    // Store event item data in localStorage
                    var categoryDataItem = JSON.stringify(categoryData.record);
                    localStorage.setItem('categoryItem' + categoryData.record.id, categoryDataItem);
                    return '<img class="log4J-action-icon" src="js/jtable.2.4.0/themes/metro/edit.png" onClick="addEditCategoryItem(' + categoryData.record.id + ')" />';
                }
            },
            delete: {
                title: '',
                width: '25',
                display: function (categoryData) {
                    return '<img class="log4J-action-icon" src="js/jtable.2.4.0/themes/metro/delete.png" onClick="deleteCategoryItem(' + categoryData.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 categories list from server
    $('#CategoriesTableContainer').jtable('load');
});