| @@ -5,8 +5,8 @@ type FullScreenFrameProps = { | |||||
| url: string; | url: string; | ||||
| className?: string; | className?: string; | ||||
| style?: React.CSSProperties; | style?: React.CSSProperties; | ||||
| onload?: () => void; | |||||
| onerror?: () => void; | |||||
| onload?: (e?: React.SyntheticEvent<HTMLIFrameElement, Event>) => void; | |||||
| onerror?: (e?: React.SyntheticEvent<HTMLIFrameElement, Event>) => void; | |||||
| }; | }; | ||||
| function FullScreenFrame({ url, className, style, onload, onerror }: FullScreenFrameProps) { | function FullScreenFrame({ url, className, style, onload, onerror }: FullScreenFrameProps) { | ||||
| @@ -2,6 +2,11 @@ import FullScreenFrame from '@/components/FullScreenFrame'; | |||||
| import KFSpin from '@/components/KFSpin'; | import KFSpin from '@/components/KFSpin'; | ||||
| import { getLabelStudioUrl } from '@/services/developmentEnvironment'; | import { getLabelStudioUrl } from '@/services/developmentEnvironment'; | ||||
| import { to } from '@/utils/promise'; | import { to } from '@/utils/promise'; | ||||
| import { | |||||
| editorUrlKey, | |||||
| getSessionStorageItem, | |||||
| removeSessionStorageItem, | |||||
| } from '@/utils/sessionStorage'; | |||||
| import classNames from 'classnames'; | import classNames from 'classnames'; | ||||
| import { useEffect, useState } from 'react'; | import { useEffect, useState } from 'react'; | ||||
| import './index.less'; | import './index.less'; | ||||
| @@ -9,6 +14,7 @@ import './index.less'; | |||||
| export enum IframePageType { | export enum IframePageType { | ||||
| DatasetAnnotation = 'DatasetAnnotation', // 数据标注 | DatasetAnnotation = 'DatasetAnnotation', // 数据标注 | ||||
| AppDevelopment = 'AppDevelopment', // 应用开发 | AppDevelopment = 'AppDevelopment', // 应用开发 | ||||
| DevEnv = 'DevEnv', // 开发环境 | |||||
| } | } | ||||
| const getRequestAPI = (type: IframePageType): (() => Promise<any>) => { | const getRequestAPI = (type: IframePageType): (() => Promise<any>) => { | ||||
| @@ -17,6 +23,8 @@ const getRequestAPI = (type: IframePageType): (() => Promise<any>) => { | |||||
| return getLabelStudioUrl; | return getLabelStudioUrl; | ||||
| case IframePageType.AppDevelopment: | case IframePageType.AppDevelopment: | ||||
| return () => Promise.resolve({ code: 200, data: 'http://172.20.32.181:30080/' }); | return () => Promise.resolve({ code: 200, data: 'http://172.20.32.181:30080/' }); | ||||
| case IframePageType.DevEnv: | |||||
| return () => Promise.resolve({ code: 200, data: getSessionStorageItem(editorUrlKey) || '' }); | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -31,6 +39,11 @@ function IframePage({ type, className, style }: IframePageProps) { | |||||
| const [loading, setLoading] = useState(false); | const [loading, setLoading] = useState(false); | ||||
| useEffect(() => { | useEffect(() => { | ||||
| requestIframeUrl(); | requestIframeUrl(); | ||||
| return () => { | |||||
| if (type === IframePageType.DevEnv) { | |||||
| removeSessionStorageItem(editorUrlKey); | |||||
| } | |||||
| }; | |||||
| }, []); | }, []); | ||||
| const requestIframeUrl = async () => { | const requestIframeUrl = async () => { | ||||
| setLoading(true); | setLoading(true); | ||||
| @@ -4,35 +4,9 @@ | |||||
| * @Description: 开发环境 | * @Description: 开发环境 | ||||
| */ | */ | ||||
| import { | |||||
| editorUrlKey, | |||||
| getSessionStorageItem, | |||||
| removeSessionStorageItem, | |||||
| } from '@/utils/sessionStorage'; | |||||
| // import { getJupyterUrl } from '@/services/developmentEnvironment'; | |||||
| // import { to } from '@/utils/promise'; | |||||
| import { useEffect, useState } from 'react'; | |||||
| import IframePage, { IframePageType } from '@/components/IFramePage'; | |||||
| function DevEditor() { | function DevEditor() { | ||||
| const [iframeUrl, setIframeUrl] = useState(''); | |||||
| useEffect(() => { | |||||
| const url = getSessionStorageItem(editorUrlKey) || ''; | |||||
| setIframeUrl(url); | |||||
| return () => { | |||||
| removeSessionStorageItem(editorUrlKey); | |||||
| }; | |||||
| // requestJupyterUrl(); | |||||
| }, []); | |||||
| // const requestJupyterUrl = async () => { | |||||
| // const [res, error] = await to(getJupyterUrl()); | |||||
| // if (res) { | |||||
| // setIframeUrl(res.data as string); | |||||
| // } else { | |||||
| // console.log(error); | |||||
| // } | |||||
| // }; | |||||
| return <iframe style={{ width: '100%', height: '100%', border: 0 }} src={iframeUrl}></iframe>; | |||||
| return <IframePage type={IframePageType.DevEnv}></IframePage>; | |||||
| } | } | ||||
| export default DevEditor; | export default DevEditor; | ||||
| @@ -1,6 +1,8 @@ | |||||
| import { ExperimentStatus } from '@/enums'; | import { ExperimentStatus } from '@/enums'; | ||||
| import themes from '@/styles/theme.less'; | import themes from '@/styles/theme.less'; | ||||
| export { ExperimentStatus }; | |||||
| export interface ExperimentStatusInfo { | export interface ExperimentStatusInfo { | ||||
| label: string; | label: string; | ||||
| color: string; | color: string; | ||||
| @@ -1,5 +1,5 @@ | |||||
| import KFIcon from '@/components/KFIcon'; | import KFIcon from '@/components/KFIcon'; | ||||
| import { ExperimentStatusValues, experimentStatusInfo } from '@/pages/Experiment/status'; | |||||
| import { ExperimentStatus, experimentStatusInfo } from '@/pages/Experiment/status'; | |||||
| import { ExperimentInstance } from '@/types'; | import { ExperimentInstance } from '@/types'; | ||||
| import { elapsedTime, formatDate } from '@/utils/date'; | import { elapsedTime, formatDate } from '@/utils/date'; | ||||
| import { useNavigate } from '@umijs/max'; | import { useNavigate } from '@umijs/max'; | ||||
| @@ -13,7 +13,7 @@ type ExperimentTableProps = { | |||||
| function ExperimentTable({ tableData = [], style }: ExperimentTableProps) { | function ExperimentTable({ tableData = [], style }: ExperimentTableProps) { | ||||
| const navigate = useNavigate(); | const navigate = useNavigate(); | ||||
| const gotoExperiment = (record: ExperimentInstance) => { | const gotoExperiment = (record: ExperimentInstance) => { | ||||
| navigate(`/pipeline/experiment/${record.workflow_id}/${record.id}`); | |||||
| navigate(`/pipeline/experiment/instance/${record.workflow_id}/${record.id}`); | |||||
| }; | }; | ||||
| return ( | return ( | ||||
| @@ -28,7 +28,7 @@ function ExperimentTable({ tableData = [], style }: ExperimentTableProps) { | |||||
| <div className={styles['experiment-table__content']} key={item.id}> | <div className={styles['experiment-table__content']} key={item.id}> | ||||
| <div className={styles['experiment-table__status']} style={{ paddingLeft: '6.5px' }}> | <div className={styles['experiment-table__status']} style={{ paddingLeft: '6.5px' }}> | ||||
| <img | <img | ||||
| src={experimentStatusInfo[item.status as ExperimentStatusValues]?.icon} | |||||
| src={experimentStatusInfo[item.status as ExperimentStatus]?.icon} | |||||
| width={17} | width={17} | ||||
| height={17} | height={17} | ||||
| /> | /> | ||||