develop #4
@@ -107,13 +107,27 @@
|
|||||||
var promEl = document.getElementById('source-status-prometheus');
|
var promEl = document.getElementById('source-status-prometheus');
|
||||||
var osEl = document.getElementById('source-status-openstack');
|
var osEl = document.getElementById('source-status-openstack');
|
||||||
if (!promEl || !osEl) return;
|
if (!promEl || !osEl) return;
|
||||||
fetch('/api/source-status/').then(function(r) { return r.ok ? r.json() : {}; }).then(function(data) {
|
fetch('/api/source-status/')
|
||||||
updateSourceStatus(promEl, 'Prometheus', data.prometheus);
|
.then(function(r) {
|
||||||
updateSourceStatus(osEl, 'OpenStack', data.openstack);
|
if (r.ok) return r.json().then(function(data) { return { data: data }; });
|
||||||
}).catch(function() {
|
return r.json().catch(function() { return {}; }).then(function(body) {
|
||||||
updateSourceStatus(promEl, 'Prometheus', { status: 'error', message: 'Failed to fetch status' });
|
return { error: true, message: (body && body.message) || 'Failed to fetch status' };
|
||||||
updateSourceStatus(osEl, 'OpenStack', { status: 'error', message: 'Failed to fetch status' });
|
});
|
||||||
});
|
})
|
||||||
|
.then(function(result) {
|
||||||
|
if (result && result.error) {
|
||||||
|
updateSourceStatus(promEl, 'Prometheus', { status: 'error', message: result.message });
|
||||||
|
updateSourceStatus(osEl, 'OpenStack', { status: 'error', message: result.message });
|
||||||
|
} else {
|
||||||
|
var data = result && result.data;
|
||||||
|
updateSourceStatus(promEl, 'Prometheus', data && data.prometheus);
|
||||||
|
updateSourceStatus(osEl, 'OpenStack', data && data.openstack);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(function() {
|
||||||
|
updateSourceStatus(promEl, 'Prometheus', { status: 'error', message: 'Failed to fetch status' });
|
||||||
|
updateSourceStatus(osEl, 'OpenStack', { status: 'error', message: 'Failed to fetch status' });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user