| | |
| | | _config.plot.height = Utils.getHeight(_config.plot.height) |
| | | _config.style.height = 'auto' |
| | | |
| | | if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { |
| | | if (_config.setting.sync === 'true') { |
| | | _config.setting.onload = 'false' |
| | | |
| | | if (window.GLOB.SyncData.has(_config.dataName)) { |
| | | this.data = window.GLOB.SyncData.get(_config.dataName) || [] |
| | | |
| | | if (_config.$cache) { |
| | |
| | | |
| | | window.GLOB.SyncData.delete(_config.dataName) |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | config: _config, |
| | |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | plot: _config.plot, |
| | | search: _config.$searches |
| | | }, () => { |
| | | if (config.setting.sync !== 'true' && config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, _config.setting.delay || 0) |
| | | } |
| | | }) |
| | | |
| | | if (this.data.length > 0) { |
| | | this.handleData() |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | }) |
| | | } |
| | | |
| | | if (config.$cache && !this.loaded) { |
| | | Api.getLCacheConfig(config.uuid).then(res => { |
| | | if (!res || this.loaded) return |
| | | |
| | | if (!is(fromJS(this.data), fromJS(res))) { |
| | | this.data = res |
| | | this.handleData() |
| | | } |
| | | this.setState({empty: res.length > 0}) |
| | | }) |
| | | } |
| | | this.initExec() |
| | | } |
| | | |
| | | /** |
| | |
| | | this.timer && this.timer.stop() |
| | | } |
| | | |
| | | initExec = () => { |
| | | const { config } = this.state |
| | | |
| | | if (config.$cache) { |
| | | if (config.$time) { |
| | | if (!this.loaded) { |
| | | Api.getLCacheConfig(config.uuid, config.$time).then(res => { |
| | | if (!res && config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | |
| | | if (!res || this.loaded) return |
| | | |
| | | this.data = res |
| | | this.handleData() |
| | | |
| | | this.setState({empty: res.length === 0}) |
| | | }) |
| | | } else { |
| | | this.handleData() |
| | | } |
| | | } else { |
| | | if (!this.loaded) { |
| | | Api.getLCacheConfig(config.uuid, 0).then(res => { |
| | | if (!res || this.loaded) return |
| | | |
| | | this.data = res |
| | | this.handleData() |
| | | |
| | | this.setState({empty: res.length === 0}) |
| | | }) |
| | | } |
| | | |
| | | if (config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, config.setting.delay || 0) |
| | | } else if (this.loaded) { |
| | | this.handleData() |
| | | } |
| | | } |
| | | } else if (config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, config.setting.delay || 0) |
| | | } else if (this.loaded) { |
| | | this.handleData() |
| | | } |
| | | } |
| | | |
| | | transferSyncData = (syncId) => { |
| | | const { config } = this.state |
| | | |