mirror of
https://github.com/nasa/openmct.git
synced 2025-05-08 11:38:35 +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 () {
|
function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function CouchIndicator($http, $interval, PATH, INTERVAL) {
|
var CONNECTED = {
|
||||||
function updateIndicator() {
|
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);
|
$interval(updateIndicator, INTERVAL);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getGlyph: function () {
|
getGlyph: function () {
|
||||||
return "D";
|
return "D";
|
||||||
|
},
|
||||||
|
getGlyphClass: function () {
|
||||||
|
return state.glyphClass;
|
||||||
|
},
|
||||||
|
getText: function () {
|
||||||
|
return state.text;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user