// page
import Login from './page/login/index.jsx'
import Home from './page/home/index.jsx'
-
import Status from './page/status/index.jsx'
+import Machine from './page/machine/index.jsx'
import PPolicy from './page/ppolicy/index.jsx'
+
import DetailInfo from './page/detailInfo/index.jsx'
import MachinelInfo from './page/machineInfo/index.jsx'
<Route exact path="/home/" component={Home}/>
<Route exact path="/status/" component={Status}/>
+ <Route exact path="/machine/" component={Machine}/>
<Route exact path="/ppolicy/" component={PPolicy}/>
<Route exact path="/portal/" component={Portal}/>
--- /dev/null
+.flex-box{
+ display: flex;
+ justify-content:center;
+ align-items:center;
+}
\ No newline at end of file
import React from 'react';
-
+import {Link} from 'react-router-dom';
import NavTop from 'component/nav-top/index.jsx';
// import './index.css';
import {Image, Card, Button, List, Icon} from 'semantic-ui-react'
</List>
</Card.Description>
</Card.Content>
- <Card.Content extra>
+ <Card.Content extra className='flex-box'>
<div className='ui buttons'>
{/*todo link to machine page*/}
- <Button basic color='blue'>
- Other records
- </Button>
+
+ <Link color='linkedin' to={'/machineInfo/' + machine.machine_sn}>
+ <Button basic color='blue'>
+ Other records
+ </Button>
+ </Link>
+
</div>
</Card.Content>
</Card>
--- /dev/null
+.flex-box{
+ display: flex;
+ justify-content:center;
+ align-items:center;
+}
\ No newline at end of file
import React from 'react';
import NavTop from 'component/nav-top/index.jsx';
-// import './index.css';
+import './index.css';
import {Image, Card, Button, List, Icon} from 'semantic-ui-react'
class FarmerDetailCard extends React.Component {
constructor(props){
</List>
</Card.Description>
</Card.Content>
- <Card.Content extra>
+ <Card.Content extra className='flex-box'>
<div className='ui buttons'>
{/*todo link to machine page*/}
- <Button basic mini color='grey'>
- {branch_num} branches involved
- </Button>
+ <Button basic mini color='grey'>
+ {branch_num} branches involved
+ </Button>
</div>
</Card.Content>
</Card>
this.loadMachineRecordListByBranch()
}
componentWillReceiveProps(nextProps) {
+ let _this = this
this.setState({
branches: nextProps.branches,
machine_sn: nextProps.machine_sn,
+ },() => {
+ if(this.state.branches.length > 0) {
+ _this.handleBranchTagClick(_this.state.branches[0].value)
+ }
+
});
}
handleBranchTagClick(branch_id){
<div>
<div className="branch-tags-container">
{branch_tags}
+ <div>
+ current num: {this.state.currentTotal}
+ </div>
</div>
<MachineRecordTable list={this.state.currentList} total={this.state.currentTotal} current={this.state.currentPage} loadfunc={this.loadMachineRecordListByBranch}/>
</li>
<li><Link to="/status"><span className="glyphicon glyphicon-tasks" aria-hidden="true"></span>Status</Link>
</li>
- {/*<li><Link to="/classifiedDisplay">分类展示</Link><a href="/status"> <span className="glyphicon glyphicon-tasks" aria-hidden="true"></span> Status</a>*/}
- {/*</li>*/}
- <li><a href="#"> <span className="glyphicon glyphicon-blackboard" aria-hidden="true"></span>Machine</a>
+
+ <li><Link to="/machine"> <span className="glyphicon glyphicon-blackboard" aria-hidden="true"></span>Machine</Link>
</li>
<li className="dropdown">
<Segment vertical>Farmer Info</Segment>
<FarmerCard machine={machine}></FarmerCard>
{/*//todo add a catalog*/}
- <div className="affix">aaaa</div>
+ {/*<div className="affix">aaaa</div>*/}
</div>
<div className="col-md-9">
--- /dev/null
+import React from 'react';
+// import './index.css';
+import ResultFilter from 'component/result-filter/index.jsx';
+import RecordTable from 'util/record-table/index.jsx';
+import MachineService from 'service/machine-service.jsx'
+import MachineTable from 'util/machine-table/index.jsx';
+import PGUtil from 'util/util.jsx'
+
+const _util = new PGUtil();
+const _machine = new MachineService();
+class Machine extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ isLoading: false,
+ currentPage: 1,
+ total: 3,
+ machines: [],
+ },
+
+ // this.onPageChange = this.onPageChange.bind(this);
+
+ this.loadMachineList = this.loadMachineList.bind(this);
+ }
+
+ componentDidMount(){
+ this.loadMachineList();
+ }
+
+ loadMachineList(page=1){
+ _machine.getMachineList().then(res => {
+ this.setState({
+ machines: res.results,
+ total: res.count,
+ isLoading: false
+ });
+ }, errMsg => {
+ _util.errorTips(errMsg);
+ });
+ }
+
+
+ render() {
+ return (
+ <div id="page-wrapper">
+ <h1>machine page</h1>
+ <p>
+ Shown here is the latest status of each farm member for each branch it has reported on in the last
+ 30 days.
+ Use the farm member link for history of that member on the relevant branch.
+ </p>
+
+ <MachineTable list={this.state.machines} total={this.state.total} current={this.state.currentPage} loadfunc={this.loadRecordList}/>
+
+ </div>
+ )
+ }
+}
+
+export default Machine;
\ No newline at end of file
}
render() {
- let show = this.state.isLoading ? "none" : "block";
- let style = {
- display: show
- };
-
return (
<div className="container-fluid detail-container">
--- /dev/null
+import PGUtil from 'util/util.jsx'
+import PGConstant from 'util/constant.jsx'
+// const _const = new PGConstant();
+const _util = new PGUtil();
+
+class MachineService{
+ getMachineList(pageNum){
+ let url = PGConstant.base_url + '/machines';
+ return _util.request({
+ type : 'get',
+ url : url,
+ data : {
+ pageNum : pageNum
+ }
+ });
+ }
+}
+
+export default MachineService;
\ No newline at end of file
return (
<Table.Row key={index} className={color}>
{/*alias*/}
- <Table.Cell><a href="#">{machine.alias}</a></Table.Cell>
+ <Table.Cell>
+ <Link color='linkedin' to={'machineInfo/' + machine.machine_sn}>
+ {machine.alias}
+ </Link>
+ </Table.Cell>
{/*system*/}
- <Table.Cell><a href="#">{system}</a></Table.Cell>
+ <Table.Cell>{system}</Table.Cell>
{/*State*/}
<Table.Cell>
serializer_class = UserMachineManageSerializer
# pagination_class = StandardResultsSetPagination
+class PublicMachineListViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
+ """
+ List all machines
+ """
+ queryset = UserMachine.objects.all().order_by('add_time')
+ serializer_class = UserMachineManageSerializer
+
class UserPortalInfoViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet):
"""
user info
# 'get': 'list',
# 'post': 'create'
# })
-from user_operation.views import UserMachineListViewSet, UserPortalInfoViewSet, UserMachineRecordByBranchListViewSet
+from user_operation.views import UserMachineListViewSet, UserPortalInfoViewSet, UserMachineRecordByBranchListViewSet, \
+ PublicMachineListViewSet
router = DefaultRouter()
router.register(r'records', TestRecordListViewSet, base_name="records")
-
+router.register(r'machines', PublicMachineListViewSet, base_name="machines")
router.register(r'branches', TestBranchListViewSet, base_name="branches")
router.register(r'records-by-branch', TestRecordListByBranchViewSet, base_name="records-by-branch")
# router.register(r'status-records', TestStatusRecordListViewSet, base_name="status-records")