Skip to content

Commit 4d15f1d

Browse files
Merge pull request #414 from JLG-WOCFR-DEV/codex/check-roadmap-status
Add proactive surveillance configuration and escalation
2 parents 202222f + 16c5487 commit 4d15f1d

File tree

6 files changed

+1473
-0
lines changed

6 files changed

+1473
-0
lines changed

liens-morts-detector-jlg/assets/css/blc-admin-styles.css

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,6 +2530,145 @@ body.blc-modal-open {
25302530
color: var(--blc-admin-text-subtle);
25312531
}
25322532

2533+
.blc-surveillance-thresholds {
2534+
display: grid;
2535+
gap: 1.5rem;
2536+
margin-top: 0.5rem;
2537+
}
2538+
2539+
.blc-surveillance-thresholds__title {
2540+
margin: 0;
2541+
font-size: 1.1rem;
2542+
}
2543+
2544+
.blc-surveillance-table {
2545+
width: 100%;
2546+
border-collapse: collapse;
2547+
}
2548+
2549+
.blc-surveillance-table th,
2550+
.blc-surveillance-table td {
2551+
padding: 0.6rem 0.75rem;
2552+
vertical-align: top;
2553+
}
2554+
2555+
.blc-surveillance-table thead th {
2556+
background: var(--blc-admin-surface-subtle);
2557+
border-bottom: 1px solid var(--blc-admin-border-subtle);
2558+
font-weight: 600;
2559+
text-transform: uppercase;
2560+
font-size: 0.75rem;
2561+
letter-spacing: 0.04em;
2562+
color: var(--blc-admin-text-subtle);
2563+
}
2564+
2565+
.blc-surveillance-table tbody tr:nth-child(even) {
2566+
background: color-mix(in srgb, var(--blc-admin-surface-subtle) 45%, transparent);
2567+
}
2568+
2569+
.blc-surveillance-table__actions {
2570+
width: 120px;
2571+
text-align: right;
2572+
}
2573+
2574+
.blc-surveillance-table__actions .button-link-delete {
2575+
color: var(--blc-admin-danger-text);
2576+
}
2577+
2578+
.blc-surveillance-table__empty {
2579+
text-align: center;
2580+
color: var(--blc-admin-text-subtle);
2581+
font-style: italic;
2582+
padding: 1.25rem 0.75rem;
2583+
}
2584+
2585+
.blc-surveillance-inline-toggle {
2586+
display: flex;
2587+
align-items: center;
2588+
gap: 0.35rem;
2589+
margin-top: 0.5rem;
2590+
font-size: 0.85rem;
2591+
color: var(--blc-admin-text-subtle);
2592+
}
2593+
2594+
.blc-surveillance-actions {
2595+
margin: 0;
2596+
}
2597+
2598+
.blc-surveillance-escalation {
2599+
border: 1px solid var(--blc-admin-border-subtle);
2600+
border-radius: var(--blc-admin-radius-md);
2601+
padding: 1rem 1.25rem;
2602+
background: var(--blc-admin-surface-subtle);
2603+
display: flex;
2604+
flex-direction: column;
2605+
gap: 1rem;
2606+
}
2607+
2608+
.blc-surveillance-escalation__grid {
2609+
display: grid;
2610+
gap: 1rem;
2611+
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
2612+
}
2613+
2614+
.blc-surveillance-escalation__column h4 {
2615+
margin: 0 0 0.75rem;
2616+
font-size: 1rem;
2617+
}
2618+
2619+
.blc-surveillance-escalation__toggle,
2620+
.blc-surveillance-escalation__cooldown {
2621+
display: flex;
2622+
align-items: center;
2623+
gap: 0.5rem;
2624+
margin-bottom: 0.75rem;
2625+
font-size: 0.95rem;
2626+
}
2627+
2628+
.blc-surveillance-escalation__toggle input[type="checkbox"] {
2629+
width: 18px;
2630+
height: 18px;
2631+
}
2632+
2633+
.blc-surveillance-escalation__cooldown input[type="number"] {
2634+
max-width: 90px;
2635+
}
2636+
2637+
.blc-surveillance-escalation__unit {
2638+
color: var(--blc-admin-text-subtle);
2639+
font-size: 0.85rem;
2640+
}
2641+
2642+
.blc-surveillance-table textarea.is-readonly {
2643+
background: var(--blc-admin-surface-subtle);
2644+
color: var(--blc-admin-text-subtle);
2645+
cursor: not-allowed;
2646+
}
2647+
2648+
@media (max-width: 782px) {
2649+
.blc-surveillance-table thead {
2650+
display: none;
2651+
}
2652+
2653+
.blc-surveillance-table tr {
2654+
display: grid;
2655+
grid-template-columns: 1fr;
2656+
gap: 0.5rem;
2657+
padding: 0.75rem 0;
2658+
border-bottom: 1px solid var(--blc-admin-border-subtle);
2659+
}
2660+
2661+
.blc-surveillance-table td,
2662+
.blc-surveillance-table th {
2663+
padding: 0;
2664+
width: 100%;
2665+
}
2666+
2667+
.blc-surveillance-table__actions {
2668+
text-align: left;
2669+
}
2670+
}
2671+
25332672
.blc-settings-group--collapsible {
25342673
padding: 0;
25352674
overflow: hidden;

liens-morts-detector-jlg/assets/js/blc-admin-scripts.js

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5846,10 +5846,175 @@ jQuery(document).ready(function($) {
58465846
});
58475847
}
58485848

5849+
function initSurveillanceThresholds() {
5850+
var $container = $('#blc-surveillance-thresholds[data-blc-surveillance]');
5851+
5852+
if (!$container.length) {
5853+
return;
5854+
}
5855+
5856+
function syncApplyToAllState($checkbox) {
5857+
if (!$checkbox || !$checkbox.length) {
5858+
return;
5859+
}
5860+
5861+
var $cell = $checkbox.closest('td');
5862+
var $textarea = $cell.find('textarea');
5863+
var isChecked = $checkbox.is(':checked');
5864+
5865+
if ($textarea.length) {
5866+
$textarea.prop('readonly', isChecked);
5867+
$textarea.toggleClass('is-readonly', isChecked);
5868+
}
5869+
}
5870+
5871+
function computeNextIndex($body) {
5872+
var nextIndex = 0;
5873+
5874+
$body.children('[data-blc-surveillance-index]').each(function() {
5875+
var rawIndex = parseInt($(this).attr('data-blc-surveillance-index'), 10);
5876+
var isFiniteIndex = typeof Number !== 'undefined' && typeof Number.isFinite === 'function'
5877+
? Number.isFinite(rawIndex)
5878+
: isFinite(rawIndex);
5879+
5880+
if (isFiniteIndex && rawIndex >= nextIndex) {
5881+
nextIndex = rawIndex + 1;
5882+
}
5883+
});
5884+
5885+
return nextIndex;
5886+
}
5887+
5888+
function resolveTemplateHtml(templateId, index) {
5889+
if (!templateId) {
5890+
return '';
5891+
}
5892+
5893+
var template = document.getElementById(templateId);
5894+
if (!template) {
5895+
return '';
5896+
}
5897+
5898+
var html = template.innerHTML;
5899+
var pattern = /__index__/g;
5900+
5901+
return html.replace(pattern, String(index));
5902+
}
5903+
5904+
var tables = {};
5905+
5906+
$container.find('[data-blc-surveillance-table]').each(function() {
5907+
var $table = $(this);
5908+
var templateId = $table.attr('data-blc-template-id') || '';
5909+
var $body = $table.find('tbody[data-blc-surveillance-body]');
5910+
5911+
if (!templateId || !$body.length) {
5912+
return;
5913+
}
5914+
5915+
var scope = $body.attr('data-blc-surveillance-body') || '';
5916+
if (!scope) {
5917+
return;
5918+
}
5919+
5920+
var nextIndex = computeNextIndex($body);
5921+
5922+
tables[scope] = {
5923+
table: $table,
5924+
body: $body,
5925+
templateId: templateId,
5926+
emptyMessage: $table.attr('data-blc-empty-message') || ''
5927+
};
5928+
5929+
$table.data('blcNextIndex', nextIndex);
5930+
5931+
$body.find('input[name$="[apply_to_all_terms]"]').each(function() {
5932+
syncApplyToAllState($(this));
5933+
});
5934+
5935+
if ($body.find('[data-blc-surveillance-row]').length) {
5936+
$body.find('[data-blc-surveillance-empty]').remove();
5937+
}
5938+
});
5939+
5940+
if ($.isEmptyObject(tables)) {
5941+
return;
5942+
}
5943+
5944+
$container.on('click', '[data-blc-surveillance-add-row]', function(event) {
5945+
event.preventDefault();
5946+
var scope = $(this).attr('data-scope') || '';
5947+
5948+
if (!scope || !tables[scope]) {
5949+
return;
5950+
}
5951+
5952+
var tableInfo = tables[scope];
5953+
var nextIndex = parseInt(tableInfo.table.data('blcNextIndex'), 10);
5954+
var isFiniteIndex = typeof Number !== 'undefined' && typeof Number.isFinite === 'function'
5955+
? Number.isFinite(nextIndex)
5956+
: isFinite(nextIndex);
5957+
5958+
if (!isFiniteIndex) {
5959+
nextIndex = computeNextIndex(tableInfo.body);
5960+
}
5961+
5962+
var html = resolveTemplateHtml(tableInfo.templateId, nextIndex);
5963+
if (!html) {
5964+
return;
5965+
}
5966+
5967+
var $row = $(html);
5968+
5969+
tableInfo.body.find('[data-blc-surveillance-empty]').remove();
5970+
tableInfo.body.append($row);
5971+
tableInfo.table.data('blcNextIndex', nextIndex + 1);
5972+
5973+
$row.find('input[name$="[apply_to_all_terms]"]').each(function() {
5974+
syncApplyToAllState($(this));
5975+
});
5976+
});
5977+
5978+
$container.on('click', '[data-blc-surveillance-remove-row]', function(event) {
5979+
event.preventDefault();
5980+
var $row = $(this).closest('[data-blc-surveillance-row]');
5981+
if (!$row.length) {
5982+
return;
5983+
}
5984+
5985+
var $body = $row.closest('tbody[data-blc-surveillance-body]');
5986+
var scope = $body.attr('data-blc-surveillance-body') || '';
5987+
var columnCount = $row.closest('table').find('thead th').length || 1;
5988+
$row.remove();
5989+
5990+
if (!scope || !tables[scope]) {
5991+
return;
5992+
}
5993+
5994+
if ($body.find('[data-blc-surveillance-row]').length) {
5995+
return;
5996+
}
5997+
5998+
var message = tables[scope].emptyMessage;
5999+
if (!message) {
6000+
return;
6001+
}
6002+
6003+
var $empty = $('<tr data-blc-surveillance-empty><td class="blc-surveillance-table__empty" colspan="' + columnCount + '"></td></tr>');
6004+
$empty.find('td').text(message);
6005+
$body.append($empty);
6006+
});
6007+
6008+
$container.on('change', 'input[name$="[apply_to_all_terms]"]', function() {
6009+
syncApplyToAllState($(this));
6010+
});
6011+
}
6012+
58496013
fieldHelpApi = initFieldHelp();
58506014
initAdvancedSettings();
58516015
initSettingsModeToggle();
58526016
initLinksTableAjax();
6017+
initSurveillanceThresholds();
58536018

58546019
window.blcAdmin.helpers = window.blcAdmin.helpers || {};
58556020

0 commit comments

Comments
 (0)