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/frontend/compute/compute-server-log.tsx
Views: 687
/*1Show the log entries for a specific compute server.23More precisely this is a little button that you click on, and4it shows the log in a modal.5*/67import { Modal, Button, Spin, Table, Tooltip } from "antd";8import { useEffect, useState } from "react";9import LogEntry from "./log-entry";10import type { ComputeServerEvent } from "@cocalc/util/compute/log";11import { TimeAgo } from "@cocalc/frontend/components";12import { getLog } from "./api";13import { Icon } from "@cocalc/frontend/components";14import getTitle from "./get-title";1516export default function ComputeServerLog({17id,18style,19}: {20id: number;21style?;22color?: string;23}) {24const [open, setOpen] = useState<boolean>(false);2526return (27<Tooltip title={"Show configuration and control log"}>28<Button29size={"small"}30type="text"31style={{ color: "#666", ...style }}32onClick={() => {33setOpen(true);34}}35>36<Icon name="history" /> Log37</Button>38{open && <LogModal id={id} close={() => setOpen(false)} />}39</Tooltip>40);41}4243export function LogModal({ id, close }) {44const [log, setLog] = useState<45null | { time: Date; project_id: string; event: ComputeServerEvent }[]46>(null);47const [title, setTitle] = useState<string>("");4849useEffect(() => {50(async () => {51setLog(await getLog({ id }));52setTitle((await getTitle(id)).title);53})();54}, []);5556return (57<Modal58width={800}59title={60<>61<Icon name="server" /> Compute Server Log - "{title}"62</>63}64open65onCancel={close}66onOk={close}67>68{log == null && <Spin />}69{log != null && (70<Table dataSource={log} rowKey={(record) => record.time.toString()}>71<Table.Column72title="Log Entry"73render={(record) => (74<LogEntry75event={record.event}76hideTitle77project_id={record.project_id}78/>79)}80/>81<Table.Column82title="Time"83render={(record) => <TimeAgo date={record.time} />}84/>85</Table>86)}87</Modal>88);89}909192