1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-15 07:40:07 +02:00
copilot/frontend/src/index.js

105 lines
3.0 KiB
JavaScript
Raw Normal View History

2017-02-24 14:13:10 +02:00
import { IntlProvider } from 'react-intl-redux';
import { BrowserRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import a11y from 'react-a11y';
import ReactDOM from 'react-dom';
import React from 'react';
2017-02-24 14:13:10 +02:00
import App from '@containers/app';
2017-03-20 19:43:26 +02:00
// import MockState from './mock-state.json';
import MockStateTesting from './mock-state-testing.json';
2017-03-20 21:46:44 +02:00
import MockState from './mock-state.json';
import NormalDatasets from './dataset-leak.json';
import LeakDatasets from './dataset-normal.json';
2017-02-24 14:13:10 +02:00
import Store from '@state/store';
2016-10-20 04:14:26 +03:00
2016-10-25 22:36:05 +03:00
if (process.env.NODE_ENV !== 'production') {
a11y(React, {
ReactDOM
});
}
2017-03-20 19:43:26 +02:00
// TODO want ot be able to switch whic mock state to use
// based on a query string
const mockState = MockStateTesting;
2017-03-20 21:46:44 +02:00
// node_memory_rss_bytes
// node_memory_heap_total_bytes
// node_memory_heap_used_bytes
// process_heap_bytes
// process_resident_memory_bytes
// process_virtual_memory_bytes
// process_cpu_seconds_total
// process_cpu_system_seconds_total
// process_cpu_user_seconds_total
// node_lag_duration_milliseconds
// http_request_duration_milliseconds
// node_memory_rss_bytes
// node_memory_heap_total_bytes
// node_memory_heap_used_bytes
// process_heap_bytes
// process_resident_memory_bytes
// process_virtual_memory_bytes
// process_cpu_seconds_total
// process_cpu_system_seconds_total
// process_cpu_user_seconds_total
// node_lag_duration_milliseconds
// http_request_duration_milliseconds
2017-03-20 19:43:26 +02:00
2017-03-17 21:27:15 +02:00
// TMP - ensure datasets are at least 2 hrs long - START
import getTwoHourDatasets from './utils/two-hour-metric-datasets';
2017-03-20 21:46:44 +02:00
const leakTwoHourLongDatasets = getTwoHourDatasets(LeakDatasets);
const normalTwoHourLongDatasets = getTwoHourDatasets(NormalDatasets);
2017-03-17 21:27:15 +02:00
// TMP - ensure datasets are at least 2 hrs long - END
// TMP - plug fake metric data - START
2017-03-20 21:46:44 +02:00
const isCrazy = (uuid) => uuid === 'crazy-cpu' ||
uuid === 'crazy-disk' || uuid === 'crazy-memory';
const isCPU = (uuid) => uuid === 'crazy-cpu'
|| uuid === '3e6ee79a-7453-4fc6-b9da-7ae1e41138ec';
const isDisk = (uuid) => uuid === 'crazy-disk'
|| uuid === '4e6ee79a-7453-4fc6-b9da-7ae1e41138ed';
const isMemory = (uuid) => uuid === 'crazy-memory'
|| uuid === '6e6ee79a-7453-4fc6-b9da-7ae1e41138ed';
const getDataset = (twoHourLongDatasets, uuid) => {
if(isCPU(uuid)) {
return twoHourLongDatasets.process_cpu_seconds_total;
}
if(isDisk(uuid)) {
return twoHourLongDatasets.process_heap_bytes;
}
if(isMemory(uuid)) {
return twoHourLongDatasets.node_memory_heap_used_bytes;
}
};
const datasets = MockState.metrics.data.datasets.map((dataset, index) => {
const data = isCrazy(dataset.uuid) ?
getDataset(leakTwoHourLongDatasets, dataset.uuid) :
getDataset(normalTwoHourLongDatasets, dataset.uuid);
2017-03-17 21:27:15 +02:00
return {
...dataset,
2017-03-20 21:46:44 +02:00
data: data
2017-03-17 21:27:15 +02:00
};
});
2017-03-20 19:43:26 +02:00
mockState.metrics.data.datasets = datasets;
2017-03-17 21:27:15 +02:00
// TMP - plug fake metric data - END
ReactDOM.render(
2017-03-20 19:43:26 +02:00
<Provider store={Store(mockState)}>
2017-02-24 14:13:10 +02:00
<IntlProvider>
<BrowserRouter>
<App />
</BrowserRouter>
</IntlProvider>
</Provider>,
document.getElementById('root')
);