mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-26 18:06:17 -05:00
Creating File Statistics page.
This commit is contained in:
parent
fef8e123a0
commit
e24990aae2
7 changed files with 165 additions and 2 deletions
|
|
@ -1,11 +1,12 @@
|
|||
import React, {useContext} from 'react';
|
||||
import {Divider, SegmentGroup} from "semantic-ui-react";
|
||||
import {Divider, SegmentGroup, StatisticLabel, StatisticValue} from "semantic-ui-react";
|
||||
import {Route, Routes} from "react-router-dom";
|
||||
import "../static/wrolpi.css";
|
||||
import {decryptOTP, encryptOTP} from "../api";
|
||||
import {PageContainer, useTitle} from "./Common";
|
||||
import {ThemeContext} from "../contexts/contexts";
|
||||
import {Button, Header, Segment, TextArea} from "./Theme";
|
||||
import {Button, Header, Loader, Segment, Statistic, StatisticGroup, TextArea} from "./Theme";
|
||||
import {useFileStatistics} from "../hooks/customHooks";
|
||||
|
||||
class Encrypt extends React.Component {
|
||||
constructor(props) {
|
||||
|
|
@ -145,10 +146,72 @@ function OTP() {
|
|||
</>
|
||||
}
|
||||
|
||||
function FileStatistics() {
|
||||
useTitle('File Statistics');
|
||||
|
||||
const {s} = useContext(ThemeContext);
|
||||
|
||||
const {statistics} = useFileStatistics();
|
||||
|
||||
let body = <Loader inline active/>;
|
||||
|
||||
if (statistics === undefined) {
|
||||
body = <p {...s}>Failed to fetch statistics</p>;
|
||||
}
|
||||
|
||||
if (statistics !== undefined && statistics !== null) {
|
||||
const {total_count, video_count, pdf_count, ebook_count, archive_count, image_count, zip_count} = statistics;
|
||||
body = <>
|
||||
<StatisticGroup>
|
||||
<Statistic>
|
||||
<StatisticValue>{total_count}</StatisticValue>
|
||||
<StatisticLabel>All Files</StatisticLabel>
|
||||
</Statistic>
|
||||
</StatisticGroup>
|
||||
<StatisticGroup size='small'>
|
||||
<Statistic color='blue'>
|
||||
<StatisticValue>{video_count}</StatisticValue>
|
||||
<StatisticLabel>Videos</StatisticLabel>
|
||||
</Statistic>
|
||||
<Statistic color='red'>
|
||||
<StatisticValue>{pdf_count}</StatisticValue>
|
||||
<StatisticLabel>PDFs</StatisticLabel>
|
||||
</Statistic>
|
||||
<Statistic color='yellow'>
|
||||
<StatisticValue>{ebook_count}</StatisticValue>
|
||||
<StatisticLabel>eBooks</StatisticLabel>
|
||||
</Statistic>
|
||||
<Statistic color='green'>
|
||||
<StatisticValue>{archive_count}</StatisticValue>
|
||||
<StatisticLabel>Archives</StatisticLabel>
|
||||
</Statistic>
|
||||
<Statistic color='pink'>
|
||||
<StatisticValue>{image_count}</StatisticValue>
|
||||
<StatisticLabel>Images</StatisticLabel>
|
||||
</Statistic>
|
||||
</StatisticGroup>
|
||||
<StatisticGroup>
|
||||
<Statistic color='grey'>
|
||||
<StatisticValue>{zip_count}</StatisticValue>
|
||||
<StatisticLabel>ZIP</StatisticLabel>
|
||||
</Statistic>
|
||||
</StatisticGroup>
|
||||
</>;
|
||||
}
|
||||
|
||||
return <>
|
||||
<Header as='h1'>File Statistics</Header>
|
||||
<Segment>
|
||||
{body}
|
||||
</Segment>
|
||||
</>
|
||||
}
|
||||
|
||||
export function AppsRoute(props) {
|
||||
return (<PageContainer>
|
||||
<Routes>
|
||||
<Route path='otp' exact element={<OTP/>}/>
|
||||
<Route path='file_statistics' exact element={<FileStatistics/>}/>
|
||||
</Routes>
|
||||
</PageContainer>)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ const links = [
|
|||
{
|
||||
key: 'apps', text: 'Apps', links: [
|
||||
{to: '/apps/otp', text: 'One Time Pad', end: true},
|
||||
{to: '/apps/file_statistics', text: 'File Statistics', end: true},
|
||||
]
|
||||
},
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue