From 09a4efbfa96fbc60b800ac521599c12161799f2f Mon Sep 17 00:00:00 2001 From: Hongyuan Ma Date: Sat, 7 Jul 2018 17:33:50 +0800 Subject: [PATCH] add userinfo-card --- front-end/src/app.jsx | 4 ++ front-end/src/component/layout/theme.css | 2 + .../src/component/userinfo-card/index.css | 12 +++++ .../src/component/userinfo-card/index.jsx | 39 +++++++++++++++ front-end/src/page/portal/index.css | 3 ++ front-end/src/page/portal/index.jsx | 50 ++++++++++++++++--- front-end/src/service/user-service.jsx | 13 +++-- front-end/src/util/basic-table/index.jsx | 10 ++-- 8 files changed, 119 insertions(+), 14 deletions(-) create mode 100644 front-end/src/component/userinfo-card/index.css create mode 100644 front-end/src/component/userinfo-card/index.jsx diff --git a/front-end/src/app.jsx b/front-end/src/app.jsx index 3ed34ff..c2f23ec 100644 --- a/front-end/src/app.jsx +++ b/front-end/src/app.jsx @@ -13,6 +13,8 @@ import Home from './page/home/index.jsx' import Status from './page/status/index.jsx' import PPolicy from './page/ppolicy/index.jsx' import DetailInfo from './page/detailInfo/index.jsx' + +import Portal from './page/portal/index.jsx' // we need to map the `scale` prop we define below // to the transform style property function mapStyles(styles) { @@ -64,6 +66,8 @@ class App extends React.Component { + + {/**/} {/**/} diff --git a/front-end/src/component/layout/theme.css b/front-end/src/component/layout/theme.css index d179450..edb28f9 100644 --- a/front-end/src/component/layout/theme.css +++ b/front-end/src/component/layout/theme.css @@ -133,6 +133,8 @@ p { .panel-default { border-color: #ECECEC; + border: 1px solid transparent; + border-radius: 4px; } .panel-default > .panel-heading { diff --git a/front-end/src/component/userinfo-card/index.css b/front-end/src/component/userinfo-card/index.css new file mode 100644 index 0000000..e5c7b4e --- /dev/null +++ b/front-end/src/component/userinfo-card/index.css @@ -0,0 +1,12 @@ +.panel-blue{ + border-top: 3px solid #2497ba; +} + +.panel-default > .panel-heading { + background-color: #dadada; +} + +.panel-body-ul{ + list-style: none!important; + padding: 0!important; +} \ No newline at end of file diff --git a/front-end/src/component/userinfo-card/index.jsx b/front-end/src/component/userinfo-card/index.jsx new file mode 100644 index 0000000..6aacbe3 --- /dev/null +++ b/front-end/src/component/userinfo-card/index.jsx @@ -0,0 +1,39 @@ +import React from 'react'; + +import NavTop from 'component/nav-top/index.jsx'; +// import './index.css'; +import {Image, Card, Button, List, Icon} from 'semantic-ui-react' +class UserInfoCard extends React.Component { + constructor(props){ + super(props); + } + render(){ + let userinfo = this.props.userinfo || {} + + return ( + +
+
+ +
+

+   Your Info +

+
+
+

{userinfo.username}

+
    +
  • {userinfo.machine_num} machine(s)
  • +
  • {userinfo.reports} report(s)
  • +
  • {userinfo.branches} branch(es) involved
  • +
  • {userinfo.email}
  • +
+
+ {/*
*/} + {/*
*/} +
+
+ ); + } +}export default UserInfoCard; + diff --git a/front-end/src/page/portal/index.css b/front-end/src/page/portal/index.css index e69de29..d53a1d5 100644 --- a/front-end/src/page/portal/index.css +++ b/front-end/src/page/portal/index.css @@ -0,0 +1,3 @@ +.panel-blue{ + border-top: 3px solid #2497ba; +} \ No newline at end of file diff --git a/front-end/src/page/portal/index.jsx b/front-end/src/page/portal/index.jsx index c20f25b..3f4ca85 100644 --- a/front-end/src/page/portal/index.jsx +++ b/front-end/src/page/portal/index.jsx @@ -1,9 +1,12 @@ import React from 'react'; -// import './index.css'; +import './index.css'; import ResultFilter from 'component/result-filter/index.jsx'; import BasicTable from 'util/basic-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(); @@ -15,6 +18,16 @@ class Portal extends React.Component { } } + componentDidMount(){ + this.loadUserMachineManageList(); + } + loadUserMachineManageList(){ + _user.getUserMachineManageList().then(res => { + this.setState(res); + }, errMsg => { + _mm.errorTips(errMsg); + }); + } render() { let show = this.state.isLoading ? "none" : "block"; @@ -23,15 +36,40 @@ class Portal extends React.Component { }; return ( -
-

portal page

-

+

+ +
+ + {/*Farmer Info*/} + -

+
+
+

+   Shortcuts +

+
+ +
+
- {/**/} +
+
+

Welcome Back, {this.state.username}

+
+ +
+ + ) } } diff --git a/front-end/src/service/user-service.jsx b/front-end/src/service/user-service.jsx index 611bd41..1ca1f0d 100644 --- a/front-end/src/service/user-service.jsx +++ b/front-end/src/service/user-service.jsx @@ -44,9 +44,16 @@ class User{ }); } - // getUserList(pageNum){ - // # todo - // } + getUserMachineManageList(pageNum){ + let url = PGConstant.base_url + '/my-machine'; + return _util.request({ + type : 'get', + url : url, + data : { + pageNum : pageNum + } + }); + } } export default User; \ No newline at end of file diff --git a/front-end/src/util/basic-table/index.jsx b/front-end/src/util/basic-table/index.jsx index c5677db..22d5b41 100644 --- a/front-end/src/util/basic-table/index.jsx +++ b/front-end/src/util/basic-table/index.jsx @@ -74,8 +74,8 @@ class BasicTable extends React.Component { } render() { - let branch = record.pg_info.pg_branch; - let _list = this.props.list + // let branch = record.pg_info.pg_branch; + let _list = this.props.list || [] let style = { display: 'show' }; @@ -134,9 +134,9 @@ class BasicTable extends React.Component { return ( - - Branch: 10_STABLE - + {/**/} + {/*Branch: 10_STABLE*/} + {/**/} Alias System -- 2.39.5