diff --git a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricPieChart/CustomMetricPieChart.tsx b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricPieChart/CustomMetricPieChart.tsx index 6d1cd01e4..76b8697c1 100644 --- a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricPieChart/CustomMetricPieChart.tsx +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricPieChart/CustomMetricPieChart.tsx @@ -9,8 +9,6 @@ import { numberWithCommas } from 'App/utils'; interface Props { metric: any, data: any; - params: any; - // seriesMap: any; colors: any; onClick?: (filters) => void; } diff --git a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricTableSessions/CustomMetricTableSessions.tsx b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricTableSessions/CustomMetricTableSessions.tsx new file mode 100644 index 000000000..4bd4cb983 --- /dev/null +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricTableSessions/CustomMetricTableSessions.tsx @@ -0,0 +1,16 @@ +import React from 'react'; + +interface Props { + data: any + metric?: any + isTemplate?: boolean; +} +function CustomMetricTableSessions(props: Props) { + return ( +
+ +
+ ); +} + +export default CustomMetricTableSessions; \ No newline at end of file diff --git a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricTableSessions/index.ts b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricTableSessions/index.ts new file mode 100644 index 000000000..46889345c --- /dev/null +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricTableSessions/index.ts @@ -0,0 +1 @@ +export { default } from './CustomMetricTableSessions'; \ No newline at end of file diff --git a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricWidgetPreview/CustomMetricWidgetPreview.tsx b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricWidgetPreview/CustomMetricWidgetPreview.tsx index 5f90e01ac..f248fbc89 100644 --- a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricWidgetPreview/CustomMetricWidgetPreview.tsx +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricWidgetPreview/CustomMetricWidgetPreview.tsx @@ -1,28 +1,24 @@ import React, { useEffect, useState, useRef } from 'react'; import { connect } from 'react-redux'; -import { Loader, NoContent, SegmentSelection, Icon } from 'UI'; +import { Loader, NoContent, SegmentSelection } from 'UI'; import { Styles } from '../../common'; -// import { ResponsiveContainer, XAxis, YAxis, CartesianGrid, Tooltip, LineChart, Line, Legend } from 'recharts'; -import Period, { LAST_24_HOURS, LAST_30_MINUTES, YESTERDAY, LAST_7_DAYS } from 'Types/app/period'; +import Period from 'Types/app/period'; import stl from './CustomMetricWidgetPreview.module.css'; -import { getChartFormatter } from 'Types/dashboard/helper'; import { remove } from 'Duck/customMetrics'; import DateRange from 'Shared/DateRange'; import { edit } from 'Duck/customMetrics'; import CustomMetriLineChart from '../CustomMetriLineChart'; import CustomMetricPercentage from '../CustomMetricPercentage'; import CustomMetricTable from '../CustomMetricTable'; - -import APIClient from 'App/api_client'; import CustomMetricPieChart from '../CustomMetricPieChart'; -const customParams = rangeName => { +const customParams = (rangeName: string) => { const params = { density: 70 } - if (rangeName === LAST_24_HOURS) params.density = 70 - if (rangeName === LAST_30_MINUTES) params.density = 70 - if (rangeName === YESTERDAY) params.density = 70 - if (rangeName === LAST_7_DAYS) params.density = 70 + // if (rangeName === LAST_24_HOURS) params.density = 70 + // if (rangeName === LAST_30_MINUTES) params.density = 70 + // if (rangeName === YESTERDAY) params.density = 70 + // if (rangeName === LAST_7_DAYS) params.density = 70 return params } @@ -30,23 +26,18 @@ const customParams = rangeName => { interface Props { metric: any; data?: any; - showSync?: boolean; - // compare?: boolean; onClickEdit?: (e) => void; remove: (id) => void; edit: (metric) => void; } function CustomMetricWidget(props: Props) { - const { metric, showSync } = props; + const { metric } = props; const [loading, setLoading] = useState(false) const [data, setData] = useState({ chart: [{}] }) - const [seriesMap, setSeriesMap] = useState([]); const [period, setPeriod] = useState(Period({ rangeName: metric.rangeName, startDate: metric.startDate, endDate: metric.endDate })); const colors = Styles.customMetricColors; const params = customParams(period.rangeName) - const gradientDef = Styles.gradientDef(); - const metricParams = { ...params, metricId: metric.metricId, viewType: 'lineChart' } const prevMetricRef = useRef(); const isTimeSeries = metric.metricType === 'timeseries'; const isTable = metric.metricType === 'table'; @@ -59,29 +50,6 @@ function CustomMetricWidget(props: Props) { }; prevMetricRef.current = metric; setLoading(true); - - // fetch new data for the widget preview - // new APIClient()['post']('/custom_metrics/try', { ...metricParams, ...metric.toSaveData() }) - // .then(response => response.json()) - // .then(({ errors, data }) => { - // if (errors) { - // console.log('err', errors) - // } else { - // const namesMap = data - // .map(i => Object.keys(i)) - // .flat() - // .filter(i => i !== 'time' && i !== 'timestamp') - // .reduce((unique: any, item: any) => { - // if (!unique.includes(item)) { - // unique.push(item); - // } - // return unique; - // }, []); - - // setSeriesMap(namesMap); - // setData(getChartFormatter(period)(data)); - // } - // }).finally(() => setLoading(false)); }, [metric]) const onDateChange = (changedDates) => { @@ -185,7 +153,6 @@ function CustomMetricWidget(props: Props) { metric={metric} data={data[0]} colors={colors} - params={params} /> )} diff --git a/frontend/app/components/Dashboard/components/WidgetForm/WidgetForm.tsx b/frontend/app/components/Dashboard/components/WidgetForm/WidgetForm.tsx index 0ba99c29d..9d95fc503 100644 --- a/frontend/app/components/Dashboard/components/WidgetForm/WidgetForm.tsx +++ b/frontend/app/components/Dashboard/components/WidgetForm/WidgetForm.tsx @@ -36,17 +36,22 @@ function WidgetForm(props: Props) { // const write = ({ target: { value, name } }) => metricStore.merge({ [ name ]: value }); const writeOption = ({ value, name }: any) => { - value = value.value + value = Array.isArray(value) ? value : value.value const obj: any = { [ name ]: value }; if (name === 'metricValue') { - obj['metricValue'] = [value]; + obj['metricValue'] = value; + + // handle issues (remove all when other option is selected) + if (Array.isArray(obj['metricValue']) && obj['metricValue'].length > 1) { + obj['metricValue'] = obj['metricValue'].filter(i => i.value !== 'all'); + } } if (name === 'metricOf') { - if (value === FilterKey.ISSUE) { - obj['metricValue'] = ['all']; - } + // if (value === FilterKey.ISSUE) { + // obj['metricValue'] = [{ value: 'all', label: 'All' }]; + // } } if (name === 'metricType') { @@ -71,7 +76,6 @@ function WidgetForm(props: Props) { } else { history.replace(withSiteId(metricDetails(metric.metricId), siteId)); } - } }); } @@ -131,9 +135,11 @@ function WidgetForm(props: Props) { issue type