From bf6c4e9f5d8ff041eea41315137cc05311ec7358 Mon Sep 17 00:00:00 2001 From: jlampar Date: Mon, 11 Jun 2018 14:04:58 +0200 Subject: [PATCH] moving safecomposeID to state --- .../priv/src/actions/CollectingActions.js | 17 ++++++++++++++++- .../src/components/monitoring/Graph/Graph.jsx | 3 +-- .../monitoring/GraphPanel/GraphPanel.jsx | 5 +++-- .../monitoring/Monitoring/Monitoring.jsx | 3 +++ .../MonitoringContainer/MonitoringContainer.jsx | 2 ++ apps/xprof_gui/priv/src/reducers/monitoring.js | 6 ++++++ 6 files changed, 31 insertions(+), 5 deletions(-) diff --git a/apps/xprof_gui/priv/src/actions/CollectingActions.js b/apps/xprof_gui/priv/src/actions/CollectingActions.js index 32ffc4a3..fbfd64db 100644 --- a/apps/xprof_gui/priv/src/actions/CollectingActions.js +++ b/apps/xprof_gui/priv/src/actions/CollectingActions.js @@ -9,7 +9,12 @@ import { getStatus, } from '../selectors'; import { setCallsControl, getCalleesForFunctions } from './'; -import { determineNextData, determineNextCalls, roll } from '../utils'; +import { + determineNextData, + determineNextCalls, + roll, + safecomposeID, +} from '../utils'; export const updateListMonitoringFunctions = monitoredCollection => ({ type: types.UPDATE_MONITORED_FUNCTIONS, @@ -39,8 +44,17 @@ const updateSize = (property, value) => ({ export const getMonitoredFunctions = () => async (dispatch, getState) => { const state = getState(); + const ids = getIDs(state); + const identifiedFunctions = Object.keys(ids); const monitoredCollection = getAllMonitored(state); + monitoredCollection.forEach((monitored) => { + if (!identifiedFunctions.includes(monitored.query)) { + const id = safecomposeID(monitored.query); + ids[monitored.query] = id; + } + }); + const { json, error } = await XProf.getAllMonitoredFunctions(); if (error) { console.log('ERROR: ', error); @@ -61,6 +75,7 @@ export const getMonitoredFunctions = () => async (dispatch, getState) => { {}, ); + dispatch(updateIDs(ids)); dispatch(getCalleesForFunctions(newMonitoredCollection)); dispatch(setCallsControl(newControls)); dispatch(updateListMonitoringFunctions(json)); diff --git a/apps/xprof_gui/priv/src/components/monitoring/Graph/Graph.jsx b/apps/xprof_gui/priv/src/components/monitoring/Graph/Graph.jsx index 6c96e684..1ff1a8ac 100644 --- a/apps/xprof_gui/priv/src/components/monitoring/Graph/Graph.jsx +++ b/apps/xprof_gui/priv/src/components/monitoring/Graph/Graph.jsx @@ -2,8 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import GridGraph from '../GridGraph'; import LineGraph from '../LineGraph'; -import { GRAPH_TYPE } from '../../../constants/GraphTypes'; -import { GRAPH_INITIAL_SIZE } from '../../../constants'; +import { GRAPH_INITIAL_SIZE, GRAPH_TYPE } from '../../../constants'; const defaultProps = { size: GRAPH_INITIAL_SIZE, diff --git a/apps/xprof_gui/priv/src/components/monitoring/GraphPanel/GraphPanel.jsx b/apps/xprof_gui/priv/src/components/monitoring/GraphPanel/GraphPanel.jsx index 6830066a..dc88fd54 100644 --- a/apps/xprof_gui/priv/src/components/monitoring/GraphPanel/GraphPanel.jsx +++ b/apps/xprof_gui/priv/src/components/monitoring/GraphPanel/GraphPanel.jsx @@ -2,7 +2,6 @@ import PropTypes from 'prop-types'; import React from 'react'; import { Graph, GraphPanelHeading } from '../'; import { GRAPH_INITIAL_SIZE } from '../../../constants'; -import { safecomposeID } from '../../../utils'; const defaultProps = { dps: [], @@ -30,6 +29,7 @@ const propTypes = { calleeClick: PropTypes.func.isRequired, setSize: PropTypes.func.isRequired, size: PropTypes.shape(PropTypes.any), + ids: PropTypes.shape(PropTypes.any).isRequired, }; const GraphPanel = ({ @@ -46,8 +46,9 @@ const GraphPanel = ({ calleeClick, setSize, size, + ids, }) => { - const monitoredID = safecomposeID(monitored.query); + const monitoredID = ids[monitored.query]; return (
@@ -77,6 +79,7 @@ class Monitoring extends React.Component { calleeClick={calleeClick} setSize={setSize} size={size} + ids={ids} />
); diff --git a/apps/xprof_gui/priv/src/containers/MonitoringContainer/MonitoringContainer.jsx b/apps/xprof_gui/priv/src/containers/MonitoringContainer/MonitoringContainer.jsx index 0aa6532f..d23f93fe 100644 --- a/apps/xprof_gui/priv/src/containers/MonitoringContainer/MonitoringContainer.jsx +++ b/apps/xprof_gui/priv/src/containers/MonitoringContainer/MonitoringContainer.jsx @@ -18,6 +18,7 @@ import { getFunctionCalleesVisibility, getFunctionGraphVisibility, getSize, + getIDs, } from '../../selectors'; const MonitoringContainer = props => ; @@ -32,6 +33,7 @@ const mapStateToProps = (state, ownProps) => ({ ), panelVisibility: getFunctionGraphVisibility(state, ownProps.monitored.query), size: getSize(state), + ids: getIDs(state), }); const mapDispatchToProps = { diff --git a/apps/xprof_gui/priv/src/reducers/monitoring.js b/apps/xprof_gui/priv/src/reducers/monitoring.js index 9d7aec18..e3fb1231 100644 --- a/apps/xprof_gui/priv/src/reducers/monitoring.js +++ b/apps/xprof_gui/priv/src/reducers/monitoring.js @@ -5,6 +5,7 @@ const initialState = { data: {}, panel: {}, callees: {}, + ids: {}, size: { width: 0, height: 0, @@ -37,6 +38,11 @@ const monitoring = (state = initialState, action) => { [action.property]: action.value, }, }; + case types.ASSIGN_GRAPH_ID: + return { + ...state, + ids: action.ids, + }; default: return state; }