import {LoadStatistic, PageContainer, SearchInput, useTitle} from "./components/Common"; import {useSearchFiles} from "./hooks/customHooks"; import React, {useContext, useState} from "react"; import {StatusContext} from "./contexts/contexts"; import {DownloadMenu} from "./components/Download"; import {FilesSearchView} from "./components/Files"; import {Header, Segment, Statistic, StatisticGroup} from "./components/Theme"; import {Link} from "react-router-dom"; import {BandwidthProgressCombined, CPUUsageProgress} from "./components/admin/Status"; import {ProgressPlaceholder} from "./components/Placeholder"; import {Divider, Icon, Message} from "semantic-ui-react"; import Grid from "semantic-ui-react/dist/commonjs/collections/Grid"; import {refreshFiles} from "./api"; import _ from "lodash"; import {TagsDashboard, TagsProvider} from "./Tags"; function FlagsMessages({flags}) { if (!flags) { return <> } let refreshing; let refreshRequired; let dbDown; // Do not tell the maintainer to refresh the files if they are already refreshing. if (flags.indexOf('refreshing') >= 0) { // Actively refreshing. refreshing = Refreshing Your files are being refreshed. ; } else if (flags.indexOf('refresh_complete') === -1) { // `refresh_complete` flag is not set. Tell the maintainer to refresh the files. refreshRequired = Refresh required Click here to refresh all your files. ; } if (flags.indexOf('db_up') === -1) { dbDown = Database is down API is unable to connect to the database. Check the server logs. } return <> {refreshing} {dbDown || refreshRequired} } export function Dashboard() { useTitle('Dashboard'); const {searchStr, setSearchStr, activeTags} = useSearchFiles(); const {status} = useContext(StatusContext); const wrol_mode = status ? status['wrol_mode'] : null; const [downloadOpen, setDownloadOpen] = useState(false); const onDownloadOpen = (name) => setDownloadOpen(!!name); const downloadsDisabled = status?.flags?.indexOf('refresh_complete') === -1; const downloads = ; // Only show dashboard parts if not searching. let body; if (searchStr || activeTags) { body = ; } else { body = <> {!wrol_mode && downloads} {/* Hide Status when user is starting a download */} {!downloadOpen && } ; } return {!searchStr && } {body} } function DashboardStatus() { const {status} = useContext(StatusContext); let percent = 0; let load = {}; let cores = 0; let pending_downloads = '?'; if (status && status['cpu_info']) { percent = status['cpu_info']['percent']; load = status['load']; cores = status['cpu_info']['cores']; } const {downloads} = status; if (!_.isEmpty(downloads)) { pending_downloads = downloads && downloads['disabled'] ? 'x' : downloads['pending']; } let bandwidths = ; if (status && status['bandwidth']) { bandwidths = status['bandwidth'].map(i => ); } return
Status
Bandwidth
{bandwidths}
; }