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:
parent
e1131d961d
commit
9d5086290f
5 changed files with 58 additions and 29 deletions
|
@ -1,6 +1,6 @@
|
||||||
NEXT_PUBLIC_API_HOST=https://pig.staging.vault48.org/
|
#NEXT_PUBLIC_API_HOST=https://pig.staging.vault48.org/
|
||||||
NEXT_PUBLIC_REMOTE_CURRENT=https://pig.staging.vault48.org/static/
|
#NEXT_PUBLIC_REMOTE_CURRENT=https://pig.staging.vault48.org/static/
|
||||||
#NEXT_PUBLIC_API_HOST=http://localhost:8888/
|
#NEXT_PUBLIC_API_HOST=http://localhost:8888/
|
||||||
#NEXT_PUBLIC_REMOTE_CURRENT=http://localhost:8888/static/
|
#NEXT_PUBLIC_REMOTE_CURRENT=http://localhost:8888/static/
|
||||||
#NEXT_PUBLIC_API_HOST=https://pig.vault48.org/
|
NEXT_PUBLIC_API_HOST=https://pig.vault48.org/
|
||||||
#NEXT_PUBLIC_REMOTE_CURRENT=https://pig.vault48.org/static/
|
NEXT_PUBLIC_REMOTE_CURRENT=https://pig.vault48.org/static/
|
||||||
|
|
42
src/components/charts/BasicCurveChart/index.tsx
Normal file
42
src/components/charts/BasicCurveChart/index.tsx
Normal 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 };
|
|
@ -4,6 +4,7 @@ import { useRouter } from 'next/router';
|
||||||
|
|
||||||
import { BorisSidebar } from '~/components/boris/BorisSidebar';
|
import { BorisSidebar } from '~/components/boris/BorisSidebar';
|
||||||
import { Superpower } from '~/components/boris/Superpower';
|
import { Superpower } from '~/components/boris/Superpower';
|
||||||
|
import { BasicCurveChart } from '~/components/charts/BasicCurveChart';
|
||||||
import { Card } from '~/components/containers/Card';
|
import { Card } from '~/components/containers/Card';
|
||||||
import { Group } from '~/components/containers/Group';
|
import { Group } from '~/components/containers/Group';
|
||||||
import { Padder } from '~/components/containers/Padder';
|
import { Padder } from '~/components/containers/Padder';
|
||||||
|
@ -52,6 +53,7 @@ const BorisLayout: FC<IProps> = ({ title, setIsBetaTester, isTester, stats, isLo
|
||||||
<Padder>
|
<Padder>
|
||||||
<Group>
|
<Group>
|
||||||
<h2>Тестовые фичи</h2>
|
<h2>Тестовые фичи</h2>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Button onClick={() => openProfileSidebar({})}>Профиль в сайдбаре</Button>
|
<Button onClick={() => openProfileSidebar({})}>Профиль в сайдбаре</Button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -61,6 +63,14 @@ const BorisLayout: FC<IProps> = ({ title, setIsBetaTester, isTester, stats, isLo
|
||||||
Профиль на отдельной странице
|
Профиль на отдельной странице
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</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>
|
</Group>
|
||||||
</Padder>
|
</Padder>
|
||||||
</Superpower>
|
</Superpower>
|
||||||
|
|
|
@ -11,12 +11,6 @@ export interface GithubIssue {
|
||||||
|
|
||||||
export type IGetGithubIssuesResult = GithubIssue[];
|
export type IGetGithubIssuesResult = GithubIssue[];
|
||||||
|
|
||||||
export type IStatGitRow = {
|
|
||||||
commit: string;
|
|
||||||
subject: string;
|
|
||||||
timestamp: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type StatBackend = {
|
export type StatBackend = {
|
||||||
users: {
|
users: {
|
||||||
total: number;
|
total: number;
|
||||||
|
@ -28,9 +22,11 @@ export type StatBackend = {
|
||||||
videos: number;
|
videos: number;
|
||||||
texts: number;
|
texts: number;
|
||||||
total: number;
|
total: number;
|
||||||
|
by_month: number[];
|
||||||
};
|
};
|
||||||
comments: {
|
comments: {
|
||||||
total: number;
|
total: number;
|
||||||
|
by_month: number[];
|
||||||
};
|
};
|
||||||
files: {
|
files: {
|
||||||
count: number;
|
count: number;
|
||||||
|
|
|
@ -1,24 +1,5 @@
|
||||||
import { IError, INode, ITag } from '~/types';
|
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 {
|
export enum LabNodesSort {
|
||||||
New = 'new',
|
New = 'new',
|
||||||
Hot = 'hot',
|
Hot = 'hot',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue