add setting wristband
This commit is contained in:
parent
b781efabea
commit
e18fa6546b
@ -59,6 +59,7 @@
|
||||
"ERR0057": "連動資料輸入錯誤",
|
||||
"ERR0058": "timezone輸入錯誤",
|
||||
"ERR0059": "timezone設定失敗",
|
||||
"ERR0060": "手環ID輸入錯誤",
|
||||
|
||||
"ERR7000": "命令執行失敗",
|
||||
|
||||
|
@ -34369,7 +34369,7 @@ var DeviceSelect = function DeviceSelect(_ref) {
|
||||
permissions.dio ? _react2.default.createElement(
|
||||
'option',
|
||||
{ value: 'do' },
|
||||
i18n && i18n.t ? i18n.t('select.digitoutput') : ''
|
||||
i18n && i18n.t ? i18n.t('select.digitaloutput') : ''
|
||||
) : null,
|
||||
permissions.leone ? _react2.default.createElement(
|
||||
'option',
|
||||
@ -88088,8 +88088,11 @@ var LocStatus = function (_React$Component) {
|
||||
),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Table.HeaderCell,
|
||||
null,
|
||||
'\u6642\u9593'
|
||||
{ className: 'pointer', onClick: function onClick() {
|
||||
_this2.handlerSort('time');
|
||||
} },
|
||||
'\u66F4\u65B0\u6642\u9593',
|
||||
this.renderSortIcon('time')
|
||||
)
|
||||
)
|
||||
),
|
||||
@ -88136,6 +88139,10 @@ var _LocStatus = __webpack_require__(1103);
|
||||
|
||||
var _LocStatus2 = _interopRequireDefault(_LocStatus);
|
||||
|
||||
var _WristbandInfo = __webpack_require__(1141);
|
||||
|
||||
var _WristbandInfo2 = _interopRequireDefault(_WristbandInfo);
|
||||
|
||||
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"); } }
|
||||
@ -88165,9 +88172,13 @@ var WristbandPage = function (_React$Component) {
|
||||
page: page
|
||||
});
|
||||
}, _this.getRenderPage = function () {
|
||||
var i18n = _this.props.i18n;
|
||||
|
||||
switch (_this.state.page) {
|
||||
case 'locstatus':
|
||||
return _react2.default.createElement(_LocStatus2.default, null);
|
||||
case 'wristband':
|
||||
return _react2.default.createElement(_WristbandInfo2.default, null);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@ -88179,9 +88190,11 @@ var WristbandPage = function (_React$Component) {
|
||||
value: function render() {
|
||||
var _this2 = this;
|
||||
|
||||
var i18n = this.props.i18n;
|
||||
|
||||
return _react2.default.createElement(
|
||||
_semanticUiReact.Container,
|
||||
{ fluid: true },
|
||||
{ fluid: true, style: { paddingLeft: '10px', paddingRight: '10px' } },
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Grid,
|
||||
null,
|
||||
@ -88190,7 +88203,7 @@ var WristbandPage = function (_React$Component) {
|
||||
{ width: 4 },
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Menu,
|
||||
{ vertical: true },
|
||||
{ vertical: true, fluid: true },
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Menu.Item,
|
||||
null,
|
||||
@ -88202,6 +88215,13 @@ var WristbandPage = function (_React$Component) {
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Menu.Menu,
|
||||
null,
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Menu.Item,
|
||||
{ active: this.state.page == 'wristband', onClick: function onClick() {
|
||||
_this2.changePage('wristband');
|
||||
} },
|
||||
'\u624B\u74B0\u540D\u7A31\u8A2D\u5B9A'
|
||||
),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Menu.Item,
|
||||
{ active: this.state.page == 'locstatus', onClick: function onClick() {
|
||||
@ -88259,7 +88279,7 @@ var AlertItem = function AlertItem(_ref) {
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Grid.Column,
|
||||
null,
|
||||
_react2.default.createElement(_semanticUiReact.Label, { basic: true, content: type == 'di' ? "DigitInput" : "LeOne" })
|
||||
_react2.default.createElement(_semanticUiReact.Label, { basic: true, content: type == 'di' ? "DigitalInput" : "LeOne" })
|
||||
),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Grid.Column,
|
||||
@ -88271,7 +88291,7 @@ var AlertItem = function AlertItem(_ref) {
|
||||
_semanticUiReact.Grid.Column,
|
||||
null,
|
||||
_react2.default.createElement(_semanticUiReact.Label, { basic: true, content: i18n && i18n.t ? i18n.t('dashboard.label.status') : '' }),
|
||||
i18n && i18n.t ? type == 'di' ? i18n.t('dashboard.status.digitinput') : i18n.t('dashboard.status.leone') : ''
|
||||
i18n && i18n.t ? type == 'di' ? i18n.t('dashboard.status.digitalinput') : i18n.t('dashboard.status.leone') : ''
|
||||
)
|
||||
);
|
||||
};
|
||||
@ -92851,5 +92871,413 @@ var PageRoot = function (_React$Component) {
|
||||
|
||||
_reactDom2.default.render(_react2.default.createElement(PageRoot, null), document.getElementById('app'));
|
||||
|
||||
/***/ }),
|
||||
/* 1139 */,
|
||||
/* 1140 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||
|
||||
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__(22);
|
||||
|
||||
var _ListItem = __webpack_require__(1142);
|
||||
|
||||
var _ListItem2 = _interopRequireDefault(_ListItem);
|
||||
|
||||
var _WristbandModal = __webpack_require__(1143);
|
||||
|
||||
var _WristbandModal2 = _interopRequireDefault(_WristbandModal);
|
||||
|
||||
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 stateDefault = function stateDefault() {
|
||||
return {
|
||||
list: [],
|
||||
modal: {
|
||||
open: false,
|
||||
type: 0,
|
||||
data: {}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var WristbandInfo = function (_React$Component) {
|
||||
_inherits(WristbandInfo, _React$Component);
|
||||
|
||||
function WristbandInfo() {
|
||||
var _ref;
|
||||
|
||||
var _temp, _this, _ret;
|
||||
|
||||
_classCallCheck(this, WristbandInfo);
|
||||
|
||||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = WristbandInfo.__proto__ || Object.getPrototypeOf(WristbandInfo)).call.apply(_ref, [this].concat(args))), _this), _this.state = _extends({}, stateDefault()), _this.getList = function () {
|
||||
var _this$props = _this.props,
|
||||
showDialog = _this$props.showDialog,
|
||||
toggleLoading = _this$props.toggleLoading;
|
||||
|
||||
|
||||
fetch('/api/wristband/getwristbandlist', (0, _actions.getRequest)()).then(function (response) {
|
||||
return response.json();
|
||||
}).then(function (json) {
|
||||
if (json.status != 1) return showDialog(json.message);
|
||||
_this.setState({
|
||||
list: json.data.record || []
|
||||
});
|
||||
});
|
||||
}, _this.delWristband = function (id) {
|
||||
if (!id) return;
|
||||
|
||||
fetch('/api/wristband/delwristband', (0, _actions.getRequest)({ id: id })).then(function (response) {
|
||||
return response.json();
|
||||
}).then(function (json) {
|
||||
if (json.status != 1) return showDialog(json.message);
|
||||
_this.getList();
|
||||
});
|
||||
}, _this.openModal = function (type) {
|
||||
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
_this.setState({
|
||||
modal: {
|
||||
type: type,
|
||||
data: data,
|
||||
open: true
|
||||
}
|
||||
});
|
||||
}, _this.closeModal = function () {
|
||||
_this.setState({
|
||||
modal: _extends({}, stateDefault().modal)
|
||||
});
|
||||
}, _this.submitModal = function (type) {
|
||||
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var _this$props2 = _this.props,
|
||||
showDialog = _this$props2.showDialog,
|
||||
toggleLoading = _this$props2.toggleLoading;
|
||||
|
||||
if (type == 1 && !data.id) return showDialog('資料取得失敗');
|
||||
if (type == 0 && !data.mac) return showDialog('請填寫手環ID');
|
||||
|
||||
var url = type == 1 ? '/api/wristband/editwristband' : '/api/wristband/addwristband';
|
||||
|
||||
fetch(url, (0, _actions.getRequest)(data)).then(function (response) {
|
||||
return response.json();
|
||||
}).then(function (json) {
|
||||
if (json.status != 1) return showDialog(json.message);
|
||||
_this.setState({
|
||||
modal: _extends({}, stateDefault().modal)
|
||||
}, function () {
|
||||
_this.getList();
|
||||
});
|
||||
});
|
||||
}, _temp), _possibleConstructorReturn(_this, _ret);
|
||||
}
|
||||
|
||||
_createClass(WristbandInfo, [{
|
||||
key: 'componentDidMount',
|
||||
value: function componentDidMount() {
|
||||
this.getList();
|
||||
}
|
||||
}, {
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
var _this2 = this;
|
||||
|
||||
var i18n = this.props.i18n;
|
||||
|
||||
return _react2.default.createElement(
|
||||
_semanticUiReact.Container,
|
||||
{ fluid: true },
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Segment,
|
||||
{ className: 'clearfix' },
|
||||
_react2.default.createElement(_semanticUiReact.Button, { basic: true, color: 'green', icon: 'plus', content: '\u65B0\u589E', floated: 'right', onClick: function onClick() {
|
||||
_this2.openModal(0);
|
||||
}, style: { marginBottom: '15px' } }),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Table,
|
||||
null,
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Table.Header,
|
||||
null,
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Table.Row,
|
||||
null,
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Table.HeaderCell,
|
||||
null,
|
||||
'\u64CD\u4F5C'
|
||||
),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Table.HeaderCell,
|
||||
null,
|
||||
'\u624B\u74B0ID'
|
||||
),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Table.HeaderCell,
|
||||
null,
|
||||
'\u624B\u74B0\u540D\u7A31'
|
||||
)
|
||||
)
|
||||
),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Table.Body,
|
||||
null,
|
||||
this.state.list.map(function (t, idx) {
|
||||
return _react2.default.createElement(_ListItem2.default, { key: idx, data: t, i18n: i18n, delWristband: _this2.delWristband, editWristband: _this2.openModal });
|
||||
})
|
||||
)
|
||||
)
|
||||
),
|
||||
_react2.default.createElement(_WristbandModal2.default, { i18n: i18n,
|
||||
open: this.state.modal.open,
|
||||
type: this.state.modal.type,
|
||||
data: this.state.modal.data,
|
||||
closeModal: this.closeModal,
|
||||
submitModal: this.submitModal })
|
||||
);
|
||||
}
|
||||
}]);
|
||||
|
||||
return WristbandInfo;
|
||||
}(_react2.default.Component);
|
||||
|
||||
exports.default = WristbandInfo;
|
||||
|
||||
/***/ }),
|
||||
/* 1141 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _reactRedux = __webpack_require__(25);
|
||||
|
||||
var _actions = __webpack_require__(22);
|
||||
|
||||
var _WristbandInfo = __webpack_require__(1140);
|
||||
|
||||
var _WristbandInfo2 = _interopRequireDefault(_WristbandInfo);
|
||||
|
||||
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)(_WristbandInfo2.default);
|
||||
|
||||
/***/ }),
|
||||
/* 1142 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _react = __webpack_require__(0);
|
||||
|
||||
var _react2 = _interopRequireDefault(_react);
|
||||
|
||||
var _semanticUiReact = __webpack_require__(8);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var ListItem = function ListItem(_ref) {
|
||||
var i18n = _ref.i18n,
|
||||
data = _ref.data,
|
||||
delWristband = _ref.delWristband,
|
||||
editWristband = _ref.editWristband;
|
||||
|
||||
|
||||
return _react2.default.createElement(
|
||||
_semanticUiReact.Table.Row,
|
||||
null,
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Table.Cell,
|
||||
null,
|
||||
_react2.default.createElement(_semanticUiReact.Button, { content: 'Edit', basic: true, onClick: function onClick() {
|
||||
editWristband(1, data);
|
||||
} }),
|
||||
_react2.default.createElement(_semanticUiReact.Button, { content: 'Delete', basic: true, onClick: function onClick() {
|
||||
delWristband(data.uid);
|
||||
} })
|
||||
),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Table.Cell,
|
||||
null,
|
||||
data.mac
|
||||
),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Table.Cell,
|
||||
null,
|
||||
data.name
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
exports.default = ListItem;
|
||||
|
||||
/***/ }),
|
||||
/* 1143 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _react = __webpack_require__(0);
|
||||
|
||||
var _react2 = _interopRequireDefault(_react);
|
||||
|
||||
var _semanticUiReact = __webpack_require__(8);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var WristbandModal = function WristbandModal(_ref) {
|
||||
var i18n = _ref.i18n,
|
||||
open = _ref.open,
|
||||
type = _ref.type,
|
||||
data = _ref.data,
|
||||
closeModal = _ref.closeModal,
|
||||
submitModal = _ref.submitModal;
|
||||
|
||||
|
||||
return _react2.default.createElement(
|
||||
_semanticUiReact.Modal,
|
||||
{ open: open },
|
||||
_react2.default.createElement(_semanticUiReact.Modal.Header, { content: type == 1 ? '修改資料' : '新增資料' }),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Modal.Content,
|
||||
null,
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Form,
|
||||
{ onSubmit: function onSubmit(e, d) {
|
||||
e.preventDefault();
|
||||
submitModal(type, d.formData);
|
||||
}, serializer: function serializer(e) {
|
||||
var json = {
|
||||
name: '',
|
||||
identity: '',
|
||||
monitor: 0,
|
||||
notify: 0,
|
||||
id: type == 1 ? data.uid : '',
|
||||
mac: ''
|
||||
};
|
||||
|
||||
var mac = e.querySelector('input[name="mac"]');
|
||||
if (mac && 'value' in mac) json.mac = mac.value;
|
||||
var name = e.querySelector('input[name="name"]');
|
||||
if (name && 'value' in name) json.name = name.value;
|
||||
var identity = e.querySelector('input[name="identity"]');
|
||||
if (identity && 'value' in identity) json.identity = identity.value;
|
||||
var monitor = e.querySelector('input[name="monitor"]');
|
||||
if (monitor && 'checked' in monitor) json.monitor = monitor.checked ? 1 : 0;
|
||||
var notify = e.querySelector('input[name="notify"]');
|
||||
if (notify && 'checked' in notify) json.notify = notify.checked ? 1 : 0;
|
||||
|
||||
return json;
|
||||
} },
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Form.Field,
|
||||
null,
|
||||
_react2.default.createElement(_semanticUiReact.Input, { label: '\u624B\u74B0ID', name: 'mac', defaultValue: data.mac, disabled: type == 1 })
|
||||
),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Form.Field,
|
||||
null,
|
||||
_react2.default.createElement(_semanticUiReact.Input, { label: '\u540D\u7A31', name: 'name', defaultValue: data.name })
|
||||
),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Form.Field,
|
||||
null,
|
||||
_react2.default.createElement(_semanticUiReact.Input, { label: '\u8EAB\u4EFD', name: 'identity', defaultValue: data.identity })
|
||||
),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Form.Field,
|
||||
null,
|
||||
_react2.default.createElement(_semanticUiReact.Checkbox, { label: '\u76E3\u63A7', name: 'monitor', defaultChecked: data.monitor == 1 })
|
||||
),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Form.Field,
|
||||
null,
|
||||
_react2.default.createElement(_semanticUiReact.Checkbox, { label: '\u901A\u77E5', name: 'notify', defaultChecked: data.notify == 1 })
|
||||
),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Form.Field,
|
||||
null,
|
||||
_react2.default.createElement(_semanticUiReact.Checkbox, { label: '\u555F\u7528', name: 'switch', defaultChecked: data.switch == 1 })
|
||||
),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Grid,
|
||||
{ columns: 2 },
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Grid.Column,
|
||||
null,
|
||||
_react2.default.createElement(_semanticUiReact.Button, { content: '\u9001\u51FA', fluid: true, type: 'submit' })
|
||||
),
|
||||
_react2.default.createElement(
|
||||
_semanticUiReact.Grid.Column,
|
||||
null,
|
||||
_react2.default.createElement(_semanticUiReact.Button, { content: '\u53D6\u6D88', fluid: true, type: 'button', onClick: function onClick() {
|
||||
closeModal();
|
||||
} })
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
};
|
||||
exports.default = WristbandModal;
|
||||
|
||||
/***/ })
|
||||
/******/ ]);
|
@ -74,8 +74,8 @@
|
||||
},
|
||||
"dio": {
|
||||
"title": {
|
||||
"di": "DigitInput",
|
||||
"do": "DigitOutput"
|
||||
"di": "DigitalInput",
|
||||
"do": "DigitalOutput"
|
||||
},
|
||||
"form": {
|
||||
"label": {
|
||||
@ -255,7 +255,7 @@
|
||||
},
|
||||
"status": {
|
||||
"leone": "無回應(網路問題或是IP/密碼錯誤)",
|
||||
"digitinput": "觸發"
|
||||
"digitalinput": "觸發"
|
||||
}
|
||||
},
|
||||
"menu": {
|
||||
@ -342,17 +342,17 @@
|
||||
"sun": "週日"
|
||||
},
|
||||
"porttype": [
|
||||
{"code": "1", "name":"DigitOutput"},
|
||||
{"code": "2", "name":"DigitInput"},
|
||||
{"code": "3", "name":"AnalogyOutput"},
|
||||
{"code": "4", "name":"AnalogyInput"}
|
||||
{ "code": "1", "name": "DigitalOutput" },
|
||||
{ "code": "2", "name": "DigitalInput" },
|
||||
{ "code": "3", "name": "AnalogyOutput" },
|
||||
{ "code": "4", "name": "AnalogyInput" }
|
||||
],
|
||||
"select": {
|
||||
"select_action": "請選擇動作",
|
||||
"dev_type": "請選擇裝置類型",
|
||||
"dev_name": "請選擇裝置",
|
||||
"action": "請選擇動作",
|
||||
"digitoutput": "DigitOutput",
|
||||
"digitaloutput": "DigitalOutput",
|
||||
"leone": "LeOne",
|
||||
"iogroup": "IOGroup"
|
||||
}
|
||||
|
@ -11,10 +11,10 @@ router
|
||||
.get('/', (req, res) => {
|
||||
res.send({ name: 'WebIO Modbus API' });
|
||||
})
|
||||
.post('*', async(req,res,n) => {
|
||||
try{
|
||||
.post('*', async(req, res, n) => {
|
||||
try {
|
||||
res.db = await mysql.getConn();
|
||||
}catch(e){
|
||||
} catch (e) {
|
||||
console.log(`Get DB Connection ERROR ${e}`);
|
||||
return n('ERR8100');
|
||||
}
|
||||
@ -27,7 +27,7 @@ router
|
||||
let param = [config.db.db5, 'device'];
|
||||
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res,err,n,'ERR8000');
|
||||
if (err) return rt.err(res, err, n, 'ERR8000');
|
||||
|
||||
res.api_res = {
|
||||
record: tool.checkArray(row)
|
||||
@ -47,7 +47,7 @@ router
|
||||
let param = [config.db.db5, 'device', arr.data.id];
|
||||
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err || row.length == 0) return rt.err(res,err,n,'ERR8000');
|
||||
if (err || row.length == 0) return rt.err(res, err, n, 'ERR8000');
|
||||
|
||||
res.api_res = {
|
||||
record: tool.checkArray(row),
|
||||
@ -80,7 +80,7 @@ router
|
||||
}
|
||||
return n();
|
||||
})
|
||||
.catch(err => rt.err(res,err,n,'ERR8000'));
|
||||
.catch(err => rt.err(res, err, n, 'ERR8000'));
|
||||
});
|
||||
})
|
||||
.post('/getporttype', (req, res, n) => {
|
||||
@ -90,7 +90,7 @@ router
|
||||
let param = [config.db.db5, 'porttype'];
|
||||
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res,err,n,'ERR8000');
|
||||
if (err) return rt.err(res, err, n, 'ERR8000');
|
||||
res.api_res = {
|
||||
record: tool.checkArray(row)
|
||||
};
|
||||
@ -115,7 +115,7 @@ router
|
||||
let param = [config.db.db5, 'device', arr.data.name, arr.data.node, type, u, u];
|
||||
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res,err,n,'ERR8001');
|
||||
if (err) return rt.err(res, err, n, 'ERR8001');
|
||||
|
||||
res.api_res = {
|
||||
record: []
|
||||
@ -138,7 +138,7 @@ router
|
||||
let query = "select count(*) as num from ??.?? where `node` = ? and `uid` != ?";
|
||||
let param = [config.db.db5, 'device', arr.data.node, arr.data.id];
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err || row.length == 0) return rt.err(res,err,n,'ERR8000');
|
||||
if (err || row.length == 0) return rt.err(res, err, n, 'ERR8000');
|
||||
if (row[0].num > 0) return n('ERR0047');
|
||||
|
||||
let u = '';
|
||||
@ -155,7 +155,7 @@ router
|
||||
`uid` = ?";
|
||||
let param = [config.db.db5, 'device', arr.data.name, arr.data.node, type, u, arr.data.id];
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res,err,n,'ERR8002');
|
||||
if (err) return rt.err(res, err, n, 'ERR8002');
|
||||
|
||||
let q = "delete from ??.?? where `node` in (?)";
|
||||
let p = [config.db.db6, 'jcmbrt', [arr.data.node, arr.data.original_node]];
|
||||
@ -176,6 +176,8 @@ router
|
||||
if (!arr.data) return n('ERR0000');
|
||||
if (!arr.data.id) return n('ERR0028');
|
||||
|
||||
res.db.query(`use ${config.db.db5}`);
|
||||
|
||||
let query = "delete d,i,s,rt from ??.?? d \
|
||||
left join ??.?? i \
|
||||
on d.`uid` = i.`devuid` \
|
||||
@ -187,7 +189,7 @@ router
|
||||
d.`uid` = ?";
|
||||
let param = [config.db.db5, 'device', config.db.db5, 'iolist', config.db.db5, 'aioset', config.db.db6, 'jcmbrt', arr.data.id];
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res,err,n,'ERR8003');
|
||||
if (err) return rt.err(res, err, n, 'ERR8003');
|
||||
res.api_res = {
|
||||
record: []
|
||||
};
|
||||
@ -218,7 +220,7 @@ router
|
||||
let param = [config.db.db6, 'jcmbrt', config.db.db5, 'device', config.db.db5, 'iolist', arr.data.type, config.db.db5, 'aioset', arr.data.id, arr.data.type];
|
||||
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res,err,n,'ERR8000');
|
||||
if (err) return rt.err(res, err, n, 'ERR8000');
|
||||
|
||||
res.api_res = {
|
||||
record: tool.checkArray(row)
|
||||
@ -235,7 +237,7 @@ router
|
||||
let query = "select * from ??.?? where `uid` = ? ";
|
||||
let param = [config.db.db5, 'iolist', arr.data.id];
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res,err,n,'ERR8000');
|
||||
if (err) return rt.err(res, err, n, 'ERR8000');
|
||||
|
||||
res.api_res = {
|
||||
record: tool.checkArray(row)
|
||||
@ -263,14 +265,14 @@ router
|
||||
and `addr` = ?";
|
||||
let param = [config.db.db5, 'iolist', arr.data.id, arr.data.type, arr.data.addr];
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err || row.length == 0) return rt.err(res,err,n,'ERR8000');
|
||||
if (err || row.length == 0) return rt.err(res, err, n, 'ERR8000');
|
||||
|
||||
if (row[0].c > 0) return n('ERR0054');
|
||||
|
||||
let query = "insert into ??.?? (`devuid`,`type`,`addr`,`num`,`datalen`,`ctime`,`mtime`) values (?, ?, ?, ?, ?, unix_timestamp(), unix_timestamp())";
|
||||
let param = [config.db.db5, 'iolist', arr.data.id, arr.data.type, arr.data.addr, arr.data.num, dlen];
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res,err,n,'ERR8001');
|
||||
if (err) return rt.err(res, err, n, 'ERR8001');
|
||||
|
||||
res.api_res = {
|
||||
record: []
|
||||
@ -301,7 +303,7 @@ router
|
||||
and i2.`uid` is not null ";
|
||||
let param = [config.db.db5, 'iolist', config.db.db5, 'iolist', arr.data.addr, arr.data.id, arr.data.id];
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err || row.length == 0) return rt.err(res,err,n,'ERR8000');
|
||||
if (err || row.length == 0) return rt.err(res, err, n, 'ERR8000');
|
||||
if (row[0].c > 0) return n('ERR0054');
|
||||
|
||||
let q = "update ??.?? set \
|
||||
@ -313,7 +315,7 @@ router
|
||||
`uid` = ?";
|
||||
let p = [config.db.db5, 'iolist', arr.data.addr, arr.data.num, dlen, arr.data.id];
|
||||
res.db.query(q, p, (err, row) => {
|
||||
if (err) return rt.err(res,err,n,'ERR8002');
|
||||
if (err) return rt.err(res, err, n, 'ERR8002');
|
||||
|
||||
res.api_res = {
|
||||
record: []
|
||||
@ -338,7 +340,7 @@ router
|
||||
i.`uid` = ?";
|
||||
let param = [config.db.db5, 'iolist', config.db.db5, 'aioset', arr.data.id];
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res,err,n,'ERR8003');
|
||||
if (err) return rt.err(res, err, n, 'ERR8003');
|
||||
|
||||
res.api_res = {
|
||||
record: []
|
||||
@ -359,7 +361,7 @@ router
|
||||
i.`uid` = ?";
|
||||
let param = [config.db.db5, 'aioset', config.db.db5, 'iolist', arr.data.id];
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res,err,n,'ERR8000');
|
||||
if (err) return rt.err(res, err, n, 'ERR8000');
|
||||
|
||||
res.api_res = {
|
||||
record: tool.checkArray(row)
|
||||
@ -376,7 +378,7 @@ router
|
||||
let query = "select * from ??.?? where `uid` = ?";
|
||||
let param = [config.db.db5, 'aioset', arr.data.id];
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res,err,n,'ERR8000');
|
||||
if (err) return rt.err(res, err, n, 'ERR8000');
|
||||
|
||||
res.api_res = {
|
||||
record: tool.checkArray(row)
|
||||
@ -394,7 +396,7 @@ router
|
||||
let query = "delete from ??.?? where `uid` = ?";
|
||||
let param = [config.db.db5, 'aioset', arr.data.id];
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res,err,n,'ERR8003');
|
||||
if (err) return rt.err(res, err, n, 'ERR8003');
|
||||
res.api_res = {
|
||||
record: []
|
||||
};
|
||||
@ -418,7 +420,7 @@ router
|
||||
let query = "select count(*) as count from ??.?? where `iouid` = ? and `portnum` = ?";
|
||||
let param = [config.db.db5, 'aioset', arr.data.iouid, arr.data.portnum];
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err || row.length == 0) return rt.err(res,err,n,'ERR8000');
|
||||
if (err || row.length == 0) return rt.err(res, err, n, 'ERR8000');
|
||||
|
||||
if (row[0].count > 0) return n('ERR0054');
|
||||
|
||||
@ -426,7 +428,7 @@ router
|
||||
(?, ?, ?, ?, ?, ?, ?, ?, unix_timestamp(), unix_timestamp())";
|
||||
let p = [config.db.db5, 'aioset', arr.data.iouid, arr.data.name, arr.data.portnum, arr.data.type, arr.data.range_min, arr.data.range_max, arr.data.scale_min, arr.data.scale_max];
|
||||
res.db.query(q, p, (err, row) => {
|
||||
if (err) return rt.err(res,err,n,'ERR8001');
|
||||
if (err) return rt.err(res, err, n, 'ERR8001');
|
||||
|
||||
res.api_res = {
|
||||
record: []
|
||||
@ -458,7 +460,7 @@ router
|
||||
and `uid` != ?";
|
||||
let param = [config.db.db5, 'aioset', arr.data.iouid, arr.data.portnum, arr.data.id];
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err || row.length == 0) return rt.err(res,err,n,'ERR8000');
|
||||
if (err || row.length == 0) return rt.err(res, err, n, 'ERR8000');
|
||||
if (row[0].length > 0) return n('ERR0054');
|
||||
|
||||
let query = "update ??.?? set \
|
||||
@ -473,7 +475,7 @@ router
|
||||
where `uid` = ?";
|
||||
let param = [config.db.db5, 'aioset', arr.data.name, arr.data.portnum, arr.data.type, arr.data.range_min, arr.data.range_max, arr.data.scale_min, arr.data.scale_max, arr.data.id];
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res,err,n,'ERR8002');
|
||||
if (err) return rt.err(res, err, n, 'ERR8002');
|
||||
|
||||
res.api_res = {
|
||||
record: []
|
||||
@ -482,16 +484,16 @@ router
|
||||
});
|
||||
});
|
||||
})
|
||||
.post('/modbuscmd', (req,res,n) => {
|
||||
.post('/modbuscmd', (req, res, n) => {
|
||||
if (!config.permission.modbus) return n('ERR9000');
|
||||
if (!tool.checkPermission(req)) return n('ERR9000');
|
||||
let arr = req.body;
|
||||
if (!arr.data) return n('ERR0000');
|
||||
if(!arr.data.ip) return n('ERR0010');
|
||||
if(!('node' in arr.data) || arr.data.node.length == 0) return n('ERR0038');
|
||||
if(!('func' in arr.data) || arr.data.func.length == 0) return n('ERR0055');
|
||||
if(!('addr' in arr.data) || arr.data.addr.length == 0) return n('ERR0048');
|
||||
if(!('value' in arr.data) || arr.data.value.length == 0) return n('ERR0049');
|
||||
if (!arr.data.ip) return n('ERR0010');
|
||||
if (!('node' in arr.data) || arr.data.node.length == 0) return n('ERR0038');
|
||||
if (!('func' in arr.data) || arr.data.func.length == 0) return n('ERR0055');
|
||||
if (!('addr' in arr.data) || arr.data.addr.length == 0) return n('ERR0048');
|
||||
if (!('value' in arr.data) || arr.data.value.length == 0) return n('ERR0049');
|
||||
|
||||
let cmd = `mbtcpm ${arr.data.ip} ${arr.data.node} ${arr.data.func} ${arr.data.addr} ${arr.data.value}`;
|
||||
res.api_res = {
|
||||
@ -499,17 +501,17 @@ router
|
||||
};
|
||||
exec(cmd, (err, stdout, stderr) => {
|
||||
let msg = err ? err.toString() : `${stdout}${stderr}`;
|
||||
res.api_res.record.push({msg});
|
||||
res.api_res.record.push({ msg });
|
||||
|
||||
n();
|
||||
})
|
||||
})
|
||||
.post('/getmodbuslog', (req,res,n) => {
|
||||
.post('/getmodbuslog', (req, res, n) => {
|
||||
if (!config.permission.modbus) return n('ERR9000');
|
||||
let arr = req.body;
|
||||
if(!arr.data) return n('ERR0000');
|
||||
if(!arr.data.ids || !Array.isArray(arr.data.ids)) return n('ERR0028');
|
||||
if(!arr.data.stime || !arr.data.etime) return n('ERR0015');
|
||||
if (!arr.data) return n('ERR0000');
|
||||
if (!arr.data.ids || !Array.isArray(arr.data.ids)) return n('ERR0028');
|
||||
if (!arr.data.stime || !arr.data.etime) return n('ERR0015');
|
||||
|
||||
let query = "select log.`node`, log.`type`, log.`port`, log.`value2` as value, log.`tst`, dev.`name` as devname, aio.`name` as aioname \
|
||||
from ??.?? log \
|
||||
@ -531,8 +533,8 @@ router
|
||||
limit 0, 100";
|
||||
let param = [config.db.db10, 'jcmbrt', config.db.db5, 'device', config.db.db5, 'iolist', config.db.db5, 'aioset', arr.data.ids, arr.data.stime, arr.data.etime];
|
||||
|
||||
res.db.query(query, param, (err,row) => {
|
||||
if(err) return rt.err(res,err,n,'ERR8000');
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res, err, n, 'ERR8000');
|
||||
res.api_res = {
|
||||
record: tool.checkArray(row)
|
||||
}
|
||||
|
@ -126,6 +126,7 @@ router
|
||||
n();
|
||||
})
|
||||
.post('/getstatus', (req, res, n) => {
|
||||
if (!config.permission.wristband) return n('ERR9000');
|
||||
|
||||
let query = "select w.`name`, coalesce(l.`name`, l2.`name`) as locname, ll.*\
|
||||
from ??.?? w\
|
||||
@ -172,6 +173,9 @@ router
|
||||
case 'loc':
|
||||
query += `order by locname ${sortorder}`;
|
||||
break;
|
||||
case 'time':
|
||||
query += 'order by ll.`timestamp` ' + sortorder;
|
||||
break;
|
||||
default:
|
||||
query += 'order by w.`uid`';
|
||||
break;
|
||||
@ -186,6 +190,101 @@ router
|
||||
n();
|
||||
})
|
||||
})
|
||||
.post('/getwristbandlist', (req, res, n) => {
|
||||
if (!config.permission.wristband) return n('ERR9000');
|
||||
|
||||
let query = "select * from ??.?? ";
|
||||
let param = [config.db.db9, 'wristband'];
|
||||
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res, err, n, 'ERR8000');
|
||||
|
||||
res.api_res = {
|
||||
record: tool.checkArray(row)
|
||||
};
|
||||
|
||||
n();
|
||||
})
|
||||
})
|
||||
.post('/delwristband', (req, res, n) => {
|
||||
if (!config.permission.wristband) return n('ERR9000');
|
||||
if (!tool.checkPermission(req)) return n('ERR9000');
|
||||
let arr = req.body;
|
||||
if (!arr.data) return n('ERR0000');
|
||||
if (!arr.data.id) return n('ERR0028');
|
||||
|
||||
res.db.query(`use ${config.db.db9}`);
|
||||
let query = "delete from ??.?? where `uid` = ?";
|
||||
let param = [config.db.db9, 'wristband', arr.data.id];
|
||||
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res, err, n, 'ERR8003');
|
||||
|
||||
res.api_res = {
|
||||
record: []
|
||||
};
|
||||
n();
|
||||
});
|
||||
})
|
||||
.post('/addwristband', (req, res, n) => {
|
||||
if (!config.permission.wristband) return n('ERR9000');
|
||||
if (!tool.checkPermission(req)) return n('ERR9000');
|
||||
let arr = req.body;
|
||||
if (!arr.data) return n('ERR0000')
|
||||
if (!arr.data.mac) return n('ERR0060');
|
||||
|
||||
let name = arr.data.name || '';
|
||||
let identity = arr.data.identity || 0;
|
||||
let monitor = arr.data.monitor || 0;
|
||||
let notify = arr.data.notify || 0;
|
||||
let sw = arr.data.switch || 0;
|
||||
|
||||
let query = "insert into ??.?? (`mac`, `name`, `identity`, `monitor`, `notify`, `switch`, `ctime`, `mtime`) values \
|
||||
( ?, ?, ?, ?, ?, ?, unix_timestamp(), unix_timestamp() )";
|
||||
let param = [config.db.db9, 'wristband', arr.data.mac, name, identity, monitor, notify, sw];
|
||||
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res, err, n, 'ERR8001');
|
||||
|
||||
res.api_res = {
|
||||
record: []
|
||||
};
|
||||
n();
|
||||
});
|
||||
|
||||
})
|
||||
.post('/editwristband', (req, res, n) => {
|
||||
if (!config.permission.wristband) return n('ERR9000');
|
||||
if (!tool.checkPermission(req)) return n('ERR9000');
|
||||
let arr = req.body;
|
||||
if (!arr.data) return n('ERR0000');
|
||||
if (!arr.data.id) return n('ERR0028');
|
||||
|
||||
let name = arr.data.name || '';
|
||||
let identity = arr.data.identity || 0;
|
||||
let monitor = arr.data.monitor || 0;
|
||||
let notify = arr.data.notify || 0;
|
||||
let sw = arr.data.switch || 0;
|
||||
|
||||
let query = "update ??.?? set \
|
||||
`name` = ?, \
|
||||
`identity` = ?, \
|
||||
`monitor` = ?, \
|
||||
`notify` = ?, \
|
||||
`switch` = ?, \
|
||||
`mtime` = unix_timestamp() \
|
||||
where \
|
||||
`uid` = ?";
|
||||
let param = [config.db.db9, 'wristband', name, identity, monitor, notify, sw, arr.data.id];
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res, err, n, 'ERR8002');
|
||||
|
||||
res.api_res = {
|
||||
record: []
|
||||
}
|
||||
n();
|
||||
})
|
||||
})
|
||||
.all('*', rt.send);
|
||||
|
||||
module.exports = router;
|
@ -138,7 +138,10 @@ class LocStatus extends React.Component{
|
||||
SOS
|
||||
{this.renderSortIcon('val9')}
|
||||
</Table.HeaderCell>
|
||||
<Table.HeaderCell>時間</Table.HeaderCell>
|
||||
<Table.HeaderCell className="pointer" onClick={()=>{this.handlerSort('time')}}>
|
||||
更新時間
|
||||
{this.renderSortIcon('time')}
|
||||
</Table.HeaderCell>
|
||||
{/*<Table.HeaderCell></Table.HeaderCell>*/}
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
|
18
src/components/AdminPage/Wristband/WristbandInfo/ListItem.js
Normal file
18
src/components/AdminPage/Wristband/WristbandInfo/ListItem.js
Normal file
@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
import { Table, Button } from 'semantic-ui-react';
|
||||
|
||||
const ListItem = ({ i18n, data, delWristband, editWristband }) => {
|
||||
|
||||
return (
|
||||
<Table.Row>
|
||||
<Table.Cell>
|
||||
<Button content="Edit" basic onClick={()=>{editWristband(1, data)}} />
|
||||
<Button content="Delete" basic onClick={()=>{delWristband(data.uid)}} />
|
||||
</Table.Cell>
|
||||
<Table.Cell>{data.mac}</Table.Cell>
|
||||
<Table.Cell>{data.name}</Table.Cell>
|
||||
</Table.Row>
|
||||
)
|
||||
}
|
||||
|
||||
export default ListItem;
|
@ -0,0 +1,67 @@
|
||||
import React from 'react';
|
||||
import { Modal, Form, Input, Button, Checkbox, Grid } from 'semantic-ui-react';
|
||||
|
||||
const WristbandModal = ({ i18n, open, type, data, closeModal, submitModal }) => {
|
||||
|
||||
return (
|
||||
<Modal open={open}>
|
||||
<Modal.Header content={type == 1 ? '修改資料' : '新增資料'} />
|
||||
<Modal.Content>
|
||||
<Form onSubmit={(e,d)=>{
|
||||
e.preventDefault();
|
||||
submitModal(type, d.formData);
|
||||
}} serializer={e => {
|
||||
let json = {
|
||||
name: '',
|
||||
identity: '',
|
||||
monitor: 0,
|
||||
notify: 0,
|
||||
id: type == 1 ? data.uid : '',
|
||||
mac: ''
|
||||
};
|
||||
|
||||
let mac = e.querySelector('input[name="mac"]');
|
||||
if(mac && 'value' in mac) json.mac = mac.value;
|
||||
let name = e.querySelector('input[name="name"]');
|
||||
if(name && 'value' in name) json.name = name.value;
|
||||
let identity = e.querySelector('input[name="identity"]');
|
||||
if(identity && 'value' in identity) json.identity = identity.value;
|
||||
let monitor = e.querySelector('input[name="monitor"]');
|
||||
if(monitor && 'checked' in monitor) json.monitor = monitor.checked ? 1 : 0;
|
||||
let notify = e.querySelector('input[name="notify"]');
|
||||
if(notify && 'checked' in notify) json.notify = notify.checked ? 1 : 0;
|
||||
|
||||
return json;
|
||||
}}>
|
||||
<Form.Field>
|
||||
<Input label="手環ID" name="mac" defaultValue={data.mac} disabled={type == 1} />
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
<Input label="名稱" name="name" defaultValue={data.name} />
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
<Input label="身份" name="identity" defaultValue={data.identity} />
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
<Checkbox label="監控" name="monitor" defaultChecked={data.monitor == 1} />
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
<Checkbox label="通知" name="notify" defaultChecked={data.notify == 1} />
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
<Checkbox label="啟用" name="switch" defaultChecked={data.switch == 1} />
|
||||
</Form.Field>
|
||||
<Grid columns={2}>
|
||||
<Grid.Column>
|
||||
<Button content="送出" fluid type="submit" />
|
||||
</Grid.Column>
|
||||
<Grid.Column>
|
||||
<Button content="取消" fluid type="button" onClick={()=>{ closeModal() }} />
|
||||
</Grid.Column>
|
||||
</Grid>
|
||||
</Form>
|
||||
</Modal.Content>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
export default WristbandModal;
|
120
src/components/AdminPage/Wristband/WristbandInfo/index.js
Normal file
120
src/components/AdminPage/Wristband/WristbandInfo/index.js
Normal file
@ -0,0 +1,120 @@
|
||||
import React from 'react';
|
||||
import { Container, Segment, Table, Button } from 'semantic-ui-react';
|
||||
import {getRequest} from '../../../../actions';
|
||||
import ListItem from './ListItem';
|
||||
import WristbandModal from './WristbandModal';
|
||||
|
||||
const stateDefault = ()=>({
|
||||
list: [],
|
||||
modal: {
|
||||
open: false,
|
||||
type: 0,
|
||||
data: {}
|
||||
}
|
||||
})
|
||||
|
||||
class WristbandInfo extends React.Component {
|
||||
state = {
|
||||
...stateDefault()
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
this.getList();
|
||||
}
|
||||
|
||||
getList = () => {
|
||||
let {showDialog, toggleLoading} = this.props;
|
||||
|
||||
fetch('/api/wristband/getwristbandlist', getRequest())
|
||||
.then(response=>response.json())
|
||||
.then(json =>{
|
||||
if(json.status != 1) return showDialog(json.message);
|
||||
this.setState({
|
||||
list: json.data.record || []
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
delWristband = (id) => {
|
||||
if(!id) return ;
|
||||
|
||||
fetch('/api/wristband/delwristband', getRequest({id}))
|
||||
.then(response=>response.json())
|
||||
.then(json=>{
|
||||
if(json.status!=1) return showDialog(json.message);
|
||||
this.getList();
|
||||
})
|
||||
}
|
||||
|
||||
openModal = (type, data = {}) => {
|
||||
this.setState({
|
||||
modal: {
|
||||
type,
|
||||
data,
|
||||
open: true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
closeModal = () => {
|
||||
this.setState({
|
||||
modal: {
|
||||
...stateDefault().modal
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
submitModal = (type, data = {}) => {
|
||||
let {showDialog, toggleLoading} = this.props;
|
||||
if(type == 1 && !data.id) return showDialog('資料取得失敗');
|
||||
if(type == 0 && !data.mac) return showDialog('請填寫手環ID');
|
||||
|
||||
let url = type == 1 ? '/api/wristband/editwristband' : '/api/wristband/addwristband';
|
||||
|
||||
fetch(url, getRequest(data))
|
||||
.then(response=>response.json())
|
||||
.then(json => {
|
||||
if(json.status != 1) return showDialog(json.message);
|
||||
this.setState({
|
||||
modal: {...stateDefault().modal}
|
||||
}, ()=>{
|
||||
this.getList();
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
let { i18n } = this.props;
|
||||
return (
|
||||
<Container fluid>
|
||||
<Segment className="clearfix">
|
||||
<Button basic color="green" icon="plus" content="新增" floated="right" onClick={()=>{this.openModal(0)}} style={{marginBottom: '15px'}} />
|
||||
<Table>
|
||||
<Table.Header>
|
||||
<Table.Row>
|
||||
<Table.HeaderCell>操作</Table.HeaderCell>
|
||||
<Table.HeaderCell>手環ID</Table.HeaderCell>
|
||||
<Table.HeaderCell>手環名稱</Table.HeaderCell>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
{
|
||||
this.state.list.map((t,idx) => (
|
||||
<ListItem key={idx} data={t} i18n={i18n} delWristband={this.delWristband} editWristband={this.openModal}/>
|
||||
))
|
||||
}
|
||||
</Table.Body>
|
||||
</Table>
|
||||
</Segment>
|
||||
<WristbandModal i18n={i18n}
|
||||
open={this.state.modal.open}
|
||||
type={this.state.modal.type}
|
||||
data={this.state.modal.data}
|
||||
closeModal={this.closeModal}
|
||||
submitModal={this.submitModal} />
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default WristbandInfo;
|
@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import {Grid, Container, Segment, Menu, List} from 'semantic-ui-react';
|
||||
import LocStatus from '../../../containers/AdminPage/Wristband/LocStatus';
|
||||
import WristbandInfo from '../../../containers/AdminPage/Wristband/WristbandInfo';
|
||||
|
||||
class WristbandPage extends React.Component{
|
||||
state = {
|
||||
@ -14,24 +15,30 @@ class WristbandPage extends React.Component{
|
||||
}
|
||||
|
||||
getRenderPage = () => {
|
||||
let {i18n} = this.props;
|
||||
switch(this.state.page) {
|
||||
case 'locstatus':
|
||||
return <LocStatus />;
|
||||
return <LocStatus/>;
|
||||
case 'wristband':
|
||||
return <WristbandInfo />
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
render(){
|
||||
|
||||
let {i18n} = this.props;
|
||||
return (
|
||||
<Container fluid>
|
||||
<Container fluid style={{paddingLeft: '10px', paddingRight: '10px'}}>
|
||||
<Grid>
|
||||
<Grid.Column width={4}>
|
||||
<Menu vertical={true}>
|
||||
<Menu vertical={true} fluid>
|
||||
<Menu.Item>
|
||||
<Menu.Header>主選單</Menu.Header>
|
||||
<Menu.Menu>
|
||||
<Menu.Item active={this.state.page == 'wristband'} onClick={()=>{this.changePage('wristband')}}>
|
||||
手環名稱設定
|
||||
</Menu.Item>
|
||||
<Menu.Item active={this.state.page == 'locstatus'} onClick={()=>{ this.changePage('locstatus'); }}>
|
||||
位置資訊
|
||||
</Menu.Item>
|
||||
|
@ -14,7 +14,7 @@ const DeviceSelect = ({i18n, querySelectList, page, permissions, devs, addSelect
|
||||
<option value="">{i18n&&i18n.t?i18n.t('select.dev_type') : ''}</option>
|
||||
{
|
||||
permissions.dio ?
|
||||
<option value="do">{i18n&&i18n.t ? i18n.t('select.digitoutput') : ''}</option> : null
|
||||
<option value="do">{i18n&&i18n.t ? i18n.t('select.digitaloutput') : ''}</option> : null
|
||||
}
|
||||
{
|
||||
permissions.leone ?
|
||||
|
@ -6,14 +6,14 @@ const AlertItem = ({i18n, name, type}) => {
|
||||
return (
|
||||
<Grid.Row columns={3} color="red">
|
||||
<Grid.Column>
|
||||
<Label basic content={type == 'di' ? "DigitInput" : "LeOne"} />
|
||||
<Label basic content={type == 'di' ? "DigitalInput" : "LeOne"} />
|
||||
</Grid.Column>
|
||||
<Grid.Column>
|
||||
<Label basic content={i18n&&i18n.t ? i18n.t('dashboard.label.name') : ''} />{name}
|
||||
</Grid.Column>
|
||||
<Grid.Column>
|
||||
<Label basic content={i18n&&i18n.t ? i18n.t('dashboard.label.status') : ''} />
|
||||
{i18n&&i18n.t ? ( type == 'di' ? i18n.t('dashboard.status.digitinput') : i18n.t('dashboard.status.leone') ): ''}
|
||||
{i18n&&i18n.t ? ( type == 'di' ? i18n.t('dashboard.status.digitalinput') : i18n.t('dashboard.status.leone') ): ''}
|
||||
</Grid.Column>
|
||||
</Grid.Row>
|
||||
)
|
||||
|
19
src/containers/AdminPage/Wristband/WristbandInfo.js
Normal file
19
src/containers/AdminPage/Wristband/WristbandInfo.js
Normal file
@ -0,0 +1,19 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { add_dialog_msg, toggle_loading } from '../../../actions';
|
||||
import WristbandInfo from '../../../components/AdminPage/Wristband/WristbandInfo';
|
||||
|
||||
|
||||
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)(WristbandInfo);
|
Loading…
Reference in New Issue
Block a user