diff --git a/src/ts/containers/agent/AgentDetail.tsx b/src/ts/containers/agent/AgentDetail.tsx index 2434d56..0a26fd1 100644 --- a/src/ts/containers/agent/AgentDetail.tsx +++ b/src/ts/containers/agent/AgentDetail.tsx @@ -40,7 +40,7 @@ export class AgentDetail extends React.Component { appToAdd: 1, addType : 'host' } - + console.log(this.props.agent); }; handleAddTarget = () => { diff --git a/src/ts/containers/agent/Agents.tsx b/src/ts/containers/agent/Agents.tsx index 6784003..44840d4 100644 --- a/src/ts/containers/agent/Agents.tsx +++ b/src/ts/containers/agent/Agents.tsx @@ -22,43 +22,6 @@ const styles = { }, }; -const tableData = [ - { - agentId: '111', - desc: 'Agent 1', - status: 'Wait For Auth', - }, - { - agentId: 'wqekoekeeeeerw', - desc: 'Agent 2', - status: 'Wait For Auth', - }, - { - agentId: 'wqekoekeeeeerw', - desc: 'Agent 3', - status: 'Wait For Auth', - }, - { - agentId: 'wqekoekeeeeerw', - desc: 'Agent 4', - status: 'Wait For Auth', - }, - { - agentId: 'wqekoekeeeeerw', - desc: 'Agent 5', - status: 'Wait For Auth', - }, - { - agentId: 'wqekoekeeeeerw', - desc: 'Agent 6', - status: 'Wait For Auth', - }, - { - agentId: 'wqekoekeeeeerw', - desc: 'Agent 7', - status: 'Wait For Auth', - }, -]; export class Agents extends React.Component { constructor(props: any, context: any) { @@ -66,30 +29,42 @@ export class Agents extends React.Component { this.state = { agents: [] }; - this.getAgents(); + }; + componentDidMount() { + this.getAgents(); + } + getAgents = () => { - let output: string; - let obj: any; //new object declaration - obj = { - "phone": this.state.phone - }; + // let output: string; + // let obj: any; //new object declaration + // obj = { + // "memberId":"1" + // }; - let os: OFRest = new OFRest("Agent", "Regist", obj); + // let os: OFRest = new OFRest("Agent", "getAgentList", obj); - os.Call().then(function (res) { - return res.json(); - }).then(function (json) { - console.log(json); - }).catch(function (err) { - console.log(err); + // os.Call().then(function (res) { + // return res.json(); + // }).then(function (json) { + // console.log(json); + // }).catch(function (err) { + // console.log(err); + // }); + + var val = '[{"id":3,"member":{"id":1,"email":"insanity33@loafle.com","pwSalt":"salktttt","digest":"bbbbbbbbb","name":"insanity3","company":"loafle","phone":"000-000-0000","authorizedDate":null},"authorizedDate":null,"description":"test agent2"},{"id":4,"member":{"id":1,"email":"","pwSalt":"","digest":"","name":"","company":"","phone":"","authorizedDate":0},"authorizedDate":null,"description":"test agent3"}]'; + this.setState({ + agents : JSON.parse(val) }); } handleRowSelected = (selectedRows: number[] | string) => { - this.props.history.push('/agent/agentDetail'); + this.props.history.push({ + pathname : '/agent/agentDetail', + props: { agent : this.state.agents[selectedRows[0]] } + }); } render() { @@ -107,19 +82,23 @@ export class Agents extends React.Component { enableSelectAll={false} displaySelectAll={false}> - Agent Id - Description - Status + Agent Id + Description + Authorized At + Status + Last Polling At - {tableData.map((row: any, index: number) => ( + {this.state.agents.map((row: any, index: number) => ( - {row.agentId} - {row.desc} + {row.id} + {row.description} + {row.authorizedDate} {row.status} + {row.lastPollingDate} ))};