about summary refs log tree commit diff
path: root/src/pages/Home.tsx
blob: 04e30d4a1ba5091065ed0b9a276fdcb376284c88 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { useEffect, useState, useCallback } from "react"

import { useNavigate } from "react-router-dom"
import SideBar from "../components/Sidebar/Sidebar"
import LineGraph from "../components/Graphs/LineGraph"
import TimePicker from "../components/TimePicker/TimePicker"
import DonutChart from "../components/Graphs/DonutChart"
import MostEditedFiles from "../components/MostEditedFiles"

export default function Home(props: any) {
  const navigate = useNavigate()

  useEffect(() => {
    if (!props.session) {
      navigate('/login')
    }
  }, [props.session])

  return (
    <>
      <div className="flex h-screen">
        <SideBar currentPage="Home" />
        <main className="overflow-y-auto flex flex-col flex-1 mx-5">
          <div className="flex flex-col w-full gap-7 flex-grow">
            <div className="flex flex-row gap-7 flex-grow">
              <div className="ml-auto mt-2">
                <TimePicker timeframe={props.timeframe} setTimeframe={props.setTimeframe} />
              </div>
            </div>
            <div className="flex flex-row gap-7 flex-grow">
              <div className="w-1/2 flex flex-col">
                <p className="text-center">Active hosts</p>
                <div className="flex-grow block bg-white-500 border border-gray-200 rounded-lg shadow">
                  <ol>
                    {/*TODO: Actually implement active hosts */}
                    <li>N/A</li>
                  </ol>
                </div>
              </div>
              <div className="w-1/2 ml-auto">
                <LineGraph name="File writes per second" supabase={props.supabase} timeframe={props.timeframe} />
              </div>
            </div>
            <div className="flex flex-row gap-7 mb-5 flex-grow">
              <div className="w-1/2 mr-auto">
                <DonutChart name="File writes size percentiles" supabase={props.supabase} timeframe={props.timeframe} />
              </div>
              <div className="w-1/2 flex flex-col">
                <p className="text-center">Most edited files</p>
                <div className="flex-grow block bg-white-500 border border-gray-200 rounded-lg shadow">
                  <MostEditedFiles supabase={props.supabase} timeframe={props.timeframe} />
                </div>
              </div>
            </div>
          </div>
        </main>
      </div>
    </>
  )
}