From fdb0478889a365ed5056eeea3b663fbe4281c6b9 Mon Sep 17 00:00:00 2001 From: JUDIT GRESKOVITS Date: Wed, 22 Mar 2017 13:21:44 +0000 Subject: [PATCH] Remove metrics and and settings and correct measurements --- .../src/components/metric-charts/index.js | 16 ++++++++------ frontend/src/containers/metrics/index.js | 21 +++++++++++++------ frontend/src/index.js | 16 +++++++++++--- frontend/src/mock-state-testing.json | 6 +++--- frontend/src/state/selectors.js | 17 ++++++++++----- 5 files changed, 53 insertions(+), 23 deletions(-) diff --git a/frontend/src/components/metric-charts/index.js b/frontend/src/components/metric-charts/index.js index a66f4bea..05477f25 100644 --- a/frontend/src/components/metric-charts/index.js +++ b/frontend/src/components/metric-charts/index.js @@ -37,24 +37,28 @@ const MetricCharts = ({ type, uuid }, index) => { - const onSelectChange = (evt) => - onDurationChange(Number(evt.target.value), uuid); + const handleSelectChange = (evt) => {}; + // onDurationChange(Number(evt.target.value), uuid); + const handleSettingsClick = (evt) => {}; + const handleRemoveMetric = (evt) => {}; return ( - + {type.name} + {/**/} - + {optionList} - + - + null; return ( + + ); + + /*return (
@@ -43,7 +52,7 @@ const Metrics = ({ onAddMetric={addMetric} />
- ); + );*/ }; Metrics.propTypes = { diff --git a/frontend/src/index.js b/frontend/src/index.js index 966cf318..4dd9b371 100644 --- a/frontend/src/index.js +++ b/frontend/src/index.js @@ -70,16 +70,26 @@ const getDataset = (twoHourLongDatasets, uuid) => { return twoHourLongDatasets.process_cpu_seconds_total; } if(isDisk(uuid)) { - return twoHourLongDatasets.process_heap_bytes; + return twoHourLongDatasets.process_heap_bytes.map((sample) => + [ + sample[0], + sample[1]/1024/1024 + ] + ); } if(isMemory(uuid)) { - return twoHourLongDatasets.node_memory_heap_used_bytes; + return twoHourLongDatasets.node_memory_heap_used_bytes.map((sample) => + [ + sample[0], + sample[1]/1024/1024 + ] + ); } }; const datasets = MockState.metrics.data.datasets.map((dataset, index) => { - const data = isCrazy(dataset.uuid) ? + const data = isCrazy(dataset.uuid) && dataset.uuid !== 'crazy-cpu' ? getDataset(leakTwoHourLongDatasets, dataset.uuid) : getDataset(normalTwoHourLongDatasets, dataset.uuid); diff --git a/frontend/src/mock-state-testing.json b/frontend/src/mock-state-testing.json index a224d1db..71550a2a 100644 --- a/frontend/src/mock-state-testing.json +++ b/frontend/src/mock-state-testing.json @@ -75,7 +75,7 @@ "id": "cpu-wait-time", "min": 0, "max": 100, - "measurement": "%" + "measurement": "bytes" }, { "uuid": "dca08514-72e5-46ce-ad91-e68b3b0914d7", "name": "Zfs used", @@ -96,14 +96,14 @@ "id": "load-average", "min": 0, "max": 20, - "measurement": "kb" + "measurement": " Mb" }, { "uuid": "dca08514-72e5-46ce-ad92-e68b3b0914d4", "name": "Memory", "id": "mem-agg-usage", "min": 0, "max": 100, - "measurement": "%" + "measurement": " Mb" }, { "uuid": "dca08514-72e5-46ce-ad93-e68b3b0914d4", "name": "Memory limit", diff --git a/frontend/src/state/selectors.js b/frontend/src/state/selectors.js index df294329..b85934cf 100644 --- a/frontend/src/state/selectors.js +++ b/frontend/src/state/selectors.js @@ -232,10 +232,16 @@ const metricByInterval = (data = [], { }; // TMP - get min and max for total data - START -const getMinMax = (data) => { +const getMinMax = (data, measurement) => { + if(measurement === '%') { + return { + min: 0, + max: 100 + }; + } const values = data.map((d) => Number(d[1])); - const min = statistics.min(values); - const max = statistics.max(values); + const min = Math.floor(statistics.min(values)); + const max = Math.ceil(statistics.max(values)); return { min, @@ -272,12 +278,13 @@ const datasets = ( ) => serviceOrInstanceMetrics.map((soim) => { const dataset = find(metricsData.datasets, ['uuid', soim.dataset]); + const type = find(metricsData.types, ['uuid', soim.type]); const dataSubset = getDataSubset(dataset.data, metricsUI, metricOptions); - const minMax = getMinMax(dataset.data); + const minMax = getMinMax(dataset.data, type.measurement); return ({ ...dataset, data: metricByInterval(dataSubset, minMax, metricOptions), - type: find(metricsData.types, ['uuid', soim.type]), + type: type, ...metricsUI[soim.dataset] }); });