Grid.tsx 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321
  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. const prefix = window.localStorage.getItem('inDataService') ?? ''
  743. const prefixPath = prefix ? '/' + prefix : prefix
  744. this.props.history.push(`/project/${projectId}${prefixPath}/widget/${widgetId}`)
  745. }
  746. private dataDrill = (drillDetail) => {
  747. const { onDrillDashboardItem, onLoadDashboardItemData } = this.props
  748. const { itemId, widgetId, cols, rows, type, groups, filters, currentGroup } = drillDetail
  749. const currentDrillStatus: IDrillDetail = { cols, rows, type, groups, filters, currentGroup }
  750. onDrillDashboardItem(itemId, currentDrillStatus)
  751. onLoadDashboardItemData('rerender', itemId, {
  752. drillStatus: currentDrillStatus
  753. })
  754. }
  755. private selectDrillHistory = (history, item, itemId) => {
  756. const { onLoadDashboardItemData, onDeleteDrillHistory } = this.props
  757. setTimeout(() => {
  758. if (history) {
  759. onLoadDashboardItemData('rerender', itemId, {
  760. drillStatus: history
  761. })
  762. } else {
  763. onLoadDashboardItemData('rerender', itemId)
  764. }
  765. }, 50)
  766. onDeleteDrillHistory(itemId, item)
  767. }
  768. private selectChartsItems = (itemId, renderType, selectedItems) => {
  769. const { onSelectDashboardItemChart } = this.props
  770. onSelectDashboardItemChart(itemId, renderType, selectedItems)
  771. }
  772. public render () {
  773. const {
  774. dashboards,
  775. widgets,
  776. currentDashboard,
  777. currentDashboardLoading,
  778. currentItems,
  779. currentItemsInfo,
  780. views,
  781. formedViews,
  782. currentProject,
  783. currentLinkages,
  784. onLoadViewsDetail,
  785. onOpenSharePanel,
  786. onLoadDashboardItemData,
  787. onLoadBatchDataWithControlValues,
  788. onLoadColumnDistinctValue,
  789. onResizeDashboardItem,
  790. onRenderChartError,
  791. onSetFullScreenPanelItemId,
  792. onMonitoredSyncDataAction,
  793. onMonitoredSearchDataAction
  794. } = this.props
  795. const {
  796. mounted,
  797. dashboardItemFormType,
  798. dashboardItemFormVisible,
  799. modalLoading,
  800. selectedWidgets,
  801. polling,
  802. currentItemId,
  803. dashboardItemFormStep,
  804. linkageConfigVisible,
  805. interactingStatus,
  806. globalControlConfigVisible
  807. } = this.state
  808. let navDropdown = (<span />)
  809. let grids = void 0
  810. if (dashboards) {
  811. const navDropdownItems = dashboards.map((d) => (
  812. <Menu.Item key={d.id}>
  813. {d.name}
  814. </Menu.Item>
  815. ))
  816. navDropdown = (
  817. <Menu onClick={this.navDropdownClick}>
  818. {navDropdownItems}
  819. </Menu>
  820. )
  821. }
  822. let nextNavDropdown = (<span />)
  823. if (currentDashboard && widgets) {
  824. const navDropdownItems = currentItems.map((d) => {
  825. const wid = (widgets.find((widget) => widget.id === d.widgetId))
  826. return (
  827. <Menu.Item key={d.id}>
  828. {d.widgetId ?
  829. wid && wid.name ? wid.name : ''
  830. : ''}
  831. </Menu.Item>
  832. )})
  833. nextNavDropdown = (
  834. <Menu onClick={this.nextNavDropdownClick}>
  835. {navDropdownItems}
  836. </Menu>
  837. )
  838. }
  839. let gridEditable = false
  840. if (currentProject && currentItems && widgets) {
  841. const itemblocks = []
  842. const layouts = { lg: [] }
  843. gridEditable = hasVizEditPermission(currentProject.permission)
  844. currentItems.forEach((dashboardItem) => {
  845. const { id, x, y, width, height, widgetId, polling, frequency, alias } = dashboardItem
  846. const {
  847. datasource,
  848. loading,
  849. shareToken,
  850. shareLoading,
  851. downloadCsvLoading,
  852. interactId,
  853. rendered,
  854. renderType,
  855. queryConditions,
  856. selectedItems,
  857. errorMessage
  858. } = currentItemsInfo[id]
  859. const widget = widgets.find((w) => w.id === widgetId)
  860. const interacting = interactingStatus[id] || false
  861. const view = formedViews[widget.viewId]
  862. const isTrigger = currentLinkages && currentLinkages.length ? currentLinkages.map((linkage) => linkage.trigger[0]
  863. ).some((tr) => tr === String(id)) : false
  864. itemblocks.push((
  865. <div key={id} className={styles.authSizeTag}>
  866. <DashboardItem
  867. itemId={id}
  868. alias={alias}
  869. widgets={widgets}
  870. formedViews={formedViews}
  871. widget={widget}
  872. isTrigger={isTrigger}
  873. datasource={datasource}
  874. loading={loading}
  875. polling={polling}
  876. interacting={interacting}
  877. frequency={frequency}
  878. shareToken={shareToken}
  879. view={view}
  880. shareLoading={shareLoading}
  881. downloadCsvLoading={downloadCsvLoading}
  882. currentProject={currentProject}
  883. rendered={rendered}
  884. renderType={renderType}
  885. queryConditions={queryConditions}
  886. errorMessage={errorMessage}
  887. onSelectDrillHistory={this.selectDrillHistory}
  888. onLoadData={onLoadDashboardItemData}
  889. onShowEdit={this.showEditDashboardItemForm}
  890. onShowDrillEdit={this.showDrillDashboardItemForm}
  891. onDeleteDashboardItem={this.deleteItem}
  892. onResizeDashboardItem={onResizeDashboardItem}
  893. onRenderChartError={onRenderChartError}
  894. onOpenSharePanel={onOpenSharePanel}
  895. onDownloadCsv={this.initiateWidgetDownloadTask}
  896. onTurnOffInteract={this.turnOffInteract}
  897. onCheckTableInteract={this.checkInteract}
  898. onDoTableInteract={this.doInteract}
  899. onShowFullScreen={onSetFullScreenPanelItemId}
  900. onEditWidget={this.toWorkbench}
  901. onDrillData={this.dataDrill}
  902. onSelectChartsItems={this.selectChartsItems}
  903. onGetControlOptions={this.getControlSelectOptions}
  904. onControlSearch={onLoadBatchDataWithControlValues}
  905. selectedItems={selectedItems}
  906. onMonitoredSyncDataAction={onMonitoredSyncDataAction}
  907. onMonitoredSearchDataAction={onMonitoredSearchDataAction}
  908. ref={(f) => this[`dashboardItem${id}`] = f}
  909. />
  910. </div>
  911. ))
  912. layouts.lg.push({
  913. x,
  914. y,
  915. w: width,
  916. h: height,
  917. i: `${id}`
  918. })
  919. })
  920. grids = (
  921. <ResponsiveReactGridLayout
  922. className={styles.grid}
  923. rowHeight={GRID_ROW_HEIGHT}
  924. margin={[GRID_ITEM_MARGIN, GRID_ITEM_MARGIN]}
  925. breakpoints={GRID_BREAKPOINTS}
  926. cols={GRID_COLS}
  927. layouts={layouts}
  928. onDragStop={this.onDragStop}
  929. onResizeStop={this.onResizeStop}
  930. onBreakpointChange={this.onBreakpointChange}
  931. measureBeforeMount={false}
  932. draggableHandle={`.${styles.title}`}
  933. useCSSTransforms={mounted}
  934. isDraggable={gridEditable}
  935. isResizable={gridEditable}
  936. >
  937. {itemblocks}
  938. </ResponsiveReactGridLayout>
  939. )
  940. }
  941. const saveDashboardItemButton = (
  942. <Button
  943. key="submit"
  944. size="large"
  945. type="primary"
  946. loading={modalLoading}
  947. disabled={modalLoading}
  948. onClick={this.saveDashboardItem}
  949. >
  950. 保 存
  951. </Button>
  952. )
  953. const modalButtons = dashboardItemFormType === 'add'
  954. ? dashboardItemFormStep
  955. ? [(
  956. <Button
  957. key="back"
  958. size="large"
  959. onClick={this.changeDashboardItemFormStep(0)}
  960. >
  961. 上一步
  962. </Button>
  963. ), saveDashboardItemButton]
  964. : [(
  965. <Button
  966. key="forward"
  967. size="large"
  968. type="primary"
  969. disabled={selectedWidgets.length === 0}
  970. onClick={this.changeDashboardItemFormStep(1)}
  971. >
  972. 下一步
  973. </Button>
  974. )]
  975. : saveDashboardItemButton
  976. return (
  977. <Container>
  978. <Helmet title={currentDashboard && currentDashboard.name} />
  979. <ContainerTitle>
  980. <Row>
  981. <Col sm={12}>
  982. <Breadcrumb className={utilStyles.breadcrumb}>
  983. {
  984. currentDashboard && (
  985. <Breadcrumb.Item>
  986. <Link to="">
  987. {`${currentDashboard.name} `}
  988. </Link>
  989. </Breadcrumb.Item>
  990. )
  991. }
  992. </Breadcrumb>
  993. </Col>
  994. <Toolbar
  995. currentProject={currentProject}
  996. currentDashboard={currentDashboard}
  997. showAddDashboardItem={this.showAddDashboardItemForm}
  998. onOpenSharePanel={this.openDashboardSharePanel}
  999. onOpenGlobalControlConfig={this.openGlobalControlConfig}
  1000. onOpenLinkageConfig={this.openLinkageConfig}
  1001. onDownloadDashboard={this.initiateDashboardDownloadTask}
  1002. />
  1003. </Row>
  1004. <GlobalControlPanel
  1005. currentDashboard={currentDashboard}
  1006. currentItems={currentItems}
  1007. formedViews={formedViews}
  1008. layoutType={ControlPanelLayoutTypes.Dashboard}
  1009. onGetOptions={this.getControlSelectOptions}
  1010. onSearch={onLoadBatchDataWithControlValues}
  1011. onMonitoredSearchDataAction={onMonitoredSearchDataAction}
  1012. />
  1013. </ContainerTitle>
  1014. <ContainerBody grid ref={this.containerBody}>
  1015. {grids}
  1016. <div className={styles.gridBottom} />
  1017. </ContainerBody>
  1018. <FullScreenPanel
  1019. currentDashboard={currentDashboard}
  1020. widgets={widgets}
  1021. formedViews={formedViews}
  1022. currentItems={currentItems}
  1023. currentItemsInfo={currentItemsInfo}
  1024. onLoadData={onLoadDashboardItemData}
  1025. onGetOptions={this.getControlSelectOptions}
  1026. onSearch={onLoadBatchDataWithControlValues}
  1027. onMonitoredSearchDataAction={onMonitoredSearchDataAction}
  1028. />
  1029. <SharePanel />
  1030. {gridEditable && (
  1031. <>
  1032. <Modal
  1033. title={`${dashboardItemFormType === 'add' ? '新增' : '修改'} Widget`}
  1034. wrapClassName="ant-modal-large"
  1035. visible={dashboardItemFormVisible}
  1036. footer={modalButtons}
  1037. onCancel={this.hideDashboardItemForm}
  1038. afterClose={this.afterDashboardItemFormClose}
  1039. >
  1040. <DashboardItemForm
  1041. type={dashboardItemFormType}
  1042. widgets={widgets || []}
  1043. selectedWidgets={selectedWidgets}
  1044. currentDashboard={this.props.currentDashboard}
  1045. polling={polling}
  1046. step={dashboardItemFormStep}
  1047. onWidgetSelect={this.widgetSelect}
  1048. onPollingSelect={this.pollingSelect}
  1049. wrappedComponentRef={this.refHandles.dashboardItemForm}
  1050. />
  1051. </Modal>
  1052. <DashboardLinkageConfig
  1053. currentDashboard={currentDashboard}
  1054. currentItems={currentItems}
  1055. currentItemsInfo={currentItemsInfo}
  1056. views={formedViews}
  1057. widgets={widgets}
  1058. visible={linkageConfigVisible}
  1059. loading={currentDashboardLoading}
  1060. onGetWidgetInfo={this.getWidgetInfo}
  1061. onSave={this.saveLinkageConfig}
  1062. onCancel={this.closeLinkageConfig}
  1063. linkages={currentLinkages}
  1064. />
  1065. <GlobalControlConfig
  1066. type={ControlPanelTypes.Global}
  1067. originalControls={currentDashboard.config.filters}
  1068. currentItems={currentItems}
  1069. views={views}
  1070. formedViews={formedViews}
  1071. widgets={widgets}
  1072. visible={globalControlConfigVisible}
  1073. loading={currentDashboardLoading}
  1074. queryMode={currentDashboard.config.queryMode}
  1075. onCancel={this.closeGlobalControlConfig}
  1076. onSave={this.saveControls}
  1077. onLoadViews={this.loadViews}
  1078. onLoadViewDetail={onLoadViewsDetail}
  1079. onGetOptions={onLoadColumnDistinctValue}
  1080. />
  1081. </>
  1082. )}
  1083. </Container>
  1084. )
  1085. }
  1086. }
  1087. const mapStateToProps = createStructuredSelector({
  1088. currentProject: makeSelectCurrentProject(),
  1089. dashboards: makeSelectCurrentDashboards(),
  1090. widgets: makeSelectWidgets(),
  1091. views: makeSelectViews(),
  1092. formedViews: makeSelectFormedViews(),
  1093. currentPortal: makeSelectCurrentPortal(),
  1094. currentDashboard: makeSelectCurrentDashboard(),
  1095. currentDashboardLoading: makeSelectCurrentDashboardLoading(),
  1096. currentItems: makeSelectCurrentItems(),
  1097. currentItemsInfo: makeSelectCurrentItemsInfo(),
  1098. currentLinkages: makeSelectCurrentLinkages()
  1099. })
  1100. export function mapDispatchToProps (dispatch) {
  1101. return {
  1102. onLoadDashboardDetail: (
  1103. portalId: number,
  1104. dashboardId: number
  1105. ) => dispatch(loadDashboardDetail(portalId, dashboardId)),
  1106. onAddDashboardItems: (
  1107. portalId: number,
  1108. items: Array<Omit<IDashboardItem, 'id' | 'config'>>,
  1109. resolve: (items: IDashboardItem[]) => void
  1110. ) => dispatch(addDashboardItems(portalId, items, resolve)),
  1111. onEditCurrentDashboard: (
  1112. dashboard: IDashboard,
  1113. type: 'linkage' | 'control',
  1114. resolve: () => void
  1115. ) => dispatch(VizActions.editCurrentDashboard(dashboard, type, resolve)),
  1116. onEditDashboardItem: (
  1117. portalId: number,
  1118. item: IDashboardItem,
  1119. resolve: () => void
  1120. ) => dispatch(editDashboardItem(portalId, item, resolve)),
  1121. onEditDashboardItems: (
  1122. portalId: number,
  1123. items: IDashboardItem[]
  1124. ) => dispatch(editDashboardItems(portalId, items)),
  1125. onDeleteDashboardItem: (
  1126. id: number,
  1127. resolve?: () => void
  1128. ) => dispatch(deleteDashboardItem(id, resolve)),
  1129. onLoadDashboardItemData: (
  1130. renderType: RenderType,
  1131. itemId: number,
  1132. queryConditions?: Partial<IQueryConditions>
  1133. ) => dispatch(loadDashboardItemData(renderType, itemId, queryConditions)),
  1134. onLoadBatchDataWithControlValues: (
  1135. type: ControlPanelTypes,
  1136. relatedItems: number[],
  1137. formValues?: object,
  1138. itemId?: number
  1139. ) => dispatch(loadBatchDataWithControlValues(type, relatedItems, formValues, itemId)),
  1140. onLoadColumnDistinctValue: (
  1141. paramsByViewId: {
  1142. [viewId: string]: Omit<IDistinctValueReqeustParams, 'cache' | 'expired'>
  1143. },
  1144. callback: (options?: object[]) => void
  1145. ) => dispatch(loadColumnDistinctValue(paramsByViewId, callback)),
  1146. onLoadViews: (projectId: number) => dispatch(loadViews(projectId)),
  1147. onLoadViewsDetail: (
  1148. viewIds: number[],
  1149. resolve: (views: IView[]) => void
  1150. ) => dispatch(loadViewsDetail(viewIds, resolve)),
  1151. onClearCurrentDashboard: () => dispatch(clearCurrentDashboard()),
  1152. onInitiateDownloadTask: (
  1153. type: DownloadTypes,
  1154. id?: number,
  1155. itemId?: number
  1156. ) => dispatch(initiateDownloadTask(type, id, itemId)),
  1157. onLoadSelectOptions: (
  1158. controlKey: string,
  1159. requestParams: { [viewId: string]: IDistinctValueReqeustParams },
  1160. itemId?: number
  1161. ) => dispatch(loadSelectOptions(controlKey, requestParams, itemId)),
  1162. onSetSelectOptions: (
  1163. controlKey: string,
  1164. options: any[],
  1165. itemId?: number
  1166. ) => dispatch(setSelectOptions(controlKey, options, itemId)),
  1167. onRenderDashboardItem: (itemId: number) => dispatch(renderDashboardItem(itemId)),
  1168. onResizeDashboardItem: (itemId: number) => dispatch(resizeDashboardItem(itemId)),
  1169. onResizeAllDashboardItem: () => dispatch(resizeAllDashboardItem()),
  1170. onRenderChartError: (itemId: number, error: Error) =>
  1171. dispatch(renderChartError(itemId, error)),
  1172. onOpenSharePanel: (
  1173. id: number,
  1174. type: TShareVizsType,
  1175. title: string,
  1176. itemId?: number
  1177. ) => dispatch(openSharePanel(id, type, title, itemId)),
  1178. onDrillDashboardItem: (
  1179. itemId: number,
  1180. drillHistory: any
  1181. ) => dispatch(drillDashboardItem(itemId, drillHistory)),
  1182. onDrillPathSetting: (
  1183. itemId: number,
  1184. history: any[]
  1185. ) => dispatch(drillPathsetting(itemId, history)),
  1186. onDeleteDrillHistory: (
  1187. itemId: number,
  1188. index: number
  1189. ) => dispatch(deleteDrillHistory(itemId, index)),
  1190. onSelectDashboardItemChart: (
  1191. itemId: number,
  1192. renderType: RenderType,
  1193. selectedItems: number[]
  1194. ) => dispatch(selectDashboardItemChart(itemId, renderType, selectedItems)),
  1195. onSetFullScreenPanelItemId: (itemId: number) => dispatch(setFullScreenPanelItemId(itemId)),
  1196. onMonitoredSyncDataAction: () => dispatch(monitoredSyncDataAction()),
  1197. onMonitoredLinkageDataAction: () => dispatch(monitoredLinkageDataAction()),
  1198. onMonitoredSearchDataAction: () => dispatch(monitoredSearchDataAction())
  1199. }
  1200. }
  1201. const withConnect = connect(mapStateToProps, mapDispatchToProps)
  1202. const withViewReducer = injectReducer({ key: 'view', reducer: viewReducer })
  1203. const withViewSaga = injectSaga({ key: 'view', saga: viewSaga })
  1204. const withControlReducer = injectReducer({ key: 'control', reducer: controlReducer })
  1205. export default compose(
  1206. withViewReducer,
  1207. withControlReducer,
  1208. withViewSaga,
  1209. withConnect
  1210. )(Grid)