import * as React from 'react'; import { withRouter, RouteComponentProps } from 'react-router-dom'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons'; import { MaterialTable, ColumnType, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; import { Panel } from '../../../../framework/src/components/material-ui'; import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore'; import connect, { Connect, IDispatcher } from '../../../../framework/src/flux/connect'; import { Fault } from '../models/fault'; import { PanelId } from '../models/panelId'; import { createCurrentProblemsProperties, createCurrentProblemsActions, currentProblemsReloadAction } from '../handlers/currentProblemsHandler'; import { createAlarmLogEntriesProperties, createAlarmLogEntriesActions, alarmLogEntriesReloadAction } from '../handlers/alarmLogEntriesHandler'; import { SetPanelAction } from '../actions/panelChangeActions'; const mapProps = (state: IApplicationStoreState) => ({ activePanel: state.fault.currentOpenPanel, currentProblemsProperties: createCurrentProblemsProperties(state), faultNotifications: state.fault.faultNotifications, alarmLogEntriesProperties: createAlarmLogEntriesProperties(state) }); const mapDisp = (dispatcher: IDispatcher) => ({ currentProblemsActions: createCurrentProblemsActions(dispatcher.dispatch), alarmLogEntriesActions: createAlarmLogEntriesActions(dispatcher.dispatch), reloadCurrentProblems: () => dispatcher.dispatch(currentProblemsReloadAction), reloadAlarmLogEntries: () => dispatcher.dispatch(alarmLogEntriesReloadAction), setCurrentPanel: (panelId: PanelId) => dispatcher.dispatch(new SetPanelAction(panelId)) }); type FaultApplicationComponentProps = RouteComponentProps & Connect; const FaultTable = MaterialTable as MaterialTableCtorType; class FaultApplicationComponent extends React.Component{ render(): JSX.Element { const { activePanel } = this.props; const onTogglePanel = (panelId: PanelId) => { const nextActivePanel = panelId === this.props.activePanel ? null : panelId; this.props.setCurrentPanel(nextActivePanel); switch (nextActivePanel) { case 'CurrentProblem': this.props.reloadCurrentProblems(); break; case 'AlarmLog': this.props.reloadAlarmLogEntries(); break; case 'AlarmNotifications': case null: default: // nothing to do break; } }; return ( <> ); }; private renderIcon = (props: { rowData: Fault }) => { return ( ); }; } export const FaultApplication = withRouter(connect(mapProps, mapDisp)(FaultApplicationComponent)); export default FaultApplication;