feat(ui) - custom metrics - chart click handler

This commit is contained in:
Shekar Siri 2022-02-08 14:59:52 +01:00
parent ec2eff546a
commit 7ec1788f6b
3 changed files with 12 additions and 8 deletions

View file

@ -75,9 +75,12 @@ function CustomMetricWidget(props: Props) {
}, [period])
const clickHandler = (event, index) => {
const timestamp = event.activePayload[0].payload.timestamp;
const { startTimestamp, endTimestamp } = getStartAndEndTimestampsByDensity(timestamp, period.start, period.end, params.density);
props.setActiveWidget({ widget: metric, startTimestamp, endTimestamp, timestamp: event.activePayload[0].payload.timestamp, index })
if (event) {
const payload = event.activePayload[0].payload;
const timestamp = payload.timestamp;
const { startTimestamp, endTimestamp } = getStartAndEndTimestampsByDensity(timestamp, period.start, period.end, params.density);
props.setActiveWidget({ widget: metric, startTimestamp, endTimestamp, timestamp: payload.timestamp, index })
}
}
const updateActiveState = (metricId, state) => {

View file

@ -1,4 +1,3 @@
import { edit } from 'App/components/ui/ItemMenu/itemMenu.css';
import React, { useState, useRef, useEffect } from 'react';
import { Icon } from 'UI';

View file

@ -131,12 +131,14 @@ export function fetch(id) {
}
}
export function save(instance) {
return {
export const save = (instance) => (dispatch, getState) => {
return dispatch({
types: SAVE.array,
call: client => client.post( `/${ instance.exists() ? name + 's/' + instance[idKey] : name + 's'}`, instance.toSaveData()),
};
}
}).then(() => {
dispatch(fetchList());
});
};
export function fetchList() {
return {