Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphs for Dashboard #69

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ dist-ssr
*.njsproj
*.sln
*.sw?



# add:
docker-compose.yaml
build.sh
TODO
30 changes: 0 additions & 30 deletions docker-compose.yml

This file was deleted.

25,781 changes: 14,670 additions & 11,111 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/client/components/monitor/MonitorDataChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ export const MonitorDataChart: React.FC<{ monitorId: string }> = React.memo(

return (
<div>
<div className="mb-4 text-right">
<Area {...config} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you need prettier.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you need prettier.

and why move its order?

<div className="mt-4 text-right">
<Select
className="w-20 text-center"
size="small"
Expand All @@ -172,7 +173,6 @@ export const MonitorDataChart: React.FC<{ monitorId: string }> = React.memo(
</Select>
</div>

<Area {...config} />
</div>
);
}
Expand Down
113 changes: 66 additions & 47 deletions src/client/components/monitor/MonitorListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { last } from 'lodash-es';
import { getMonitorProvider, getProviderDisplay } from './provider';
import { Tooltip } from 'antd';
import { useTranslation } from '@i18next-toolkit/react';

import { MonitorDataChart } from './MonitorDataChart';
export const MonitorListItem: React.FC<{
className?: string;
workspaceId: string;
Expand All @@ -26,6 +26,8 @@ export const MonitorListItem: React.FC<{
onClick,
} = props;

const [showGraph, setShowGraph] = useState<boolean>(true);

const [beats, setBeats] = useState<
({
value: number;
Expand Down Expand Up @@ -67,56 +69,73 @@ export const MonitorListItem: React.FC<{
}, [beats, provider]);

return (
<div
className={clsx(
className,
'mb-1 flex items-center rounded-lg bg-green-500 bg-opacity-0 px-4 py-3 hover:bg-opacity-10',
onClick && 'cursor-pointer'
)}
onClick={onClick}
>
<div>
<span
className={clsx(
'inline-block min-w-[62px] rounded-full p-0.5 text-center text-white',
upPercent === 100 ? 'bg-green-400' : 'bg-amber-400'
)}
>
{upPercent}%
</span>
</div>
<div className={
clsx(
'flex justify-between items-center flex-col w-full h-fit',
className
)
}>
<div
className={clsx(
className,
'mb-1 flex items-center rounded-lg bg-green-500 bg-opacity-0 px-4 py-3 hover:bg-opacity-10 w-full',
onClick && 'cursor-pointer'
)}
// onClick={onClick}
onClick={() => {
setShowGraph(!showGraph);
}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this not a good idea because you break normal list logic.

here:
image

>
<div>
<span
className={clsx(
'inline-block min-w-[62px] rounded-full p-0.5 text-center text-white',
upPercent === 100 ? 'bg-green-400' : 'bg-amber-400'
)}
>
{upPercent}%
</span>
</div>

<div className="flex-1 pl-2">
<div className="text-base">{monitorName}</div>
{/* <div>
{monitor.tags.map((tag) => (
<span
className="py-0.5 px-1 rounded-full text-white text-sm"
style={{ backgroundColor: tag.color }}
>
{tag.label}
</span>
))}
</div> */}
</div>
<div className="flex-1 pl-2">
<div className="text-base">{monitorName}</div>
{/* <div>
{monitor.tags.map((tag) => (
<span
className="py-0.5 px-1 rounded-full text-white text-sm"
style={{ backgroundColor: tag.color }}
>
{tag.label}
</span>
))}
</div> */}
</div>

{showCurrentResponse && latestResponse && (
<Tooltip title={t('Current')}>
<div className="px-2 text-sm text-gray-800 dark:text-gray-400">
{latestResponse}
</div>
</Tooltip>
)}
{showCurrentResponse && latestResponse && (
<Tooltip title={t('Current')}>
<div className="px-2 text-sm text-gray-800 dark:text-gray-400">
{latestResponse}
</div>
</Tooltip>
)}

<div className="flex items-center">
<MonitorHealthBar
workspaceId={workspaceId}
monitorId={monitorId}
monitorType={monitorType}
onBeatsItemUpdate={setBeats}
/>
<div className="flex items-center">
<MonitorHealthBar
workspaceId={workspaceId}
monitorId={monitorId}
monitorType={monitorType}
onBeatsItemUpdate={setBeats}
/>
</div>
</div>
{ monitorType != "ping" && showGraph ?
<div className={clsx(
"w-full px-5"
)}>
<MonitorDataChart monitorId={monitorId} />
</div> : null }
</div>

);
});
MonitorListItem.displayName = 'MonitorListItem';
MonitorListItem.displayName = 'MonitorListItem';
12 changes: 10 additions & 2 deletions src/client/store/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ import { create } from 'zustand';
import { Layouts, Layout } from 'react-grid-layout';
import { mapValues } from 'lodash-es';
import { v1 as uuid } from 'uuid';
import { MonitorDataChart } from '../monitor/MonitorDataChart';

export type DashboardItemType =
| 'websiteOverview'
| 'websiteEvents'
| 'monitorHealthBar'
| 'monitorMetrics'
| 'monitorChart'
| 'monitorEvents';
| 'monitorEvents'
| 'monitorDataChart';

export interface DashboardItem {
key: string; // match with layout, not equal
key: string;
id: string;
title: string;
type: DashboardItemType;
Expand Down Expand Up @@ -95,4 +97,10 @@ export const defaultItemLayout: Record<DashboardItemType, Omit<Layout, 'i'>> = {
monitorMetrics: { x: 0, y: Infinity, w: 2, h: 3 },
monitorChart: { x: 0, y: Infinity, w: 2, h: 6 },
monitorEvents: { x: 0, y: Infinity, w: 2, h: 10 },
monitorDataChart: { x: 0, y: Infinity, w: 2, h: 8 },
};

// Add the MonitorDataChart component to be shown
export const MonitorDataChartComponent = () => {
return <MonitorDataChart />;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont need dashboard anymore

};
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.