From 8693fcec246198d97cd1b10c33f990eaebecd92b Mon Sep 17 00:00:00 2001 From: insanity Date: Wed, 23 Aug 2017 11:43:06 +0900 Subject: [PATCH] probe detail modify --- .../react/components/ProbeDetailInfo.tsx | 181 ++++++++++++------ 1 file changed, 118 insertions(+), 63 deletions(-) diff --git a/src/ts/@overflow/probe/react/components/ProbeDetailInfo.tsx b/src/ts/@overflow/probe/react/components/ProbeDetailInfo.tsx index f6ae817..179ec71 100644 --- a/src/ts/@overflow/probe/react/components/ProbeDetailInfo.tsx +++ b/src/ts/@overflow/probe/react/components/ProbeDetailInfo.tsx @@ -8,8 +8,7 @@ import { Container, Input, InputOnChangeData, - Loader, - Dimmer, + Icon, } from 'semantic-ui-react'; import Probe from '@overflow/probe/api/model/Probe'; import { Discovery } from '@overflow/discovery/react/components/Discovery'; @@ -17,8 +16,8 @@ import { Discovery } from '@overflow/discovery/react/components/Discovery'; import * as Utils from '@overflow/commons/util/Utils'; export interface StateProps { - id: string; - probe: Probe; + id?: string; + probe?: Probe; } export interface DispatchProps { @@ -32,6 +31,8 @@ export type Props = StateProps & DispatchProps; export interface State { name: string; desc: string; + nameModifying: boolean; + descModifying: boolean; } @@ -42,11 +43,14 @@ export class ProbeDetailInfo extends React.Component { this.state = { name: undefined, desc: undefined, + nameModifying: false, + descModifying: false, }; + this.props.onRead(this.props.id); } public componentWillMount(): void { - this.props.onRead(this.props.id); + console.log(''); } public handleStartStop(event: any, data: any): void { @@ -68,12 +72,18 @@ export class ProbeDetailInfo extends React.Component { const p: Probe = this.props.probe; p.displayName = this.state.name; this.props.onModify(p); + this.setState({ + nameModifying: false, + }); } public handleDescModify = () => { let p: Probe = this.props.probe; p.description = this.state.desc; this.props.onModify(p); + this.setState({ + descModifying: false, + }); } @@ -83,64 +93,7 @@ export class ProbeDetailInfo extends React.Component { } return ( - - - - -
Name
-
- - , data: InputOnChangeData) => { - this.setState({ name: data.value }); - }} /> - -
- - -
Status
-
- {this.props.probe.status.name} -
- - -
Created at
-
- {Utils.date2date(this.props.probe.createDate)} -
- - -
Authorized at
-
- {Utils.date2date(this.props.probe.authorizeDate)} -
- - -
Authorized by
-
- {this.props.probe.authorizeMember.name} -
- - -
Uptime
-
- todo. -
- - -
Description
-
- - , data: InputOnChangeData) => { - this.setState({ desc: data.value }); - }} /> - -
-
-
+ {this.renderDetail()} {this.showStopBtn()} + + ); + } + } + + public renderDescription(): JSX.Element { + if (this.state.descModifying) { + return ( + , data: InputOnChangeData) => { + this.setState({ desc: data.value }); + }} /> + ); + } else { + return ( +
+ {this.props.probe.description} + +
+ ); + } + } + + private renderDetail(): JSX.Element { + if (this.props.probe === undefined) { + return null; + } + return ( + + + + +
Name
+
+ + {this.renderDisplayName()} + +
+ + +
Status
+
+ {this.props.probe.status.name} +
+ + +
Created at
+
+ {Utils.date2date(this.props.probe.createDate)} +
+ + +
Authorized at
+
+ {Utils.date2date(this.props.probe.authorizeDate)} +
+ + +
Authorized by
+
+ {this.props.probe.authorizeMember.name} +
+ + +
Uptime
+
+ todo. +
+ + +
Description
+
+ + {this.renderDescription()} + +
+
+
+ ); + } + }