Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/components/landing/executables-table.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Input, Table } from "antd";6import { debounce } from "lodash";7import { useMemo, useState } from "react";89import Code from "components/landing/code";10import { Text, Title } from "components/misc";11import executables, { Item } from "lib/landing/executables";12import { ComputeInventory } from "lib/landing/types";13import { SoftwareSpecTimestamp } from "./software-libraries";1415const INFO_STYLE: React.CSSProperties = {16overflow: "auto",17maxHeight: "10em",18maxWidth: "40vw",19backgroundColor: "rgba(150, 150, 150, 0.1)",20fontSize: "10px",21border: "none",22borderRadius: "3px",23} as const;2425const PRE_STYLE: React.CSSProperties = {26padding: "5px",27margin: 0,28overflow: "unset", // parent div will show scroll handles29} as const;3031const COLUMNS = [32{33title: "Name",34key: "name",35dataIndex: "name",36responsive: ["md" as any],37render: (name) => (38<Text strong style={{ fontSize: "12pt" }}>39{name}40</Text>41),42},43{44title: "Path",45key: "path",46dataIndex: "path",47render: (path) => <Code>{path}</Code>,48},49{50title: "Information",51key: "output",52dataIndex: "output",53width: "40%",54render: (output) => {55return {56props: { style: { padding: "0 0 1em 0" } },57children: (58<div style={INFO_STYLE}>59<pre style={PRE_STYLE}>{output}</pre>60</div>61),62};63},64},65];6667export default function ExecutablesTable({68executablesSpec,69timestamp,70}: {71executablesSpec: ComputeInventory["executables"];72timestamp: string;73}) {74const dataSource = executables(executablesSpec);75const [search, setSearch] = useState<string>("");76const onChange = useMemo(77() =>78debounce((e) => {79setSearch(e.target.value);80}, 300),81[],82);8384let data: Item[];85if (!search) {86data = dataSource;87} else {88const s = search.toLowerCase();89data = [];90for (const x of dataSource) {91if (x.path.includes(s)) {92data.push(x);93}94}95}9697return (98<div style={{ clear: "both" }}>99<Title level={2}>Showing {data.length} executables</Title>100<Input.Search101style={{ padding: "0 30px 15px 0", width: "50%", minWidth: "300px" }}102placeholder="Search..."103allowClear104onChange={onChange}105onPressEnter={(e) => setSearch((e.target as any).value)}106/>107<div style={{ overflowX: "auto", width: "100%" }}>108<Table109columns={COLUMNS}110bordered111pagination={false}112rowKey={"path"}113dataSource={data}114/>115</div>116<SoftwareSpecTimestamp timestamp={timestamp} />117</div>118);119}120121122