"examples/vscode:/vscode.git/clone" did not exist on "ee4e708d16e3672f512062f952001847876764f8"
Commit 5e178524 authored by 杨明亮's avatar 杨明亮 Committed by xuehui
Browse files

copy parameters to clipboard in form of python dict. (#908)

* copy parameters in form of python dict.

* remove irrelevant files

* better ui and ux

* better ui
parent e7d31abd
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
"antd": "^3.8.1", "antd": "^3.8.1",
"axios": "^0.18.0", "axios": "^0.18.0",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"copy-to-clipboard": "^3.0.8",
"echarts": "^4.1.0", "echarts": "^4.1.0",
"echarts-for-react": "^2.0.14", "echarts-for-react": "^2.0.14",
"react": "^16.4.2", "react": "^16.4.2",
......
import * as React from 'react'; import * as React from 'react';
import * as copy from 'copy-to-clipboard';
import PaiTrialLog from '../public-child/PaiTrialLog'; import PaiTrialLog from '../public-child/PaiTrialLog';
import TrialLog from '../public-child/TrialLog'; import TrialLog from '../public-child/TrialLog';
import JSONTree from 'react-json-tree';
import { TableObj } from '../../static/interface'; import { TableObj } from '../../static/interface';
import { Row, Tabs } from 'antd'; import { Row, Tabs, Button, message } from 'antd';
import JSONTree from 'react-json-tree';
const TabPane = Tabs.TabPane; const TabPane = Tabs.TabPane;
interface OpenRowProps { interface OpenRowProps {
...@@ -19,6 +20,15 @@ class OpenRow extends React.Component<OpenRowProps, {}> { ...@@ -19,6 +20,15 @@ class OpenRow extends React.Component<OpenRowProps, {}> {
} }
copyParams = (record: TableObj) => {
let params = JSON.stringify(record.description.parameters);
if (copy(params)) {
message.success('Success copy parameters to clipboard in form of python dict !', 3);
} else {
message.error('Failed !', 2);
}
}
render() { render() {
const { trainingPlatform, record, logCollection } = this.props; const { trainingPlatform, record, logCollection } = this.props;
...@@ -42,12 +52,19 @@ class OpenRow extends React.Component<OpenRowProps, {}> { ...@@ -42,12 +52,19 @@ class OpenRow extends React.Component<OpenRowProps, {}> {
{ {
isHasParameters isHasParameters
? ?
<JSONTree <div>
hideRoot={true} <JSONTree
shouldExpandNode={() => true} // default expandNode hideRoot={true}
getItemString={() => (<span />)} // remove the {} items shouldExpandNode={() => true} // default expandNode
data={openRowDataSource} getItemString={() => (<span />)} // remove the {} items
/> data={openRowDataSource.parameters}
/>
<Button
onClick={this.copyParams.bind(this, record)}
>
Copy as Python
</Button>
</div>
: :
<div className="logpath"> <div className="logpath">
<span className="logName">Error: </span> <span className="logName">Error: </span>
......
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