This commit is contained in:
insanity 2017-06-05 18:26:58 +09:00
parent 35852f03a0
commit ab6862f894
2 changed files with 37 additions and 58 deletions

View File

@ -40,7 +40,7 @@ export class AgentDetail extends React.Component<any, any> {
appToAdd: 1, appToAdd: 1,
addType : 'host' addType : 'host'
} }
console.log(this.props.agent);
}; };
handleAddTarget = () => { handleAddTarget = () => {

View File

@ -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<any, any> { export class Agents extends React.Component<any, any> {
constructor(props: any, context: any) { constructor(props: any, context: any) {
@ -66,30 +29,42 @@ export class Agents extends React.Component<any, any> {
this.state = { this.state = {
agents: [] agents: []
}; };
this.getAgents();
}; };
componentDidMount() {
this.getAgents();
}
getAgents = () => { getAgents = () => {
let output: string; // let output: string;
let obj: any; //new object declaration // let obj: any; //new object declaration
obj = { // obj = {
"phone": this.state.phone // "memberId":"1"
}; // };
let os: OFRest = new OFRest("Agent", "Regist", obj); // let os: OFRest = new OFRest("Agent", "getAgentList", obj);
os.Call().then(function (res) { // os.Call().then(function (res) {
return res.json(); // return res.json();
}).then(function (json) { // }).then(function (json) {
console.log(json); // console.log(json);
}).catch(function (err) { // }).catch(function (err) {
console.log(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) => { 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() { render() {
@ -107,19 +82,23 @@ export class Agents extends React.Component<any, any> {
enableSelectAll={false} enableSelectAll={false}
displaySelectAll={false}> displaySelectAll={false}>
<TableRow> <TableRow>
<TableHeaderColumn tooltip="The Agent Id">Agent Id</TableHeaderColumn> <TableHeaderColumn >Agent Id</TableHeaderColumn>
<TableHeaderColumn tooltip="The Description">Description</TableHeaderColumn> <TableHeaderColumn >Description</TableHeaderColumn>
<TableHeaderColumn tooltip="The Status">Status</TableHeaderColumn> <TableHeaderColumn >Authorized At</TableHeaderColumn>
<TableHeaderColumn >Status</TableHeaderColumn>
<TableHeaderColumn >Last Polling At</TableHeaderColumn>
</TableRow> </TableRow>
</TableHeader> </TableHeader>
<TableBody <TableBody
displayRowCheckbox={false} displayRowCheckbox={false}
> >
{tableData.map((row: any, index: number) => ( {this.state.agents.map((row: any, index: number) => (
<TableRow key={index} > <TableRow key={index} >
<TableRowColumn>{row.agentId}</TableRowColumn> <TableRowColumn>{row.id}</TableRowColumn>
<TableRowColumn>{row.desc}</TableRowColumn> <TableRowColumn>{row.description}</TableRowColumn>
<TableRowColumn>{row.authorizedDate}</TableRowColumn>
<TableRowColumn>{row.status}</TableRowColumn> <TableRowColumn>{row.status}</TableRowColumn>
<TableRowColumn>{row.lastPollingDate}</TableRowColumn>
</TableRow> </TableRow>
))}; ))};