2017-05-16 16:00:32 +02:00
|
|
|
/* exported store */
|
|
|
|
|
2017-05-16 19:18:35 +02:00
|
|
|
|
|
|
|
const store = {
|
|
|
|
'stats': {
|
|
|
|
'Clients': 0,
|
|
|
|
'ClientsWifi': 0,
|
|
|
|
'ClientsWifi24': 0,
|
|
|
|
'ClientsWifi5': 0,
|
|
|
|
'Firmwares': {},
|
|
|
|
'Gateways': 0,
|
|
|
|
'Models': {},
|
|
|
|
'Nodes': 0
|
|
|
|
}
|
2017-05-08 19:13:29 +02:00
|
|
|
};
|
|
|
|
|
2017-05-16 19:18:35 +02:00
|
|
|
(function init () {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const list = {},
|
|
|
|
toupdate = {};
|
|
|
|
|
|
|
|
function getNode (nodeid) {
|
|
|
|
let node = {};
|
|
|
|
|
|
|
|
if (toupdate[nodeid]) {
|
|
|
|
node = toupdate[nodeid];
|
|
|
|
} else if (list[nodeid]) {
|
|
|
|
node = list[nodeid];
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
// eslint-disable-next-line no-underscore-dangle
|
|
|
|
node._wireless = list[nodeid].wireless;
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
store.updateNode = function updateNode (node, real) {
|
|
|
|
if (real) {
|
|
|
|
list[node.node_id] = node;
|
|
|
|
} else {
|
|
|
|
toupdate[node.node_id] = node;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
store.getNode = getNode;
|
2017-05-15 21:59:48 +02:00
|
|
|
|
2017-05-16 19:18:35 +02:00
|
|
|
store.getNodes = function getNodes () {
|
|
|
|
return Object.keys(list).map(getNode);
|
|
|
|
};
|
2017-05-08 19:13:29 +02:00
|
|
|
})();
|