- Change the data type of custom fields with stored values via a preview: values that cannot be converted need an explicit decision, the conversion runs in one transaction with row locks and a stale-preview check, old values are saved to data/backups and recorded in history. - Table filters: "!value" excludes rows, "=value" compares exactly; Excel-like value list (▾) per column in all tables. The software job list computes its value list on the server over the full job history. - Bulk edit offers custom fields with type-specific input and validation. - MeshCentral mappings: optional "value if empty" with a guard path; fallbacks are skipped when only basic data was delivered. - Deleting a field removes its translations (same name can be reused); one confirmation with the value count replaces the checkbox. - Job list filters recognize the "reinstall" action and the "software deployment" job type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
2.3 KiB
JavaScript
Executable File
62 lines
2.3 KiB
JavaScript
Executable File
(() => {
|
||
const container = document.getElementById('toast-container');
|
||
if (!container) return;
|
||
|
||
const body = document.body;
|
||
const allowedPositions = new Set([
|
||
'top-left', 'top-center', 'top-right',
|
||
'bottom-left', 'bottom-center', 'bottom-right'
|
||
]);
|
||
const position = allowedPositions.has(body.dataset.toastPosition)
|
||
? body.dataset.toastPosition
|
||
: 'top-right';
|
||
const seconds = Math.max(1, Math.min(120, Number.parseInt(body.dataset.toastDuration || '6', 10) || 6));
|
||
container.classList.add(`toast-position-${position}`);
|
||
|
||
const params = new URLSearchParams(window.location.search);
|
||
const entries = [
|
||
['toast_error', 'error'],
|
||
['toast_warning', 'warning'],
|
||
['toast_success', 'success']
|
||
];
|
||
|
||
function showToast(message, level) {
|
||
if (!message) return;
|
||
const toast = document.createElement('div');
|
||
toast.className = `toast toast-${level}`;
|
||
const symbol = level === 'success' ? '✓' : level === 'warning' ? '⚠' : '✕';
|
||
toast.innerHTML = `<span class="toast-symbol">${symbol}</span><span class="toast-message"></span><button type="button" class="toast-close">×</button>`;
|
||
toast.querySelector('.toast-close').setAttribute('aria-label', document.body.dataset.toastCloseLabel || 'Close');
|
||
toast.querySelector('.toast-message').textContent = message;
|
||
toast.querySelector('.toast-close').addEventListener('click', () => toast.remove());
|
||
container.appendChild(toast);
|
||
window.setTimeout(() => {
|
||
toast.classList.add('toast-hide');
|
||
window.setTimeout(() => toast.remove(), 350);
|
||
}, seconds * 1000);
|
||
}
|
||
|
||
// Small API for scripts that need to report an error without a page reload.
|
||
window.AssetManagerToast = {
|
||
error: message => showToast(message, 'error'),
|
||
warning: message => showToast(message, 'warning'),
|
||
success: message => showToast(message, 'success')
|
||
};
|
||
|
||
let changed = false;
|
||
entries.forEach(([key, level]) => {
|
||
const values = params.getAll(key);
|
||
values.forEach(value => showToast(value, level));
|
||
if (values.length) {
|
||
params.delete(key);
|
||
changed = true;
|
||
}
|
||
});
|
||
|
||
if (changed) {
|
||
const query = params.toString();
|
||
const cleanUrl = `${window.location.pathname}${query ? `?${query}` : ''}${window.location.hash}`;
|
||
window.history.replaceState({}, document.title, cleanUrl);
|
||
}
|
||
})();
|