diff --git a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetriLineChart/CustomMetriLineChart.tsx b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetriLineChart/CustomMetriLineChart.tsx new file mode 100644 index 000000000..9f68abf3a --- /dev/null +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetriLineChart/CustomMetriLineChart.tsx @@ -0,0 +1,56 @@ +import React from 'react' +import { Styles } from '../../common'; +import { ResponsiveContainer, XAxis, YAxis, CartesianGrid, Area, Tooltip } from 'recharts'; +import { LineChart, Line, Legend } from 'recharts'; + +interface Props { + data: any; + params: any; + seriesMap: any; + colors: any; +} +function CustomMetriLineChart(props: Props) { + const { data, params, seriesMap, colors } = props; + return ( + + + + + + + + { seriesMap.map((key, index) => ( + + ))} + + + ) +} + +export default CustomMetriLineChart diff --git a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetriLineChart/index.ts b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetriLineChart/index.ts new file mode 100644 index 000000000..f05a16274 --- /dev/null +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetriLineChart/index.ts @@ -0,0 +1 @@ +export { default } from './CustomMetriLineChart'; \ No newline at end of file diff --git a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetriPercentage/CustomMetriPercentage.tsx b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetriPercentage/CustomMetriPercentage.tsx new file mode 100644 index 000000000..7138f2b1c --- /dev/null +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetriPercentage/CustomMetriPercentage.tsx @@ -0,0 +1,16 @@ +import React from 'react' + +interface Props { + data: any; +} +function CustomMetriPercentage(props: Props) { + const { data } = props; + return ( +
+
0%
+
0 ( 0.0% ) from previous hour
+
+ ) +} + +export default CustomMetriPercentage; diff --git a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetriPercentage/index.ts b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetriPercentage/index.ts new file mode 100644 index 000000000..a36f4ae23 --- /dev/null +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetriPercentage/index.ts @@ -0,0 +1 @@ +export { default } from './CustomMetriPercentage'; \ No newline at end of file diff --git a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricPieChart/CustomMetricPieChart.css b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricPieChart/CustomMetricPieChart.css new file mode 100644 index 000000000..1d1ef3ee4 --- /dev/null +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricPieChart/CustomMetricPieChart.css @@ -0,0 +1,6 @@ +.wrapper { + background-color: white; + /* border: solid thin $gray-medium; */ + border-radius: 3px; + padding: 10px; +} \ No newline at end of file diff --git a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricPieChart/CustomMetricPieChart.tsx b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricPieChart/CustomMetricPieChart.tsx new file mode 100644 index 000000000..a771a0f45 --- /dev/null +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricPieChart/CustomMetricPieChart.tsx @@ -0,0 +1,16 @@ +import React from 'react' + +interface Props { + data: any; +} +function CustomMetricPieChart(props: Props) { + const { data } = props; + return ( +
+
0%
+
0 ( 0.0% ) from previous hour
+
+ ) +} + +export default CustomMetricPieChart; diff --git a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricPieChart/index.ts b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricPieChart/index.ts new file mode 100644 index 000000000..6bdaf2270 --- /dev/null +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricPieChart/index.ts @@ -0,0 +1 @@ +export { default } from './CustomMetricPieChart'; \ No newline at end of file diff --git a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricTable/CustomMetricTable.css b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricTable/CustomMetricTable.css new file mode 100644 index 000000000..1d1ef3ee4 --- /dev/null +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricTable/CustomMetricTable.css @@ -0,0 +1,6 @@ +.wrapper { + background-color: white; + /* border: solid thin $gray-medium; */ + border-radius: 3px; + padding: 10px; +} \ No newline at end of file diff --git a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricTable/CustomMetricTable.tsx b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricTable/CustomMetricTable.tsx new file mode 100644 index 000000000..9ab0d72eb --- /dev/null +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricTable/CustomMetricTable.tsx @@ -0,0 +1,44 @@ +import React from 'react' +import { Table } from '../../common'; +import { List } from 'immutable'; + +const cols = [ + { + key: 'name', + title: 'Resource', + toText: name => name, + width: '70%', + }, + { + key: 'sessions', + title: 'Sessions', + toText: sessions => sessions, + width: '30%', + }, +]; + +interface Props { + data: any; +} +function CustomMetriTable(props: Props) { + const { data } = props; + const rows = List([ + { name: 'one', sessions: 2 }, + { name: 'two', sessions: 3 }, + { name: 'three', sessions: 4 }, + { name: 'four', sessions: 1 }, + { name: 'five', sessions: 6 }, + ]) + return ( +
+ + + ) +} + +export default CustomMetriTable; diff --git a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricTable/index.ts b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricTable/index.ts new file mode 100644 index 000000000..dc43c93b4 --- /dev/null +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricTable/index.ts @@ -0,0 +1 @@ +export { default } from './CustomMetricTable'; \ 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 8af9784d5..f0ca8aa80 100644 --- a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricWidgetPreview/CustomMetricWidgetPreview.tsx +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/CustomMetricWidgetPreview/CustomMetricWidgetPreview.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState, useRef } from 'react'; import { connect } from 'react-redux'; -import { Loader, NoContent, Icon } from 'UI'; +import { Loader, NoContent, SegmentSelection, Icon } 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'; @@ -9,6 +9,9 @@ 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 CustomMetriPercentage from '../CustomMetriPercentage'; +import CustomMetricTable from '../CustomMetricTable'; import APIClient from 'App/api_client'; @@ -83,11 +86,28 @@ function CustomMetricWidget(props: Props) { props.edit({ ...changedDates, rangeName: changedDates.rangeValue }); } + const chagneViewType = (e, { name, value }) => { + props.edit({ [ name ]: value }); + } + return (
Preview
-
+
+ +
+ Time Range - - - - - - - - { seriesMap.map((key, index) => ( - + { metric.viewType === 'percent' && ( + + )} + { metric.viewType === 'chart' && ( + - ))} - - + )} + + )} + + { metric.metricType === 'table' && ( +
+ +
+ )}
diff --git a/frontend/app/components/Dashboard/Widgets/common/Table.js b/frontend/app/components/Dashboard/Widgets/common/Table.js index 0aecca5ea..73192a501 100644 --- a/frontend/app/components/Dashboard/Widgets/common/Table.js +++ b/frontend/app/components/Dashboard/Widgets/common/Table.js @@ -16,7 +16,8 @@ export default class Table extends React.PureComponent { rowProps, rowClass = '', small = false, - compare = false + compare = false, + maxHeight = 200, } = this.props; const { showAll } = this.state; @@ -30,7 +31,7 @@ export default class Table extends React.PureComponent {
{ title }
) }
-
+
{ rows.take(showAll ? 10 : (small ? 3 : 5)).map(row => (
{ cols.map(({ cellClass = '', className = '', Component, key, toText = t => t, width }) => ( @@ -41,9 +42,9 @@ export default class Table extends React.PureComponent {
)) }
- )) } - - { rows.size > (small ? 3 : 5) && !showAll && + )) } +
+ { rows.size > (small ? 3 : 5) && !showAll &&
} -
); } diff --git a/frontend/app/components/shared/CustomMetrics/CustomMetricForm/CustomMetricForm.tsx b/frontend/app/components/shared/CustomMetrics/CustomMetricForm/CustomMetricForm.tsx index fd95cd5c6..754af89e2 100644 --- a/frontend/app/components/shared/CustomMetrics/CustomMetricForm/CustomMetricForm.tsx +++ b/frontend/app/components/shared/CustomMetrics/CustomMetricForm/CustomMetricForm.tsx @@ -24,6 +24,8 @@ interface Props { function CustomMetricForm(props: Props) { const { metric, loading } = props; const metricOfOptions = metricOf.filter(i => i.key === metric.metricType); + const timeseriesOptions = metricOf.filter(i => i.key === 'timeseries'); + const tableOptions = metricOf.filter(i => i.key === 'table'); const addSeries = () => { props.addSeries(); @@ -34,7 +36,17 @@ function CustomMetricForm(props: Props) { } const write = ({ target: { value, name } }) => props.editMetric({ [ name ]: value }, false); - const writeOption = (e, { value, name }) => props.editMetric({ [ name ]: value }, false); + const writeOption = (e, { value, name }) => { + props.editMetric({ [ name ]: value }, false); + + if (name === 'metricType') { + if (value === 'timeseries') { + props.editMetric({ metricOf: timeseriesOptions[0].value }, false); + } else if (value === 'table') { + props.editMetric({ metricOf: tableOptions[0].value }, false); + } + } + }; const changeConditionTab = (e, { name, value }) => { props.editMetric({[ 'viewType' ]: value }); @@ -89,22 +101,44 @@ function CustomMetricForm(props: Props) { value={ metric.metricType } onChange={ writeOption } /> - of - - showing - + + {metric.metricType === 'timeseries' && ( + <> + of + + + )} + + {metric.metricType === 'table' && ( + <> + of + + + )} + + {metric.metricType === 'table' && ( + <> + showing + + + )}
{/*
Timeseries diff --git a/frontend/app/components/shared/DropdownPlain/DropdownPlain.css b/frontend/app/components/shared/DropdownPlain/DropdownPlain.css index 87e26bc68..1bf3e305c 100644 --- a/frontend/app/components/shared/DropdownPlain/DropdownPlain.css +++ b/frontend/app/components/shared/DropdownPlain/DropdownPlain.css @@ -4,6 +4,8 @@ border-radius: 3px; color: $gray-darkest; font-weight: 500; + background-color: white; + border: solid thin $gray-light; &:hover { background-color: $gray-light; } diff --git a/frontend/app/components/shared/DropdownPlain/DropdownPlain.tsx b/frontend/app/components/shared/DropdownPlain/DropdownPlain.tsx index d3313ac3e..07d64aa5d 100644 --- a/frontend/app/components/shared/DropdownPlain/DropdownPlain.tsx +++ b/frontend/app/components/shared/DropdownPlain/DropdownPlain.tsx @@ -12,7 +12,7 @@ interface Props { } export default function DropdownPlain(props: Props) { - const { name = "sort", value, options, icon = "chevron-down", direction = "left" } = props; + const { name = "sort", value, options, icon = "chevron-down", direction = "right" } = props; return (
{ list.map(item => ( @@ -27,7 +27,7 @@ class SegmentSelection extends React.Component { data-active={ this.props.value && this.props.value.value === item.value } onClick={ () => !item.disabled && this.setActiveItem(item) } > - { item.icon && } + { item.icon && }
{ item.name }
} diff --git a/frontend/app/components/ui/SegmentSelection/segmentSelection.css b/frontend/app/components/ui/SegmentSelection/segmentSelection.css index 20007b010..197627c9f 100644 --- a/frontend/app/components/ui/SegmentSelection/segmentSelection.css +++ b/frontend/app/components/ui/SegmentSelection/segmentSelection.css @@ -12,13 +12,13 @@ padding: 10px; flex: 1; text-align: center; - border-right: solid thin $teal; cursor: pointer; background-color: $gray-lightest; display: flex; align-items: center; justify-content: center; white-space: nowrap; + border-right: solid thin $gray-light; & span svg { fill: $gray-medium; @@ -53,6 +53,7 @@ & .item { color: $teal; background-color: white; + border-right: solid thin $teal; &[data-active=true] { background-color: $teal; color: white; @@ -65,6 +66,6 @@ } .extraSmall .item { - padding: 0 4px; + padding: 6px !important; font-size: 12px; } \ No newline at end of file diff --git a/frontend/app/constants/filterOptions.js b/frontend/app/constants/filterOptions.js index 215832c1a..9884d7851 100644 --- a/frontend/app/constants/filterOptions.js +++ b/frontend/app/constants/filterOptions.js @@ -61,7 +61,7 @@ export const metricTypes = [ export const metricOf = [ { text: 'Session Count', value: 'sessionCount', key: 'timeseries' }, - { text: 'Users', value: 'users', key: 'table' }, + { text: 'Users', value: 'USERID', key: 'table' }, { text: 'Rage Click', value: 'rageClick', key: 'table' }, { text: 'Dead Click', value: 'deadClick', key: 'table' }, { text: 'Browser', value: 'browser', key: 'table' }, diff --git a/frontend/app/svg/icons/graph-up-arrow.svg b/frontend/app/svg/icons/graph-up-arrow.svg new file mode 100644 index 000000000..fd582e467 --- /dev/null +++ b/frontend/app/svg/icons/graph-up-arrow.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/frontend/app/svg/icons/hash.svg b/frontend/app/svg/icons/hash.svg new file mode 100644 index 000000000..4621b1dac --- /dev/null +++ b/frontend/app/svg/icons/hash.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/frontend/app/types/customMetric.js b/frontend/app/types/customMetric.js index 902c10a23..9b3585be1 100644 --- a/frontend/app/types/customMetric.js +++ b/frontend/app/types/customMetric.js @@ -27,9 +27,9 @@ export const FilterSeries = Record({ export default Record({ metricId: undefined, name: 'Series', - metricType: 'timeseries', - metricOf: 'sessionCount', - viewType: 'sessionCount', + metricType: 'table', + metricOf: 'USERID', + viewType: 'lineChart', series: List(), isPublic: true, startDate: '',