About.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import * as React from "react";
  2. import { DefaultButton, Dialog, DialogFooter, DialogType, Pivot, PivotItem } from "@fluentui/react";
  3. import { useConst } from "@fluentui/react-hooks";
  4. import { Bar } from "@hpcc-js/chart";
  5. import { fetchStats } from "src/KeyValStore";
  6. import nlsHPCC from "src/nlsHPCC";
  7. import { TpGetServerVersion } from "src/WsTopology";
  8. import { AutosizeHpccJSComponent } from "../layouts/HpccJSAdapter";
  9. import { TableGroup } from "./forms/Groups";
  10. interface AboutProps {
  11. show?: boolean;
  12. onClose?: () => void;
  13. }
  14. export const About: React.FunctionComponent<AboutProps> = ({
  15. show = false,
  16. onClose = () => { }
  17. }) => {
  18. const [version, setVersion] = React.useState("");
  19. const [browser, setBrowser] = React.useState([]);
  20. const [os, setOS] = React.useState([]);
  21. React.useEffect(() => {
  22. TpGetServerVersion().then(version => {
  23. setVersion(version);
  24. });
  25. fetchStats().then(response => {
  26. setBrowser(response.browser);
  27. setOS(response.os);
  28. });
  29. }, []);
  30. const browserChart = useConst(new Bar().columns([nlsHPCC.Client, nlsHPCC.Count]));
  31. browserChart
  32. .data(browser)
  33. ;
  34. const osChart = useConst(new Bar().columns([nlsHPCC.Client, nlsHPCC.Count]));
  35. osChart
  36. .data(os)
  37. ;
  38. const dialogContentProps = {
  39. type: DialogType.largeHeader,
  40. title: nlsHPCC.AboutHPCCSystems
  41. };
  42. return <Dialog hidden={!show} onDismiss={onClose} dialogContentProps={dialogContentProps} minWidth="640px">
  43. <Pivot>
  44. <PivotItem itemKey="about" headerText={nlsHPCC.About}>
  45. <div style={{ minHeight: "208px", paddingTop: "32px" }}>
  46. <TableGroup fields={{
  47. version: { label: nlsHPCC.Version, type: "string", value: version || "???", readonly: true },
  48. homepage: { label: nlsHPCC.Homepage, type: "link", href: "https://hpccsystems.com" },
  49. }}>
  50. </TableGroup>
  51. </div>
  52. </PivotItem>
  53. <PivotItem itemKey="browser" headerText={nlsHPCC.BrowserStats} alwaysRender>
  54. <AutosizeHpccJSComponent widget={browserChart} fixedHeight="240px" />
  55. </PivotItem>
  56. <PivotItem itemKey="os" headerText={nlsHPCC.OSStats} alwaysRender>
  57. <AutosizeHpccJSComponent widget={osChart} fixedHeight="240px" />
  58. </PivotItem>
  59. </Pivot>
  60. <DialogFooter>
  61. <DefaultButton onClick={onClose} text={nlsHPCC.OK} />
  62. </DialogFooter>
  63. </Dialog>;
  64. };