mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 17:51:21 +00:00
Metric feeder as higher order component to feed sparklines data
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import React from 'react';
|
||||
import filesize from 'filesize';
|
||||
import d3 from 'd3';
|
||||
|
||||
const formatLargeValue = d3.format('s');
|
||||
|
||||
const formatters = {
|
||||
filesize(value) {
|
||||
@@ -8,11 +11,14 @@ const formatters = {
|
||||
},
|
||||
|
||||
number(value) {
|
||||
return value;
|
||||
if (value < 1100 && value >= 0) {
|
||||
return Number(value).toFixed(2);
|
||||
}
|
||||
return formatLargeValue(value);
|
||||
},
|
||||
|
||||
percent(value) {
|
||||
return formatters.metric(value, '%');
|
||||
return formatters.metric(formatters.number(value), '%');
|
||||
},
|
||||
|
||||
metric(text, unit) {
|
||||
|
||||
@@ -6,13 +6,13 @@ import { clearControlError, closeWebsocket, openWebsocket, receiveError,
|
||||
receiveControlPipe, receiveControlPipeStatus, receiveControlSuccess,
|
||||
receiveTopologies, receiveNotFound } from '../actions/app-actions';
|
||||
|
||||
import { API_INTERVAL, TOPOLOGY_INTERVAL } from '../constants/timer';
|
||||
|
||||
const wsProto = location.protocol === 'https:' ? 'wss' : 'ws';
|
||||
const wsUrl = wsProto + '://' + location.host + location.pathname.replace(/\/$/, '');
|
||||
const log = debug('scope:web-api-utils');
|
||||
|
||||
const apiTimerInterval = 10000;
|
||||
const reconnectTimerInterval = 5000;
|
||||
const topologyTimerInterval = apiTimerInterval;
|
||||
const updateFrequency = '5s';
|
||||
|
||||
let socket;
|
||||
@@ -95,14 +95,14 @@ export function getTopologies(options) {
|
||||
receiveTopologies(res);
|
||||
topologyTimer = setTimeout(function() {
|
||||
getTopologies(options);
|
||||
}, topologyTimerInterval / 2);
|
||||
}, TOPOLOGY_INTERVAL);
|
||||
},
|
||||
error: function(err) {
|
||||
log('Error in topology request: ' + err);
|
||||
receiveError(url);
|
||||
topologyTimer = setTimeout(function() {
|
||||
getTopologies(options);
|
||||
}, topologyTimerInterval / 2);
|
||||
}, TOPOLOGY_INTERVAL / 2);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -155,12 +155,12 @@ export function getApiDetails() {
|
||||
url: url,
|
||||
success: function(res) {
|
||||
receiveApiDetails(res);
|
||||
apiDetailsTimer = setTimeout(getApiDetails, apiTimerInterval);
|
||||
apiDetailsTimer = setTimeout(getApiDetails, API_INTERVAL);
|
||||
},
|
||||
error: function(err) {
|
||||
log('Error in api details request: ' + err);
|
||||
receiveError(url);
|
||||
apiDetailsTimer = setTimeout(getApiDetails, apiTimerInterval / 2);
|
||||
apiDetailsTimer = setTimeout(getApiDetails, API_INTERVAL / 2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user