diff --git a/src/components/AdminPage/ActionLinkAdd/ActionItem.js b/src/components/AdminPage/ActionLinkAdd/ActionItem.js
deleted file mode 100644
index e30ce3b..0000000
--- a/src/components/AdminPage/ActionLinkAdd/ActionItem.js
+++ /dev/null
@@ -1,17 +0,0 @@
-import React from 'react';
-import {List, Label, Button} from 'semantic-ui-react';
-
-const ActionItem = ({i18n, data, idx, removeAction}) => {
-
- return (
-
- {data.devName}
- {data.actName}
-
- )
-}
-
-export default ActionItem;
\ No newline at end of file
diff --git a/src/components/AdminPage/ActionLinkAdd/ActionSelect.js b/src/components/AdminPage/ActionLinkAdd/ActionSelect.js
deleted file mode 100644
index baf6e17..0000000
--- a/src/components/AdminPage/ActionLinkAdd/ActionSelect.js
+++ /dev/null
@@ -1,127 +0,0 @@
-import React from 'react';
-import {Form, Button, Input, Segment} from 'semantic-ui-react';
-
-class ActionSelect extends React.Component{
- state = {
- showTemp: false,
- temp: '0'
- }
-
- checkShowTemp = (cmd = '') => {
- let c = cmd;
- let cs = c.split(' ');
- let showTemp = false;
- if(cs[0] == 2) {
- showTemp = true;
- }
-
- this.setState({
- showTemp
- });
- }
-
- updateTemp = (temp) => {
- this.setState({
- temp
- })
- }
-
- render(){
- let {i18n,list, unit, getList, addAction} = this.props;
- let actlist = i18n&&i18n.getResource&&i18n.language ? i18n.getResource(i18n.language + '.translation.action_list') : [];
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {
- this.state.showTemp ?
- (
-
- {
- this.updateTemp(d.value);
- }} />
-
- ) : null
- }
-
-
-
- )
- }
-}
-
-export default ActionSelect;
\ No newline at end of file
diff --git a/src/components/AdminPage/ActionLinkAdd/UnitItem.js b/src/components/AdminPage/ActionLinkAdd/UnitItem.js
deleted file mode 100644
index fde8ba3..0000000
--- a/src/components/AdminPage/ActionLinkAdd/UnitItem.js
+++ /dev/null
@@ -1,279 +0,0 @@
-import React from 'react';
-import {Grid, Form, Segment, Input} from 'semantic-ui-react';
-
-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 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: '-'
- }
-}
-
-class UnitItem extends React.Component {
-
- state = {
- st: '',
- data:{}
- }
-
- handleDataChange = (tag, value) => {
- let {data} = this.state;
- let {updateData} = this.props;
- if(tag in data) {
- data[tag] = value;
- }
-
- this.setState({
- data
- }, () => {
- let {data} = this.state
- let d = {...this.props.data.data}
- let {st} = this.props.data;
-
- 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);
- });
- }
-
- componentWillReceiveProps(np) {
- let data = {...this.state.data};
-
- if(np.data.st != this.state.st){
-
- if(np.data.st in stype) {
- data = {...stype[np.data.st]};
- }else {
- data = {}
- }
-
- }
-
- this.setState({
- data,
- st: np.data.st
- })
- }
-
- render() {
- let {unit, data, getList} = this.props;
-
- return (
-
-
-
-
-
-
- {
- !data.st
- ? null
- : ()
- }
-
-
- )
- }
-}
-
-const UnitPanel = ({data, state, dataChange}) => {
- if (data.st == 'di') {
- return (
-
-
-
-
-
- )
- }
- if(data.st == 'leone') {
- return (
-
-
-
-
- {
- dataChange('value', d.value);
- }} />
-
- )
- }
- if(data.st == 'unit') {
- return (
-
-
-
- )
- }
- if(data.st == 'time') {
- return (
-
-
- {
- dataChange('year', d.value.length == 0 ? '-' : d.value);
- }} />
- {
- dataChange('week', d.value.length == 0 ? '-' : d.value);
- }} />
- {
- dataChange('month', d.value.length == 0 ? '-' : d.value);
- }} />
- {
- dataChange('day', d.value.length == 0 ? '-' : d.value);
- }} />
- {
- dataChange('hour', d.value.length == 0 ? '-' : d.value);
- }} />
- {
- dataChange('min', d.value.length == 0 ? '-' : d.value);
- }} />
-
- )
- }
-
- return null;
-}
-
-export default UnitItem;
\ No newline at end of file
diff --git a/src/components/AdminPage/ActionLinkAdd/ViewTreeModal.js b/src/components/AdminPage/ActionLinkAdd/ViewTreeModal.js
deleted file mode 100644
index 4081406..0000000
--- a/src/components/AdminPage/ActionLinkAdd/ViewTreeModal.js
+++ /dev/null
@@ -1,41 +0,0 @@
-import React from 'react';
-import {Modal, Form, Button} from 'semantic-ui-react';
-
-const ViewTree = ({i18n, open, data, closeView, removeNode}) => {
- let seNode = null;
- let nodeKey = Object.keys(data);
- return (
- {closeView()}} >
-
-
-
-
-
-
-
-
-
-
-
-
- {
- JSON.stringify(data, null, 4)
- }
-
-
-
- )
-}
-
-export default ViewTree;
\ No newline at end of file
diff --git a/src/components/AdminPage/ActionLinkAdd/index.js b/src/components/AdminPage/ActionLinkAdd/index.js
deleted file mode 100644
index 8d5333b..0000000
--- a/src/components/AdminPage/ActionLinkAdd/index.js
+++ /dev/null
@@ -1,353 +0,0 @@
-import React from 'react';
-import {
- Container,
- Segment,
- Form,
- Input,
- Button,
- Checkbox,
- Grid,
- Menu,
- List
-} from 'semantic-ui-react';
-import {getRequest} from '../../../actions';
-import UnitItem from './UnitItem';
-import ActionSelect from './ActionSelect';
-import ActionItem from './ActionItem';
-import ViewTree from './ViewTreeModal';
-
-const defState = () => ({
- gidx: 0,
- groups: {},
- active: false,
- edit: {
- name: '',
- type: 'ln',
- op: '',
- id1: {
- st: '',
- list: [],
- data: {}
- },
- id2: {
- st: '',
- list: [],
- data: {}
- }
- },
- actDevlist: [],
- items: [],
- showTree: false
-})
-const gtype = {
- lc: {
- type: 'lc',
- id: '',
- op: '',
- value: ''
- },
- ln: {
- type: 'ln',
- dev: ''
- }
-}
-
-class ActionLinkAdd extends React.Component {
- state = {
- ...defState()
- }
-
- getSelectList = (unit, type = '') => {
- if (!unit) {
- return;
- }
- if(unit != 'act'){
- let edit = {
- ...this.state.edit
- };
- if (!(unit in edit)) {
- return;
- }
- edit[unit].st = type;
- edit[unit].data = {
- ...gtype.lc
- }
- if (type != 'di' && type != 'leone' && type != 'unit') {
- return this.setState({edit});
- }
-
- if (type == 'di' || type == 'leone') {
- this.props.toggleLoading(1);
- let json = {
- type
- };
- fetch('/api/system/getselectlist', getRequest(json))
- .then(response => response.json())
- .then(json => {
- if (json.status != 1)
- return this.props.showDialog(json.message);
- edit[unit].list = json.data.record || [];
- this.setState({edit}, () => {
- this.props.toggleLoading(0);
- });
- });
- }
- if(type == 'unit') {
- let list = [];
- for(let i in this.state.groups){
- list.push({id: i, name: this.state.groups[i].name});
- }
- edit[unit].list = list;
- edit[unit].data = {
- ...gtype.ln
- }
- this.setState({edit})
- }
- }else{
- let actDevlist = [];
- if(!type) {
- this.setState({
- actDevlist
- });
- return ;
- }
- this.props.toggleLoading(1);
- fetch('/api/system/getselectlist', getRequest({type}))
- .then(response => response.json())
- .then(json => {
- if (json.status != 1)
- return this.props.showDialog(json.message);
- actDevlist = json.data.record || []
- this.setState({
- actDevlist
- }, ()=>{
- this.props.toggleLoading(0);
- })
- })
- }
- }
-
- updateData = (unit, data) => {
- let {edit} = this.state;
- if(!(unit in edit)) return ;
- edit[unit].data = data;
-
- this.setState({
- edit
- })
- }
-
- updateEditData = (tag, value) => {
- let {edit} = this.state;
- if(tag in edit){
- edit[tag] = value;
- }
-
- this.setState({
- edit
- })
- }
-
- updateActive = (active = false) => {
- this.setState({
- active: active ? 1 : 0
- })
- }
-
- joinUnit = () => {
- let {edit} = this.state;
- let {i18n} = this.props;
- 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') : '');
-
- let unitKey = [];
- if(edit.id1.data.type == 'lc'){
- edit.id1 = {
- ...edit.id1.data
- }
- }else if(edit.id1.data.type == 'ln'){
- unitKey.push(edit.id1.data.dev)
- edit.id1 = {
- ...this.state.groups[edit.id1.data.dev]
- }
- }
- if(edit.id2.data.type == 'lc'){
- edit.id2 = {
- ...edit.id2.data
- }
- }else if(edit.id2.data.type == 'ln'){
- unitKey.push(edit.id2.data.dev)
- edit.id2 = {
- ...this.state.groups[edit.id2.data.dev]
- }
- }
- let groups = {...this.state.groups};
- for(let i in unitKey){
- if(unitKey[i] in groups) delete groups[unitKey[i]];
- }
-
- groups[`unit${this.state.gidx}`] = {
- ...edit
- }
-
- this.setState({
- gidx: this.state.gidx+1,
- groups: {...groups}
- }, ()=>{
- this.resetEdit()
- })
- }
-
- resetEdit = () => {
- this.setState({
- edit:{
- ...defState().edit
- }
- })
- }
-
- addAction = (item) => {
- if(!item) return this.props.showDialog('動作請選擇完整');
- let 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: [...this.state.items, item]
- })
- }
-
- removeAction = (idx) => {
- let items = [...this.state.items];
- items.splice(idx, 1);
- this.setState({
- items
- })
- }
-
- toggleView = (sw = false) => {
- this.setState({
- showTree: sw ? true : false
- })
- }
-
- removeNode = (node) => {
- if(!node) return ;
- let groups = {...this.state.groups};
- if(node in groups){
- delete groups[node];
- this.setState({
- groups: {...groups}
- })
- }
- }
-
- saveLink = () => {
- 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('請選擇動作');
- let json = {
- active: this.state.active,
- link: this.state.groups[Object.keys(this.state.groups)[0]],
- action: ''
- }
-
- let acts = this.state.items.map(t => {
- return `${t.id},${t.act.replace(' ', ',')},0`
- })
-
- json.action = acts.join('|')
-
- this.props.toggleLoading(1);
- fetch('/api/link/addlink', getRequest(json))
- .then(response => response.json())
- .then(json => {
- this.props.toggleLoading(0);
- if(json.status != 1) return this.props.showDialog(json.message);
- this.resetAll();
- })
- }
-
- resetAll = () => {
- this.setState({
- ...defState()
- })
- }
-
- render() {
- let {i18n} = this.props;
- return (
-
-
-
- {
- this.updateActive(d.checked ? 1 : 0);
- }}/>
-
-
-
-
-
- {
- this.updateEditData('name', d.value);
- }}/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {
- this.state.items.map((t,idx) => (
-
- ))
- }
-
-
-
-
-
-
- )
- }
-}
-
-export default ActionLinkAdd;
\ No newline at end of file