import React from "react"; import { observer } from "mobx-react"; import classNames from "classnames"; import { IconAction, TextAction } from "eez-studio-ui/action"; import { ProjectContext } from "project-editor/project/context"; import { dockerBuildManager } from "./build-manager"; import { dockerBuildState } from "./docker-build-state"; //////////////////////////////////////////////////////////////////////////////// export const DockerSimulatorLogsPanel = observer( class DockerSimulatorLogsPanel extends React.Component { static contextType = ProjectContext; declare context: React.ContextType; logsEndRef = React.createRef(); componentDidUpdate() { this.scrollToBottom(); } scrollToBottom = () => { this.logsEndRef.current?.scrollIntoView({ behavior: "instant" }); }; get projectState() { return dockerBuildState.getProjectState(this.context?.filePath); } handleClear = () => { this.projectState.clearLogs(); }; handleBuild = async () => { if (this.context) { await dockerBuildManager.startFullSimulator(this.context, true); } }; handleCleanBuild = async () => { if (this.context) { await dockerBuildManager.cleanBuildCache(this.context); } }; handleCleanAll = async () => { if (this.context) { await dockerBuildManager.cleanAll(this.context); } }; handleStop = async () => { await dockerBuildManager.stopFullSimulator(this.context?.filePath); }; render() { const projectState = this.projectState; const isBuilding = projectState.state === "building"; return (
{!isBuilding && ( <> )} {isBuilding && ( )}
{projectState.logs.map(log => (
{log.timestamp.toLocaleTimeString()} {log.message}
))}
); } } );