Просмотр исходного кода

【看板客户端】【多模板刷新】

zhuth 8 лет назад
Родитель
Сommit
b3141a7e61

+ 10 - 4
kanban-client/app/component/factory.js

@@ -6,18 +6,20 @@ import DateFormatter from '../utils/DateTimeUtils.js';
 import {converter} from '../component/converter.js';
 import RenderUtils from '../utils/RenderUtils.js';
 import config from '../data/cc.json';
+import URL from '../constants/url.json';
 
 class Factory extends React.Component {
 
     constructor(props) {
         super(props);
+        this.index = 0;
         this.state = {
         };
     }
 
     getModelConfig(mid) {
         let me = this;
-        fetch('http://10.10.100.191:8082/kanbanInstance/parseData/4F75DDBB413', {
+        fetch(URL.path+mid, {
             method: 'GET'
         }).then(function (response) {
             return (response.json())
@@ -35,14 +37,18 @@ class Factory extends React.Component {
     }
 
     componentWillMount() {
-        this.getModelConfig();
+        let {code} = this.props;
+        this.getModelConfig(code[0]);
     }
 
     componentDidMount() {
-        let { refresh } = this.props;
+        let {code, refresh} = this.props;
         if (refresh.interval) {
             setInterval(function () {
-                this.getModelConfig();
+                if(this.index == code.length) {
+                    this.index = 0;
+                }
+                this.getModelConfig(code[this.index++]);
 
             }.bind(this), refresh.interval || 3000)
         }

+ 3 - 0
kanban-client/app/constants/url.json

@@ -0,0 +1,3 @@
+{
+    "path": "http://10.10.100.191:8082/kanbanInstance/parseData/"
+}

+ 1 - 1
kanban-client/app/main.js

@@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';
 import Factory from './component/Factory.js';
 
 ReactDOM.render(
-    <Factory refresh={{interval: false}}/>,
+    <Factory code={['4F75DDBB413','4F75DDBB413']} refresh={{interval: 2000}}/>,
 ( document.getElementById('root')));
 
   

+ 0 - 42
kanban-client/app/test/test-hook.jsx

@@ -1,42 +0,0 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
-require('../css/layoutStyle.css');
-typeof window !== "undefined" && (window.React = React); // for devtools
-
-module.exports = function(Layout) {
-  class ExampleLayout extends React.Component {
-
-    state = {layout: []};
-
-    onLayoutChange = (layout) => {
-      this.setState({layout: layout});
-    };
-
-    stringifyLayout() {
-      return this.state.layout.map(function(l) {
-        return <div className="layoutItem" key={l.i}><b>{l.i}</b>: [{l.x}, {l.y}, {l.w}, {l.h}]</div>;
-      });
-    }
-
-    render(){
-      return (
-        <div>
-          <div className="layoutJSON">
-            Displayed as <code>[x, y, w, h]</code>:
-            <div className="columns">
-              {this.stringifyLayout()}
-            </div>
-          </div>
-          <Layout onLayoutChange={this.onLayoutChange} />
-        </div>
-      );
-    }
-  }
-
-  document.addEventListener("DOMContentLoaded", function() {
-    const contentDiv = document.getElementById('root');
-    const gridProps = window.gridProps || {};
-    ReactDOM.render(React.createElement(ExampleLayout, gridProps), contentDiv);
-  });
-};
-