diff --git a/includes/language/zh.json b/includes/language/zh.json index ca7f354..d6c6bc7 100644 --- a/includes/language/zh.json +++ b/includes/language/zh.json @@ -65,6 +65,7 @@ "ERR0063": "機器序號已存在", "ERR0064": "MAC Addr 輸入錯誤", "ERR0065": "版本輸入錯誤", + "ERR0066": "SNMP Level輸入錯誤", "ERR7000": "命令執行失敗", diff --git a/public/js/admin_bundle.js b/public/js/admin_bundle.js index de4792e..4b63bed 100644 --- a/public/js/admin_bundle.js +++ b/public/js/admin_bundle.js @@ -80593,1229 +80593,11 @@ var ActionLinkPage = function (_React$Component) { exports.default = ActionLinkPage; /***/ }), -/* 1030 */ -/***/ (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 ActionItem = function ActionItem(_ref) { - var i18n = _ref.i18n, - data = _ref.data, - idx = _ref.idx, - removeAction = _ref.removeAction; - - - return _react2.default.createElement( - _semanticUiReact.List.Item, - null, - _react2.default.createElement(_semanticUiReact.Label, { basic: true, content: '\u88DD\u7F6E\u540D\u7A31' }), - _react2.default.createElement( - 'span', - null, - data.devName - ), - _react2.default.createElement(_semanticUiReact.Label, { basic: true, content: '\u52D5\u4F5C' }), - _react2.default.createElement( - 'span', - null, - data.actName - ), - _react2.default.createElement(_semanticUiReact.Button, { floated: 'right', color: 'red', basic: true, size: 'tiny', content: 'Delete', type: 'button', onClick: function onClick() { - removeAction(idx); - } }) - ); -}; - -exports.default = ActionItem; - -/***/ }), -/* 1031 */ -/***/ (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); - -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 ActionSelect = function (_React$Component) { - _inherits(ActionSelect, _React$Component); - - function ActionSelect() { - var _ref; - - var _temp, _this, _ret; - - _classCallCheck(this, ActionSelect); - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ActionSelect.__proto__ || Object.getPrototypeOf(ActionSelect)).call.apply(_ref, [this].concat(args))), _this), _this.state = { - showTemp: false, - temp: '0' - }, _this.checkShowTemp = function () { - var cmd = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - - var c = cmd; - var cs = c.split(' '); - var showTemp = false; - if (cs[0] == 2) { - showTemp = true; - } - - _this.setState({ - showTemp: showTemp - }); - }, _this.updateTemp = function (temp) { - _this.setState({ - temp: temp - }); - }, _temp), _possibleConstructorReturn(_this, _ret); - } - - _createClass(ActionSelect, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - i18n = _props.i18n, - list = _props.list, - unit = _props.unit, - getList = _props.getList, - addAction = _props.addAction; - - var actlist = i18n && i18n.getResource && i18n.language ? i18n.getResource(i18n.language + '.translation.action_list') : []; - return _react2.default.createElement( - _semanticUiReact.Form.Field, - null, - _react2.default.createElement( - 'label', - null, - '\u52A0\u5165\u52D5\u4F5C' - ), - _react2.default.createElement( - _semanticUiReact.Segment, - { color: 'green', className: 'clearfix' }, - _react2.default.createElement( - _semanticUiReact.Form.Group, - { inline: true }, - _react2.default.createElement( - _semanticUiReact.Form.Field, - null, - _react2.default.createElement( - 'label', - null, - '\u9078\u64C7\u88DD\u7F6E' - ), - _react2.default.createElement( - 'select', - { ref: 'devType', onChange: function onChange(e) { - getList(unit, e.target.value); - } }, - _react2.default.createElement( - 'option', - { value: '' }, - '\u9078\u64C7\u88DD\u7F6E\u985E\u578B' - ), - _react2.default.createElement( - 'option', - { value: 'do' }, - 'DigitOutput' - ), - _react2.default.createElement( - 'option', - { value: 'leone' }, - 'LeOne' - ), - _react2.default.createElement( - 'option', - { value: 'iogroup' }, - 'IOGroup' - ) - ) - ), - _react2.default.createElement( - _semanticUiReact.Form.Field, - null, - _react2.default.createElement( - 'select', - { ref: 'devName' }, - _react2.default.createElement( - 'option', - { value: '' }, - '\u9078\u64C7\u88DD\u7F6E' - ), - list.map(function (t, idx) { - return _react2.default.createElement( - 'option', - { key: idx, value: t.id }, - t.name - ); - }) - ) - ) - ), - _react2.default.createElement( - _semanticUiReact.Form.Group, - { inline: true }, - _react2.default.createElement( - _semanticUiReact.Form.Field, - null, - _react2.default.createElement( - 'label', - null, - '\u9078\u64C7\u52D5\u4F5C' - ), - _react2.default.createElement( - 'select', - { ref: 'act', onChange: function onChange(e) { - _this2.checkShowTemp(e.target.value); - } }, - _react2.default.createElement( - 'option', - { value: '' }, - '\u9078\u64C7\u52D5\u4F5C' - ), - actlist.map(function (t, idx) { - return _react2.default.createElement( - 'option', - { key: idx, value: t.cmd }, - t.name - ); - }) - ) - ), - this.state.showTemp ? _react2.default.createElement( - _semanticUiReact.Form.Field, - null, - _react2.default.createElement(_semanticUiReact.Input, { size: 'mini', placeholder: '\u8ACB\u8F38\u5165\u6EAB\u5EA6', value: this.state.temp, onChange: function onChange(e, d) { - _this2.updateTemp(d.value); - } }) - ) : null - ), - _react2.default.createElement(_semanticUiReact.Button, { floated: 'right', content: '\u52A0\u5165\u52D5\u4F5C', size: 'tiny', basic: true, color: 'orange', onClick: function onClick() { - var type = _this2.refs.devType.value; - var dev = _this2.refs.devName.value; - var devName = _this2.refs.devName.options[_this2.refs.devName.selectedIndex].innerHTML; - var act = _this2.refs.act.value; - var actName = _this2.refs.act.options[_this2.refs.act.selectedIndex].innerHTML; - var temp = _this2.state.temp; - var prefix = ''; - - switch (type) { - case 'do': - prefix = 'do'; - break; - case 'leone': - prefix = 'le'; - break; - case 'iogroup': - prefix = 'iogroup'; - break; - default: - return addAction(null); - } - - if (!act) return addAction(null); - if (act == 2) { - act = act + ' ' + temp; - actName += ' ' + temp; - } - - var data = { - id: '' + prefix + dev, - act: act, - actName: actName, - devName: devName - }; - - return addAction(data); - } }) - ) - ); - } - }]); - - return ActionSelect; -}(_react2.default.Component); - -exports.default = ActionSelect; - -/***/ }), -/* 1032 */ -/***/ (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); - -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 ops = [{ - "code": "0", - "name": "等於" -}, { - "code": "1", - "name": "大於" -}, { - "code": "2", - "name": "小於" -}, { - "code": "3", - "name": "大於等於" -}, { - "code": "4", - "name": "小於等於" -}, { - "code": "5", - "name": "不等於" -}, { - "code": "8", - "name": "AND" -}, { - "code": "9", - "name": "OR" -}]; - -var stype = { - di: { - prefix: 'di', - dev: '', - op: '', - value: '', - mode: 'di_status' - }, - leone: { - prefix: 'le', - dev: '', - op: '', - value: '', - mode: '' - }, - unit: { - dev: '' - }, - time: { - op: '', - dev: 'dt0', - mode: 'mode0', - year: '-', - week: '-', - month: '-', - day: '-', - hour: '-', - min: '-' - } -}; - -var UnitItem = function (_React$Component) { - _inherits(UnitItem, _React$Component); - - function UnitItem() { - var _ref; - - var _temp, _this, _ret; - - _classCallCheck(this, UnitItem); - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = UnitItem.__proto__ || Object.getPrototypeOf(UnitItem)).call.apply(_ref, [this].concat(args))), _this), _this.state = { - st: '', - data: {} - }, _this.handleDataChange = function (tag, value) { - var data = _this.state.data; - var updateData = _this.props.updateData; - - if (tag in data) { - data[tag] = value; - } - - _this.setState({ - data: data - }, function () { - var data = _this.state.data; - - var d = _extends({}, _this.props.data.data); - var st = _this.props.data.st; - - - if (st == 'di' || st == 'leone') { - d.id = '' + data.prefix + data.dev + ',' + data.mode; - d.op = data.op; - d.value = data.value; - } - if (st == 'unit') { - d.dev = data.dev; - } - if (st == 'time') { - d.id = data.dev + ',' + data.mode; - d.op = data.op; - d.value = data.min + '|' + data.hour + '|' + data.day + '|' + data.month + '|' + data.week + '|' + data.year; - } - - updateData(_this.props.unit, d); - }); - }, _temp), _possibleConstructorReturn(_this, _ret); - } - - _createClass(UnitItem, [{ - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(np) { - var data = _extends({}, this.state.data); - - if (np.data.st != this.state.st) { - - if (np.data.st in stype) { - data = _extends({}, stype[np.data.st]); - } else { - data = {}; - } - } - - this.setState({ - data: data, - st: np.data.st - }); - } - }, { - key: 'render', - value: function render() { - var _props = this.props, - unit = _props.unit, - data = _props.data, - getList = _props.getList; - - - return _react2.default.createElement( - _semanticUiReact.Grid.Column, - null, - _react2.default.createElement( - _semanticUiReact.Segment, - null, - _react2.default.createElement( - _semanticUiReact.Form.Field, - null, - _react2.default.createElement( - 'label', - null, - '\u9078\u64C7\u5143\u4EF6' - ), - _react2.default.createElement( - 'select', - { - value: data.st, - onChange: function onChange(e) { - getList(unit, e.target.value); - } }, - _react2.default.createElement( - 'option', - { value: '' }, - '\u8ACB\u9078\u64C7\u5143\u4EF6' - ), - _react2.default.createElement( - 'option', - { value: 'leone' }, - 'LeOne' - ), - _react2.default.createElement( - 'option', - { value: 'di' }, - 'DigitInput' - ), - _react2.default.createElement( - 'option', - { value: 'time' }, - '\u6642\u9593' - ), - _react2.default.createElement( - 'option', - { value: 'unit' }, - '\u5DF2\u5EFA\u7ACB\u7FA4\u7D44' - ) - ) - ), - !data.st ? null : _react2.default.createElement(UnitPanel, { data: data, state: this.state.data, dataChange: this.handleDataChange }) - ) - ); - } - }]); - - return UnitItem; -}(_react2.default.Component); - -var UnitPanel = function UnitPanel(_ref2) { - var data = _ref2.data, - state = _ref2.state, - dataChange = _ref2.dataChange; - - if (data.st == 'di') { - return _react2.default.createElement( - 'div', - null, - _react2.default.createElement( - 'select', - { value: state.dev, onChange: function onChange(e) { - dataChange('dev', e.target.value); - } }, - _react2.default.createElement( - 'option', - { value: '' }, - '\u9078\u64C7\u88DD\u7F6E' - ), - data.list.map(function (t, idx) { - return _react2.default.createElement( - 'option', - { key: idx, value: t.id }, - t.name - ); - }) - ), - _react2.default.createElement( - 'select', - { value: state.op, onChange: function onChange(e) { - dataChange('op', e.target.value); - } }, - _react2.default.createElement( - 'option', - { value: '' }, - '\u9078\u64C7\u689D\u4EF6' - ), - ops.map(function (t, idx) { - if (t.code == 8 || t.code == 9) return; - return _react2.default.createElement( - 'option', - { key: idx, value: t.code }, - t.name - ); - }) - ), - _react2.default.createElement( - 'select', - { value: state.value, onChange: function onChange(e) { - dataChange('value', e.target.value); - } }, - _react2.default.createElement( - 'option', - { value: '' }, - '\u9078\u64C7\u72C0\u614B' - ), - _react2.default.createElement( - 'option', - { value: '0' }, - '0' - ), - _react2.default.createElement( - 'option', - { value: '1' }, - '1' - ) - ) - ); - } - if (data.st == 'leone') { - return _react2.default.createElement( - 'div', - null, - _react2.default.createElement( - 'select', - { value: state.dev, onChange: function onChange(e) { - dataChange('dev', e.target.value); - } }, - _react2.default.createElement( - 'option', - { value: '' }, - '\u9078\u64C7\u88DD\u7F6E' - ), - data.list.map(function (t, idx) { - return _react2.default.createElement( - 'option', - { key: idx, value: t.id }, - t.name - ); - }) - ), - _react2.default.createElement( - 'select', - { value: state.mode, onChange: function onChange(e) { - dataChange('mode', e.target.value); - } }, - _react2.default.createElement( - 'option', - { value: '' }, - '\u9078\u64C7\u611F\u6E2C\u5668' - ), - _react2.default.createElement( - 'option', - { value: 'leone_ttrigger1' }, - '\u6EAB\u5EA6' - ), - _react2.default.createElement( - 'option', - { value: 'leone_htrigger1' }, - '\u6FD5\u5EA6' - ) - ), - _react2.default.createElement( - 'select', - { value: state.op, onChange: function onChange(e) { - dataChange('op', e.target.value); - } }, - _react2.default.createElement( - 'option', - { value: '' }, - '\u9078\u64C7\u689D\u4EF6' - ), - ops.map(function (t, idx) { - if (t.code == 8 || t.code == 9) return; - return _react2.default.createElement( - 'option', - { key: idx, value: t.code }, - t.name - ); - }) - ), - _react2.default.createElement(_semanticUiReact.Input, { size: 'mini', placeholder: '\u8ACB\u8F38\u5165\u6578\u503C', value: state.value, onChange: function onChange(e, d) { - dataChange('value', d.value); - } }) - ); - } - if (data.st == 'unit') { - return _react2.default.createElement( - 'div', - null, - _react2.default.createElement( - 'select', - { value: state.dev, onChange: function onChange(e) { - dataChange('dev', e.target.value); - } }, - _react2.default.createElement( - 'option', - { value: '' }, - '\u9078\u64C7\u7FA4\u7D44' - ), - data.list.map(function (t, idx) { - return _react2.default.createElement( - 'option', - { key: idx, value: t.id }, - t.name - ); - }) - ) - ); - } - if (data.st == 'time') { - return _react2.default.createElement( - 'div', - null, - _react2.default.createElement( - 'select', - { value: state.op, onChange: function onChange(e) { - dataChange('op', e.target.value); - } }, - _react2.default.createElement( - 'option', - { value: '' }, - '\u9078\u64C7\u689D\u4EF6' - ), - ops.map(function (t, idx) { - if (t.code == 8 || t.code == 9) return; - return _react2.default.createElement( - 'option', - { key: idx, value: t.code }, - t.name - ); - }) - ), - _react2.default.createElement(_semanticUiReact.Input, { size: 'mini', placeholder: '\u5E74(\u4E0D\u6307\u5B9A\u8ACB\u7559\u7A7A)', value: state.year == '-' ? '' : state.year, onChange: function onChange(e, d) { - dataChange('year', d.value.length == 0 ? '-' : d.value); - } }), - _react2.default.createElement(_semanticUiReact.Input, { size: 'mini', placeholder: '\u9031(\u4E0D\u6307\u5B9A\u8ACB\u7559\u7A7A)', value: state.week == '-' ? '' : state.week, onChange: function onChange(e, d) { - dataChange('week', d.value.length == 0 ? '-' : d.value); - } }), - _react2.default.createElement(_semanticUiReact.Input, { size: 'mini', placeholder: '\u6708(\u4E0D\u6307\u5B9A\u8ACB\u7559\u7A7A)', value: state.month == '-' ? '' : state.month, onChange: function onChange(e, d) { - dataChange('month', d.value.length == 0 ? '-' : d.value); - } }), - _react2.default.createElement(_semanticUiReact.Input, { size: 'mini', placeholder: '\u65E5(\u4E0D\u6307\u5B9A\u8ACB\u7559\u7A7A)', value: state.day == '-' ? '' : state.day, onChange: function onChange(e, d) { - dataChange('day', d.value.length == 0 ? '-' : d.value); - } }), - _react2.default.createElement(_semanticUiReact.Input, { size: 'mini', placeholder: '\u6642(\u4E0D\u6307\u5B9A\u8ACB\u7559\u7A7A)', value: state.hour == '-' ? '' : state.hour, onChange: function onChange(e, d) { - dataChange('hour', d.value.length == 0 ? '-' : d.value); - } }), - _react2.default.createElement(_semanticUiReact.Input, { size: 'mini', placeholder: '\u5206(\u4E0D\u6307\u5B9A\u8ACB\u7559\u7A7A)', value: state.min == '-' ? '' : state.min, onChange: function onChange(e, d) { - dataChange('min', d.value.length == 0 ? '-' : d.value); - } }) - ); - } - - return null; -}; - -exports.default = UnitItem; - -/***/ }), -/* 1033 */ -/***/ (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 ViewTree = function ViewTree(_ref) { - var i18n = _ref.i18n, - open = _ref.open, - data = _ref.data, - closeView = _ref.closeView, - removeNode = _ref.removeNode; - - var seNode = null; - var nodeKey = Object.keys(data); - return _react2.default.createElement( - _semanticUiReact.Modal, - { open: open, onClose: function onClose() { - closeView(); - } }, - _react2.default.createElement(_semanticUiReact.Modal.Header, { content: '\u9023\u52D5\u7FA4\u7D44\u8CC7\u6599' }), - _react2.default.createElement( - _semanticUiReact.Modal.Content, - null, - _react2.default.createElement( - _semanticUiReact.Form, - { as: 'div' }, - _react2.default.createElement( - _semanticUiReact.Form.Group, - { inline: true }, - _react2.default.createElement( - _semanticUiReact.Form.Field, - null, - _react2.default.createElement( - 'label', - null, - '\u522A\u9664\u7BC0\u9EDE' - ), - _react2.default.createElement( - 'select', - { ref: function ref(node) { - return seNode = node; - } }, - nodeKey.map(function (t, idx) { - return _react2.default.createElement( - 'option', - { key: idx, value: t }, - data[t].name - ); - }) - ) - ), - _react2.default.createElement( - _semanticUiReact.Form.Field, - null, - _react2.default.createElement(_semanticUiReact.Button, { type: 'button', basic: true, size: 'tiny', content: '\u522A\u9664\u7BC0\u9EDE', onClick: function onClick() { - if (!seNode) return; - removeNode(seNode.value); - } }) - ) - ) - ), - _react2.default.createElement( - 'pre', - null, - JSON.stringify(data, null, 4) - ) - ) - ); -}; - -exports.default = ViewTree; - -/***/ }), -/* 1034 */ -/***/ (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__(18); - -var _UnitItem = __webpack_require__(1032); - -var _UnitItem2 = _interopRequireDefault(_UnitItem); - -var _ActionSelect = __webpack_require__(1031); - -var _ActionSelect2 = _interopRequireDefault(_ActionSelect); - -var _ActionItem = __webpack_require__(1030); - -var _ActionItem2 = _interopRequireDefault(_ActionItem); - -var _ViewTreeModal = __webpack_require__(1033); - -var _ViewTreeModal2 = _interopRequireDefault(_ViewTreeModal); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } - -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 defState = function defState() { - return { - gidx: 0, - groups: {}, - active: false, - edit: { - name: '', - type: 'ln', - op: '', - id1: { - st: '', - list: [], - data: {} - }, - id2: { - st: '', - list: [], - data: {} - } - }, - actDevlist: [], - items: [], - showTree: false - }; -}; -var gtype = { - lc: { - type: 'lc', - id: '', - op: '', - value: '' - }, - ln: { - type: 'ln', - dev: '' - } -}; - -var ActionLinkAdd = function (_React$Component) { - _inherits(ActionLinkAdd, _React$Component); - - function ActionLinkAdd() { - var _ref; - - var _temp, _this, _ret; - - _classCallCheck(this, ActionLinkAdd); - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ActionLinkAdd.__proto__ || Object.getPrototypeOf(ActionLinkAdd)).call.apply(_ref, [this].concat(args))), _this), _this.state = _extends({}, defState()), _this.getSelectList = function (unit) { - var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; - - if (!unit) { - return; - } - if (unit != 'act') { - var edit = _extends({}, _this.state.edit); - if (!(unit in edit)) { - return; - } - edit[unit].st = type; - edit[unit].data = _extends({}, gtype.lc); - if (type != 'di' && type != 'leone' && type != 'unit') { - return _this.setState({ edit: edit }); - } - - if (type == 'di' || type == 'leone') { - _this.props.toggleLoading(1); - var json = { - type: type - }; - fetch('/api/system/getselectlist', (0, _actions.getRequest)(json)).then(function (response) { - return response.json(); - }).then(function (json) { - if (json.status != 1) return _this.props.showDialog(json.message); - edit[unit].list = json.data.record || []; - _this.setState({ edit: edit }, function () { - _this.props.toggleLoading(0); - }); - }); - } - if (type == 'unit') { - var list = []; - for (var i in _this.state.groups) { - list.push({ id: i, name: _this.state.groups[i].name }); - } - edit[unit].list = list; - edit[unit].data = _extends({}, gtype.ln); - _this.setState({ edit: edit }); - } - } else { - var actDevlist = []; - if (!type) { - _this.setState({ - actDevlist: actDevlist - }); - return; - } - _this.props.toggleLoading(1); - fetch('/api/system/getselectlist', (0, _actions.getRequest)({ type: type })).then(function (response) { - return response.json(); - }).then(function (json) { - if (json.status != 1) return _this.props.showDialog(json.message); - actDevlist = json.data.record || []; - _this.setState({ - actDevlist: actDevlist - }, function () { - _this.props.toggleLoading(0); - }); - }); - } - }, _this.updateData = function (unit, data) { - var edit = _this.state.edit; - - if (!(unit in edit)) return; - edit[unit].data = data; - - _this.setState({ - edit: edit - }); - }, _this.updateEditData = function (tag, value) { - var edit = _this.state.edit; - - if (tag in edit) { - edit[tag] = value; - } - - _this.setState({ - edit: edit - }); - }, _this.updateActive = function () { - var active = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - - _this.setState({ - active: active ? 1 : 0 - }); - }, _this.joinUnit = function () { - var edit = _this.state.edit; - var i18n = _this.props.i18n; - - if (!edit.name || edit.op.length == 0 || Object.keys(edit.id1.data).length == 0 || Object.keys(edit.id2.data).length == 0) return _this.props.showDialog(i18n && i18n.t ? i18n.t('tip.input_empty') : ''); - if (edit.id1.data.type == 'lc' && (edit.id1.data.id.length == 0 || edit.id1.data.op.length == 0 || edit.id1.data.value.length == 0)) return _this.props.showDialog(i18n && i18n.t ? i18n.t('tip.input_empty') : ''); - if (edit.id2.data.type == 'lc' && (edit.id2.data.id.length == 0 || edit.id2.data.op.length == 0 || edit.id2.data.value.length == 0)) return _this.props.showDialog(i18n && i18n.t ? i18n.t('tip.input_empty') : ''); - if (edit.id1.data.type == 'ln' && edit.id1.data.dev.length == 0) return _this.props.showDialog(i18n && i18n.t ? i18n.t('tip.input_empty') : ''); - if (edit.id2.data.type == 'ln' && edit.id2.data.dev.length == 0) return _this.props.showDialog(i18n && i18n.t ? i18n.t('tip.input_empty') : ''); - - var unitKey = []; - if (edit.id1.data.type == 'lc') { - edit.id1 = _extends({}, edit.id1.data); - } else if (edit.id1.data.type == 'ln') { - unitKey.push(edit.id1.data.dev); - edit.id1 = _extends({}, _this.state.groups[edit.id1.data.dev]); - } - if (edit.id2.data.type == 'lc') { - edit.id2 = _extends({}, edit.id2.data); - } else if (edit.id2.data.type == 'ln') { - unitKey.push(edit.id2.data.dev); - edit.id2 = _extends({}, _this.state.groups[edit.id2.data.dev]); - } - var groups = _extends({}, _this.state.groups); - for (var i in unitKey) { - if (unitKey[i] in groups) delete groups[unitKey[i]]; - } - - groups['unit' + _this.state.gidx] = _extends({}, edit); - - _this.setState({ - gidx: _this.state.gidx + 1, - groups: _extends({}, groups) - }, function () { - _this.resetEdit(); - }); - }, _this.resetEdit = function () { - _this.setState({ - edit: _extends({}, defState().edit) - }); - }, _this.addAction = function (item) { - if (!item) return _this.props.showDialog('動作請選擇完整'); - var cmds = item.act.split(' '); - if (cmds.length != 2) return _this.props.showDialog('動作選擇錯誤'); - if (cmds[0] == 2 && (cmds[1] < 16 || cmds[1] > 30)) return _this.props.showDialog('溫度範圍錯誤(16-30)'); - - _this.setState({ - items: [].concat(_toConsumableArray(_this.state.items), [item]) - }); - }, _this.removeAction = function (idx) { - var items = [].concat(_toConsumableArray(_this.state.items)); - items.splice(idx, 1); - _this.setState({ - items: items - }); - }, _this.toggleView = function () { - var sw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - - _this.setState({ - showTree: sw ? true : false - }); - }, _this.removeNode = function (node) { - if (!node) return; - var groups = _extends({}, _this.state.groups); - if (node in groups) { - delete groups[node]; - _this.setState({ - groups: _extends({}, groups) - }); - } - }, _this.saveLink = function () { - if (Object.keys(_this.state.groups).length == 0) return _this.props.showDialog('請先建立群組'); - if (Object.keys(_this.state.groups).length > 1) return _this.props.showDialog('根節點數量大於一'); - if (_this.state.items.length == 0) return _this.props.showDialog('請選擇動作'); - var json = { - active: _this.state.active, - link: _this.state.groups[Object.keys(_this.state.groups)[0]], - action: '' - }; - - var acts = _this.state.items.map(function (t) { - return t.id + ',' + t.act.replace(' ', ',') + ',0'; - }); - - json.action = acts.join('|'); - - _this.props.toggleLoading(1); - fetch('/api/link/addlink', (0, _actions.getRequest)(json)).then(function (response) { - return response.json(); - }).then(function (json) { - _this.props.toggleLoading(0); - if (json.status != 1) return _this.props.showDialog(json.message); - _this.resetAll(); - }); - }, _this.resetAll = function () { - _this.setState(_extends({}, defState())); - }, _temp), _possibleConstructorReturn(_this, _ret); - } - - _createClass(ActionLinkAdd, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var i18n = this.props.i18n; - - return _react2.default.createElement( - _semanticUiReact.Container, - null, - _react2.default.createElement( - _semanticUiReact.Menu, - null, - _react2.default.createElement( - _semanticUiReact.Menu.Menu, - { position: 'right' }, - _react2.default.createElement(_semanticUiReact.Menu.Item, { content: 'ShowTree', onClick: function onClick() { - _this2.toggleView(1); - } }), - _react2.default.createElement(_semanticUiReact.Menu.Item, { content: 'Save', onClick: function onClick() { - _this2.saveLink(); - } }) - ) - ), - _react2.default.createElement( - _semanticUiReact.Form, - { as: _semanticUiReact.Segment }, - _react2.default.createElement( - _semanticUiReact.Form.Field, - null, - _react2.default.createElement(_semanticUiReact.Checkbox, { label: '\u555F\u7528\u9023\u52D5', checked: this.state.active == 1, onChange: function onChange(e, d) { - _this2.updateActive(d.checked ? 1 : 0); - } }) - ), - _react2.default.createElement( - _semanticUiReact.Form.Field, - null, - _react2.default.createElement( - 'label', - null, - '\u5EFA\u7ACB\u689D\u4EF6\u7FA4\u7D44' - ), - _react2.default.createElement( - _semanticUiReact.Segment, - { color: 'red' }, - _react2.default.createElement( - _semanticUiReact.Form.Field, - null, - _react2.default.createElement(_semanticUiReact.Input, { label: '\u7BC0\u9EDE\u540D\u7A31', value: this.state.edit.name, onChange: function onChange(e, d) { - _this2.updateEditData('name', d.value); - } }) - ), - _react2.default.createElement( - _semanticUiReact.Form.Field, - null, - _react2.default.createElement( - 'label', - null, - '\u89F8\u767C\u689D\u4EF6' - ), - _react2.default.createElement( - 'select', - { value: this.state.edit.op, onChange: function onChange(e) { - _this2.updateEditData('op', e.target.value); - } }, - _react2.default.createElement( - 'option', - { value: '' }, - '\u8ACB\u9078\u64C7\u89F8\u767C\u689D\u4EF6' - ), - _react2.default.createElement( - 'option', - { value: '8' }, - 'AND' - ), - _react2.default.createElement( - 'option', - { value: '9' }, - 'OR' - ) - ) - ), - _react2.default.createElement( - _semanticUiReact.Grid, - { columns: 2, padded: true }, - _react2.default.createElement(_UnitItem2.default, { unit: 'id1', data: this.state.edit.id1, getList: this.getSelectList, updateData: this.updateData }), - _react2.default.createElement(_UnitItem2.default, { unit: 'id2', data: this.state.edit.id2, getList: this.getSelectList, updateData: this.updateData }) - ), - _react2.default.createElement( - 'div', - { - style: { - textAlign: 'right' - } }, - _react2.default.createElement(_semanticUiReact.Button, { type: 'button', basic: true, size: 'tiny', color: 'blue', content: '\u52A0\u5165', onClick: function onClick() { - _this2.joinUnit(); - } }), - _react2.default.createElement(_semanticUiReact.Button, { type: 'button', basic: true, size: 'tiny', color: 'green', content: '\u6E05\u9664', onClick: function onClick() { - _this2.resetEdit(); - } }) - ) - ) - ), - _react2.default.createElement(_ActionSelect2.default, { i18n: i18n, unit: 'act', list: this.state.actDevlist, getList: this.getSelectList, addAction: this.addAction }), - _react2.default.createElement( - _semanticUiReact.Form.Field, - null, - _react2.default.createElement( - 'label', - null, - '\u88DD\u7F6E\u52D5\u4F5C\u5217\u8868' - ), - _react2.default.createElement( - _semanticUiReact.Segment, - { color: 'blue' }, - _react2.default.createElement( - _semanticUiReact.List, - null, - this.state.items.map(function (t, idx) { - return _react2.default.createElement(_ActionItem2.default, { key: idx, i18n: i18n, data: t, idx: idx, removeAction: _this2.removeAction }); - }) - ) - ) - ) - ), - _react2.default.createElement(_ViewTreeModal2.default, { i18n: i18n, data: this.state.groups, open: this.state.showTree, closeView: this.toggleView, removeNode: this.removeNode }) - ); - } - }]); - - return ActionLinkAdd; -}(_react2.default.Component); - -exports.default = ActionLinkAdd; - -/***/ }), +/* 1030 */, +/* 1031 */, +/* 1032 */, +/* 1033 */, +/* 1034 */, /* 1035 */ /***/ (function(module, exports, __webpack_require__) { @@ -90090,39 +88872,39 @@ exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)( Object.defineProperty(exports, "__esModule", { - value: true + value: true }); var _reactRedux = __webpack_require__(24); var _actions = __webpack_require__(18); -var _ActionLinkAdd = __webpack_require__(1034); +var _ActionLinkAddN = __webpack_require__(1155); -var _ActionLinkAdd2 = _interopRequireDefault(_ActionLinkAdd); +var _ActionLinkAddN2 = _interopRequireDefault(_ActionLinkAddN); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var mapStateToProps = function mapStateToProps(state) { - return { - i18n: state.i18n - }; + 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 active = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + return { + showDialog: function showDialog(msg) { + dispatch((0, _actions.add_dialog_msg)(msg)); + }, + toggleLoading: function toggleLoading() { + var active = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - dispatch((0, _actions.toggle_loading)(active)); - } - }; + dispatch((0, _actions.toggle_loading)(active)); + } + }; }; -exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_ActionLinkAdd2.default); +exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_ActionLinkAddN2.default); /***/ }), /* 1102 */ @@ -94425,5 +93207,1054 @@ var PageRoot = function (_React$Component) { _reactDom2.default.render(_react2.default.createElement(PageRoot, null), document.getElementById('app')); +/***/ }), +/* 1154 */, +/* 1155 */ +/***/ (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 _Condition = __webpack_require__(1156); + +var _Condition2 = _interopRequireDefault(_Condition); + +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 { + groups: { + "g1": { + name: "aaa" + }, + "g2": { + name: "bbb" + } + } + }; +}; + +var ActionLinkAdd = function (_React$Component) { + _inherits(ActionLinkAdd, _React$Component); + + function ActionLinkAdd() { + var _ref; + + var _temp, _this, _ret; + + _classCallCheck(this, ActionLinkAdd); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ActionLinkAdd.__proto__ || Object.getPrototypeOf(ActionLinkAdd)).call.apply(_ref, [this].concat(args))), _this), _this.state = _extends({}, stateDefault()), _temp), _possibleConstructorReturn(_this, _ret); + } + + _createClass(ActionLinkAdd, [{ + key: 'render', + value: function render() { + var _props = this.props, + i18n = _props.i18n, + showDialog = _props.showDialog, + toggleLoading = _props.toggleLoading; + + return _react2.default.createElement( + _semanticUiReact.Container, + null, + _react2.default.createElement( + _semanticUiReact.Menu, + null, + _react2.default.createElement( + _semanticUiReact.Menu.Menu, + { position: 'right' }, + _react2.default.createElement(_semanticUiReact.Menu.Item, { content: 'ShowTree', onClick: function onClick() {} }), + _react2.default.createElement(_semanticUiReact.Menu.Item, { content: 'Save', onClick: function onClick() {} }) + ) + ), + _react2.default.createElement( + _semanticUiReact.Form, + { as: _semanticUiReact.Segment }, + _react2.default.createElement( + _semanticUiReact.Form.Field, + null, + _react2.default.createElement(_semanticUiReact.Checkbox, { label: '\u555F\u7528\u9023\u52D5' }) + ), + _react2.default.createElement( + _semanticUiReact.Form.Field, + null, + _react2.default.createElement( + 'label', + null, + '\u5EFA\u7ACB\u689D\u4EF6\u7FA4\u7D44' + ), + _react2.default.createElement(_Condition2.default, { i18n: i18n, showDialog: showDialog, toggleLoading: toggleLoading, groups: this.state.groups }) + ) + ) + ); + } + }]); + + return ActionLinkAdd; +}(_react2.default.Component); + +exports.default = ActionLinkAdd; + +/***/ }), +/* 1156 */ +/***/ (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 _Unit = __webpack_require__(1157); + +var _Unit2 = _interopRequireDefault(_Unit); + +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 ops = [{ + "code": "0", + "name": "等於" +}, { + "code": "1", + "name": "大於" +}, { + "code": "2", + "name": "小於" +}, { + "code": "3", + "name": "大於等於" +}, { + "code": "4", + "name": "小於等於" +}, { + "code": "5", + "name": "不等於" +}, { + "code": "8", + "name": "AND" +}, { + "code": "9", + "name": "OR" +}]; + +var stateDefault = function stateDefault() { + return { + id1: { + unit: '', + data: {} + }, + id2: { + unit: '', + data: {} + } + }; +}; + +var lcDef = function lcDef() { + return { + type: 'lc', + id: '', + op: '', + value: '' + }; +}; + +var lnDef = function lnDef() { + return { + type: 'ln', + dev: '' + }; +}; + +var ConditionField = function (_React$Component) { + _inherits(ConditionField, _React$Component); + + function ConditionField() { + var _ref; + + var _temp, _this, _ret; + + _classCallCheck(this, ConditionField); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ConditionField.__proto__ || Object.getPrototypeOf(ConditionField)).call.apply(_ref, [this].concat(args))), _this), _this.state = _extends({}, stateDefault()), _this.changeUnitType = function (id, type) { + var st = _this.state; + if (id in st) { + st[id].unit = type; + if (type == '') { + st[id].data = {}; + } else if (type == 'unit') { + st[id].data = _extends({}, lnDef()); + } else { + st[id].data = _extends({}, lcDef()); + } + _this.setState(_extends({}, st)); + } + }, _this.updateData = function (id, data) { + var st = _this.state; + if (id in st) { + st[id].data = data; + _this.setState(_extends({}, st)); + } + }, _this.clearField = function () { + _this.setState(_extends({}, stateDefault())); + }, _this.joinGroup = function () { + console.log(_this.state); + }, _temp), _possibleConstructorReturn(_this, _ret); + } + + _createClass(ConditionField, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + i18n = _props.i18n, + showDialog = _props.showDialog, + toggleLoading = _props.toggleLoading; + + return _react2.default.createElement( + _semanticUiReact.Segment, + { color: 'red' }, + _react2.default.createElement( + _semanticUiReact.Form.Field, + null, + _react2.default.createElement(_semanticUiReact.Input, { label: '\u7BC0\u9EDE\u540D\u7A31' }) + ), + _react2.default.createElement( + _semanticUiReact.Form.Field, + null, + _react2.default.createElement( + 'label', + null, + '\u89F8\u767C\u689D\u4EF6' + ), + _react2.default.createElement( + 'select', + null, + _react2.default.createElement( + 'option', + { value: '' }, + '\u8ACB\u9078\u64C7\u89F8\u767C\u689D\u4EF6' + ), + ops.map(function (t, idx) { + if (t.code == 8 || t.code == 9) { + return _react2.default.createElement( + 'option', + { key: idx, value: t.code }, + t.name + ); + } + }) + ) + ), + _react2.default.createElement( + _semanticUiReact.Grid, + { columns: 2, padded: true }, + _react2.default.createElement( + _semanticUiReact.Grid.Column, + null, + _react2.default.createElement(_Unit2.default, { i18n: i18n, id: 'id1', + data: this.state.id1, + groups: this.props.groups, + ops: ops, + toggleLoading: toggleLoading, + showDialog: showDialog, + updateData: this.updateData, + changeUnitType: this.changeUnitType }) + ), + _react2.default.createElement( + _semanticUiReact.Grid.Column, + null, + _react2.default.createElement(_Unit2.default, { i18n: i18n, id: 'id2', + data: this.state.id2, + groups: this.props.groups, + ops: ops, + toggleLoading: toggleLoading, + showDialog: showDialog, + updateData: this.updateData, + changeUnitType: this.changeUnitType }) + ) + ), + _react2.default.createElement( + 'div', + { style: { textAlign: 'right' } }, + _react2.default.createElement(_semanticUiReact.Button, { content: '\u52A0\u5165', basic: true, size: 'mini', color: 'blue', onClick: function onClick() { + _this2.joinGroup(); + } }), + _react2.default.createElement(_semanticUiReact.Button, { content: '\u6E05\u9664', basic: true, size: 'mini', color: 'red', onClick: function onClick() { + _this2.clearField(); + } }) + ) + ); + } + }]); + + return ConditionField; +}(_react2.default.Component); + +exports.default = ConditionField; + +/***/ }), +/* 1157 */ +/***/ (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 _UnitLeone = __webpack_require__(1158); + +var _UnitLeone2 = _interopRequireDefault(_UnitLeone); + +var _UnitDigitalInput = __webpack_require__(1159); + +var _UnitDigitalInput2 = _interopRequireDefault(_UnitDigitalInput); + +var _UnitTime = __webpack_require__(1160); + +var _UnitTime2 = _interopRequireDefault(_UnitTime); + +var _UnitGroups = __webpack_require__(1161); + +var _UnitGroups2 = _interopRequireDefault(_UnitGroups); + +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 Unit = function (_React$Component) { + _inherits(Unit, _React$Component); + + function Unit() { + var _ref; + + var _temp, _this, _ret; + + _classCallCheck(this, Unit); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Unit.__proto__ || Object.getPrototypeOf(Unit)).call.apply(_ref, [this].concat(args))), _this), _this.handleChangeUnit = function (val) { + _this.props.changeUnitType(_this.props.id, val); + }, _this.getUnitComponent = function () { + var _this$props = _this.props, + data = _this$props.data, + ops = _this$props.ops, + i18n = _this$props.i18n, + showDialog = _this$props.showDialog, + toggleLoading = _this$props.toggleLoading, + groups = _this$props.groups; + + + switch (data.unit) { + case 'leone': + return _react2.default.createElement(_UnitLeone2.default, { ops: ops, data: data.data, i18n: i18n, showDialog: showDialog, toggleLoading: toggleLoading, updateData: _this.updateData }); + case 'di': + return _react2.default.createElement(_UnitDigitalInput2.default, { ops: ops, data: data.data, i18n: i18n, showDialog: showDialog, toggleLoading: toggleLoading, updateData: _this.updateData }); + case 'time': + return _react2.default.createElement(_UnitTime2.default, { ops: ops, data: data.data, i18n: i18n, showDialog: showDialog, toggleLoading: toggleLoading, updateData: _this.updateData }); + case 'unit': + return _react2.default.createElement(_UnitGroups2.default, { i18n: i18n, data: data.data, groups: groups, updateData: _this.updateData }); + default: + return null; + } + }, _this.updateData = function (data) { + _this.props.updateData(_this.props.id, data); + }, _temp), _possibleConstructorReturn(_this, _ret); + } + + _createClass(Unit, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + ops = _props.ops, + id = _props.id; + + return _react2.default.createElement( + _semanticUiReact.Segment, + null, + _react2.default.createElement( + _semanticUiReact.Form.Field, + null, + _react2.default.createElement( + 'label', + null, + '\u9078\u64C7\u5143\u4EF6' + ), + _react2.default.createElement( + 'select', + { value: this.props.data.unit, onChange: function onChange(e) { + _this2.handleChangeUnit(e.target.value); + } }, + _react2.default.createElement( + 'option', + { value: '' }, + '\u8ACB\u9078\u64C7\u5143\u4EF6' + ), + _react2.default.createElement( + 'option', + { value: 'leone' }, + 'LeOne' + ), + _react2.default.createElement( + 'option', + { value: 'di' }, + 'DigitInput' + ), + _react2.default.createElement( + 'option', + { value: 'time' }, + '\u6642\u9593' + ), + _react2.default.createElement( + 'option', + { value: 'unit' }, + '\u5DF2\u5EFA\u7ACB\u7FA4\u7D44' + ) + ) + ), + this.getUnitComponent() + ); + } + }]); + + return Unit; +}(_react2.default.Component); + +exports.default = Unit; + +/***/ }), +/* 1158 */ +/***/ (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__(18); + +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 UnitLeone = function (_React$Component) { + _inherits(UnitLeone, _React$Component); + + function UnitLeone() { + var _ref; + + var _temp, _this, _ret; + + _classCallCheck(this, UnitLeone); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = UnitLeone.__proto__ || Object.getPrototypeOf(UnitLeone)).call.apply(_ref, [this].concat(args))), _this), _this.state = { + list: [], + data: { + id: '', + op: '', + mode: '', + value: '' + } + }, _this.changeState = function (key, value) { + var data = _extends({}, _this.state.data); + if (key == 'dev') { + data.id = value == '' ? '' : 'le' + value; + } + if (key == 'mode') { + data.mode = value; + } + if (key == 'op') { + data.op = value; + } + if (key == 'value') { + data.value = value; + } + + _this.setState({ + data: _extends({}, data) + }, function () { + _this.sendUpdate(); + }); + }, _this.sendUpdate = function () { + var data = _extends({}, _this.state.data); + data.id = data.id + ',' + data.mode; + delete data.mode; + _this.props.updateData(_extends({}, _this.props.data, data)); + }, _temp), _possibleConstructorReturn(_this, _ret); + } + + _createClass(UnitLeone, [{ + key: 'componentDidMount', + value: function componentDidMount() { + var _this2 = this; + + var _props = this.props, + showDialog = _props.showDialog, + toggleLoading = _props.toggleLoading; + + + toggleLoading(1); + fetch('/api/system/getselectlist', (0, _actions.getRequest)({ type: 'leone' })).then(function (response) { + return response.json(); + }).then(function (json) { + toggleLoading(0); + if (json.status != 1) return showDialog(json.message); + _this2.setState({ + list: json.data.record || [] + }); + }); + } + }, { + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(np) { + var data = _extends({}, this.state.data); + if (np.data.op != data.op) data.op = np.data.op; + if (np.data.value != data.value) data.value = np.data.op; + + var id = np.data.id.split(',')[0]; + var mode = np.data.id.split(',')[1]; + if (id != data.id) data.id = id; + if (mode != data.mode) data.mode = mode; + + this.setState({ + data: _extends({}, data) + }); + } + }, { + key: 'render', + value: function render() { + var _this3 = this; + + var ops = this.props.ops; + + var id = ''; + if (this.state.data.id != '') { + var m = this.state.data.id.match(/(\d+)/); + if (m != null && m.length > 1) { + id = m[1]; + } + } + return _react2.default.createElement( + 'div', + null, + _react2.default.createElement( + 'select', + { value: id, onChange: function onChange(e) { + _this3.changeState('dev', e.target.value); + } }, + _react2.default.createElement( + 'option', + { value: '' }, + '\u9078\u64C7\u88DD\u7F6E' + ), + this.state.list.map(function (t, idx) { + return _react2.default.createElement( + 'option', + { key: idx, value: t.id }, + t.name + ); + }) + ), + _react2.default.createElement( + 'select', + { value: this.state.data.mode, onChange: function onChange(e) { + _this3.changeState('mode', e.target.value); + } }, + _react2.default.createElement( + 'option', + { value: '' }, + '\u9078\u64C7\u611F\u6E2C\u5668' + ), + _react2.default.createElement( + 'option', + { value: 'leone_ttrigger1' }, + '\u6EAB\u5EA6' + ), + _react2.default.createElement( + 'option', + { value: 'leone_htrigger1' }, + '\u6FD5\u5EA6' + ) + ), + _react2.default.createElement( + 'select', + { value: this.state.data.op, onChange: function onChange(e) { + _this3.changeState('op', e.target.value); + } }, + _react2.default.createElement( + 'option', + { value: '' }, + '\u9078\u64C7\u689D\u4EF6' + ), + ops.map(function (t, idx) { + if (t.code != 8 && t.code != 9) { + return _react2.default.createElement( + 'option', + { value: t.code, key: idx }, + t.name + ); + } + }) + ), + _react2.default.createElement(_semanticUiReact.Input, { placeholder: '\u8ACB\u8F38\u5165\u6578\u503C', value: this.state.data.value, onChange: function onChange(e, d) { + _this3.changeState('value', d.value); + } }) + ); + } + }]); + + return UnitLeone; +}(_react2.default.Component); + +exports.default = UnitLeone; + +/***/ }), +/* 1159 */ +/***/ (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__(18); + +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 UnitDigitalInput = function (_React$Component) { + _inherits(UnitDigitalInput, _React$Component); + + function UnitDigitalInput() { + var _ref; + + var _temp, _this, _ret; + + _classCallCheck(this, UnitDigitalInput); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = UnitDigitalInput.__proto__ || Object.getPrototypeOf(UnitDigitalInput)).call.apply(_ref, [this].concat(args))), _this), _this.state = { + list: [], + data: { + id: '', + op: '', + value: '' + } + }, _this.changeState = function (key, value) { + var data = _extends({}, _this.state.data); + if (key == 'dev') { + data.id = value == '' ? '' : 'di' + value + ',di_status'; + } + if (key == 'op') { + data.op = value; + } + if (key == 'value') { + data.value = value; + } + + _this.setState({ + data: _extends({}, data) + }, function () { + _this.sendUpdate(); + }); + }, _this.sendUpdate = function () { + _this.props.updateData(_extends({}, _this.props.data, _this.state.data)); + }, _temp), _possibleConstructorReturn(_this, _ret); + } + + _createClass(UnitDigitalInput, [{ + key: 'componentDidMount', + value: function componentDidMount() { + var _this2 = this; + + var _props = this.props, + showDialog = _props.showDialog, + toggleLoading = _props.toggleLoading; + + + toggleLoading(1); + fetch('/api/system/getselectlist', (0, _actions.getRequest)({ type: 'di' })).then(function (response) { + return response.json(); + }).then(function (json) { + toggleLoading(0); + if (json.status != 1) return showDialog(json.message); + _this2.setState({ + list: json.data.record || [] + }); + }); + } + }, { + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(np) { + var data = _extends({}, this.state.data); + if (np.data.id != data.id) data.id = np.data.id; + if (np.data.op != data.op) data.op = np.data.op; + if (np.data.value != data.value) data.value = np.data.op; + + this.setState({ + data: _extends({}, data) + }); + } + }, { + key: 'render', + value: function render() { + var _this3 = this; + + var ops = this.props.ops; + + var id = ''; + if (this.state.data.id != '') { + var m = this.state.data.id.match(/(\d+)/); + if (m != null && m.length > 1) { + id = m[1]; + } + } + return _react2.default.createElement( + 'div', + null, + _react2.default.createElement( + 'select', + { value: id, onChange: function onChange(e) { + _this3.changeState('dev', e.target.value); + } }, + _react2.default.createElement( + 'option', + { value: '' }, + '\u9078\u64C7\u88DD\u7F6E' + ), + this.state.list.map(function (t, idx) { + return _react2.default.createElement( + 'option', + { key: idx, value: t.id }, + t.name + ); + }) + ), + _react2.default.createElement( + 'select', + { value: this.state.data.op, onChange: function onChange(e) { + _this3.changeState('op', e.target.value); + } }, + _react2.default.createElement( + 'option', + { value: '' }, + '\u9078\u64C7\u689D\u4EF6' + ), + ops.map(function (t, idx) { + if (t.code != 8 && t.code != 9) { + return _react2.default.createElement( + 'option', + { value: t.code, key: idx }, + t.name + ); + } + }) + ), + _react2.default.createElement( + 'select', + { value: this.state.data.value, onChange: function onChange(e) { + _this3.changeState('value', e.target.value); + } }, + _react2.default.createElement( + 'option', + { value: '' }, + '\u9078\u64C7\u72C0\u614B' + ), + _react2.default.createElement( + 'option', + { value: '0' }, + '0' + ), + _react2.default.createElement( + 'option', + { value: '1' }, + '1' + ) + ) + ); + } + }]); + + return UnitDigitalInput; +}(_react2.default.Component); + +exports.default = UnitDigitalInput; + +/***/ }), +/* 1160 */ +/***/ (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__(18); + +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 UnitTime = function (_React$Component) { + _inherits(UnitTime, _React$Component); + + function UnitTime() { + var _ref; + + var _temp, _this, _ret; + + _classCallCheck(this, UnitTime); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = UnitTime.__proto__ || Object.getPrototypeOf(UnitTime)).call.apply(_ref, [this].concat(args))), _this), _this.state = { + list: [] + }, _temp), _possibleConstructorReturn(_this, _ret); + } + + _createClass(UnitTime, [{ + key: 'componentDidMount', + value: function componentDidMount() {} + }, { + key: 'render', + value: function render() { + var ops = this.props.ops; + + return _react2.default.createElement( + 'div', + null, + _react2.default.createElement( + 'select', + null, + _react2.default.createElement( + 'option', + { value: '' }, + '\u9078\u64C7\u689D\u4EF6' + ), + ops.map(function (t, idx) { + if (t.code != 8 && t.code != 9) { + return _react2.default.createElement( + 'option', + { value: t.code, key: idx }, + t.name + ); + } + }) + ), + _react2.default.createElement(_semanticUiReact.Input, { size: 'mini', placeholder: '\u5E74(\u4E0D\u6307\u5B9A\u8ACB\u7559\u7A7A)' }), + _react2.default.createElement(_semanticUiReact.Input, { size: 'mini', placeholder: '\u9031(\u4E0D\u6307\u5B9A\u8ACB\u7559\u7A7A)' }), + _react2.default.createElement(_semanticUiReact.Input, { size: 'mini', placeholder: '\u6708(\u4E0D\u6307\u5B9A\u8ACB\u7559\u7A7A)' }), + _react2.default.createElement(_semanticUiReact.Input, { size: 'mini', placeholder: '\u65E5(\u4E0D\u6307\u5B9A\u8ACB\u7559\u7A7A)' }), + _react2.default.createElement(_semanticUiReact.Input, { size: 'mini', placeholder: '\u6642(\u4E0D\u6307\u5B9A\u8ACB\u7559\u7A7A)' }), + _react2.default.createElement(_semanticUiReact.Input, { size: 'mini', placeholder: '\u5206(\u4E0D\u6307\u5B9A\u8ACB\u7559\u7A7A)' }) + ); + } + }]); + + return UnitTime; +}(_react2.default.Component); + +exports.default = UnitTime; + +/***/ }), +/* 1161 */ +/***/ (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__(18); + +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 UnitGroups = function (_React$Component) { + _inherits(UnitGroups, _React$Component); + + function UnitGroups() { + _classCallCheck(this, UnitGroups); + + return _possibleConstructorReturn(this, (UnitGroups.__proto__ || Object.getPrototypeOf(UnitGroups)).apply(this, arguments)); + } + + _createClass(UnitGroups, [{ + key: 'render', + value: function render() { + var _props = this.props, + groups = _props.groups, + data = _props.data, + updateData = _props.updateData; + + return _react2.default.createElement( + 'div', + null, + _react2.default.createElement( + 'select', + { value: data.dev, onChange: function onChange(e) { + updateData(_extends({}, data, { dev: e.target.value })); + } }, + _react2.default.createElement( + 'option', + { value: '' }, + '\u9078\u64C7\u7FA4\u7D44' + ), + Object.keys(groups).map(function (t, idx) { + return _react2.default.createElement( + 'option', + { key: idx, value: t }, + groups[t].name + ); + }) + ) + ); + } + }]); + + return UnitGroups; +}(_react2.default.Component); + +exports.default = UnitGroups; + /***/ }) /******/ ]); \ No newline at end of file diff --git a/route/api/server.js b/route/api/server.js index 04a8983..1cb1d51 100644 --- a/route/api/server.js +++ b/route/api/server.js @@ -53,6 +53,10 @@ router if (!arr.data.stype) return n('ERR0009'); if (!arr.data.sname) return n('ERR0026'); if (!arr.data.sver) return n('ERR0065'); + if (arr.data.sver == 'v3' && !arr.data.v3level) return n('ERR0066'); + if (arr.data.v3level) { + + } } }) .all('*', rt.send); diff --git a/src/components/AdminPage/ActionLinkAddN/Condition/Unit/UnitDigitalInput.js b/src/components/AdminPage/ActionLinkAddN/Condition/Unit/UnitDigitalInput.js new file mode 100644 index 0000000..d159001 --- /dev/null +++ b/src/components/AdminPage/ActionLinkAddN/Condition/Unit/UnitDigitalInput.js @@ -0,0 +1,105 @@ +import React from 'react'; +import {Input} from 'semantic-ui-react'; +import {getRequest} from '../../../../../actions'; + +class UnitDigitalInput extends React.Component { + state = { + list: [], + data: { + id: '', + op: '', + value: '' + } + } + + componentDidMount(){ + let {showDialog, toggleLoading} = this.props; + + toggleLoading(1); + fetch('/api/system/getselectlist', getRequest({type: 'di'})) + .then(response=>response.json()) + .then(json=>{ + toggleLoading(0); + if(json.status != 1) return showDialog(json.message); + this.setState({ + list: json.data.record || [] + }) + }) + } + + componentWillReceiveProps(np) { + let data = {...this.state.data}; + if(np.data.id != data.id) data.id = np.data.id; + if(np.data.op != data.op) data.op = np.data.op; + if(np.data.value != data.value) data.value = np.data.op; + + this.setState({ + data: {...data} + }) + } + + changeState = (key, value) => { + let data = { + ...this.state.data + } + if(key == 'dev') { + data.id = value == '' ? '' : `di${value},di_status`; + } + if(key == 'op'){ + data.op = value; + } + if(key == 'value') { + data.value = value; + } + + this.setState({ + data: {...data} + }, ()=>{ this.sendUpdate() }); + } + + sendUpdate = () => { + this.props.updateData({...this.props.data, ...this.state.data}); + } + + render() { + let {ops} = this.props; + let id = ''; + if(this.state.data.id != '') { + let m = this.state.data.id.match(/(\d+)/); + if(m != null && m.length > 1){ + id = m[1]; + } + } + return ( +
+ + + +
+ ) + } +} + +export default UnitDigitalInput; \ No newline at end of file diff --git a/src/components/AdminPage/ActionLinkAddN/Condition/Unit/UnitGroups.js b/src/components/AdminPage/ActionLinkAddN/Condition/Unit/UnitGroups.js new file mode 100644 index 0000000..0a16e91 --- /dev/null +++ b/src/components/AdminPage/ActionLinkAddN/Condition/Unit/UnitGroups.js @@ -0,0 +1,26 @@ +import React from 'react'; +import {Input} from 'semantic-ui-react'; +import {getRequest} from '../../../../../actions'; + +class UnitGroups extends React.Component { + + render() { + let {groups, data, updateData } = this.props; + return ( +
+ +
+ ) + } +} + +export default UnitGroups; \ No newline at end of file diff --git a/src/components/AdminPage/ActionLinkAddN/Condition/Unit/UnitLeone.js b/src/components/AdminPage/ActionLinkAddN/Condition/Unit/UnitLeone.js new file mode 100644 index 0000000..e246014 --- /dev/null +++ b/src/components/AdminPage/ActionLinkAddN/Condition/Unit/UnitLeone.js @@ -0,0 +1,117 @@ +import React from 'react'; +import {Input} from 'semantic-ui-react'; +import {getRequest} from '../../../../../actions'; + +class UnitLeone extends React.Component { + state = { + list: [], + data: { + id: '', + op: '', + mode: '', + value: '' + } + } + + componentDidMount(){ + let {showDialog, toggleLoading} = this.props; + + toggleLoading(1); + fetch('/api/system/getselectlist', getRequest({type: 'leone'})) + .then(response=>response.json()) + .then(json=>{ + toggleLoading(0); + if(json.status != 1) return showDialog(json.message); + this.setState({ + list: json.data.record || [] + }) + }) + } + + componentWillReceiveProps(np) { + let data = {...this.state.data}; + if(np.data.op != data.op) data.op = np.data.op; + if(np.data.value != data.value) data.value = np.data.op; + + let id = np.data.id.split(',')[0]; + let mode = np.data.id.split(',')[1]; + if(id != data.id) data.id = id; + if(mode != data.mode) data.mode = mode; + + this.setState({ + data: {...data} + }) + } + + changeState = (key, value) => { + let data = { + ...this.state.data + } + if(key == 'dev') { + data.id = value == '' ? '' : `le${value}`; + } + if(key == 'mode'){ + data.mode = value; + } + if(key == 'op'){ + data.op = value; + } + if(key == 'value') { + data.value = value; + } + + this.setState({ + data: {...data} + }, ()=>{ this.sendUpdate() }); + } + + sendUpdate = () => { + let data = {...this.state.data}; + data.id = `${data.id},${data.mode}`; + delete data.mode; + this.props.updateData({...this.props.data, ...data}); + } + + render() { + let {ops} = this.props; + let id = ''; + if(this.state.data.id != '') { + let m = this.state.data.id.match(/(\d+)/); + if(m != null && m.length > 1){ + id = m[1]; + } + } + return ( +
+ + + + {this.changeState('value', d.value)}} /> +
+ ) + } +} + +export default UnitLeone; \ No newline at end of file diff --git a/src/components/AdminPage/ActionLinkAddN/Condition/Unit/UnitTime.js b/src/components/AdminPage/ActionLinkAddN/Condition/Unit/UnitTime.js new file mode 100644 index 0000000..1000d2e --- /dev/null +++ b/src/components/AdminPage/ActionLinkAddN/Condition/Unit/UnitTime.js @@ -0,0 +1,41 @@ +import React from 'react'; +import {Input} from 'semantic-ui-react'; +import {getRequest} from '../../../../../actions'; + +class UnitTime extends React.Component { + state = { + list: [] + } + + componentDidMount(){ + + } + + render() { + let {ops} = this.props; + return ( +
+ + + + + + + +
+ ) + } +} + +export default UnitTime; \ No newline at end of file diff --git a/src/components/AdminPage/ActionLinkAddN/Condition/Unit/index.js b/src/components/AdminPage/ActionLinkAddN/Condition/Unit/index.js new file mode 100644 index 0000000..1318e1b --- /dev/null +++ b/src/components/AdminPage/ActionLinkAddN/Condition/Unit/index.js @@ -0,0 +1,58 @@ +import React from 'react'; +import {Segment, Input, Form} from 'semantic-ui-react'; +import UnitLeone from './UnitLeone'; +import UnitDigitalInput from './UnitDigitalInput'; +import UnitTime from './UnitTime'; +import UnitGroups from './UnitGroups'; + +class Unit extends React.Component { + + handleChangeUnit = (val) => { + this.props.changeUnitType(this.props.id, val); + } + + getUnitComponent = () => { + + let {data, ops, i18n, showDialog, toggleLoading, groups} = this.props; + + switch(data.unit){ + case 'leone': + return + case 'di': + return + case 'time': + return + case 'unit': + return + default: + return null; + } + } + + updateData = (data) => { + this.props.updateData(this.props.id, data); + } + + render() { + let {ops, id} = this.props; + return ( + + + + + + {this.getUnitComponent()} + + ) + } +} + +export default Unit; \ No newline at end of file diff --git a/src/components/AdminPage/ActionLinkAddN/Condition/index.js b/src/components/AdminPage/ActionLinkAddN/Condition/index.js new file mode 100644 index 0000000..4c13976 --- /dev/null +++ b/src/components/AdminPage/ActionLinkAddN/Condition/index.js @@ -0,0 +1,151 @@ +import React from 'react'; +import { Segment, Input, Button, Form, Grid } from 'semantic-ui-react'; +import Unit from './Unit'; + +const ops = [ + { + "code": "0", + "name": "等於" + }, { + "code": "1", + "name": "大於" + }, { + "code": "2", + "name": "小於" + }, { + "code": "3", + "name": "大於等於" + }, { + "code": "4", + "name": "小於等於" + }, { + "code": "5", + "name": "不等於" + }, { + "code": "8", + "name": "AND" + }, { + "code": "9", + "name": "OR" + } +]; + +const stateDefault = () => ({ + id1: { + unit: '', + data: {} + }, + id2: { + unit: '', + data: {} + } +}) + +const lcDef = () => ({ + type: 'lc', + id: '', + op: '', + value: '' +}) + +const lnDef = () => ({ + type: 'ln', + dev: '' +}) + +class ConditionField extends React.Component { + state = { + ...stateDefault() + } + + changeUnitType = (id, type) => { + let st = this.state; + if(id in st){ + st[id].unit = type; + if(type == ''){ + st[id].data = {} + }else if(type == 'unit'){ + st[id].data = {...lnDef()} + }else { + st[id].data = {...lcDef()} + } + this.setState({ + ...st + }) + } + } + + updateData = (id, data) => { + let st = this.state; + if(id in st) { + st[id].data = data; + this.setState({ + ...st + }) + } + } + + clearField = () => { + this.setState({ + ...stateDefault() + }) + } + + joinGroup = () => { + console.log(this.state); + } + + render() { + let {i18n, showDialog, toggleLoading} = this.props; + return ( + + + + + + + + + + + + + + + + +
+
+
+ ) + } +} + +export default ConditionField; \ No newline at end of file diff --git a/src/components/AdminPage/ActionLinkAddN/index.js b/src/components/AdminPage/ActionLinkAddN/index.js new file mode 100644 index 0000000..7683b5d --- /dev/null +++ b/src/components/AdminPage/ActionLinkAddN/index.js @@ -0,0 +1,55 @@ +import React from 'react'; +import { + Container, + Segment, + Form, + Input, + Button, + Checkbox, + Grid, + Menu, + List +} from 'semantic-ui-react'; +import ConditionField from './Condition'; + +const stateDefault = ()=>({ + groups: { + "g1":{ + name: "aaa" + }, + "g2":{ + name: "bbb" + } + } +}) + +class ActionLinkAdd extends React.Component { + state = { + ...stateDefault() + } + + render() { + let {i18n, showDialog, toggleLoading} = this.props; + return ( + + + + {}}/> + {}}/> + + +
+ + + + + + + +
+
+ ) + } +} + +export default ActionLinkAdd; \ No newline at end of file diff --git a/src/containers/AdminPage/ActionLinkAdd.js b/src/containers/AdminPage/ActionLinkAdd.js index c7fe422..d47d91d 100644 --- a/src/containers/AdminPage/ActionLinkAdd.js +++ b/src/containers/AdminPage/ActionLinkAdd.js @@ -1,18 +1,18 @@ -import {connect} from 'react-redux'; -import {add_dialog_msg, toggle_loading} from '../../actions'; -import ActionLinkAdd from '../../components/AdminPage/ActionLinkAdd'; +import { connect } from 'react-redux'; +import { add_dialog_msg, toggle_loading } from '../../actions'; +import ActionLinkAdd from '../../components/AdminPage/ActionLinkAddN'; const mapStateToProps = (state) => ({ - i18n: state.i18n + i18n: state.i18n }); const mapDispatchToProps = (dispatch, ownProps) => ({ - showDialog: (msg) => { - dispatch(add_dialog_msg(msg)); - }, - toggleLoading: (active = false) => { - dispatch(toggle_loading(active)); - } + showDialog: (msg) => { + dispatch(add_dialog_msg(msg)); + }, + toggleLoading: (active = false) => { + dispatch(toggle_loading(active)); + } }) export default connect(mapStateToProps, mapDispatchToProps)(ActionLinkAdd); \ No newline at end of file