@@ -25,27 +25,26 @@ import {
2525 actionsTray ,
2626 widgetContainerCommon ,
2727} from "../../Common/FormComponents/common/styleLibrary" ;
28- import { IDashboardPanel , widgetType } from "./types" ;
28+ import { IDashboardPanel } from "./types" ;
2929import { getWidgetsWithValue , panelsConfiguration } from "./utils" ;
3030import { TabPanel } from "../../../shared/tabs" ;
3131import { ErrorResponseHandler } from "../../../../common/types" ;
3232import { setErrorSnackMessage } from "../../../../actions" ;
33- import SingleValueWidget from "./Widgets/SingleValueWidget" ;
34- import LinearGraphWidget from "./Widgets/LinearGraphWidget" ;
35- import BarChartWidget from "./Widgets/BarChartWidget" ;
36- import PieChartWidget from "./Widgets/PieChartWidget" ;
37- import SingleRepWidget from "./Widgets/SingleRepWidget" ;
3833import DateTimePickerWrapper from "../../Common/FormComponents/DateTimePickerWrapper/DateTimePickerWrapper" ;
3934import api from "../../../../common/api" ;
4035import SyncIcon from "../../../../icons/SyncIcon" ;
4136import TabSelector from "../../Common/TabSelector/TabSelector" ;
42- import SimpleWidget from "./Widgets/SimpleWidget" ;
4337import MergedWidgets from "./MergedWidgets" ;
38+ import { componentToUse } from "./widgetUtils" ;
39+ import ZoomWidget from "./ZoomWidget" ;
40+ import { AppState } from "../../../../store" ;
4441
4542interface IPrDashboard {
4643 classes : any ;
4744 displayErrorMessage : typeof setErrorSnackMessage ;
4845 apiPrefix ?: string ;
46+ zoomOpen : boolean ;
47+ zoomWidget : null | IDashboardPanel ;
4948}
5049
5150const styles = ( theme : Theme ) =>
@@ -82,6 +81,8 @@ const PrDashboard = ({
8281 classes,
8382 displayErrorMessage,
8483 apiPrefix = "admin" ,
84+ zoomOpen,
85+ zoomWidget,
8586} : IPrDashboard ) => {
8687 const [ timeStart , setTimeStart ] = useState < any > ( null ) ;
8788 const [ timeEnd , setTimeEnd ] = useState < any > ( null ) ;
@@ -92,88 +93,6 @@ const PrDashboard = ({
9293
9394 const panels = useCallback (
9495 ( tabName : string , filterPanels ?: number [ ] [ ] | null ) => {
95- const componentToUse = ( value : IDashboardPanel , index : number ) => {
96- switch ( value . type ) {
97- case widgetType . singleValue :
98- return (
99- < SingleValueWidget
100- title = { value . title }
101- panelItem = { value }
102- timeStart = { timeStart }
103- timeEnd = { timeEnd }
104- propLoading = { loading }
105- apiPrefix = { apiPrefix }
106- />
107- ) ;
108- case widgetType . simpleWidget :
109- return (
110- < SimpleWidget
111- title = { value . title }
112- panelItem = { value }
113- timeStart = { timeStart }
114- timeEnd = { timeEnd }
115- propLoading = { loading }
116- apiPrefix = { apiPrefix }
117- iconWidget = { value . widgetIcon }
118- />
119- ) ;
120- case widgetType . pieChart :
121- return (
122- < PieChartWidget
123- title = { value . title }
124- panelItem = { value }
125- timeStart = { timeStart }
126- timeEnd = { timeEnd }
127- propLoading = { loading }
128- apiPrefix = { apiPrefix }
129- />
130- ) ;
131- case widgetType . linearGraph :
132- case widgetType . areaGraph :
133- return (
134- < LinearGraphWidget
135- title = { value . title }
136- panelItem = { value }
137- timeStart = { timeStart }
138- timeEnd = { timeEnd }
139- propLoading = { loading }
140- hideYAxis = { value . disableYAxis }
141- xAxisFormatter = { value . xAxisFormatter }
142- yAxisFormatter = { value . yAxisFormatter }
143- apiPrefix = { apiPrefix }
144- areaWidget = { value . type === widgetType . areaGraph }
145- />
146- ) ;
147- case widgetType . barChart :
148- return (
149- < BarChartWidget
150- title = { value . title }
151- panelItem = { value }
152- timeStart = { timeStart }
153- timeEnd = { timeEnd }
154- propLoading = { loading }
155- apiPrefix = { apiPrefix }
156- />
157- ) ;
158- case widgetType . singleRep :
159- const fillColor = value . fillColor ? value . fillColor : value . color ;
160- return (
161- < SingleRepWidget
162- title = { value . title }
163- panelItem = { value }
164- timeStart = { timeStart }
165- timeEnd = { timeEnd }
166- propLoading = { loading }
167- color = { value . color as string }
168- fillColor = { fillColor as string }
169- apiPrefix = { apiPrefix }
170- />
171- ) ;
172- default :
173- return null ;
174- }
175- } ;
176-
17796 return filterPanels ?. map ( ( panelLine , indexLine ) => {
17897 const totalPanelsContained = panelLine . length ;
17998
@@ -216,16 +135,28 @@ const PrDashboard = ({
216135 title = { panelInfo . title }
217136 leftComponent = { componentToUse (
218137 panelInfo . mergedPanels [ 0 ] ,
219- 0
138+ timeStart ,
139+ timeEnd ,
140+ loading ,
141+ apiPrefix
220142 ) }
221143 rightComponent = { componentToUse (
222144 panelInfo . mergedPanels [ 1 ] ,
223- 1
145+ timeStart ,
146+ timeEnd ,
147+ loading ,
148+ apiPrefix
224149 ) }
225150 />
226151 </ Fragment >
227152 ) : (
228- componentToUse ( panelInfo , indexPanel )
153+ componentToUse (
154+ panelInfo ,
155+ timeStart ,
156+ timeEnd ,
157+ loading ,
158+ apiPrefix
159+ )
229160 ) }
230161 </ Fragment >
231162 ) : null }
@@ -313,6 +244,16 @@ const PrDashboard = ({
313244
314245 return (
315246 < Fragment >
247+ { zoomOpen && (
248+ < ZoomWidget
249+ modalOpen = { zoomOpen }
250+ timeStart = { timeStart }
251+ timeEnd = { timeEnd }
252+ widgetRender = { 0 }
253+ value = { zoomWidget }
254+ apiPrefix = { apiPrefix }
255+ />
256+ ) }
316257 < Grid
317258 item
318259 xs = { 12 }
@@ -379,11 +320,13 @@ const PrDashboard = ({
379320 </ Fragment >
380321 ) ;
381322} ;
382- /*
383- <
384- */
385323
386- const connector = connect ( null , {
324+ const mapState = ( state : AppState ) => ( {
325+ zoomOpen : state . dashboard . zoom . openZoom ,
326+ zoomWidget : state . dashboard . zoom . widgetRender ,
327+ } ) ;
328+
329+ const connector = connect ( mapState , {
387330 displayErrorMessage : setErrorSnackMessage ,
388331} ) ;
389332
0 commit comments