Page MenuHomeSoftware Heritage

status-widget.js
No OneTemporary

status-widget.js

/**
* Copyright (C) 2020 The Software Heritage developers
* See the AUTHORS file at the top-level directory of this distribution
* License: GNU Affero General Public License version 3, or any later version
* See top-level LICENSE file for more information
*/
import './status-widget.css';
const statusCodeColor = {
'100': 'green', // Operational
'200': 'blue', // Scheduled Maintenance
'300': 'yellow', // Degraded Performance
'400': 'yellow', // Partial Service Disruption
'500': 'red', // Service Disruption
'600': 'red' // Security Event
};
export function initStatusWidget(statusDataURL) {
$('.swh-current-status-indicator').ready(async() => {
let maxStatusCode = '';
let maxStatusDescription = '';
let sc = '';
let sd = '';
try {
const response = await fetch(statusDataURL);
const data = await response.json();
for (let s of data.result.status) {
sc = s.status_code;
sd = s.status;
if (maxStatusCode < sc) {
maxStatusCode = sc;
maxStatusDescription = sd;
}
}
if (maxStatusCode === '') {
$('.swh-current-status').remove();
return;
}
$('.swh-current-status-indicator').removeClass('green');
$('.swh-current-status-indicator').addClass(statusCodeColor[maxStatusCode]);
$('#swh-current-status-description').text(maxStatusDescription);
} catch (e) {
console.log(e);
$('.swh-current-status').remove();
}
});
}

File Metadata

Mime Type
text/x-java
Expires
Thu, Jul 3, 12:17 PM (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3333687

Event Timeline