diff --git a/lib/config-template.php b/lib/config-template.php index 4d6e38b6771647d2feb85f240048e2b3b66bcb98..61665272f8901e661ba5249fe94bdde5a36be4c0 100644 --- a/lib/config-template.php +++ b/lib/config-template.php @@ -44,9 +44,12 @@ define('BACK_TIME_ENTITIES', '14 days'); // the log level use 3 or less for normal production define('LOG_LEVEL',5); // number of seconds to the expire time that causes the warning icon being shown -define('VALIDITY_WARNING_THRESHOLD', 388800); +define('VALIDITY_WARNING_THRESHOLD', 388800); // 108h - 4.5days // number of seconds to the expire time that causes the alert icon being shown -define('VALIDITY_ALERT_THRESHOLD', 10800); +define('VALIDITY_ALERT_THRESHOLD', 10800); // 3h +// number of seconds to the expire that the federation will be shown in red +define('ISSUES_ALERT_THRESHOLD', 129600); // 36h + // The settings below can probably stay as they are // @@ -68,6 +71,7 @@ define('WHATS_NEW_URL', ROOT_URL.'/whatsnew'); define('SYSTEM_UPDATES', 'https://wiki.geant.org/display/eduGAIN/eduGAIN+Services+Status'); define('V2_AUDIT', ROOT_URL.'/compliance_audit'); define('LINK_TESTS', ROOT_URL.'/link_tests'); +define('ISSUES_URL', ROOT_URL.'/issues'); // contacts define('EDUGAIN_EMAIL', 'edugain@geant.org'); diff --git a/page-logic/issues.php b/page-logic/issues.php new file mode 100644 index 0000000000000000000000000000000000000000..c9189a07341b9cf5ff82db0504f2b037468c2def --- /dev/null +++ b/page-logic/issues.php @@ -0,0 +1,81 @@ +<?php +require_once(eduGAIN_config . 'database_ro.php'); + +function formatSec($inSeconds) { + $inSec = abs($inSeconds); + $inMin = floor($inSec / 60); + $sec = $inSec - 60 * $inMin; + $inHours = floor ($inMin / 60); + $min = $inMin - 60 * $inHours; + $days = floor ($inHours / 24); + $hours = $inHours - 24 * $days; + return $days."d ".$hours."h ".$min."min ".$sec."s"; +} + +function prepareFederationFields($federation) { + $out = [ + 'fed' => $federation['code'], + 'name' => $federation['name'], + 'countries' => $federation['countries'], + 'color' => $federation['valid_sec'] < ISSUES_ALERT_THRESHOLD ? "red" : "#F1893B", + 'creationinstant' => [ + 'value' => $federation['creationinstant'], + 'display_title' => 'Metadata creation time', + ], + 'valid_until' => [ + 'value' => $federation['valid_until'], + 'display_title' => 'Metadata valid until', + ], + 'feed_pull_time' => [ + 'value' => $federation['feed_pull_time'], + 'display_title' => 'Last metadata pull', + ], + 'last_validation' => [ + 'value' => $federation['last_validation'], + 'display_title' => 'Last successful validation', + ], + 'feed_problem_desc' => [ + 'value' => $federation['feed_problem_desc'] ?? $federation['feed_problem_desc'] ?? "The feed is close to expiry", + 'display_title' => 'Issue', + ], + 'still_valid' => [ + 'value' => formatSec($federation['valid_sec']), + ], + 'valid_timestamp' => [ + 'value' => $federation['valid_timestamp'] + ], + 'contact_email' => [ + 'value' => $federation['contact_email'], + 'display_title' => 'Federation contact', + ], + 'valid_sec' => [ + 'value' => $federation['valid_sec'], + ], + ]; + return($out); +} + +$edugain = new eduGAIN(5); +$edugain->load_federations_state(); +$edugain->load_federation_map_codes(); +$edugain->load_federation_country_names(); +$out = []; +$tmp = []; +$times = []; +$now = time(); +foreach ($edugain->FEDS as $fed) { + if ($fed['valid_sec'] < VALIDITY_WARNING_THRESHOLD || $fed['feed_problem'] > 0 ) { + $fields = prepareFederationFields($fed); + $tmp[$fed['code']] = $fields; + $times[$fed['code']] = $fields['valid_timestamp']; + } +} + +asort($times); + +foreach ($times as $fed => $tm) { + $out[$fed] = $tmp[$fed]; +} + +$data['feds'] = $out; +echo $twig->render('issues.html', $data); \ No newline at end of file diff --git a/templates/issues.html b/templates/issues.html new file mode 100644 index 0000000000000000000000000000000000000000..d78c337cde4fa7a06ac163e7f1af1514b0f7f12e --- /dev/null +++ b/templates/issues.html @@ -0,0 +1,56 @@ +{% extends 'common/master.html' %} +{% import 'status/status-members-field-macros.html' as display %} +{% set breadcrumb = ['Members', 'Current issues'] %} +{% block title %}Federation issues{% endblock title %} +{% block main_body %} + +<div class="central-section"> + This page shows federations with potential issues. The list is ordered putting federations closest to expiry on top.<br/> +{% if feds|length > 0 %} + +<strong>All times are in UTC.</strong>. +<p> + + + <table id="issues"> + +{% for federation in feds %} + <tr> + <td colspan="2" class="issues-title" style="background-color: {{ federation.color }}">{{ federation.name }} {% if federation.countries is defined %} ({{federation.countries|join(', ')}}){% endif %} + {% if federation.valid_sec.value < 0 %} + - expired {{ federation.still_valid.value }} ago + {% else %} + - still valid {{ federation.still_valid.value }} + {% endif %}</td> + </tr> + <tr> + <th>{{ federation.feed_problem_desc.display_title }}</th><!-- comment --> + <td>{{ federation.feed_problem_desc.value }}</td><!-- comment --> + </tr> + <tr> + <th>{{ federation.creationinstant.display_title }}</th><!-- comment --> + <td>{{ federation.creationinstant.value | date("Y-m-d H:i:s") }}</td><!-- comment --> + </tr> + <tr> + <th>{{ federation.valid_until.display_title }}</th><!-- comment --> + <td>{{ federation.valid_until.value | date("Y-m-d H:i:s") }}</td><!-- comment --> + </tr> + <tr> + <th>{{ federation.feed_pull_time.display_title }}</th><!-- comment --> + <td>{{ federation.feed_pull_time.value | date("Y-m-d H:i:s") }}</td><!-- comment --> + </tr> + <tr> + <th>{{ federation.last_validation.display_title }}</th><!-- comment --> + <td>{{ federation.last_validation.value | date("Y-m-d H:i:s") }}</td><!-- comment --> + </tr> + <tr> + <th>{{ federation.contact_email.display_title }}</th><!-- comment --> + <td><a href="mailto:{{ federation.contact_email.value }}">{{ federation.contact_email.value }}</a></td><!-- comment --> + </tr> +{% endfor %} + </table> +{% else %} +<h1>Currently there are no issues</h1><!-- comment --> +{% endif %} +</div> +{% endblock main_body %} diff --git a/web/css/master.css b/web/css/master.css index 8b6823a57a6d69d7d8e9a229d668f5f124d68624..33cebb7b3b73ee4a508499d93155a5fde4000af5 100644 --- a/web/css/master.css +++ b/web/css/master.css @@ -400,3 +400,24 @@ div.api-help dt { top: 50%; display: none; } + +#issues { + font-size: 14px; +} + +#issues td.issues-title { + font-size: 1.2em; + background-color: #F1893B; + color: #FFF; + padding-left: 0.5em; + padding-right: 1em; +} + +#issues td { + +} + +#issues th { + text-align: left; + padding-left: 2em; +}