5163bf2853
* adds LinkStatus component to NavHeader to display banner with HCP link status * adds changelog entry * adds period to connected status message * updates hcp link status to current cluster polling to automatically update state
27 lines
1,019 B
JavaScript
27 lines
1,019 B
JavaScript
export default function (server) {
|
|
const handleResponse = (req, props) => {
|
|
const xhr = req.passthrough();
|
|
xhr.onreadystatechange = () => {
|
|
if (xhr.readyState === 4 && xhr.status < 300) {
|
|
// XMLHttpRequest response prop only has a getter -- redefine as writable and set value
|
|
Object.defineProperty(xhr, 'response', {
|
|
writable: true,
|
|
value: JSON.stringify({
|
|
...JSON.parse(xhr.responseText),
|
|
...props,
|
|
}),
|
|
});
|
|
}
|
|
};
|
|
};
|
|
|
|
server.get('sys/seal-status', (schema, req) => {
|
|
// randomly return one of the various states to test polling
|
|
// 401 and 500 are stubs -- update with actual API values once determined
|
|
const hcp_link_status = ['connected', 'disconnected', '401', '500'][Math.floor(Math.random() * 2)];
|
|
return handleResponse(req, { hcp_link_status });
|
|
});
|
|
// enterprise only feature initially
|
|
server.get('sys/health', (schema, req) => handleResponse(req, { version: '1.12.0-dev1+ent' }));
|
|
}
|