import React from 'react';
import {Icon, Button} from 'antd';
import {Link} from 'react-router';
import commands from './commands';
import TableControlCell from 'components/TableControlCell';

export default function(context) {
	return [{
	  title: '名称/ID',
	  dataIndex: 'loadBalancerName',
	  key: 'loadBalancerName',
	  width: 150,
	  sorter: true,
	  fixed: 'left',
	  render: (text, record) => {
	    return (
	      <Link to={`/instanceDetail/lb/${record.id}`}>
	        {`${text} / ${record.entityId}`}
	      </Link>
	    )
	  }
	}, {
    title: '资源池',
    dataIndex: 'resourcePoolName',
    key: 'resourcePoolName'  
	// }, {
	// 	title: '实例类型',
	//   dataIndex: 'loadBalancerType',
	//   key: 'loadBalancerType',
	//   render: (text, record) => {
	//   	const type = record.loadBalancerType;
	//   	const map = {
	// 	  	"1": "公网(无日租)", 
	// 	  	"2": "公网(有日租)", 
	// 	  	"3": "内网"
	//   	}
	//   	return map[type] || '';
	//   }
	}, {
		title: '域名',
	  dataIndex: 'domain',
	  key: 'domain'  
	}, {
		title: 'VIP 列表',
		dataIndex: 'vips',
		key: 'vips'
	}, {
		title: '状态',
	  dataIndex: 'status',
	  key: 'status',
	  render: (text, record) => {
	  	const status = record.status;
	  	const map = {
		  	"0": "创建中", 
		  	"1": "正常运行"
	  	}
	  	return map[status] || '';
	  }
	}, {
		title: '创建时间',
		dataIndex: 'createTime',
		key: 'createTime'
	}, {
		title: '状态转换时间',
		dataIndex: 'statusTime',
		key: 'statusTime'
	}, {
		title: '是否开启会话保持',
		dataIndex: 'sessionExpire',
		key: 'sessionExpire'
	}, {
		title: '私有网络ID',
		dataIndex: 'vpcId',
		key: 'vpcId'
	}, {
		title: '私有网络子网 ID',
		dataIndex: 'subnetId',
		key: 'subnetId'
	}, {
    title: '操作',
    dataIndex: 'control',
    key: 'control',
    fixed: 'right',
    width: 100,
    render(text, record) {
    	return (
    		<TableControlCell
  				commands={commands}
  				record={record}
  				execCommand={context.execCommand}
  				/>
  		)
    }			
	}];	
}
