Merge branch 'master' into release

This commit is contained in:
Jay 2017-04-10 17:56:19 +08:00
commit b1ad20d86c
7 changed files with 394 additions and 13 deletions

View File

@ -87810,12 +87810,17 @@ var ListItem = function ListItem(_ref) {
return _react2.default.createElement(
_semanticUiReact.Table.Row,
null,
{ style: { color: (0, _tools.padding)(data.timestamp, 13, 1, '0') < Date.now() - 60000 ? '#f00' : 'inherit' } },
_react2.default.createElement(
_semanticUiReact.Table.Cell,
null,
data.wristband
),
_react2.default.createElement(
_semanticUiReact.Table.Cell,
null,
data.name
),
_react2.default.createElement(
_semanticUiReact.Table.Cell,
null,
@ -88022,6 +88027,14 @@ var LocStatus = function (_React$Component) {
'\u624B\u74B0ID',
this.renderSortIcon('mac')
),
_react2.default.createElement(
_semanticUiReact.Table.HeaderCell,
{ className: 'pointer', onClick: function onClick() {
_this2.handlerSort('name');
} },
'\u624B\u74B0\u540D\u7A31',
this.renderSortIcon('name')
),
_react2.default.createElement(
_semanticUiReact.Table.HeaderCell,
{ className: 'pointer', onClick: function onClick() {
@ -88895,6 +88908,10 @@ var _Location = __webpack_require__(1110);
var _Location2 = _interopRequireDefault(_Location);
var _LocStatusWloc = __webpack_require__(1149);
var _LocStatusWloc2 = _interopRequireDefault(_LocStatusWloc);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@ -88929,6 +88946,8 @@ var WristbandPage = function (_React$Component) {
switch (_this.state.page) {
case 'locstatus':
return _react2.default.createElement(_LocStatus2.default, null);
case 'locstatus_wloc':
return _react2.default.createElement(_LocStatusWloc2.default, null);
case 'wristband':
return _react2.default.createElement(_WristbandInfo2.default, null);
case 'location':
@ -88989,6 +89008,13 @@ var WristbandPage = function (_React$Component) {
_this2.changePage('locstatus');
} },
'\u4F4D\u7F6E\u8CC7\u8A0A'
),
_react2.default.createElement(
_semanticUiReact.Menu.Item,
{ active: this.state.page == 'locstatus_wloc', onClick: function onClick() {
_this2.changePage('locstatus_wloc');
} },
'\u4F4D\u7F6E\u8CC7\u8A0A - \u5730\u9EDE\u5206\u985E'
)
)
)
@ -93716,5 +93742,212 @@ var PageRoot = function (_React$Component) {
_reactDom2.default.render(_react2.default.createElement(PageRoot, null), document.getElementById('app'));
/***/ }),
/* 1147 */,
/* 1148 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = __webpack_require__(0);
var _react2 = _interopRequireDefault(_react);
var _semanticUiReact = __webpack_require__(8);
var _actions = __webpack_require__(20);
var _tools = __webpack_require__(147);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var LocStatusWloc = function (_React$Component) {
_inherits(LocStatusWloc, _React$Component);
function LocStatusWloc() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, LocStatusWloc);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = LocStatusWloc.__proto__ || Object.getPrototypeOf(LocStatusWloc)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
loc: [],
ui: {
colLoading: false
}
}, _this.tick = null, _this.runTick = function () {
_this.getStatus();
}, _this.getLocList = function () {
var _this$props = _this.props,
toggleLoading = _this$props.toggleLoading,
showDialog = _this$props.showDialog;
toggleLoading(1);
fetch('/api/wristband/getlocationlist', (0, _actions.getRequest)()).then(function (response) {
return response.json();
}).then(function (json) {
toggleLoading(0);
if (json.status != 1) return showDialog(json.message);
_this.setState({
loc: json.data.record || []
}, function () {
_this.setState({
ui: {
colLoading: true
} }, function () {});
_this.getStatus();
_this.tick = setInterval(_this.runTick, 5000);
});
});
}, _this.getStatus = function () {
var _this$props2 = _this.props,
toggleLoading = _this$props2.toggleLoading,
showDialog = _this$props2.showDialog;
fetch('/api/wristband/getstatus', (0, _actions.getRequest)()).then(function (response) {
return response.json();
}).then(function (json) {
if (json.status != 1) return showDialog(json.message);
var record = json.data.record || [];
var locs = _this.state.loc;
for (var i in locs) {
locs[i].list = [];
}
for (var _i in record) {
var tmp = record[_i];
if (!tmp.locid) continue;
for (var j in locs) {
if (locs[j].serialnumber == tmp.locid) {
locs[j].list.push(tmp);
}
}
}
_this.setState({
loc: locs,
ui: {
colLoading: false
}
});
});
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(LocStatusWloc, [{
key: 'componentDidMount',
value: function componentDidMount() {
this.getLocList();
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
clearInterval(this.tick);
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
return _react2.default.createElement(
_semanticUiReact.Container,
{ fluid: true },
_react2.default.createElement(
_semanticUiReact.Grid,
{ columns: 3 },
this.state.loc.map(function (t, idx) {
return _react2.default.createElement(
_semanticUiReact.Grid.Column,
{ key: idx, className: 'clearfix' },
_react2.default.createElement(_semanticUiReact.Header, { as: 'h5', content: t.name }),
_react2.default.createElement(
_semanticUiReact.Segment,
{ style: { height: '400px', overflow: 'auto' }, loading: _this2.state.ui.colLoading },
_react2.default.createElement(
_semanticUiReact.List,
null,
t.list ? t.list.map(function (tt, idx) {
var isExpire = (0, _tools.padding)(tt.timestamp, 13, 1, '0') < Date.now() - 60000 ? true : false;
return _react2.default.createElement(
_semanticUiReact.List.Item,
{ key: idx },
tt.name ? _react2.default.createElement(_semanticUiReact.Label, { basic: true, color: isExpire ? 'red' : 'blue', size: 'tiny', content: tt.name }) : null,
_react2.default.createElement(_semanticUiReact.Label, { basic: true, color: isExpire ? 'red' : 'teal', size: 'tiny', content: tt.mac })
);
}) : null
)
)
);
})
)
);
}
}]);
return LocStatusWloc;
}(_react2.default.Component);
exports.default = LocStatusWloc;
/***/ }),
/* 1149 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _reactRedux = __webpack_require__(24);
var _actions = __webpack_require__(20);
var _LocStatusWloc = __webpack_require__(1148);
var _LocStatusWloc2 = _interopRequireDefault(_LocStatusWloc);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var mapStateToProps = function mapStateToProps(state) {
return {
i18n: state.i18n
};
};
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
return {
showDialog: function showDialog(msg) {
dispatch((0, _actions.add_dialog_msg)(msg));
},
toggleLoading: function toggleLoading() {
var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
dispatch((0, _actions.toggle_loading)(flag));
}
};
};
exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_LocStatusWloc2.default);
/***/ })
/******/ ]);

View File

@ -128,26 +128,25 @@ router
.post('/getstatus', (req, res, n) => {
if (!config.permission.wristband) return n('ERR9000');
let query = "select w.`name`, w.`mac` as wristband, coalesce(l.`name`, l2.`name`) as locname, ll.*\
let query = "select w.`name`, w.`mac` as wristband, \
coalesce(l.`name`, l2.`name`) as locname, \
coalesce(case when tmp2.`wlocrtloc` = 'NG' then null else tmp2.`wlocrtloc` end, ll.`devid`) as locid, \
ll.*\
from ??.?? w\
left join ( \
select * from ( \
select * from ??.?? \
where `timestamp` > unix_timestamp() - 30 order by conv(`val11`, 16, 10) desc limit 65535000\
) tmp group by `mac` \
) tmp2 \
on tmp2.`mac` = w.`mac` \
left join ??.?? tmp2 \
on tmp2.`wlocrtmac` = w.`mac` \
left join ??.?? ll \
on ll.`mac` = w.`mac` \
left join ??.?? l \
on \
l.`serialnumber` = tmp2.`devid` \
l.`serialnumber` = tmp2.`wlocrtloc` \
and tmp2.`wlocrtloc` != 'NG' \
left join ??.?? l2\
on \
l2.`serialnumber` = ll.`devid` \
where \
w.`switch` = 1 ";
let param = [config.db.db9, 'wristband', config.db.db9, 'rawdata', config.db.db9, 'lastdata', config.db.db9, 'location', config.db.db9, 'location', ];
let param = [config.db.db9, 'wristband', config.db.db9, 'wlocationrt', config.db.db9, 'lastdata', config.db.db9, 'location', config.db.db9, 'location', ];
let sortfield = '';
let sortorder = '';
@ -177,6 +176,8 @@ router
case 'time':
query += 'order by ll.`timestamp` ' + sortorder;
break;
case 'name':
query += `order by w.name ${sortorder}`;
default:
query += 'order by w.`uid`';
break;

View File

@ -1,12 +1,13 @@
import React from 'react';
import {Table} from 'semantic-ui-react';
import {convertTime} from '../../../../tools';
import {convertTime, padding} from '../../../../tools';
const ListItem = ({i18n, data}) => {
return (
<Table.Row>
<Table.Row style={{color: padding(data.timestamp, 13, 1, '0') < (Date.now() - 60000) ? '#f00' : 'inherit'}}>
<Table.Cell>{data.wristband}</Table.Cell>
<Table.Cell>{data.name}</Table.Cell>
<Table.Cell>{data.locname}</Table.Cell>
<Table.Cell>{data.val3 ? parseInt(data.val3, 16) : ''}</Table.Cell>
<Table.Cell>{data.val4 ? `${parseInt(data.val4, 16)}%` : ''}</Table.Cell>

View File

@ -102,6 +102,12 @@ class LocStatus extends React.Component{
this.renderSortIcon('mac')
}
</Table.HeaderCell>
<Table.HeaderCell className="pointer" onClick={()=>{ this.handlerSort('name') }}>
手環名稱
{
this.renderSortIcon('name')
}
</Table.HeaderCell>
<Table.HeaderCell className="pointer" onClick={()=>{this.handlerSort('loc')}}>
地點
{this.renderSortIcon('loc')}

View File

@ -0,0 +1,115 @@
import React from 'react';
import {Grid, Header, Container, Segment, List, Label} from 'semantic-ui-react';
import {getRequest} from '../../../../actions';
import {padding} from '../../../../tools'
class LocStatusWloc extends React.Component {
state = {
loc: [],
ui: {
colLoading: false
}
}
tick = null
componentDidMount() {
this.getLocList();
}
componentWillUnmount(){
clearInterval(this.tick);
}
runTick = ()=>{
this.getStatus();
}
getLocList = ()=>{
let {toggleLoading, showDialog} = this.props;
toggleLoading(1);
fetch('/api/wristband/getlocationlist', getRequest())
.then(response=>response.json())
.then(json=>{
toggleLoading(0);
if(json.status != 1) return showDialog(json.message);
this.setState({
loc: json.data.record || []
}, ()=>{
this.setState({
ui:{
colLoading: true
}}, ()=>{})
this.getStatus();
this.tick = setInterval(this.runTick, 5000);
})
})
}
getStatus = () => {
let {toggleLoading, showDialog} = this.props;
fetch('/api/wristband/getstatus', getRequest())
.then(response=>response.json())
.then(json => {
if(json.status != 1) return showDialog(json.message);
let record = json.data.record || [];
let locs = this.state.loc;
for(let i in locs){
locs[i].list = [];
}
for(let i in record) {
let tmp = record[i];
if(!tmp.locid) continue;
for(let j in locs) {
if(locs[j].serialnumber == tmp.locid) {
locs[j].list.push(tmp);
}
}
}
this.setState({
loc: locs,
ui:{
colLoading: false
}
})
})
}
render() {
return (
<Container fluid>
<Grid columns={3}>
{
this.state.loc.map((t,idx) => (
<Grid.Column key={idx} className="clearfix" >
<Header as="h5" content={t.name} />
<Segment style={{height: '400px', overflow: 'auto'}} loading={this.state.ui.colLoading}>
<List>
{
t.list ?
t.list.map((tt, idx) => {
let isExpire = padding(tt.timestamp, 13, 1, '0') < (Date.now() - 60000) ? true : false;
return (<List.Item key={idx}>
{
tt.name ? (
<Label basic color={isExpire ? 'red' : 'blue'} size="tiny" content={tt.name}/>
) : null
}
<Label basic color={isExpire ? 'red' : 'teal'} size="tiny" content={tt.mac}/>
</List.Item>)
})
: null
}
</List>
</Segment>
</Grid.Column>
))
}
</Grid>
</Container>
)
}
}
export default LocStatusWloc;

View File

@ -3,6 +3,7 @@ import {Grid, Container, Segment, Menu, List} from 'semantic-ui-react';
import LocStatus from '../../../containers/AdminPage/Wristband/LocStatus';
import WristbandInfo from '../../../containers/AdminPage/Wristband/WristbandInfo';
import Location from '../../../containers/AdminPage/Wristband/Location';
import LocStatusWloc from '../../../containers/AdminPage/Wristband/LocStatusWloc';
class WristbandPage extends React.Component{
state = {
@ -20,6 +21,8 @@ class WristbandPage extends React.Component{
switch(this.state.page) {
case 'locstatus':
return <LocStatus/>;
case 'locstatus_wloc':
return <LocStatusWloc />;
case 'wristband':
return <WristbandInfo />;
case 'location':
@ -48,6 +51,9 @@ class WristbandPage extends React.Component{
<Menu.Item active={this.state.page == 'locstatus'} onClick={()=>{ this.changePage('locstatus'); }}>
位置資訊
</Menu.Item>
<Menu.Item active={this.state.page == 'locstatus_wloc'} onClick={()=>{ this.changePage('locstatus_wloc'); }}>
位置資訊 - 地點分類
</Menu.Item>
</Menu.Menu>
</Menu.Item>
</Menu>

View File

@ -0,0 +1,19 @@
import { connect } from 'react-redux';
import { add_dialog_msg, toggle_loading } from '../../../actions';
import LocStatusPage from '../../../components/AdminPage/Wristband/LocStatusWloc';
const mapStateToProps = (state) => ({
i18n: state.i18n
});
const mapDispatchToProps = (dispatch, ownProps) => ({
showDialog: (msg) => {
dispatch(add_dialog_msg(msg));
},
toggleLoading: (flag = false) => {
dispatch(toggle_loading(flag));
}
})
export default connect(mapStateToProps, mapDispatchToProps)(LocStatusPage);