145 lines
5.1 KiB
PHTML
145 lines
5.1 KiB
PHTML
<?php
|
|
$pageAuth = is_array($viewAuth['page'] ?? null) ? $viewAuth['page'] : [];
|
|
$canPurgeImportAudit = (bool) ($pageAuth['can_purge'] ?? false);
|
|
$toolbarFilterSchema = is_array($toolbarFilterSchema ?? null) ? $toolbarFilterSchema : [];
|
|
$searchToolbarFilterSchema = is_array($searchToolbarFilterSchema ?? null) ? $searchToolbarFilterSchema : [];
|
|
$drawerToolbarFilterSchema = is_array($drawerToolbarFilterSchema ?? null) ? $drawerToolbarFilterSchema : [];
|
|
$toolbarFilterState = is_array($toolbarFilterState ?? null) ? $toolbarFilterState : [];
|
|
$toolbarOptionSets = is_array($toolbarOptionSets ?? null) ? $toolbarOptionSets : [];
|
|
$filterChipMeta = is_array($filterChipMeta ?? null) ? $filterChipMeta : [];
|
|
$clientFilterSchema = is_array($clientFilterSchema ?? null) ? $clientFilterSchema : [];
|
|
$searchConfig = is_array($searchConfig ?? null) ? $searchConfig : null;
|
|
?>
|
|
<?php
|
|
$breadcrumbs = [
|
|
['label' => t('Home'), 'path' => 'admin'],
|
|
['label' => t('Import audit logs')],
|
|
];
|
|
require templatePath('partials/app-breadcrumb.phtml');
|
|
?>
|
|
<?php
|
|
$listTitle = t('Import audit logs');
|
|
ob_start();
|
|
?>
|
|
<?php
|
|
$listPurgeEnabled = $canPurgeImportAudit;
|
|
$listPurgeFormId = 'import-audit-purge-form';
|
|
$listPurgeAction = 'admin/import-audit/purge';
|
|
$listPurgeConfirmMessage = t('Purge entries older than 90 days?');
|
|
$listPurgeButtonLabel = t('Purge import logs');
|
|
require templatePath('partials/app-list-purge-action.phtml');
|
|
?>
|
|
<?php
|
|
$listTitleActionsHtml = ob_get_clean();
|
|
require templatePath('partials/app-list-titlebar.phtml');
|
|
?>
|
|
<?php
|
|
$filterUiNamespace = 'import-audit';
|
|
require templatePath('partials/app-list-filters.phtml');
|
|
?>
|
|
|
|
<div class="app-list-table">
|
|
<div id="import-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 profileLabel = (value) => {
|
|
const key = String(value || '').toLowerCase();
|
|
if (key === 'users') {return "<?php e(t('Users')); ?>";}
|
|
if (key === 'departments') {return "<?php e(t('Departments')); ?>";}
|
|
return key || '-';
|
|
};
|
|
|
|
const gridOptions = {
|
|
gridjs: window.gridjs,
|
|
container: '#import-audit-grid',
|
|
dataUrl: 'admin/import-audit/data',
|
|
appBase,
|
|
columns: [
|
|
{name: "<?php e(t('Created')); ?>", sort: true},
|
|
{
|
|
name: "<?php e(t('Status')); ?>",
|
|
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('Profile')); ?>",
|
|
sort: true,
|
|
formatter: (cell) => profileLabel(cell)
|
|
},
|
|
{name: "<?php e(t('Duration (ms)')); ?>", sort: true, formatter: (cell) => (cell > 0 ? `${cell}` : '-')},
|
|
{name: "<?php e(t('Rows total')); ?>", sort: true},
|
|
{name: "<?php e(t('Created count')); ?>", sort: true},
|
|
{name: "<?php e(t('Skipped count')); ?>", sort: true},
|
|
{name: "<?php e(t('Failed count')); ?>", sort: true},
|
|
{
|
|
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: 'ID', hidden: true}
|
|
],
|
|
sortColumns: ['started_at', 'status', 'profile_key', 'duration_ms', 'rows_total', 'created_count', 'skipped_count', 'failed_count', null, null],
|
|
paginationLimit: 10,
|
|
language: <?php MintyPHP\Buffer::get('grid_lang'); ?>,
|
|
mapData: (data) => data.data.map((row) => [
|
|
row.started_at,
|
|
{variant: row.status_badge, label: row.status_label || row.status || ''},
|
|
row.profile_key,
|
|
row.duration_ms,
|
|
row.rows_total,
|
|
row.created_count,
|
|
row.skipped_count,
|
|
row.failed_count,
|
|
{uuid: row.user_uuid || '', label: row.user_label || '-'},
|
|
row.id
|
|
]),
|
|
actions: {enabled: false},
|
|
search: gridSearch,
|
|
filterSchema,
|
|
urlSync: true,
|
|
rowDblClick: {
|
|
getUrl: (rowData) => {
|
|
const id = rowData?.cells?.[9]?.data;
|
|
return id ? new URL(`admin/import-audit/view/${id}`, appBase).toString() : '';
|
|
}
|
|
}
|
|
};
|
|
|
|
const { gridConfig } = initStandardListPage({
|
|
grid: gridOptions,
|
|
filters: {
|
|
mode: 'drawer',
|
|
chipMeta: filterChipMeta,
|
|
watchInputs: ['#import-audit-search']
|
|
}
|
|
});
|
|
|
|
if (!gridConfig || !gridConfig.grid) {
|
|
console.warn('Import audit grid init failed');
|
|
}
|
|
</script>
|