Grid.tsx 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2017 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * >>
  19. */
  20. import React, { createRef, RefObject } from 'react'
  21. import { findDOMNode } from 'react-dom'
  22. import Helmet from 'react-helmet'
  23. import { connect } from 'react-redux'
  24. import { createStructuredSelector } from 'reselect'
  25. import { Link } from 'react-router-dom'
  26. import { compose } from 'redux'
  27. import injectReducer from 'utils/injectReducer'
  28. import injectSaga from 'utils/injectSaga'
  29. import viewReducer from 'containers/View/reducer'
  30. import viewSaga from 'containers/View/sagas'
  31. import controlReducer from 'app/containers/ControlPanel/reducer'
  32. import {
  33. IDashboard,
  34. IDashboardItem,
  35. QueryVariable,
  36. IQueryConditions,
  37. TShareVizsType
  38. } from './types'
  39. import { RouteComponentWithParams } from 'utils/types'
  40. import Container, { ContainerTitle, ContainerBody } from 'components/Container'
  41. import Toolbar from './components/Toolbar'
  42. import DashboardItemForm from './components/DashboardItemForm'
  43. import DashboardItem from './components/DashboardItem'
  44. import DashboardLinkageConfig from './components/DashboardLinkageConfig'
  45. import { IDistinctValueReqeustParams } from 'app/components/Control/types'
  46. import { ControlPanelLayoutTypes, ControlPanelTypes } from 'app/components/Control/constants'
  47. import GlobalControlPanel from '../ControlPanel/Global'
  48. import GlobalControlConfig from 'app/components/Control/Config'
  49. import SharePanel from './SharePanel'
  50. import { getMappingLinkage, processLinkage, removeLinkage } from 'components/Linkages'
  51. import { hasVizEditPermission } from '../Account/components/checkUtilPermission'
  52. import { Responsive, WidthProvider } from 'react-grid-layout'
  53. import AntdFormType from 'antd/lib/form/Form'
  54. import { Row, Col, Button, Modal, Breadcrumb, Menu, message } from 'antd'
  55. import FullScreenPanel from './FullScreenPanel'
  56. import { DashboardActions } from './actions'
  57. const {
  58. loadDashboardDetail,
  59. addDashboardItems,
  60. editDashboardItem,
  61. editDashboardItems,
  62. deleteDashboardItem,
  63. clearCurrentDashboard,
  64. loadDashboardItemData,
  65. loadBatchDataWithControlValues,
  66. initiateDownloadTask,
  67. renderDashboardItem,
  68. resizeDashboardItem,
  69. resizeAllDashboardItem,
  70. renderChartError,
  71. openSharePanel,
  72. drillDashboardItem,
  73. deleteDrillHistory,
  74. drillPathsetting,
  75. selectDashboardItemChart,
  76. setFullScreenPanelItemId,
  77. monitoredSyncDataAction,
  78. monitoredLinkageDataAction,
  79. monitoredSearchDataAction
  80. } = DashboardActions
  81. import {
  82. makeSelectCurrentDashboard,
  83. makeSelectCurrentDashboardLoading,
  84. makeSelectCurrentItems,
  85. makeSelectCurrentItemsInfo,
  86. makeSelectCurrentLinkages
  87. } from './selectors'
  88. import VizActions from 'containers/Viz/actions'
  89. import { makeSelectCurrentPortal, makeSelectCurrentDashboards } from 'containers/Viz/selectors'
  90. import ViewActions from 'containers/View/actions'
  91. import { ControlActions } from 'containers/ControlPanel/actions'
  92. const {
  93. loadViews,
  94. loadViewsDetail,
  95. loadSelectOptions,
  96. loadColumnDistinctValue
  97. } = ViewActions
  98. const { setSelectOptions } = ControlActions
  99. import { makeSelectWidgets } from 'containers/Widget/selectors'
  100. import { makeSelectViews, makeSelectFormedViews } from 'containers/View/selectors'
  101. import { makeSelectCurrentProject } from 'containers/Projects/selectors'
  102. import {
  103. DEFAULT_SPLITER,
  104. GRID_BREAKPOINTS,
  105. GRID_COLS,
  106. GRID_ITEM_MARGIN,
  107. GRID_ROW_HEIGHT
  108. } from 'app/globalConstants'
  109. import { RenderType } from '../Widget/components/Widget'
  110. import { DownloadTypes } from '../App/constants'
  111. import { statistic, IVizData } from 'utils/statistic/statistic.dv'
  112. const utilStyles = require('assets/less/util.less')
  113. const styles = require('./Dashboard.less')
  114. const ResponsiveReactGridLayout = WidthProvider(Responsive)
  115. import { IDrillDetail } from 'components/DataDrill/types'
  116. import { IView } from '../View/types'
  117. type MappedStates = ReturnType<typeof mapStateToProps>
  118. type MappedDispatches = ReturnType<typeof mapDispatchToProps>
  119. type IGridProps = MappedStates & MappedDispatches
  120. interface IGridStates {
  121. mounted: boolean
  122. layoutInitialized: boolean
  123. dashboardItemFormType: string
  124. dashboardItemFormVisible: boolean
  125. dashboardItemFormStep: number
  126. modalLoading: boolean
  127. selectedWidgets: number[]
  128. currentItemId: number | boolean
  129. polling: boolean
  130. linkageConfigVisible: boolean
  131. interactingStatus: { [itemId: number]: boolean }
  132. globalControlConfigVisible: boolean
  133. nextMenuTitle: string
  134. }
  135. interface IDashboardItemForm extends AntdFormType {
  136. onReset: () => void
  137. }
  138. export class Grid extends React.Component<IGridProps & RouteComponentWithParams, IGridStates> {
  139. constructor (props) {
  140. super(props)
  141. this.state = {
  142. mounted: false,
  143. layoutInitialized: false,
  144. dashboardItemFormType: '',
  145. dashboardItemFormVisible: false,
  146. dashboardItemFormStep: 0,
  147. modalLoading: false,
  148. selectedWidgets: [],
  149. polling: false,
  150. currentItemId: false,
  151. linkageConfigVisible: false,
  152. interactingStatus: {},
  153. globalControlConfigVisible: false,
  154. nextMenuTitle: ''
  155. }
  156. }
  157. private containerBody: RefObject<HTMLDivElement> = createRef()
  158. private containerBodyScrollThrottle: boolean = false
  159. private interactCallbacks: object = {}
  160. private interactingLinkagers: object = {}
  161. private interactGlobalFilters: object = {}
  162. private resizeSign: number
  163. private dashboardItemForm: IDashboardItemForm = null
  164. private refHandles = {
  165. dashboardItemForm: (f) => { this.dashboardItemForm = f }
  166. }
  167. public componentWillMount () {
  168. const { match, widgets, onLoadDashboardDetail } = this.props
  169. const { portalId, dashboardId } = match.params
  170. if (dashboardId && Number(dashboardId) !== -1 && widgets) {
  171. onLoadDashboardDetail(+portalId, Number(dashboardId))
  172. }
  173. }
  174. private getVizDataForStatistic ({
  175. portalId,
  176. projectId,
  177. dashboardId,
  178. currentPortal,
  179. currentProject,
  180. currentDashboard
  181. }): IVizData {
  182. return {
  183. project_id: +projectId,
  184. project_name: currentProject && currentProject.name,
  185. org_id: currentProject && currentProject.orgId,
  186. viz_type: 'dashboard',
  187. viz_id: +portalId,
  188. viz_name: currentPortal && currentPortal.name,
  189. sub_viz_id: +dashboardId,
  190. sub_viz_name: currentDashboard && currentDashboard['name']
  191. }
  192. }
  193. public componentWillReceiveProps (nextProps: IGridProps & RouteComponentWithParams) {
  194. const {
  195. currentDashboard,
  196. currentDashboardLoading,
  197. currentItems,
  198. currentPortal,
  199. match: { params: nextParams },
  200. onLoadDashboardDetail
  201. } = nextProps
  202. const { layoutInitialized } = this.state
  203. const { match, currentProject} = this.props
  204. const { projectId, portalId, dashboardId } = match.params
  205. const getVizData = this.getVizDataForStatistic({
  206. projectId,
  207. portalId,
  208. dashboardId: nextParams.dashboardId,
  209. currentPortal,
  210. currentProject,
  211. currentDashboard
  212. })
  213. if (nextParams.dashboardId === dashboardId) {
  214. if (nextProps.currentDashboard !== this.props.currentDashboard) {
  215. statistic.setOperations({
  216. ...getVizData,
  217. create_time: statistic.getCurrentDateTime()
  218. }, (data) => {
  219. const visitRecord = {
  220. ...data,
  221. action: 'visit'
  222. }
  223. statistic.sendOperation(visitRecord).then((res) => {
  224. statistic.updateSingleFleld('operation', 'action', 'initial')
  225. })
  226. })
  227. }
  228. }
  229. if (nextParams.dashboardId !== dashboardId) {
  230. this.setState({
  231. nextMenuTitle: ''
  232. })
  233. if (nextParams.dashboardId && Number(nextParams.dashboardId) !== -1) {
  234. onLoadDashboardDetail(+nextParams.portalId, +nextParams.dashboardId)
  235. }
  236. statistic.setDurations({
  237. ...getVizData,
  238. end_time: statistic.getCurrentDateTime()
  239. }, (data) => {
  240. statistic.sendDuration([data]).then((res) => {
  241. statistic.setDurations({
  242. start_time: statistic.getCurrentDateTime() // 初始化下一时段
  243. })
  244. })
  245. })
  246. }
  247. if (!currentDashboardLoading) {
  248. if (currentItems && !layoutInitialized) {
  249. this.setState({
  250. mounted: true
  251. }, () => {
  252. this.lazyLoad()
  253. this.containerBody.current.removeEventListener('scroll', this.lazyLoad, false)
  254. this.containerBody.current.addEventListener('scroll', this.lazyLoad, false)
  255. })
  256. }
  257. }
  258. if (currentDashboard && currentDashboard.name) {
  259. statistic.setDurations({
  260. sub_viz_name: currentDashboard.name
  261. })
  262. }
  263. if (currentProject && currentProject.name) {
  264. statistic.setDurations({
  265. project_name: currentProject.name,
  266. org_id: currentProject.orgId
  267. })
  268. }
  269. if (currentPortal && currentPortal.name) {
  270. statistic.setDurations({
  271. viz_name: currentPortal.name
  272. })
  273. }
  274. }
  275. private statisticTimeFuc = () => {
  276. statistic.isTimeout()
  277. }
  278. public componentDidMount () {
  279. const {
  280. match,
  281. currentProject,
  282. currentDashboard,
  283. currentPortal,
  284. match: { params }
  285. } = this.props
  286. const { projectId, portalId } = match.params
  287. const getVizData = this.getVizDataForStatistic({
  288. projectId,
  289. portalId,
  290. dashboardId: params.dashboardId,
  291. currentPortal,
  292. currentProject,
  293. currentDashboard
  294. })
  295. window.addEventListener('resize', this.onWindowResize, false)
  296. window.addEventListener('beforeunload', function (event) {
  297. statistic.setDurations({
  298. end_time: statistic.getCurrentDateTime()
  299. }, (data) => {
  300. statistic.setPrevDurationRecord(data, () => {
  301. statistic.setDurations({
  302. start_time: statistic.getCurrentDateTime(),
  303. end_time: ''
  304. })
  305. })
  306. })
  307. }, false)
  308. statistic.setDurations({
  309. ...getVizData,
  310. start_time: statistic.getCurrentDateTime()
  311. })
  312. statistic.startClock()
  313. window.addEventListener('mousemove', this.statisticTimeFuc, false)
  314. window.addEventListener('visibilitychange', this.onVisibilityChanged, false)
  315. window.addEventListener('keydown', this.statisticTimeFuc, false)
  316. }
  317. private onVisibilityChanged (event) {
  318. const flag = event.target.webkitHidden
  319. if (flag) {
  320. statistic.setDurations({
  321. end_time: statistic.getCurrentDateTime()
  322. }, (data) => {
  323. statistic.sendDuration([data]).then((res) => {
  324. statistic.resetClock()
  325. })
  326. })
  327. } else {
  328. statistic.setDurations({
  329. start_time: statistic.getCurrentDateTime()
  330. }, (data) => {
  331. statistic.startClock()
  332. })
  333. }
  334. }
  335. public componentWillUnmount () {
  336. statistic.setDurations({
  337. end_time: statistic.getCurrentDateTime()
  338. }, (data) => {
  339. statistic.sendDuration([data])
  340. })
  341. window.removeEventListener('resize', this.onWindowResize, false)
  342. window.removeEventListener('mousemove', this.statisticTimeFuc, false)
  343. window.removeEventListener('visibilitychange', this.onVisibilityChanged, false)
  344. window.removeEventListener('keydown', this.statisticTimeFuc, false)
  345. this.containerBody.current.removeEventListener('scroll', this.lazyLoad, false)
  346. this.props.onClearCurrentDashboard()
  347. statistic.resetClock()
  348. }
  349. private lazyLoad = () => {
  350. if (!this.containerBodyScrollThrottle) {
  351. requestAnimationFrame(() => {
  352. const { currentItems, currentItemsInfo, onRenderDashboardItem } = this.props
  353. const waitingItems = currentItems.filter((item) => !currentItemsInfo[item.id].rendered)
  354. if (waitingItems.length) {
  355. const { offsetHeight, scrollTop } = this.containerBody.current
  356. waitingItems.forEach((item) => {
  357. const itemTop = this.calcItemTop(item.y)
  358. if (itemTop - scrollTop < offsetHeight) {
  359. onRenderDashboardItem(item.id)
  360. }
  361. })
  362. } else {
  363. if (this.containerBody.current) {
  364. this.containerBody.current.removeEventListener('scroll', this.lazyLoad, false)
  365. }
  366. }
  367. this.containerBodyScrollThrottle = false
  368. })
  369. this.containerBodyScrollThrottle = true
  370. }
  371. }
  372. private calcItemTop = (y: number) => Math.round((GRID_ROW_HEIGHT + GRID_ITEM_MARGIN) * y)
  373. private loadViews = () => {
  374. const { match, onLoadViews } = this.props
  375. const { projectId } = match.params
  376. onLoadViews(Number(projectId))
  377. }
  378. private initiateWidgetDownloadTask = (itemId: number) => {
  379. this.props.onInitiateDownloadTask(DownloadTypes.Widget, void 0, itemId)
  380. }
  381. private initiateDashboardDownloadTask = () => {
  382. const { currentDashboard, onInitiateDownloadTask } = this.props
  383. onInitiateDownloadTask(DownloadTypes.Dashboard, currentDashboard.id)
  384. }
  385. private onDragStop = (layout) => {
  386. this.onEditDashboardItemsPosition(layout)
  387. }
  388. private onResizeStop = (layout, oldItem) => {
  389. this.onEditDashboardItemsPosition(layout)
  390. this.props.onResizeDashboardItem(Number(oldItem.i))
  391. }
  392. private onEditDashboardItemsPosition = (layout) => {
  393. const { currentItems, onEditDashboardItems, match } = this.props
  394. const portalId = +match.params.portalId
  395. const changedItems = currentItems.map((item) => {
  396. const { x, y, w, h } = layout.find((l) => Number(l.i) === item.id)
  397. return {
  398. ...item,
  399. x,
  400. y,
  401. width: w,
  402. height: h
  403. }
  404. })
  405. onEditDashboardItems(portalId, changedItems)
  406. }
  407. private onBreakpointChange = () => {
  408. this.props.onResizeAllDashboardItem()
  409. }
  410. private onWindowResize = () => {
  411. if (this.resizeSign) {
  412. clearTimeout(this.resizeSign)
  413. }
  414. this.resizeSign = window.setTimeout(() => {
  415. this.props.onResizeAllDashboardItem()
  416. clearTimeout(this.resizeSign)
  417. this.resizeSign = void 0
  418. }, 500)
  419. }
  420. private showAddDashboardItemForm = () => {
  421. this.setState({
  422. dashboardItemFormType: 'add',
  423. dashboardItemFormVisible: true
  424. })
  425. }
  426. private showEditDashboardItemForm = (itemId) => () => {
  427. const dashboardItem = this.props.currentItems.find((c) => c.id === itemId)
  428. this.setState({
  429. dashboardItemFormType: 'edit',
  430. dashboardItemFormVisible: true,
  431. dashboardItemFormStep: 1,
  432. selectedWidgets: [dashboardItem.widgetId],
  433. polling: dashboardItem.polling
  434. }, () => {
  435. setTimeout(() => {
  436. this.dashboardItemForm.props.form.setFieldsValue({
  437. id: dashboardItem.id,
  438. polling: dashboardItem.polling ? 'true' : 'false',
  439. frequency: dashboardItem.frequency,
  440. alias: dashboardItem.alias
  441. })
  442. }, 0)
  443. })
  444. }
  445. private showDrillDashboardItemForm = (itemId) => () => {
  446. const dashboardItem = this.props.currentItems.find((c) => c.id === itemId)
  447. this.setState({
  448. selectedWidgets: [dashboardItem.widgetId],
  449. currentItemId: itemId
  450. })
  451. }
  452. private hideDashboardItemForm = () => {
  453. this.setState({
  454. modalLoading: false,
  455. dashboardItemFormVisible: false,
  456. selectedWidgets: []
  457. })
  458. }
  459. private afterDashboardItemFormClose = () => {
  460. this.setState({
  461. selectedWidgets: [],
  462. polling: false,
  463. dashboardItemFormStep: 0
  464. })
  465. this.dashboardItemForm.onReset()
  466. this.dashboardItemForm.props.form.resetFields()
  467. }
  468. private widgetSelect = (selectedRowKeys) => {
  469. this.setState({
  470. selectedWidgets: selectedRowKeys
  471. })
  472. }
  473. private pollingSelect = (val) => {
  474. this.setState({
  475. polling: val === 'true'
  476. })
  477. }
  478. private changeDashboardItemFormStep = (sign) => () => {
  479. this.setState({
  480. dashboardItemFormStep: sign
  481. })
  482. }
  483. private saveDashboardItem = () => {
  484. const { match, currentDashboard, currentItems, widgets, formedViews, onLoadDashboardItemData } = this.props
  485. const portalId = +match.params.portalId
  486. const { selectedWidgets, dashboardItemFormType } = this.state
  487. const formdata: any = this.dashboardItemForm.props.form.getFieldsValue()
  488. const cols = GRID_COLS.lg
  489. const yArr = [...currentItems.map((item) => item.y + item.height), 0]
  490. const maxY = Math.max(...yArr)
  491. const secondMaxY = maxY === 0 ? 0 : Math.max(...yArr.filter((y) => y !== maxY))
  492. let maxX = 0
  493. if (maxY) {
  494. const maxYItems = currentItems.filter((item) => item.y + item.height === maxY)
  495. maxX = Math.max(...maxYItems.map((item) => item.x + item.width))
  496. // if (maxX + 6 > cols) {
  497. // maxX = 0
  498. // }
  499. }
  500. this.setState({ modalLoading: true })
  501. const newItem = {
  502. dashboardId: currentDashboard.id,
  503. polling: formdata.polling !== 'false',
  504. frequency: formdata.frequency
  505. }
  506. if (dashboardItemFormType === 'add') {
  507. const positionInfo = {
  508. width: 6,
  509. height: 6
  510. }
  511. const newItems = selectedWidgets.map((key, index) => {
  512. const xAxisTemp = index % 2 !== 0 ? 6 : 0
  513. const yAxisTemp = index % 2 === 0
  514. ? secondMaxY + 6 * Math.floor(index / 2)
  515. : maxY + 6 * Math.floor(index / 2)
  516. let xAxis
  517. let yAxis
  518. if (maxX > 0 && maxX <= 6) {
  519. xAxis = index % 2 === 0 ? 6 : 0
  520. yAxis = yAxisTemp
  521. } else if (maxX === 0) {
  522. xAxis = xAxisTemp
  523. yAxis = yAxisTemp
  524. } else if (maxX > 6) {
  525. xAxis = xAxisTemp
  526. yAxis = maxY + 6 * Math.floor(index / 2)
  527. }
  528. const item = {
  529. widgetId: key,
  530. x: xAxis,
  531. y: yAxis,
  532. ...newItem,
  533. ...positionInfo
  534. }
  535. return item
  536. })
  537. const selectedWidgetsViewIds = widgets.filter((w) => selectedWidgets.includes(w.id)).map((w) => w.viewId)
  538. const viewIds = selectedWidgetsViewIds
  539. .filter((viewId, idx) => selectedWidgetsViewIds.indexOf(viewId) === idx)
  540. .filter((viewId) => !formedViews[viewId])
  541. if (viewIds.length) {
  542. this.props.onLoadViewsDetail(viewIds, () => {
  543. this.props.onAddDashboardItems(portalId, newItems, () => {
  544. this.hideDashboardItemForm()
  545. })
  546. })
  547. } else {
  548. this.props.onAddDashboardItems(portalId, newItems, () => {
  549. this.hideDashboardItemForm()
  550. })
  551. }
  552. } else {
  553. const dashboardItem = currentItems.find((item) => item.id === Number(formdata.id))
  554. const modifiedDashboardItem = {
  555. ...dashboardItem,
  556. ...newItem,
  557. widgetId: selectedWidgets[0],
  558. alias: formdata['alias']
  559. }
  560. this.props.onEditDashboardItem(portalId, modifiedDashboardItem, () => {
  561. onLoadDashboardItemData('rerender', modifiedDashboardItem.id)
  562. this.hideDashboardItemForm()
  563. })
  564. }
  565. }
  566. private deleteItem = (id) => () => {
  567. this.props.onDeleteDashboardItem(id)
  568. }
  569. private navDropdownClick = (e) => {
  570. const { match } = this.props
  571. const { projectId, portalId } = match.params
  572. this.props.history.push(`/project/${projectId}/portal/${portalId}/dashboard/${e.key}`)
  573. }
  574. private nextNavDropdownClick = (e) => {
  575. const {widgets} = this.props
  576. const itemId = e.item && e.item.props && e.item.props.id
  577. const widgetId = e.item && e.item.props && e.item.props.widgetId
  578. const widgetDOM = findDOMNode(this[`dashboardItem${itemId}`])
  579. if (widgetDOM) {
  580. const widgetParentDOM = widgetDOM.parentNode as HTMLElement
  581. const scrollCount = widgetParentDOM.style.transform && widgetParentDOM.style.transform.match(/\d+/g)[1]
  582. const containerBody = widgetParentDOM.parentNode.parentNode as HTMLElement
  583. const scrollHeight = parseInt(scrollCount, 10) - GRID_ITEM_MARGIN
  584. containerBody.scrollTop = scrollHeight
  585. }
  586. this.setState({
  587. nextMenuTitle: widgets.find((widget) => widget.id === widgetId)['name']
  588. })
  589. }
  590. private openLinkageConfig = () => {
  591. this.setState({
  592. linkageConfigVisible: true
  593. })
  594. }
  595. private closeLinkageConfig = () => {
  596. this.setState({
  597. linkageConfigVisible: false
  598. })
  599. }
  600. private saveLinkageConfig = (linkages: any[]) => {
  601. const { currentDashboard, onEditCurrentDashboard } = this.props
  602. onEditCurrentDashboard(
  603. {
  604. ...currentDashboard,
  605. config: {
  606. ...currentDashboard.config,
  607. linkages
  608. }
  609. },
  610. 'linkage',
  611. () => {
  612. this.closeLinkageConfig()
  613. this.clearAllInteracts()
  614. }
  615. )
  616. }
  617. private checkInteract = (itemId: number) => {
  618. const { currentLinkages } = this.props
  619. const isInteractiveItem = currentLinkages.some((c) => {
  620. const { trigger } = c
  621. const triggerId = +trigger[0]
  622. return triggerId === itemId
  623. })
  624. return isInteractiveItem
  625. }
  626. private doInteract = (itemId: number, triggerData) => {
  627. const {
  628. currentLinkages,
  629. onLoadDashboardItemData,
  630. onMonitoredLinkageDataAction
  631. } = this.props
  632. const mappingLinkage = getMappingLinkage(itemId, currentLinkages)
  633. this.interactingLinkagers = processLinkage(itemId, triggerData, mappingLinkage, this.interactingLinkagers)
  634. Object.keys(mappingLinkage).forEach((linkagerItemId) => {
  635. const { filters, variables } = this.interactingLinkagers[linkagerItemId]
  636. onLoadDashboardItemData('clear', +linkagerItemId, {
  637. linkageFilters: Object.values(filters).reduce<string[]>((arr, f: string[]) => arr.concat(...f), []),
  638. linkageVariables: Object.values(variables).reduce<QueryVariable>((arr, p: QueryVariable) => arr.concat(...p), [])
  639. })
  640. })
  641. this.setState({
  642. interactingStatus: {
  643. ...this.state.interactingStatus,
  644. [itemId]: true
  645. }
  646. })
  647. if (onMonitoredLinkageDataAction) {
  648. onMonitoredLinkageDataAction()
  649. }
  650. }
  651. private clearAllInteracts = () => {
  652. const { onLoadDashboardItemData } = this.props
  653. Object.keys(this.interactingLinkagers).forEach((linkagerItemId) => {
  654. onLoadDashboardItemData('clear', +linkagerItemId, {
  655. linkageFilters: [],
  656. linkageVariables: []
  657. })
  658. })
  659. this.interactingLinkagers = {} // FIXME need remove interact effect
  660. this.setState({ interactingStatus: {} })
  661. }
  662. private turnOffInteract = (itemId) => {
  663. const {
  664. currentLinkages,
  665. onLoadDashboardItemData,
  666. onMonitoredLinkageDataAction
  667. } = this.props
  668. const refreshItemIds = removeLinkage(itemId, currentLinkages, this.interactingLinkagers)
  669. refreshItemIds.forEach((linkagerItemId) => {
  670. const { filters, variables } = this.interactingLinkagers[linkagerItemId]
  671. onLoadDashboardItemData('rerender', linkagerItemId, {
  672. linkageFilters: Object.values(filters).reduce<string[]>((arr, f: string[]) => arr.concat(...f), []),
  673. linkageVariables: Object.values(variables).reduce<QueryVariable>((arr, p: QueryVariable) => arr.concat(...p), [])
  674. })
  675. })
  676. this.setState({
  677. interactingStatus: {
  678. ...this.state.interactingStatus,
  679. [itemId]: false
  680. }
  681. }, () => {
  682. onLoadDashboardItemData('clear', itemId)
  683. })
  684. if (onMonitoredLinkageDataAction) {
  685. onMonitoredLinkageDataAction()
  686. }
  687. }
  688. private openGlobalControlConfig = () => {
  689. this.setState({
  690. globalControlConfigVisible: true
  691. })
  692. }
  693. private closeGlobalControlConfig = () => {
  694. this.setState({
  695. globalControlConfigVisible: false
  696. })
  697. }
  698. private saveControls = (controls, queryMode) => {
  699. const {
  700. currentDashboard,
  701. onEditCurrentDashboard
  702. } = this.props
  703. onEditCurrentDashboard(
  704. {
  705. ...currentDashboard,
  706. config: {
  707. ...currentDashboard.config,
  708. filters: controls,
  709. queryMode
  710. }
  711. },
  712. 'control',
  713. () => {
  714. this.closeGlobalControlConfig()
  715. }
  716. )
  717. }
  718. private getControlSelectOptions = (controlKey: string, useOptions: boolean, paramsOrOptions, itemId?: number) => {
  719. if (useOptions) {
  720. this.props.onSetSelectOptions(controlKey, paramsOrOptions, itemId)
  721. } else {
  722. this.props.onLoadSelectOptions(controlKey, paramsOrOptions, itemId)
  723. }
  724. }
  725. private openDashboardSharePanel = () => {
  726. const { currentDashboard, onOpenSharePanel } = this.props
  727. const { id, name } = currentDashboard
  728. onOpenSharePanel(id, 'dashboard', name)
  729. }
  730. private getWidgetInfo = (dashboardItemId) => {
  731. const { currentItems, widgets } = this.props
  732. const dashboardItem = currentItems.find((ci) => ci.id === dashboardItemId)
  733. const widget = widgets.find((w) => w.id === dashboardItem.widgetId)
  734. return {
  735. name: widget.name
  736. }
  737. }
  738. private toWorkbench = (itemId, widgetId) => {
  739. const { projectId, portalId, dashboardId } = this.props.match.params
  740. const editSign = [projectId, portalId, dashboardId, itemId].join(DEFAULT_SPLITER)
  741. sessionStorage.setItem('editWidgetFromDashboard', editSign)
  742. this.props.history.push(`/project/${projectId}/widget/${widgetId}`)
  743. }
  744. private dataDrill = (drillDetail) => {
  745. const { onDrillDashboardItem, onLoadDashboardItemData } = this.props
  746. const { itemId, widgetId, cols, rows, type, groups, filters, currentGroup } = drillDetail
  747. const currentDrillStatus: IDrillDetail = { cols, rows, type, groups, filters, currentGroup }
  748. onDrillDashboardItem(itemId, currentDrillStatus)
  749. onLoadDashboardItemData('rerender', itemId, {
  750. drillStatus: currentDrillStatus
  751. })
  752. }
  753. private selectDrillHistory = (history, item, itemId) => {
  754. const { onLoadDashboardItemData, onDeleteDrillHistory } = this.props
  755. setTimeout(() => {
  756. if (history) {
  757. onLoadDashboardItemData('rerender', itemId, {
  758. drillStatus: history
  759. })
  760. } else {
  761. onLoadDashboardItemData('rerender', itemId)
  762. }
  763. }, 50)
  764. onDeleteDrillHistory(itemId, item)
  765. }
  766. private selectChartsItems = (itemId, renderType, selectedItems) => {
  767. const { onSelectDashboardItemChart } = this.props
  768. onSelectDashboardItemChart(itemId, renderType, selectedItems)
  769. }
  770. public render () {
  771. const {
  772. dashboards,
  773. widgets,
  774. currentDashboard,
  775. currentDashboardLoading,
  776. currentItems,
  777. currentItemsInfo,
  778. views,
  779. formedViews,
  780. currentProject,
  781. currentLinkages,
  782. onLoadViewsDetail,
  783. onOpenSharePanel,
  784. onLoadDashboardItemData,
  785. onLoadBatchDataWithControlValues,
  786. onLoadColumnDistinctValue,
  787. onResizeDashboardItem,
  788. onRenderChartError,
  789. onSetFullScreenPanelItemId,
  790. onMonitoredSyncDataAction,
  791. onMonitoredSearchDataAction
  792. } = this.props
  793. const {
  794. mounted,
  795. dashboardItemFormType,
  796. dashboardItemFormVisible,
  797. modalLoading,
  798. selectedWidgets,
  799. polling,
  800. currentItemId,
  801. dashboardItemFormStep,
  802. linkageConfigVisible,
  803. interactingStatus,
  804. globalControlConfigVisible
  805. } = this.state
  806. let navDropdown = (<span />)
  807. let grids = void 0
  808. if (dashboards) {
  809. const navDropdownItems = dashboards.map((d) => (
  810. <Menu.Item key={d.id}>
  811. {d.name}
  812. </Menu.Item>
  813. ))
  814. navDropdown = (
  815. <Menu onClick={this.navDropdownClick}>
  816. {navDropdownItems}
  817. </Menu>
  818. )
  819. }
  820. let nextNavDropdown = (<span />)
  821. if (currentDashboard && widgets) {
  822. const navDropdownItems = currentItems.map((d) => {
  823. const wid = (widgets.find((widget) => widget.id === d.widgetId))
  824. return (
  825. <Menu.Item key={d.id}>
  826. {d.widgetId ?
  827. wid && wid.name ? wid.name : ''
  828. : ''}
  829. </Menu.Item>
  830. )})
  831. nextNavDropdown = (
  832. <Menu onClick={this.nextNavDropdownClick}>
  833. {navDropdownItems}
  834. </Menu>
  835. )
  836. }
  837. let gridEditable = false
  838. if (currentProject && currentItems && widgets) {
  839. const itemblocks = []
  840. const layouts = { lg: [] }
  841. gridEditable = hasVizEditPermission(currentProject.permission)
  842. currentItems.forEach((dashboardItem) => {
  843. const { id, x, y, width, height, widgetId, polling, frequency, alias } = dashboardItem
  844. const {
  845. datasource,
  846. loading,
  847. shareToken,
  848. shareLoading,
  849. downloadCsvLoading,
  850. interactId,
  851. rendered,
  852. renderType,
  853. queryConditions,
  854. selectedItems,
  855. errorMessage
  856. } = currentItemsInfo[id]
  857. const widget = widgets.find((w) => w.id === widgetId)
  858. const interacting = interactingStatus[id] || false
  859. const view = formedViews[widget.viewId]
  860. const isTrigger = currentLinkages && currentLinkages.length ? currentLinkages.map((linkage) => linkage.trigger[0]
  861. ).some((tr) => tr === String(id)) : false
  862. itemblocks.push((
  863. <div key={id} className={styles.authSizeTag}>
  864. <DashboardItem
  865. itemId={id}
  866. alias={alias}
  867. widgets={widgets}
  868. formedViews={formedViews}
  869. widget={widget}
  870. isTrigger={isTrigger}
  871. datasource={datasource}
  872. loading={loading}
  873. polling={polling}
  874. interacting={interacting}
  875. frequency={frequency}
  876. shareToken={shareToken}
  877. view={view}
  878. shareLoading={shareLoading}
  879. downloadCsvLoading={downloadCsvLoading}
  880. currentProject={currentProject}
  881. rendered={rendered}
  882. renderType={renderType}
  883. queryConditions={queryConditions}
  884. errorMessage={errorMessage}
  885. onSelectDrillHistory={this.selectDrillHistory}
  886. onLoadData={onLoadDashboardItemData}
  887. onShowEdit={this.showEditDashboardItemForm}
  888. onShowDrillEdit={this.showDrillDashboardItemForm}
  889. onDeleteDashboardItem={this.deleteItem}
  890. onResizeDashboardItem={onResizeDashboardItem}
  891. onRenderChartError={onRenderChartError}
  892. onOpenSharePanel={onOpenSharePanel}
  893. onDownloadCsv={this.initiateWidgetDownloadTask}
  894. onTurnOffInteract={this.turnOffInteract}
  895. onCheckTableInteract={this.checkInteract}
  896. onDoTableInteract={this.doInteract}
  897. onShowFullScreen={onSetFullScreenPanelItemId}
  898. onEditWidget={this.toWorkbench}
  899. onDrillData={this.dataDrill}
  900. onSelectChartsItems={this.selectChartsItems}
  901. onGetControlOptions={this.getControlSelectOptions}
  902. onControlSearch={onLoadBatchDataWithControlValues}
  903. selectedItems={selectedItems}
  904. onMonitoredSyncDataAction={onMonitoredSyncDataAction}
  905. onMonitoredSearchDataAction={onMonitoredSearchDataAction}
  906. ref={(f) => this[`dashboardItem${id}`] = f}
  907. />
  908. </div>
  909. ))
  910. layouts.lg.push({
  911. x,
  912. y,
  913. w: width,
  914. h: height,
  915. i: `${id}`
  916. })
  917. })
  918. grids = (
  919. <ResponsiveReactGridLayout
  920. className={styles.grid}
  921. rowHeight={GRID_ROW_HEIGHT}
  922. margin={[GRID_ITEM_MARGIN, GRID_ITEM_MARGIN]}
  923. breakpoints={GRID_BREAKPOINTS}
  924. cols={GRID_COLS}
  925. layouts={layouts}
  926. onDragStop={this.onDragStop}
  927. onResizeStop={this.onResizeStop}
  928. onBreakpointChange={this.onBreakpointChange}
  929. measureBeforeMount={false}
  930. draggableHandle={`.${styles.title}`}
  931. useCSSTransforms={mounted}
  932. isDraggable={gridEditable}
  933. isResizable={gridEditable}
  934. >
  935. {itemblocks}
  936. </ResponsiveReactGridLayout>
  937. )
  938. }
  939. const saveDashboardItemButton = (
  940. <Button
  941. key="submit"
  942. size="large"
  943. type="primary"
  944. loading={modalLoading}
  945. disabled={modalLoading}
  946. onClick={this.saveDashboardItem}
  947. >
  948. 保 存
  949. </Button>
  950. )
  951. const modalButtons = dashboardItemFormType === 'add'
  952. ? dashboardItemFormStep
  953. ? [(
  954. <Button
  955. key="back"
  956. size="large"
  957. onClick={this.changeDashboardItemFormStep(0)}
  958. >
  959. 上一步
  960. </Button>
  961. ), saveDashboardItemButton]
  962. : [(
  963. <Button
  964. key="forward"
  965. size="large"
  966. type="primary"
  967. disabled={selectedWidgets.length === 0}
  968. onClick={this.changeDashboardItemFormStep(1)}
  969. >
  970. 下一步
  971. </Button>
  972. )]
  973. : saveDashboardItemButton
  974. return (
  975. <Container>
  976. <Helmet title={currentDashboard && currentDashboard.name} />
  977. <ContainerTitle>
  978. <Row>
  979. <Col sm={12}>
  980. <Breadcrumb className={utilStyles.breadcrumb}>
  981. {
  982. currentDashboard && (
  983. <Breadcrumb.Item>
  984. <Link to="">
  985. {`${currentDashboard.name} `}
  986. </Link>
  987. </Breadcrumb.Item>
  988. )
  989. }
  990. </Breadcrumb>
  991. </Col>
  992. <Toolbar
  993. currentProject={currentProject}
  994. currentDashboard={currentDashboard}
  995. showAddDashboardItem={this.showAddDashboardItemForm}
  996. onOpenSharePanel={this.openDashboardSharePanel}
  997. onOpenGlobalControlConfig={this.openGlobalControlConfig}
  998. onOpenLinkageConfig={this.openLinkageConfig}
  999. onDownloadDashboard={this.initiateDashboardDownloadTask}
  1000. />
  1001. </Row>
  1002. <GlobalControlPanel
  1003. currentDashboard={currentDashboard}
  1004. currentItems={currentItems}
  1005. formedViews={formedViews}
  1006. layoutType={ControlPanelLayoutTypes.Dashboard}
  1007. onGetOptions={this.getControlSelectOptions}
  1008. onSearch={onLoadBatchDataWithControlValues}
  1009. onMonitoredSearchDataAction={onMonitoredSearchDataAction}
  1010. />
  1011. </ContainerTitle>
  1012. <ContainerBody grid ref={this.containerBody}>
  1013. {grids}
  1014. <div className={styles.gridBottom} />
  1015. </ContainerBody>
  1016. <FullScreenPanel
  1017. currentDashboard={currentDashboard}
  1018. widgets={widgets}
  1019. formedViews={formedViews}
  1020. currentItems={currentItems}
  1021. currentItemsInfo={currentItemsInfo}
  1022. onLoadData={onLoadDashboardItemData}
  1023. onGetOptions={this.getControlSelectOptions}
  1024. onSearch={onLoadBatchDataWithControlValues}
  1025. onMonitoredSearchDataAction={onMonitoredSearchDataAction}
  1026. />
  1027. <SharePanel />
  1028. {gridEditable && (
  1029. <>
  1030. <Modal
  1031. title={`${dashboardItemFormType === 'add' ? '新增' : '修改'} Widget`}
  1032. wrapClassName="ant-modal-large"
  1033. visible={dashboardItemFormVisible}
  1034. footer={modalButtons}
  1035. onCancel={this.hideDashboardItemForm}
  1036. afterClose={this.afterDashboardItemFormClose}
  1037. >
  1038. <DashboardItemForm
  1039. type={dashboardItemFormType}
  1040. widgets={widgets || []}
  1041. selectedWidgets={selectedWidgets}
  1042. currentDashboard={this.props.currentDashboard}
  1043. polling={polling}
  1044. step={dashboardItemFormStep}
  1045. onWidgetSelect={this.widgetSelect}
  1046. onPollingSelect={this.pollingSelect}
  1047. wrappedComponentRef={this.refHandles.dashboardItemForm}
  1048. />
  1049. </Modal>
  1050. <DashboardLinkageConfig
  1051. currentDashboard={currentDashboard}
  1052. currentItems={currentItems}
  1053. currentItemsInfo={currentItemsInfo}
  1054. views={formedViews}
  1055. widgets={widgets}
  1056. visible={linkageConfigVisible}
  1057. loading={currentDashboardLoading}
  1058. onGetWidgetInfo={this.getWidgetInfo}
  1059. onSave={this.saveLinkageConfig}
  1060. onCancel={this.closeLinkageConfig}
  1061. linkages={currentLinkages}
  1062. />
  1063. <GlobalControlConfig
  1064. type={ControlPanelTypes.Global}
  1065. originalControls={currentDashboard.config.filters}
  1066. currentItems={currentItems}
  1067. views={views}
  1068. formedViews={formedViews}
  1069. widgets={widgets}
  1070. visible={globalControlConfigVisible}
  1071. loading={currentDashboardLoading}
  1072. queryMode={currentDashboard.config.queryMode}
  1073. onCancel={this.closeGlobalControlConfig}
  1074. onSave={this.saveControls}
  1075. onLoadViews={this.loadViews}
  1076. onLoadViewDetail={onLoadViewsDetail}
  1077. onGetOptions={onLoadColumnDistinctValue}
  1078. />
  1079. </>
  1080. )}
  1081. </Container>
  1082. )
  1083. }
  1084. }
  1085. const mapStateToProps = createStructuredSelector({
  1086. currentProject: makeSelectCurrentProject(),
  1087. dashboards: makeSelectCurrentDashboards(),
  1088. widgets: makeSelectWidgets(),
  1089. views: makeSelectViews(),
  1090. formedViews: makeSelectFormedViews(),
  1091. currentPortal: makeSelectCurrentPortal(),
  1092. currentDashboard: makeSelectCurrentDashboard(),
  1093. currentDashboardLoading: makeSelectCurrentDashboardLoading(),
  1094. currentItems: makeSelectCurrentItems(),
  1095. currentItemsInfo: makeSelectCurrentItemsInfo(),
  1096. currentLinkages: makeSelectCurrentLinkages()
  1097. })
  1098. export function mapDispatchToProps (dispatch) {
  1099. return {
  1100. onLoadDashboardDetail: (
  1101. portalId: number,
  1102. dashboardId: number
  1103. ) => dispatch(loadDashboardDetail(portalId, dashboardId)),
  1104. onAddDashboardItems: (
  1105. portalId: number,
  1106. items: Array<Omit<IDashboardItem, 'id' | 'config'>>,
  1107. resolve: (items: IDashboardItem[]) => void
  1108. ) => dispatch(addDashboardItems(portalId, items, resolve)),
  1109. onEditCurrentDashboard: (
  1110. dashboard: IDashboard,
  1111. type: 'linkage' | 'control',
  1112. resolve: () => void
  1113. ) => dispatch(VizActions.editCurrentDashboard(dashboard, type, resolve)),
  1114. onEditDashboardItem: (
  1115. portalId: number,
  1116. item: IDashboardItem,
  1117. resolve: () => void
  1118. ) => dispatch(editDashboardItem(portalId, item, resolve)),
  1119. onEditDashboardItems: (
  1120. portalId: number,
  1121. items: IDashboardItem[]
  1122. ) => dispatch(editDashboardItems(portalId, items)),
  1123. onDeleteDashboardItem: (
  1124. id: number,
  1125. resolve?: () => void
  1126. ) => dispatch(deleteDashboardItem(id, resolve)),
  1127. onLoadDashboardItemData: (
  1128. renderType: RenderType,
  1129. itemId: number,
  1130. queryConditions?: Partial<IQueryConditions>
  1131. ) => dispatch(loadDashboardItemData(renderType, itemId, queryConditions)),
  1132. onLoadBatchDataWithControlValues: (
  1133. type: ControlPanelTypes,
  1134. relatedItems: number[],
  1135. formValues?: object,
  1136. itemId?: number
  1137. ) => dispatch(loadBatchDataWithControlValues(type, relatedItems, formValues, itemId)),
  1138. onLoadColumnDistinctValue: (
  1139. paramsByViewId: {
  1140. [viewId: string]: Omit<IDistinctValueReqeustParams, 'cache' | 'expired'>
  1141. },
  1142. callback: (options?: object[]) => void
  1143. ) => dispatch(loadColumnDistinctValue(paramsByViewId, callback)),
  1144. onLoadViews: (projectId: number) => dispatch(loadViews(projectId)),
  1145. onLoadViewsDetail: (
  1146. viewIds: number[],
  1147. resolve: (views: IView[]) => void
  1148. ) => dispatch(loadViewsDetail(viewIds, resolve)),
  1149. onClearCurrentDashboard: () => dispatch(clearCurrentDashboard()),
  1150. onInitiateDownloadTask: (
  1151. type: DownloadTypes,
  1152. id?: number,
  1153. itemId?: number
  1154. ) => dispatch(initiateDownloadTask(type, id, itemId)),
  1155. onLoadSelectOptions: (
  1156. controlKey: string,
  1157. requestParams: { [viewId: string]: IDistinctValueReqeustParams },
  1158. itemId?: number
  1159. ) => dispatch(loadSelectOptions(controlKey, requestParams, itemId)),
  1160. onSetSelectOptions: (
  1161. controlKey: string,
  1162. options: any[],
  1163. itemId?: number
  1164. ) => dispatch(setSelectOptions(controlKey, options, itemId)),
  1165. onRenderDashboardItem: (itemId: number) => dispatch(renderDashboardItem(itemId)),
  1166. onResizeDashboardItem: (itemId: number) => dispatch(resizeDashboardItem(itemId)),
  1167. onResizeAllDashboardItem: () => dispatch(resizeAllDashboardItem()),
  1168. onRenderChartError: (itemId: number, error: Error) =>
  1169. dispatch(renderChartError(itemId, error)),
  1170. onOpenSharePanel: (
  1171. id: number,
  1172. type: TShareVizsType,
  1173. title: string,
  1174. itemId?: number
  1175. ) => dispatch(openSharePanel(id, type, title, itemId)),
  1176. onDrillDashboardItem: (
  1177. itemId: number,
  1178. drillHistory: any
  1179. ) => dispatch(drillDashboardItem(itemId, drillHistory)),
  1180. onDrillPathSetting: (
  1181. itemId: number,
  1182. history: any[]
  1183. ) => dispatch(drillPathsetting(itemId, history)),
  1184. onDeleteDrillHistory: (
  1185. itemId: number,
  1186. index: number
  1187. ) => dispatch(deleteDrillHistory(itemId, index)),
  1188. onSelectDashboardItemChart: (
  1189. itemId: number,
  1190. renderType: RenderType,
  1191. selectedItems: number[]
  1192. ) => dispatch(selectDashboardItemChart(itemId, renderType, selectedItems)),
  1193. onSetFullScreenPanelItemId: (itemId: number) => dispatch(setFullScreenPanelItemId(itemId)),
  1194. onMonitoredSyncDataAction: () => dispatch(monitoredSyncDataAction()),
  1195. onMonitoredLinkageDataAction: () => dispatch(monitoredLinkageDataAction()),
  1196. onMonitoredSearchDataAction: () => dispatch(monitoredSearchDataAction())
  1197. }
  1198. }
  1199. const withConnect = connect(mapStateToProps, mapDispatchToProps)
  1200. const withViewReducer = injectReducer({ key: 'view', reducer: viewReducer })
  1201. const withViewSaga = injectSaga({ key: 'view', saga: viewSaga })
  1202. const withControlReducer = injectReducer({ key: 'control', reducer: controlReducer })
  1203. export default compose(
  1204. withViewReducer,
  1205. withControlReducer,
  1206. withViewSaga,
  1207. withConnect
  1208. )(Grid)