From e2ce31b555a9eaae1d90538e32a22815097f53fb Mon Sep 17 00:00:00 2001 From: manus-admin Date: Sat, 24 Oct 2026 09:27:58 +0000 Subject: [PATCH] fix: isoler Santelis hors inventaire dashboard --- index.html | 7 +++++-- test/portal-contract.test.js | 14 +++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 35d0517..999026b 100644 --- a/index.html +++ b/index.html @@ -60,18 +60,21 @@ }; var LEGACY_REDIRECTS = { 'portail.recette.santinova-soft.org': 'https://portail-santinova.recette.santinova-soft.org/', 'portail.santinova-soft.org': 'https://portail-santinova.santinova-soft.org/' }; var PORTAL_DEFINITIONS = [ { group:'ITINOVA',label:'Itinova',host:'portail-itinova' }, { group:'SOINS_ET_SANTE',label:'Soins et Santé',host:'portail-soins-et-sante' }, { group:'SANTINOVA',label:'Santinova',host:'portail-santinova' }, { group:'SANTELIS',label:'SANTELIS',host:'portail-santelis' } ]; + /* SANTELIS Gestion est déployée uniquement en production et volontairement hors inventaire Dashboard. */ + var PORTAL_ONLY_APPS = [{ id:'santelis-gestion', name:'SANTELIS Gestion', urls:{ prod:'https://gestion-santelis.santinova-soft.org' }, image:'images/santelis-gestion.jpg' }]; var STATUS_REFRESH_MS = 30000, APPS_REFRESH_MS = 300000, APP_IMAGE_OVERRIDES = { 'santelis-gestion': 'images/santelis-gestion.jpg' }, hasRenderedApps = false; function normalizeHostname(value) { return String(value || '').toLowerCase().replace(/\.$/, ''); } function getPortalUrl(definition, env) { return 'https://' + definition.host + (env === 'recette' ? '.recette' : '') + '.santinova-soft.org/'; } function resolvePortalConfig(hostname) { var config = PORTAL_CONFIGS[normalizeHostname(hostname)]; if (!config) return null; var origin = config.env === 'recette' ? 'https://dashboard.recette.santinova-soft.org' : 'https://dashboard.santinova-soft.org'; return Object.assign({}, config, { dashboardAppsUrl: origin + '/api/public/apps', dashboardStatusUrl: origin + '/api/public/status', envLabel: config.env === 'recette' ? 'Recette' : 'Production' }); } function isHttpsUrl(value) { try { return new URL(value).protocol === 'https:'; } catch (error) { return false; } } function isOffline(app) { return app.status === 'offline' || app.status === 'error' || app.containerRunning === false; } - function isAppInCurrentPortal(app) { if (!PORTAL || !app || !isHttpsUrl(app.urls && app.urls[PORTAL.env])) return false; if (PORTAL.group === 'SANTELIS') return app.id === 'santelis-gestion'; if (app.id === 'santelis-gestion') return false; if (PORTAL.group === 'SANTINOVA') return app.category === 'SANTINOVA' || app.category === 'INFRA'; return app.category === PORTAL.group; } + function getPortalOnlyApps() { if (!PORTAL || PORTAL.env !== 'prod' || PORTAL.group !== 'SANTELIS') return []; return PORTAL_ONLY_APPS.filter(function(app) { return isHttpsUrl(app.urls && app.urls[PORTAL.env]); }); } + function isAppInCurrentPortal(app) { if (!PORTAL || !app || !isHttpsUrl(app.urls && app.urls[PORTAL.env])) return false; if (app.id === 'santelis-gestion') return false; if (PORTAL.group === 'SANTINOVA') return app.category === 'SANTINOVA' || app.category === 'INFRA'; return app.category === PORTAL.group; } function escapeHtml(value) { return String(value || '').replace(/[&<>'"]/g, function(character) { return ({ '&':'&', '<':'<', '>':'>', "'":''', '"':'"' })[character]; }); } function buildCard(app) { var url = app.urls && app.urls[PORTAL.env], image = APP_IMAGE_OVERRIDES[app.id] || app.image || ('images/' + app.id + '.png'), offline = isOffline(app); return '
' + escapeHtml(app.name) + '
' + escapeHtml(app.name) + '
' + PORTAL.envLabel + '
Hors ligne
'; } function renderNavigation() { document.getElementById('entity-nav').innerHTML = PORTAL_DEFINITIONS.map(function(definition) { var active = definition.group === PORTAL.group; return '' + definition.label + ''; }).join(''); } function setPortalIdentity() { document.documentElement.style.setProperty('--accent', PORTAL.accent); document.title = PORTAL.title + ' — Santinova Soft'; document.getElementById('portal-title').textContent = PORTAL.title; document.getElementById('portal-subtitle').textContent = 'Environnement de ' + PORTAL.envLabel.toLowerCase(); document.getElementById('environment-badge').textContent = PORTAL.envLabel; document.getElementById('entity-heading').firstChild.nodeValue = PORTAL.title; document.getElementById('entity-description').textContent = 'Applications déployées dans l’environnement ' + PORTAL.envLabel.toLowerCase() + '.'; renderNavigation(); } - function renderApps(apps) { var visibleApps = apps.filter(isAppInCurrentPortal), grid = document.getElementById('apps-grid'); grid.innerHTML = visibleApps.length ? visibleApps.map(buildCard).join('') : '
Aucune application déployée pour ce portail.
'; document.getElementById('app-count').textContent = visibleApps.length; hasRenderedApps = true; } + function renderApps(apps) { var visibleApps = apps.filter(isAppInCurrentPortal).concat(getPortalOnlyApps()), grid = document.getElementById('apps-grid'); grid.innerHTML = visibleApps.length ? visibleApps.map(buildCard).join('') : '
Aucune application déployée pour ce portail.
'; document.getElementById('app-count').textContent = visibleApps.length; hasRenderedApps = true; } async function requestJson(url) { var controller = new AbortController(), timeoutId = setTimeout(function() { controller.abort(); }, 8000); try { var response = await fetch(url, { cache:'no-store', signal:controller.signal }); if (!response.ok) throw new Error('HTTP ' + response.status); return await response.json(); } finally { clearTimeout(timeoutId); } } async function fetchAndApplyStatuses() { try { var statuses = await requestJson(PORTAL.dashboardStatusUrl); if (!Array.isArray(statuses)) return; var byId = new Map(statuses.map(function(status) { return [status.id,status]; })); document.querySelectorAll('.app-card[data-app-id]').forEach(function(card) { var status = byId.get(card.getAttribute('data-app-id')); if (!status) return; var offline = isOffline(status); card.classList.toggle('offline', offline); card.setAttribute('aria-disabled', String(offline)); }); } catch (error) { console.warn('[Portail] Mise à jour des statuts impossible :', error.message); } } async function loadApps() { try { var apps = await requestJson(PORTAL.dashboardAppsUrl); if (!Array.isArray(apps)) throw new Error('réponse applications invalide'); renderApps(apps); await fetchAndApplyStatuses(); } catch (error) { console.warn('[Portail] Chargement des applications impossible :', error.message); if (!hasRenderedApps) { document.getElementById('apps-grid').innerHTML = '
Dashboard indisponible — veuillez réessayer.
'; document.getElementById('app-count').textContent = '!'; } } } diff --git a/test/portal-contract.test.js b/test/portal-contract.test.js index 66393cd..d302927 100644 --- a/test/portal-contract.test.js +++ b/test/portal-contract.test.js @@ -118,7 +118,7 @@ const expectedVisible = { [hosts.itinovaRecette]: ['itinova-contacts'], [hosts.soinsRecette]: ['gestion-astreintes-had'], [hosts.santinovaRecette]: ['demat-facturation-dsi', 'referentiel-ia'], - [hosts.santelisRecette]: ['santelis-gestion'] + [hosts.santelisRecette]: [] }; for (const [host, ids] of Object.entries(expectedVisible)) { @@ -127,6 +127,18 @@ for (const [host, ids] of Object.entries(expectedVisible)) { assert.deepEqual(visible, ids, `${host} ne doit afficher que les tuiles de son portail`); } +const santelisProductionPortal = loadPortal(hosts.santelisProd).sandbox; +assert.deepEqual( + Array.from(santelisProductionPortal.getPortalOnlyApps(), app => app.id), + ['santelis-gestion'], + 'SANTELIS Gestion doit être fournie par le portail production sans être publiée par le dashboard' +); +assert.equal( + santelisProductionPortal.getPortalOnlyApps()[0].urls.prod, + 'https://gestion-santelis.santinova-soft.org', + 'la tuile SANTELIS doit cibler son URL de production validée' +); + for (const imageName of ['budget-si.jpg', 'gestion-astreintes-had.jpg', 'gestion-indus-had.jpg', 'santelis-gestion.jpg', 'santino-chat.png']) { const imagePath = path.join(root, 'images', imageName); assert.equal(fs.existsSync(imagePath), true, `l’asset ${imageName} doit être publié`);