123 lines
4.5 KiB
PHTML
123 lines
4.5 KiB
PHTML
<?php
|
|
$pageAuth = is_array($viewAuth['page'] ?? null) ? $viewAuth['page'] : [];
|
|
$canPurge = (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('User lifecycle logs')],
|
|
];
|
|
require templatePath('partials/app-breadcrumb.phtml');
|
|
?>
|
|
<?php
|
|
$listTitle = t('User lifecycle logs');
|
|
ob_start();
|
|
?>
|
|
<?php
|
|
$listPurgeEnabled = $canPurge;
|
|
$listPurgeFormId = 'user-lifecycle-audit-purge-form';
|
|
$listPurgeAction = 'admin/user-lifecycle-audit/purge';
|
|
$listPurgeConfirmMessage = t('Purge entries older than 365 days?');
|
|
$listPurgeButtonLabel = t('Purge user lifecycle logs');
|
|
require templatePath('partials/app-list-purge-action.phtml');
|
|
?>
|
|
<?php
|
|
$listTitleActionsHtml = ob_get_clean();
|
|
require templatePath('partials/app-list-titlebar.phtml');
|
|
?>
|
|
|
|
<?php
|
|
$filterUiNamespace = 'user-lifecycle';
|
|
$filterToolbarId = 'user-lifecycle-audit-toolbar';
|
|
$filterDrawerToolbarId = 'user-lifecycle-drawer-toolbar';
|
|
$filterDrawerTitleId = 'user-lifecycle-filter-drawer-title';
|
|
require templatePath('partials/app-list-filters.phtml');
|
|
?>
|
|
|
|
<div class="app-list-table">
|
|
<div id="user-lifecycle-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 gridOptions = {
|
|
gridjs: window.gridjs,
|
|
container: '#user-lifecycle-audit-grid',
|
|
dataUrl: 'admin/user-lifecycle-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('Action')); ?>", sort: true},
|
|
{name: "<?php e(t('Trigger')); ?>", sort: true},
|
|
{name: "<?php e(t('Target email')); ?>", sort: false},
|
|
{name: "<?php e(t('Target UUID')); ?>", sort: false},
|
|
{name: "<?php e(t('Reason code')); ?>", sort: false},
|
|
{name: "<?php e(t('Restored at')); ?>", sort: true},
|
|
{name: 'ID', hidden: true}
|
|
],
|
|
sortColumns: ['created_at', 'status', 'action', 'trigger_type', null, null, null, 'restored_at', null],
|
|
paginationLimit: 10,
|
|
language: <?php MintyPHP\Buffer::get('grid_lang'); ?>,
|
|
mapData: (data) => data.data.map((row) => [
|
|
row.created_at,
|
|
{variant: row.status_badge, label: row.status_label || row.status || ''},
|
|
row.action_label || row.action || '-',
|
|
row.trigger_type_label || row.trigger_type || '-',
|
|
row.target_user_email || '-',
|
|
row.target_user_uuid || '-',
|
|
row.reason_code || '-',
|
|
row.restored_at || '-',
|
|
row.id
|
|
]),
|
|
actions: {enabled: false},
|
|
search: gridSearch,
|
|
filterSchema,
|
|
urlSync: true,
|
|
rowDblClick: {
|
|
getUrl: (rowData) => {
|
|
const id = rowData?.cells?.[8]?.data;
|
|
return id ? new URL(`admin/user-lifecycle-audit/view/${id}`, appBase).toString() : '';
|
|
}
|
|
}
|
|
};
|
|
|
|
const { gridConfig } = initStandardListPage({
|
|
grid: gridOptions,
|
|
filters: {
|
|
mode: 'drawer',
|
|
chipMeta: filterChipMeta,
|
|
watchInputs: ['#user-lifecycle-audit-search']
|
|
}
|
|
});
|
|
|
|
if (!gridConfig || !gridConfig.grid) {
|
|
console.warn('User lifecycle audit grid init failed');
|
|
}
|
|
</script>
|