Repo Interface für tests
This commit is contained in:
@@ -41,149 +41,29 @@ require templatePath('partials/app-list-filters.phtml');
|
||||
<div id="api-audit-grid"></div>
|
||||
</div>
|
||||
|
||||
<script src="<?php e(asset('vendor/gridjs/gridjs.umd.js')); ?>"></script>
|
||||
<script type="module">
|
||||
import { initStandardListPage } from "<?php e(assetVersion('js/core/app-grid-factory.js')); ?>";
|
||||
import { getAppBase } from "<?php e(assetVersion('js/pages/app-list-utils.js')); ?>";
|
||||
|
||||
const appBase = getAppBase();
|
||||
const gridSearch = <?php gridJsonForJs($searchConfig); ?>;
|
||||
const filterSchema = <?php gridJsonForJs($clientFilterSchema); ?>;
|
||||
const filterChipMeta = <?php gridJsonForJs($filterChipMeta); ?>;
|
||||
|
||||
const initApiAuditGrid = () => {
|
||||
const gridOptions = {
|
||||
gridjs: window.gridjs,
|
||||
container: '#api-audit-grid',
|
||||
dataUrl: 'admin/api-audit/data',
|
||||
appBase,
|
||||
columns: [
|
||||
{
|
||||
name: "<?php e(t('Created')); ?>",
|
||||
sort: true
|
||||
},
|
||||
{
|
||||
name: "<?php e(t('Status code')); ?>",
|
||||
sort: true,
|
||||
formatter: (cell) => {
|
||||
if (!cell || typeof cell !== 'object') {
|
||||
return gridjs.html('');
|
||||
}
|
||||
return gridjs.html(`<span class="badge" data-variant="${cell.variant || 'neutral'}">${cell.label || ''}</span>`);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "<?php e(t('Method')); ?>",
|
||||
sort: true,
|
||||
formatter: (cell) => {
|
||||
const method = String(cell || '').toUpperCase();
|
||||
return gridjs.html(`<span class="badge" data-variant="neutral">${method}</span>`);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "<?php e(t('Path')); ?>",
|
||||
sort: true
|
||||
},
|
||||
{
|
||||
name: "<?php e(t('Duration (ms)')); ?>",
|
||||
sort: true,
|
||||
formatter: (cell) => (cell > 0 ? `${cell}` : '-')
|
||||
},
|
||||
{
|
||||
name: "<?php e(t('User')); ?>",
|
||||
sort: false,
|
||||
formatter: (cell) => {
|
||||
if (!cell || typeof cell !== 'object') {
|
||||
return gridjs.html('-');
|
||||
}
|
||||
const label = cell.label || '-';
|
||||
if (!cell.uuid) {
|
||||
return gridjs.html(label);
|
||||
}
|
||||
const url = new URL(`admin/users/edit/${cell.uuid}`, appBase).toString();
|
||||
return gridjs.html(`<a href="${url}">${label}</a>`);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "<?php e(t('Tenant')); ?>",
|
||||
sort: false,
|
||||
formatter: (cell) => {
|
||||
if (!cell || typeof cell !== 'object') {
|
||||
return gridjs.html('-');
|
||||
}
|
||||
const label = cell.label || '-';
|
||||
if (!cell.uuid) {
|
||||
return gridjs.html(label);
|
||||
}
|
||||
const url = new URL(`admin/tenants/edit/${cell.uuid}`, appBase).toString();
|
||||
return gridjs.html(`<a href="${url}">${label}</a>`);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "<?php e(t('Error code')); ?>",
|
||||
sort: false,
|
||||
formatter: (cell) => cell ? gridjs.html(`<code>${String(cell)}</code>`) : gridjs.html('-')
|
||||
},
|
||||
{
|
||||
name: "<?php e(t('IP')); ?>",
|
||||
sort: false
|
||||
},
|
||||
{
|
||||
name: 'ID',
|
||||
hidden: true
|
||||
}
|
||||
],
|
||||
sortColumns: ['created_at', 'status_code', 'method', 'path', 'duration_ms', null, null, null, null, null],
|
||||
paginationLimit: 10,
|
||||
language: <?php MintyPHP\Buffer::get('grid_lang'); ?>,
|
||||
mapData: (data) => data.data.map((row) => [
|
||||
row.created_at,
|
||||
{
|
||||
variant: row.status_badge,
|
||||
label: String(row.status_code || '')
|
||||
},
|
||||
row.method,
|
||||
row.path,
|
||||
row.duration_ms,
|
||||
{
|
||||
uuid: row.user_uuid || '',
|
||||
label: row.user_label || '-'
|
||||
},
|
||||
{
|
||||
uuid: row.tenant_uuid || '',
|
||||
label: row.tenant_label || '-'
|
||||
},
|
||||
row.error_code || '',
|
||||
row.ip || '',
|
||||
row.id
|
||||
]),
|
||||
actions: {
|
||||
enabled: false
|
||||
},
|
||||
search: gridSearch,
|
||||
filterSchema,
|
||||
urlSync: true,
|
||||
rowDblClick: {
|
||||
getUrl: (rowData) => {
|
||||
const id = rowData?.cells?.[9]?.data;
|
||||
return id ? new URL(`admin/api-audit/view/${id}`, appBase).toString() : '';
|
||||
}
|
||||
}
|
||||
};
|
||||
const { gridConfig } = initStandardListPage({
|
||||
grid: gridOptions,
|
||||
filters: {
|
||||
mode: 'drawer',
|
||||
chipMeta: filterChipMeta,
|
||||
watchInputs: ['#api-audit-search']
|
||||
}
|
||||
});
|
||||
if (!gridConfig || !gridConfig.grid) {
|
||||
console.warn('API audit grid init failed');
|
||||
return null;
|
||||
}
|
||||
return gridConfig;
|
||||
};
|
||||
|
||||
initApiAuditGrid();
|
||||
</script>
|
||||
<?php
|
||||
$gridLang = json_decode(appBufferValue('grid_lang'), true);
|
||||
if (!is_array($gridLang)) {
|
||||
$gridLang = [];
|
||||
}
|
||||
$pageConfig = [
|
||||
'gridSearch' => $searchConfig,
|
||||
'filterSchema' => $clientFilterSchema,
|
||||
'filterChipMeta' => $filterChipMeta,
|
||||
'gridLang' => $gridLang,
|
||||
'labels' => [
|
||||
'created' => t('Created'),
|
||||
'statusCode' => t('Status code'),
|
||||
'method' => t('Method'),
|
||||
'path' => t('Path'),
|
||||
'durationMs' => t('Duration (ms)'),
|
||||
'user' => t('User'),
|
||||
'tenant' => t('Tenant'),
|
||||
'errorCode' => t('Error code'),
|
||||
'ip' => t('IP'),
|
||||
],
|
||||
];
|
||||
?>
|
||||
<script src="<?php e(assetVersion('vendor/gridjs/gridjs.umd.js')); ?>"></script>
|
||||
<script type="application/json" id="page-config-admin-api-audit-index"><?php gridJsonForJs($pageConfig); ?></script>
|
||||
<script type="module" src="<?php e(assetVersion('js/pages/admin-api-audit-index.js')); ?>"></script>
|
||||
|
||||
Reference in New Issue
Block a user