import React, { useCallback, useEffect, useState } from "react"; import Grid from "@material-ui/core/Grid"; import Paper from "@material-ui/core/Paper"; import { CartesianGrid, Legend, Line, LineChart, Tooltip, XAxis, YAxis, } from "recharts"; import { ResponsiveContainer } from "recharts/lib/component/ResponsiveContainer"; import { makeStyles } from "@material-ui/core/styles"; import pathHelper from "../../utils/page"; import API from "../../middleware/Api"; import { useDispatch } from "react-redux"; import Typography from "@material-ui/core/Typography"; import Divider from "@material-ui/core/Divider"; import List from "@material-ui/core/List"; import ListItem from "@material-ui/core/ListItem"; import ListItemAvatar from "@material-ui/core/ListItemAvatar"; import Avatar from "@material-ui/core/Avatar"; import { Description, Favorite, FileCopy, Forum, GitHub, Home, Launch, Lock, People, Public, Telegram, } from "@material-ui/icons"; import ListItemText from "@material-ui/core/ListItemText"; import ListItemIcon from "@material-ui/core/ListItemIcon"; import { blue, green, red, yellow } from "@material-ui/core/colors"; import axios from "axios"; import TimeAgo from "timeago-react"; import Chip from "@material-ui/core/Chip"; import DialogTitle from "@material-ui/core/DialogTitle"; import Dialog from "@material-ui/core/Dialog"; import DialogContent from "@material-ui/core/DialogContent"; import DialogContentText from "@material-ui/core/DialogContentText"; import DialogActions from "@material-ui/core/DialogActions"; import Button from "@material-ui/core/Button"; import { toggleSnackbar } from "../../redux/explorer"; import { Trans, useTranslation } from "react-i18next"; const useStyles = makeStyles((theme) => ({ paper: { padding: theme.spacing(3), height: "100%", }, logo: { width: 70, }, logoContainer: { padding: theme.spacing(3), display: "flex", }, title: { marginLeft: 16, }, cloudreve: { fontSize: 25, color: theme.palette.text.secondary, }, version: { color: theme.palette.text.hint, }, links: { padding: theme.spacing(3), }, iconRight: { minWidth: 0, }, userIcon: { backgroundColor: blue[100], color: blue[600], }, fileIcon: { backgroundColor: yellow[100], color: yellow[800], }, publicIcon: { backgroundColor: green[100], color: green[800], }, secretIcon: { backgroundColor: red[100], color: red[800], }, })); export default function Index() { const { t } = useTranslation("dashboard"); const classes = useStyles(); const [lineData, setLineData] = useState([]); // const [news, setNews] = useState([]); // const [newsUsers, setNewsUsers] = useState({}); const [open, setOpen] = React.useState(false); const [siteURL, setSiteURL] = React.useState(""); const [statistics, setStatistics] = useState({ fileTotal: 0, userTotal: 0, publicShareTotal: 0, secretShareTotal: 0, }); const [version, setVersion] = useState({ backend: "-", }); const dispatch = useDispatch(); const ToggleSnackbar = useCallback( (vertical, horizontal, msg, color) => dispatch(toggleSnackbar(vertical, horizontal, msg, color)), [dispatch] ); const ResetSiteURL = () => { setOpen(false); API.patch("/admin/setting", { options: [ { key: "siteURL", value: window.location.origin, }, ], }) .then(() => { setSiteURL(window.location.origin); ToggleSnackbar("top", "right", t("settings.saved"), "success"); }) .catch((error) => { ToggleSnackbar("top", "right", error.message, "error"); }); }; useEffect(() => { API.get("/admin/summary") .then((response) => { const data = []; response.data.date.forEach((v, k) => { data.push({ name: v, file: response.data.files[k], user: response.data.users[k], share: response.data.shares[k], }); }); setLineData(data); setStatistics({ fileTotal: response.data.fileTotal, userTotal: response.data.userTotal, publicShareTotal: response.data.publicShareTotal, secretShareTotal: response.data.secretShareTotal, }); setVersion(response.data.version); setSiteURL(response.data.siteURL); if ( response.data.siteURL === "" || response.data.siteURL !== window.location.origin ) { setOpen(true); } }) .catch((error) => { ToggleSnackbar("top", "right", error.message, "error"); }); // axios // .get("/api/v3/admin/news?tag=" + t("summary.newsTag")) // .then((response) => { // setNews(response.data.data); // const res = {}; // response.data.included.forEach((v) => { // if (v.type === "users") { // res[v.id] = v.attributes; // } // }); // setNewsUsers(res); // }) // .catch((error) => { // ToggleSnackbar( // "top", // "right", // t("summary.newsletterError"), // "warning" // ); // }); }, []); return ( setOpen(false)} aria-labelledby="alert-dialog-title" aria-describedby="alert-dialog-description" > {t("summary.confirmSiteURLTitle")} {siteURL === "" && t("summary.siteURLNotSet", { current: window.location.origin, })} {siteURL !== "" && t("summary.siteURLNotMatch", { current: window.location.origin, })} {t("summary.siteURLDescription")} {t("summary.trend")} {t("summary.summary")}
cloudreve
Cloudreve {version.backend}{" "} {version.is_plus === "true" && ( )}
window.open("https://cloudreve.org") } > window.open( "https://github.com/cloudreve/cloudreve" ) } > window.open("https://docs.cloudreve.org/") } > window.open(t("summary.forumLink")) } > window.open(t("summary.telegramGroupLink")) } > window.open("https://docs.cloudreve.org/use/pro/jie-shao") } >
{/* {news && news.map((v) => ( <> window.open( "https://forum.cloudreve.org/d/" + v.id ) } > {newsUsers[ v.relationships .startUser.data .id ] && newsUsers[ v.relationships .startUser .data.id ].username}{" "} , ]} /> } /> ))} */}
); }