From 20ccee48d1e0042d751f14980751b72bf1f775fc Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Mon, 1 Jul 2024 15:41:13 +0200 Subject: [PATCH] change(ui): slowest domains card change --- .../Dashboard/Widgets/CardSessionsByList.tsx | 6 +- .../CustomMetricsWidgets/SessionsBy.tsx | 146 +++++++++--------- .../SlowestDomains/SlowestDomains.tsx | 97 ++++++++---- .../NewDashModal/ExampleCards.tsx | 8 +- .../Examples/SessionsBy/ByUrl.tsx | 108 +++++++------ .../Examples/SessionsBy/SlowestDomains.tsx | 49 ++++++ .../NewDashModal/Examples/SlowestDomain.tsx | 1 + .../WidgetPredefinedChart.tsx | 2 +- 8 files changed, 260 insertions(+), 157 deletions(-) create mode 100644 frontend/app/components/Dashboard/components/DashboardList/NewDashModal/Examples/SessionsBy/SlowestDomains.tsx diff --git a/frontend/app/components/Dashboard/Widgets/CardSessionsByList.tsx b/frontend/app/components/Dashboard/Widgets/CardSessionsByList.tsx index 262916873..a150c787f 100644 --- a/frontend/app/components/Dashboard/Widgets/CardSessionsByList.tsx +++ b/frontend/app/components/Dashboard/Widgets/CardSessionsByList.tsx @@ -4,11 +4,11 @@ import cn from "classnames"; interface Props { list: any; - selected: any; - onClickHandler: (event: any, data: any) => void; + selected?: any; + onClickHandler?: (event: any, data: any) => void; } -function CardSessionsByList({ list, selected, onClickHandler }: Props) { +function CardSessionsByList({ list, selected, onClickHandler = () => null }: Props) { return ( void; - isTemplate?: boolean; + metric?: any; + data: any; + onClick?: (filters: any) => void; + isTemplate?: boolean; } function SessionsBy(props: Props) { - const {metric = {}, data = {values: []}, onClick = () => null, isTemplate} = props; - const [selected, setSelected] = React.useState(null); - const total = data.values.length - const {openModal, closeModal} = useModal(); + const { metric = {}, data = { values: [] }, onClick = () => null, isTemplate } = props; + const [selected, setSelected] = React.useState(null); + const total = data.values.length; + const { openModal, closeModal } = useModal(); - const onClickHandler = (event: any, data: any) => { - const filters = Array(); - let filter = {...filtersMap[metric.metricOf]}; - filter.value = [data.name]; - filter.type = filter.key; - delete filter.key; - delete filter.operatorOptions; - delete filter.category; - delete filter.icon; - delete filter.label; - delete filter.options; + const onClickHandler = (event: any, data: any) => { + const filters = Array(); + let filter = { ...filtersMap[metric.metricOf] }; + filter.value = [data.name]; + filter.type = filter.key; + delete filter.key; + delete filter.operatorOptions; + delete filter.category; + delete filter.icon; + delete filter.label; + delete filter.options; - setSelected(data.name) + setSelected(data.name); - filters.push(filter); - onClick(filters); - } + filters.push(filter); + onClick(filters); + }; - const showMore = () => { - openModal( - { - closeModal(); - onClickHandler(null, item) - }} selected={selected}/>, { - title: metric.name, - width: 600, - }) - } + const showMore = () => { + openModal( + { + closeModal(); + onClickHandler(null, item); + }} selected={selected} />, { + title: metric.name, + width: 600 + }); + }; - return ( -
- {data.values && data.values.length === 0 ? ( - - - No data for the selected time period -
- } - /> - ) : ( -
- - {total > 3 && ( -
- -
- )} -
- )} + return ( +
+ {data.values && data.values.length === 0 ? ( + + + No data for the selected time period +
+ } + /> + ) : ( +
+ + {total > 3 && ( +
+ +
+ )}
- ); + )} + + ); } export default SessionsBy; diff --git a/frontend/app/components/Dashboard/Widgets/PredefinedWidgets/SlowestDomains/SlowestDomains.tsx b/frontend/app/components/Dashboard/Widgets/PredefinedWidgets/SlowestDomains/SlowestDomains.tsx index 758a6575a..661a5842f 100644 --- a/frontend/app/components/Dashboard/Widgets/PredefinedWidgets/SlowestDomains/SlowestDomains.tsx +++ b/frontend/app/components/Dashboard/Widgets/PredefinedWidgets/SlowestDomains/SlowestDomains.tsx @@ -1,38 +1,83 @@ import React from 'react'; -import { NoContent } from 'UI'; +import { Icon, NoContent } from 'UI'; import { Styles } from '../../common'; import { numberWithCommas } from 'App/utils'; import Bar from './Bar'; -import { NO_METRIC_DATA } from 'App/constants/messages' +import { NO_METRIC_DATA } from 'App/constants/messages'; +import CardSessionsByList from 'Components/Dashboard/Widgets/CardSessionsByList'; +import { List, Progress, Typography } from 'antd'; +import cn from 'classnames'; interface Props { - data: any - metric?: any + data: any; } + function SlowestDomains(props: Props) { - const { data, metric } = props; - const firstAvg = metric.data.chart[0] && metric.data.chart[0].value; - return ( - -
- {metric.data.chart.map((item, i) => - ({ + name: item.domain, + icon: , + value: Math.round(item.value) + 'ms', + progress: Math.round((item.value * 100) / highest) + })); + + return ( + +
+ ( + onClickHandler(e, row)} // Remove onClick handler to disable click interaction + style={{ + borderBottom: '1px dotted rgba(0, 0, 0, 0.05)', + padding: '4px 10px', + lineHeight: '1px' + }} + className={cn('rounded')} // Remove hover:bg-active-blue and cursor-pointer + > + +
+ {row.name} + {row.value} +
+ + +
+ )} /> - )} -
-
- ); + + )} + /> + + + ); } export default SlowestDomains; diff --git a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/ExampleCards.tsx b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/ExampleCards.tsx index aa66bfa40..499a560c7 100644 --- a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/ExampleCards.tsx +++ b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/ExampleCards.tsx @@ -21,6 +21,8 @@ import CallsWithErrorsExample from "Components/Dashboard/components/DashboardList/NewDashModal/Examples/CallsWithErrorsExample"; import SessionsPerBrowserExample from 'Components/Dashboard/components/DashboardList/NewDashModal/Examples/SessionsPerBrowserExample'; +import SlowestDomains + from 'Components/Dashboard/components/DashboardList/NewDashModal/Examples/SessionsBy/SlowestDomains'; export const CARD_CATEGORY = { PRODUCT_ANALYTICS: 'product-analytics', @@ -256,7 +258,7 @@ export const CARD_LIST: CardType[] = [ }, { - title: 'Sessions per Browser', + title: 'Sessions by Browser & Version', key: FilterKey.SESSIONS_PER_BROWSER, cardType: PERFORMANCE, metricOf: FilterKey.SESSIONS_PER_BROWSER, @@ -271,8 +273,8 @@ export const CARD_LIST: CardType[] = [ cardType: PERFORMANCE, metricOf: FilterKey.SLOWEST_DOMAINS, category: CARD_CATEGORIES[1].key, - data: generateRandomBarsData(), - example: Bars, + // data: generateRandomBarsData(), + example: SlowestDomains, }, { diff --git a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/Examples/SessionsBy/ByUrl.tsx b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/Examples/SessionsBy/ByUrl.tsx index b6d35ef76..28c0b9560 100644 --- a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/Examples/SessionsBy/ByUrl.tsx +++ b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/Examples/SessionsBy/ByUrl.tsx @@ -4,6 +4,7 @@ import React from 'react'; import { Circle } from '../Count'; import ExCard from '../ExCard'; +import ByComponent from 'Components/Dashboard/components/DashboardList/NewDashModal/Examples/SessionsBy/Component'; function ByUrl(props: any) { const [mode, setMode] = React.useState(0); @@ -47,57 +48,62 @@ function ByUrl(props: any) { const lineWidth = 240; return ( - -
{props.title}
-
setMode(Number(v))} - size='small' - /> -
- - } - > -
- {rows.map((r) => ( -
- {r.icon} -
-
{mode === 0 ? r.label : r.ptitle}
-
-
-
-
-
-
{r.value}
-
- ))} -
- + + // + //
{props.title}
+ //
setMode(Number(v))} + // size='small' + // /> + //
+ //
+ // } + // > + //
+ // {rows.map((r) => ( + //
+ // {r.icon} + //
+ //
{mode === 0 ? r.label : r.ptitle}
+ //
+ //
+ //
+ //
+ //
+ //
{r.value}
+ //
+ // ))} + //
+ // ); } diff --git a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/Examples/SessionsBy/SlowestDomains.tsx b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/Examples/SessionsBy/SlowestDomains.tsx new file mode 100644 index 000000000..428c04bb3 --- /dev/null +++ b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/Examples/SessionsBy/SlowestDomains.tsx @@ -0,0 +1,49 @@ +import React from 'react'; +import ByComponent from './Component'; +import { LinkOutlined } from '@ant-design/icons'; + +function SlowestDomains(props: any) { + const rows = [ + { + label: 'res.cloudinary.com', + value: '500', + progress: 75, + icon: + }, + { + label: 'mintbase.vercel.app', + value: '306', + progress: 60, + icon: + }, + { + label: 'downloads.intercomcdn.com', + value: '198', + progress: 30, + icon: + }, + { + label: 'static.intercomassets.com', + value: '47', + progress: 15, + icon: + }, + { + label: 'mozbar.moz.com', + value: '5', + progress: 5, + icon: + } + ]; + + const lineWidth = 200; + return ( + + ); +} + +export default SlowestDomains; diff --git a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/Examples/SlowestDomain.tsx b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/Examples/SlowestDomain.tsx index d39062eb2..baded8f84 100644 --- a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/Examples/SlowestDomain.tsx +++ b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/Examples/SlowestDomain.tsx @@ -4,6 +4,7 @@ import React from 'react'; import { Circle } from './Count'; import ExCard from './ExCard'; +// TODO - delete this function SlowestDomain(props: any) { const rows = [ { diff --git a/frontend/app/components/Dashboard/components/WidgetPredefinedChart/WidgetPredefinedChart.tsx b/frontend/app/components/Dashboard/components/WidgetPredefinedChart/WidgetPredefinedChart.tsx index a3c5d81f1..dc019b8f8 100644 --- a/frontend/app/components/Dashboard/components/WidgetPredefinedChart/WidgetPredefinedChart.tsx +++ b/frontend/app/components/Dashboard/components/WidgetPredefinedChart/WidgetPredefinedChart.tsx @@ -78,7 +78,7 @@ function WidgetPredefinedChart(props: Props) { case FilterKey.SESSIONS_PER_BROWSER: return case FilterKey.SLOWEST_DOMAINS: - return + return case FilterKey.TIME_TO_RENDER: return