Commit c7187946 authored by Lijiao's avatar Lijiao Committed by GitHub
Browse files

Use office-fabric-ui components (#1964)

parent fdfff50d
import { Col, Row, Tooltip } from 'antd';
import * as React from 'react'; import * as React from 'react';
import { Stack, TooltipHost, getId } from 'office-ui-fabric-react';
import { EXPERIMENT } from '../../static/datamodel'; import { EXPERIMENT } from '../../static/datamodel';
import { formatTimestamp } from '../../static/function'; import { formatTimestamp } from '../../static/function';
...@@ -8,36 +8,48 @@ interface BasicInfoProps { ...@@ -8,36 +8,48 @@ interface BasicInfoProps {
} }
class BasicInfo extends React.Component<BasicInfoProps, {}> { class BasicInfo extends React.Component<BasicInfoProps, {}> {
// Use getId() to ensure that the ID is unique on the page.
// (It's also okay to use a plain string without getId() and manually ensure uniqueness.)
// for tooltip user the log directory
private _hostId: string = getId('tooltipHost');
constructor(props: BasicInfoProps) { constructor(props: BasicInfoProps) {
super(props); super(props);
} }
render(): React.ReactNode { render(): React.ReactNode {
return ( return (
<Row className="main"> <Stack horizontal horizontalAlign="space-between" className="main">
<Col span={8} className="padItem basic"> <Stack.Item grow={3} className="padItem basic">
<p>Name</p> <p>Name</p>
<div>{EXPERIMENT.profile.params.experimentName}</div> <div>{EXPERIMENT.profile.params.experimentName}</div>
<p>ID</p> <p>ID</p>
<div>{EXPERIMENT.profile.id}</div> <div>{EXPERIMENT.profile.id}</div>
</Col> </Stack.Item>
<Col span={8} className="padItem basic"> <Stack.Item grow={3} className="padItem basic">
<p>Start time</p> <p>Start time</p>
<div className="nowrap">{formatTimestamp(EXPERIMENT.profile.startTime)}</div> <div className="nowrap">{formatTimestamp(EXPERIMENT.profile.startTime)}</div>
<p>End time</p> <p>End time</p>
<div className="nowrap">{formatTimestamp(EXPERIMENT.profile.endTime)}</div> <div className="nowrap">{formatTimestamp(EXPERIMENT.profile.endTime)}</div>
</Col> </Stack.Item>
<Col span={8} className="padItem basic"> <Stack.Item className="padItem basic">
<p>Log directory</p> <p>Log directory</p>
<div className="nowrap"> <div className="nowrap">
<Tooltip placement="top" title={EXPERIMENT.profile.logDir || ''}> <TooltipHost
// Tooltip message content
content={EXPERIMENT.profile.logDir || 'unknown'}
id={this._hostId}
calloutProps={{ gapSpace: 0 }}
styles={{ root: { display: 'inline-block' } }}
>
{/* show logDir */}
{EXPERIMENT.profile.logDir || 'unknown'} {EXPERIMENT.profile.logDir || 'unknown'}
</Tooltip> </TooltipHost>
</div> </div>
<p>Training platform</p> <p>Training platform</p>
<div className="nowrap">{EXPERIMENT.profile.params.trainingServicePlatform}</div> <div className="nowrap">{EXPERIMENT.profile.params.trainingServicePlatform}</div>
</Col> </Stack.Item>
</Row>
</Stack>
); );
} }
} }
......
import * as React from 'react';
import { DetailsRow, IDetailsRowBaseProps } from 'office-ui-fabric-react';
import OpenRow from '../public-child/OpenRow';
interface DetailsProps {
detailsProps: IDetailsRowBaseProps;
}
interface DetailsState {
isExpand: boolean;
}
class Details extends React.Component<DetailsProps, DetailsState> {
constructor(props: DetailsProps) {
super(props);
this.state = { isExpand: false };
}
render(): React.ReactNode {
const { detailsProps } = this.props;
const { isExpand } = this.state;
return (
<div>
<div onClick={(): void => {
this.setState(() => ({ isExpand: !isExpand }));
}}>
<DetailsRow {...detailsProps} />
</div>
{isExpand && <OpenRow trialId={detailsProps.item.id} />}
</div>
);
}
}
export default Details;
\ No newline at end of file
import * as React from 'react'; import * as React from 'react';
import { Button, Row } from 'antd'; import { Stack, PrimaryButton } from 'office-ui-fabric-react';
interface ConcurrencyInputProps { interface ConcurrencyInputProps {
value: number; value: number;
...@@ -36,47 +36,38 @@ class ConcurrencyInput extends React.Component<ConcurrencyInputProps, Concurrenc ...@@ -36,47 +36,38 @@ class ConcurrencyInput extends React.Component<ConcurrencyInputProps, Concurrenc
render(): React.ReactNode { render(): React.ReactNode {
if (this.state.editting) { if (this.state.editting) {
return ( return (
<Row className="inputBox"> <Stack horizontal className="inputBox">
<input <input
type="number" type="number"
className="concurrencyInput" className="concurrencyInput"
defaultValue={this.props.value.toString()} defaultValue={this.props.value.toString()}
ref={this.input} ref={this.input}
/> />
<Button <PrimaryButton
type="primary" text="Save"
className="tableButton editStyle"
onClick={this.save} onClick={this.save}
> />
Save <PrimaryButton
</Button> text="Cancel"
<Button
type="primary"
onClick={this.cancel}
style={{ display: 'inline-block', marginLeft: 1 }} style={{ display: 'inline-block', marginLeft: 1 }}
className="tableButton editStyle" onClick={this.cancel}
> />
Cancel </Stack>
</Button>
</Row>
); );
} else { } else {
return ( return (
<Row className="inputBox"> <Stack horizontal className="inputBox">
<input <input
type="number" type="number"
className="concurrencyInput" className="concurrencyInput"
disabled={true} disabled={true}
value={this.props.value} value={this.props.value}
/> />
<Button <PrimaryButton
type="primary" text="Edit"
className="tableButton editStyle"
onClick={this.edit} onClick={this.edit}
> />
Edit </Stack>
</Button>
</Row>
); );
} }
} }
......
import * as React from 'react'; import * as React from 'react';
import { Row, Col, Progress } from 'antd'; import { Stack, StackItem, ProgressIndicator } from 'office-ui-fabric-react';
interface ProItemProps { interface ProItemProps {
who: string; who: string;
...@@ -18,29 +18,23 @@ class ProgressBar extends React.Component<ProItemProps, {}> { ...@@ -18,29 +18,23 @@ class ProgressBar extends React.Component<ProItemProps, {}> {
render(): React.ReactNode { render(): React.ReactNode {
const { who, percent, description, maxString, bgclass } = this.props; const { who, percent, description, maxString, bgclass } = this.props;
return ( return (
<div> <div>
<Row className={`probar ${bgclass}`}> <Stack horizontal className={`probar ${bgclass}`}>
<Col span={8}>
<div className="name">{who}</div> <div className="name">{who}</div>
</Col> <div className="showProgress" style={{ width: '80%' }}>
<Col span={16} className="bar"> <ProgressIndicator
<div className="showProgress"> barHeight={30}
<Progress percentComplete={percent}
percent={percent}
strokeWidth={30}
// strokeLinecap={'square'}
format={(): string => description}
/> />
<Stack horizontal className="boundary">
<StackItem grow={30}>0</StackItem>
<StackItem className="right" grow={70}>{maxString}</StackItem>
</Stack>
</div> </div>
<Row className="description"> <div className="description" style={{ width: '20%' }}>{description}</div>
<Col span={9}>0</Col> </Stack>
<Col className="right" span={15}>{maxString}</Col> <br />
</Row>
</Col>
</Row>
<br/>
</div> </div>
); );
} }
......
...@@ -18,7 +18,6 @@ class SearchSpace extends React.Component<SearchspaceProps, {}> { ...@@ -18,7 +18,6 @@ class SearchSpace extends React.Component<SearchspaceProps, {}> {
return ( return (
<div className="searchSpace"> <div className="searchSpace">
<MonacoEditor <MonacoEditor
width="100%"
height="361" height="361"
language="json" language="json"
theme="vs-light" theme="vs-light"
......
import * as React from 'react'; import * as React from 'react';
import {Stack} from 'office-ui-fabric-react';
import '../../static/style/overviewTitle.scss';
interface Title1Props { interface Title1Props {
text: string; text: string;
icon?: string; icon?: string;
...@@ -15,12 +16,10 @@ class Title1 extends React.Component<Title1Props, {}> { ...@@ -15,12 +16,10 @@ class Title1 extends React.Component<Title1Props, {}> {
render(): React.ReactNode { render(): React.ReactNode {
const { text, icon, bgcolor } = this.props; const { text, icon, bgcolor } = this.props;
return ( return (
<div> <Stack horizontal className="panelTitle" style={{ backgroundColor: bgcolor }}>
<div className="panelTitle" style={{backgroundColor: bgcolor}}>
<img src={require(`../../static/img/icon/${icon}`)} alt="icon" /> <img src={require(`../../static/img/icon/${icon}`)} alt="icon" />
<span>{text}</span> <span>{text}</span>
</div> </Stack>
</div>
); );
} }
} }
......
...@@ -27,7 +27,6 @@ class TrialInfo extends React.Component<TrialInfoProps, {}> { ...@@ -27,7 +27,6 @@ class TrialInfo extends React.Component<TrialInfoProps, {}> {
}; };
const profile = JSON.stringify(EXPERIMENT.profile, filter, 2); const profile = JSON.stringify(EXPERIMENT.profile, filter, 2);
// FIXME: highlight not working?
return ( return (
<div className="profile"> <div className="profile">
<MonacoEditor <MonacoEditor
......
import * as React from 'react';
import LogPathChild from './LogPathChild';
interface LogpathProps {
logStr: string;
}
class LogPath extends React.Component<LogpathProps, {}> {
constructor(props: LogpathProps) {
super(props);
}
render(): React.ReactNode {
const { logStr } = this.props;
const isTwopath = logStr.indexOf(',') !== -1
?
true
:
false;
return (
<div>
{
isTwopath
?
<div>
<LogPathChild
eachLogpath={logStr.split(',')[0]}
logName="LogPath:"
/>
<LogPathChild
eachLogpath={logStr.split(',')[1]}
logName="Log on HDFS:"
/>
</div>
:
<LogPathChild
eachLogpath={logStr}
logName="Log path:"
/>
}
</div>
);
}
}
export default LogPath;
\ No newline at end of file
import * as React from 'react'; import * as React from 'react';
import { Spin } from 'antd'; import { Spinner } from 'office-ui-fabric-react';
import { DRAWEROPTION } from '../../static/const'; import { DRAWEROPTION } from '../../static/const';
import MonacoEditor from 'react-monaco-editor'; import MonacoEditor from 'react-monaco-editor';
...@@ -11,7 +11,7 @@ interface MonacoEditorProps { ...@@ -11,7 +11,7 @@ interface MonacoEditorProps {
class MonacoHTML extends React.Component<MonacoEditorProps, {}> { class MonacoHTML extends React.Component<MonacoEditorProps, {}> {
public _isMonacoMount: boolean; public _isMonacoMount!: boolean;
constructor(props: MonacoEditorProps) { constructor(props: MonacoEditorProps) {
super(props); super(props);
...@@ -25,14 +25,18 @@ class MonacoHTML extends React.Component<MonacoEditorProps, {}> { ...@@ -25,14 +25,18 @@ class MonacoHTML extends React.Component<MonacoEditorProps, {}> {
this._isMonacoMount = false; this._isMonacoMount = false;
} }
render(): React.ReactNode{ render(): React.ReactNode {
const { content, loading, height } = this.props; const { content, loading, height } = this.props;
return ( return (
<div className="just-for-log"> <div className="just-for-log">
<Spin {
// tip="Loading..." loading
style={{ width: '100%', height: height }} ?
spinning={loading} <Spinner
label="Wait, wait..."
ariaLive="assertive"
labelPosition="right"
styles={{ root: { width: '100%', height: height } }}
> >
<MonacoEditor <MonacoEditor
width="100%" width="100%"
...@@ -41,7 +45,17 @@ class MonacoHTML extends React.Component<MonacoEditorProps, {}> { ...@@ -41,7 +45,17 @@ class MonacoHTML extends React.Component<MonacoEditorProps, {}> {
value={content} value={content}
options={DRAWEROPTION} options={DRAWEROPTION}
/> />
</Spin> </Spinner>
:
<MonacoEditor
width="100%"
height={height}
language="json"
value={content}
options={DRAWEROPTION}
/>
}
</div> </div>
); );
} }
......
import * as React from 'react'; import * as React from 'react';
import { Row } from 'antd';
import { DOWNLOAD_IP } from '../../static/const'; import { DOWNLOAD_IP } from '../../static/const';
interface PaiTrialChildProps { interface PaiTrialChildProps {
...@@ -24,7 +23,7 @@ class PaiTrialChild extends React.Component<PaiTrialChildProps, {}> { ...@@ -24,7 +23,7 @@ class PaiTrialChild extends React.Component<PaiTrialChildProps, {}> {
? ?
<div /> <div />
: :
<Row> <div>
{ {
logCollect logCollect
? ?
...@@ -39,7 +38,7 @@ class PaiTrialChild extends React.Component<PaiTrialChildProps, {}> { ...@@ -39,7 +38,7 @@ class PaiTrialChild extends React.Component<PaiTrialChildProps, {}> {
: :
<span>trial stdout: {logString}</span> <span>trial stdout: {logString}</span>
} }
</Row> </div>
} }
</div> </div>
); );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment