mirror of
https://github.com/nasa/openmct.git
synced 2025-05-08 03:28:33 +00:00
[Indicators] Implement CouchDB indicator
Initial implementation of an indicator which reflects current connection to CouchDB. WTD-608.
This commit is contained in:
parent
8cfcd2cd15
commit
c1ea620341
@ -5,18 +5,49 @@ define(
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
function CouchIndicator($http, $interval, PATH, INTERVAL) {
|
||||
function updateIndicator() {
|
||||
var CONNECTED = {
|
||||
text: "Connected",
|
||||
glyphClass: "ok"
|
||||
},
|
||||
DISCONNECTED = {
|
||||
text: "Disconnected",
|
||||
glyphClass: "err"
|
||||
},
|
||||
PENDING = {
|
||||
text: "Checking connection..."
|
||||
};
|
||||
|
||||
function CouchIndicator($http, $interval, PATH, INTERVAL) {
|
||||
var state = PENDING;
|
||||
|
||||
function handleError(err) {
|
||||
state = DISCONNECTED;
|
||||
}
|
||||
|
||||
function handleResponse(response) {
|
||||
var data = response.data;
|
||||
|
||||
state = data.error ? DISCONNECTED : CONNECTED;
|
||||
}
|
||||
|
||||
function updateIndicator() {
|
||||
$http.get(PATH).then(handleResponse, handleError);
|
||||
}
|
||||
|
||||
updateIndicator();
|
||||
$interval(updateIndicator, INTERVAL);
|
||||
|
||||
return {
|
||||
getGlyph: function () {
|
||||
return "D";
|
||||
},
|
||||
getGlyphClass: function () {
|
||||
return state.glyphClass;
|
||||
},
|
||||
getText: function () {
|
||||
return state.text;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user