add farmer apply page
authorHongyuan Ma <CS_MaleicAcid@163.com>
Fri, 20 Jul 2018 15:43:24 +0000 (23:43 +0800)
committerHongyuan Ma <CS_MaleicAcid@163.com>
Fri, 20 Jul 2018 15:43:24 +0000 (23:43 +0800)
front-end/src/page/farmerApply/index.css [new file with mode: 0644]
front-end/src/page/farmerApply/index.jsx [new file with mode: 0644]

diff --git a/front-end/src/page/farmerApply/index.css b/front-end/src/page/farmerApply/index.css
new file mode 100644 (file)
index 0000000..efe47f7
--- /dev/null
@@ -0,0 +1,4 @@
+.panel-blue{
+    /*border-top: 3px solid #2497ba;*/
+    border-top: 3px solid  rgb(2,141,193);
+}
\ No newline at end of file
diff --git a/front-end/src/page/farmerApply/index.jsx b/front-end/src/page/farmerApply/index.jsx
new file mode 100644 (file)
index 0000000..df329d0
--- /dev/null
@@ -0,0 +1,115 @@
+import React from 'react';
+import './index.css';
+import { hashHistory } from 'react-router'
+import ResultFilter from 'component/result-filter/index.jsx';
+import MachineTable    from 'util/machine-table/index.jsx';
+import UserInfoCard from 'component/userinfo-card/index.jsx'
+import Record      from 'service/record-service.jsx'
+import PGUtil        from 'util/util.jsx'
+import User         from 'service/user-service.jsx'
+const _user = new User();
+
+const _util = new PGUtil();
+const _record = new Record();
+class FarmerApply extends React.Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            username: '',
+            isLoading: false,
+            machines:[],
+            userinfo: {}
+        }
+
+    }
+    componentDidMount(){
+
+        let user = _util.getStorage('userInfo')
+        this.setState({
+            username: user.username,
+        });
+        console.log(user.token)
+        this.loadUserPortalInfo()
+        this.loadUserMachineManageList();
+    }
+
+    loadUserPortalInfo(){
+        _user.getUserPortalInfo().then(res => {
+            this.setState({
+                userinfo: res.results,
+            });
+        }, errMsg => {
+            _util.errorTips(errMsg);
+        });
+    }
+
+    loadUserMachineManageList(page=1){
+        _user.getUserMachineManageList().then(res => {
+            this.setState({
+                machines: res.results,
+                total: res.count,
+                isLoading: false
+            });
+        }, errMsg => {
+            _util.errorTips(errMsg);
+        });
+    }
+    onLogout(){
+        _util.removeStorage('userInfo');
+        // this.props.history.push('/login')
+        // hashHistory.push('/login')
+        window.location.href = '/';
+        // _user.logout().then(res => {
+        //     _util.removeStorage('userInfo');
+        //     window.location.href = '/login';
+        // }, errMsg => {
+        //     _util.errorTips(errMsg);
+        // });
+    }
+
+    render() {
+        let show = this.state.isLoading ? "none" : "block";
+        let style = {
+            display: show
+        };
+
+        return (
+            <div className="container-fluid detail-container">
+
+                <div className="col-md-3">
+
+                    {/*<Segment vertical>Farmer Info</Segment>*/}
+                    <UserInfoCard info={this.state.userinfo}></UserInfoCard>
+
+                    <div className="panel panel-default panel-blue">
+                        <div className="panel-heading">
+                            <h3 className="panel-title">
+                                <i className="fa fa-bookmark"></i>&nbsp; Shortcuts
+                            </h3>
+                        </div>
+                        <div className="list-group">
+                            <a href="\add-machine" className="list-group-item">
+                                <i className="fa fa-globe fa-fw"></i>&nbsp; Add a New Mchine
+                            </a>
+                            <a onClick={() => {this.onLogout()}} className="list-group-item">
+                                <i className="fa fa-arrow-left fa-fw"></i>&nbsp; Logout
+                            </a>
+                        </div>
+                    </div>
+                </div>
+
+                <div className="col-md-9">
+                    <div className="record-title">
+                        <h2 >Welcome Back, {this.state.username}</h2>
+                    </div>
+
+                    <MachineTable list={this.state.machines} total={this.state.total} current={this.state.currentPage} loadfunc={this.loadRecordList}/>
+                </div>
+            </div>
+
+
+        )
+    }
+}
+
+export default FarmerApply;
\ No newline at end of file