1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

made demo for nodes and comments count by month

This commit is contained in:
Fedor Katurov 2022-03-30 14:13:31 +07:00
parent e1131d961d
commit 9d5086290f
5 changed files with 58 additions and 29 deletions

View file

@ -1,6 +1,6 @@
NEXT_PUBLIC_API_HOST=https://pig.staging.vault48.org/
NEXT_PUBLIC_REMOTE_CURRENT=https://pig.staging.vault48.org/static/
#NEXT_PUBLIC_API_HOST=https://pig.staging.vault48.org/
#NEXT_PUBLIC_REMOTE_CURRENT=https://pig.staging.vault48.org/static/
#NEXT_PUBLIC_API_HOST=http://localhost:8888/
#NEXT_PUBLIC_REMOTE_CURRENT=http://localhost:8888/static/
#NEXT_PUBLIC_API_HOST=https://pig.vault48.org/
#NEXT_PUBLIC_REMOTE_CURRENT=https://pig.vault48.org/static/
NEXT_PUBLIC_API_HOST=https://pig.vault48.org/
NEXT_PUBLIC_REMOTE_CURRENT=https://pig.vault48.org/static/

View file

@ -0,0 +1,42 @@
import React, { VFC } from 'react';
import { SVGProps } from '~/utils/types';
interface BasicCurveChartProps extends SVGProps {
items: number[];
}
const BasicCurveChart: VFC<BasicCurveChartProps> = ({
stroke = '#007962',
items = [],
...props
}) => {
const max = Math.max(...items) + 5;
const height = props.height ? parseFloat(props.height.toString()) : 100;
const width = props.width ? parseFloat(props.width.toString()) : 100;
const d = items.reduce<string[]>(
(acc, val, index) => [
...acc,
index === 0
? `M 5 ${height - (val / max) * height}`
: `L ${(width / (items.length - 1)) * index} ${height - (val / max) * height}`,
],
[]
);
return (
<svg {...props} width={width} height={height} viewBox={`0 0 ${width} ${height}`}>
<defs>
<filter id="f1" x="0" y="0">
<feGaussianBlur in="SourceGraphic" stdDeviation="2" />
</filter>
</defs>
<path d={d.join(' ')} fill="none" x={0} y={0} stroke={stroke} filter="url(#f1)" />
<path d={d.join(' ')} fill="none" x={0} y={0} stroke={stroke} />
</svg>
);
};
export { BasicCurveChart };

View file

@ -4,6 +4,7 @@ import { useRouter } from 'next/router';
import { BorisSidebar } from '~/components/boris/BorisSidebar';
import { Superpower } from '~/components/boris/Superpower';
import { BasicCurveChart } from '~/components/charts/BasicCurveChart';
import { Card } from '~/components/containers/Card';
import { Group } from '~/components/containers/Group';
import { Padder } from '~/components/containers/Padder';
@ -52,6 +53,7 @@ const BorisLayout: FC<IProps> = ({ title, setIsBetaTester, isTester, stats, isLo
<Padder>
<Group>
<h2>Тестовые фичи</h2>
<div>
<Button onClick={() => openProfileSidebar({})}>Профиль в сайдбаре</Button>
</div>
@ -61,6 +63,14 @@ const BorisLayout: FC<IProps> = ({ title, setIsBetaTester, isTester, stats, isLo
Профиль на отдельной странице
</Button>
</div>
<Group>
<h4>Количество нод за год</h4>
<BasicCurveChart items={stats.backend.nodes.by_month} width={200} />
<h4>Количество комментов за год</h4>
<BasicCurveChart items={stats.backend.comments.by_month} width={200} />
</Group>
</Group>
</Padder>
</Superpower>

View file

@ -11,12 +11,6 @@ export interface GithubIssue {
export type IGetGithubIssuesResult = GithubIssue[];
export type IStatGitRow = {
commit: string;
subject: string;
timestamp: string;
};
export type StatBackend = {
users: {
total: number;
@ -28,9 +22,11 @@ export type StatBackend = {
videos: number;
texts: number;
total: number;
by_month: number[];
};
comments: {
total: number;
by_month: number[];
};
files: {
count: number;

View file

@ -1,24 +1,5 @@
import { IError, INode, ITag } from '~/types';
export type ILabState = Readonly<{
list: {
is_loading: boolean;
nodes: ILabNode[];
count: number;
error: IError;
};
stats: {
is_loading: boolean;
heroes: Partial<INode>[];
tags: ITag[];
error?: string;
};
updates: {
nodes: INode[];
isLoading: boolean;
};
}>;
export enum LabNodesSort {
New = 'new',
Hot = 'hot',