mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
added placeholders for boris stats
This commit is contained in:
parent
c6aa2139e0
commit
372e016e3d
5 changed files with 104 additions and 48 deletions
|
@ -8,64 +8,95 @@ interface IProps {
|
||||||
stats: IBorisState['stats'];
|
stats: IBorisState['stats'];
|
||||||
}
|
}
|
||||||
|
|
||||||
const BorisStatsBackend: FC<IProps> = ({ stats }) => {
|
const Row: FC<{ isLoading: boolean }> = ({ isLoading, children }) => (
|
||||||
if (stats.is_loading)
|
<li>
|
||||||
return (
|
{isLoading ? (
|
||||||
<>
|
<>
|
||||||
<div className={styles.title}>
|
<Placeholder active={isLoading} loading className={styles.label} />
|
||||||
<Placeholder width="50%" />
|
<Placeholder active={isLoading} loading className={styles.value} width="24px" />
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
);
|
) : (
|
||||||
|
children
|
||||||
|
)}
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
|
||||||
if (!stats.backend) return null;
|
const BorisStatsBackend: FC<IProps> = ({ stats: { is_loading, backend } }) => {
|
||||||
|
// const is_loading = true;
|
||||||
|
|
||||||
|
if (!backend && !is_loading) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.wrap}>
|
<div className={styles.wrap}>
|
||||||
<div className={styles.title}>Юнитс</div>
|
<div className={styles.title}>
|
||||||
|
<Placeholder active={is_loading} loading>
|
||||||
|
Юнитс
|
||||||
|
</Placeholder>
|
||||||
|
</div>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<Row isLoading={is_loading}>
|
||||||
В сознании <span>{stats.backend.users.alive}</span>
|
<span className={styles.label}>В сознании</span>
|
||||||
</li>
|
<span className={styles.value}>{backend.users.alive}</span>
|
||||||
|
</Row>
|
||||||
|
|
||||||
<li>
|
<Row isLoading={is_loading}>
|
||||||
Криокамера <span>{stats.backend.users.total - stats.backend.users.alive}</span>
|
<span className={styles.label}>Криокамера</span>
|
||||||
</li>
|
<span className={styles.value}>{backend.users.total - backend.users.alive}</span>
|
||||||
|
</Row>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div className={styles.title}>Контент</div>
|
<div className={styles.title}>
|
||||||
|
<Placeholder active={is_loading} loading>
|
||||||
|
Контент
|
||||||
|
</Placeholder>
|
||||||
|
</div>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<Row isLoading={is_loading}>
|
||||||
Фотографии <span>{stats.backend.nodes.images}</span>
|
<span className={styles.label}>Фотографии</span>
|
||||||
</li>
|
<span className={styles.value}>{backend.nodes.images}</span>
|
||||||
|
</Row>
|
||||||
|
|
||||||
<li>
|
<Row isLoading={is_loading}>
|
||||||
Письма <span>{stats.backend.nodes.texts}</span>
|
<span className={styles.label}>Письма</span>
|
||||||
</li>
|
<span className={styles.value}>{backend.nodes.texts}</span>
|
||||||
|
</Row>
|
||||||
|
|
||||||
<li>
|
<Row isLoading={is_loading}>
|
||||||
Видеозаписи <span>{stats.backend.nodes.videos}</span>
|
<span className={styles.label}>Видеозаписи</span>
|
||||||
</li>
|
<span className={styles.value}>{backend.nodes.videos}</span>
|
||||||
|
</Row>
|
||||||
|
|
||||||
<li>
|
<Row isLoading={is_loading}>
|
||||||
Аудиозаписи <span>{stats.backend.nodes.audios}</span>
|
<span className={styles.label}>Аудиозаписи</span>
|
||||||
</li>
|
<span className={styles.value}>{backend.nodes.audios}</span>
|
||||||
|
</Row>
|
||||||
|
|
||||||
<li>
|
<Row isLoading={is_loading}>
|
||||||
Комментарии <span>{stats.backend.comments.total}</span>
|
<span className={styles.label}>Комментарии</span>
|
||||||
</li>
|
<span className={styles.value}>{backend.comments.total}</span>
|
||||||
|
</Row>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div className={styles.title}>Сторедж</div>
|
<div className={styles.title}>
|
||||||
|
<Placeholder active={is_loading} loading>
|
||||||
|
Сторедж
|
||||||
|
</Placeholder>
|
||||||
|
</div>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<Row isLoading={is_loading}>
|
||||||
Файлы <span>{stats.backend.files.count}</span>
|
<span className={styles.label}>Файлы</span>
|
||||||
</li>
|
<span className={styles.value}>{backend.files.count}</span>
|
||||||
<li>
|
</Row>
|
||||||
На диске <span>{sizeOf(stats.backend.files.size)}</span>
|
|
||||||
</li>
|
<Row isLoading={is_loading}>
|
||||||
|
<span className={styles.label}>На диске</span>
|
||||||
|
<span className={styles.value}>{sizeOf(backend.files.size)}</span>
|
||||||
|
</Row>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
@import "src/styles/variables";
|
@import "src/styles/variables";
|
||||||
|
|
||||||
|
.value {
|
||||||
|
float: right;
|
||||||
|
color: white;
|
||||||
|
font: $font_12_semibold;
|
||||||
|
line-height: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
.wrap {
|
.wrap {
|
||||||
ul {
|
ul {
|
||||||
font: $font_12_regular;
|
font: $font_12_regular;
|
||||||
line-height: 24px;
|
line-height: 24px;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
|
|
||||||
span {
|
|
||||||
float: right;
|
|
||||||
color: white;
|
|
||||||
font: $font_12_semibold;
|
|
||||||
line-height: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
li {
|
li {
|
||||||
border-bottom: 1px solid #333333;
|
border-bottom: 1px solid #333333;
|
||||||
color: #aaaaaa;
|
color: #aaaaaa;
|
||||||
|
|
|
@ -8,6 +8,7 @@ export interface PlaceholderProps {
|
||||||
color?: string;
|
color?: string;
|
||||||
active?: boolean;
|
active?: boolean;
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Placeholder: FC<PlaceholderProps> = ({
|
const Placeholder: FC<PlaceholderProps> = ({
|
||||||
|
@ -17,10 +18,11 @@ const Placeholder: FC<PlaceholderProps> = ({
|
||||||
active,
|
active,
|
||||||
children,
|
children,
|
||||||
loading = true,
|
loading = true,
|
||||||
|
className,
|
||||||
}) => {
|
}) => {
|
||||||
return active ? (
|
return active ? (
|
||||||
<div
|
<div
|
||||||
className={classNames(styles.placeholder, { [styles.loading]: loading })}
|
className={classNames(styles.placeholder, { [styles.loading]: loading }, className)}
|
||||||
style={{ height, color, width }}
|
style={{ height, color, width }}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
opacity: 0.05;
|
opacity: 0.05;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.placeholder {
|
.placeholder {
|
||||||
height: 1em;
|
height: 1em;
|
||||||
width: 120px;
|
width: 120px;
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
border-radius: 1em;
|
border-radius: 1em;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
display: inline-flex;
|
||||||
|
|
||||||
&::after {
|
&::after {
|
||||||
content: ' ';
|
content: ' ';
|
||||||
|
|
|
@ -32,18 +32,39 @@ export type IStatBackend = {
|
||||||
export interface BorisUsageStats {
|
export interface BorisUsageStats {
|
||||||
git: Partial<IStatGitRow>[];
|
git: Partial<IStatGitRow>[];
|
||||||
issues: IGithubIssue[];
|
issues: IGithubIssue[];
|
||||||
backend?: IStatBackend;
|
backend: IStatBackend;
|
||||||
is_loading: boolean;
|
is_loading: boolean;
|
||||||
}
|
}
|
||||||
export type IBorisState = Readonly<{
|
export type IBorisState = Readonly<{
|
||||||
stats: BorisUsageStats;
|
stats: BorisUsageStats;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
const initialBackendStats: IStatBackend = {
|
||||||
|
users: {
|
||||||
|
total: 0,
|
||||||
|
alive: 0,
|
||||||
|
},
|
||||||
|
nodes: {
|
||||||
|
images: 0,
|
||||||
|
audios: 0,
|
||||||
|
videos: 0,
|
||||||
|
texts: 0,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
comments: {
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
files: {
|
||||||
|
count: 0,
|
||||||
|
size: 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const BORIS_INITIAL_STATE: IBorisState = {
|
const BORIS_INITIAL_STATE: IBorisState = {
|
||||||
stats: {
|
stats: {
|
||||||
git: [],
|
git: [],
|
||||||
issues: [],
|
issues: [],
|
||||||
backend: undefined,
|
backend: initialBackendStats,
|
||||||
is_loading: false,
|
is_loading: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue