Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9314241
status-widget.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
status-widget.js
View Options
/**
* 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
Details
Attached
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
Attached To
rDWAPPS Web applications
Event Timeline
Log In to Comment