From 05da65b2d01a75404059d7526b4cbb868f631dd7 Mon Sep 17 00:00:00 2001
From: Aijana Schumann <aijana.schumann@highstreet-technologies.com>
Date: Fri, 13 Mar 2020 10:39:11 +0100
Subject: Fix odlux bugs

Fix help and about app not scrollable

Fix filter hiding and showing without user interaction and default sort  in all tables

Issue-ID: SDNC-1117
Signed-off-by: Aijana Schumann <aijana.schumann@highstreet-technologies.com>
Change-Id: I5c6ff86c73a3b222a8d9022125454788496f6399
---
 .../apps/faultApp/src/views/faultApplication.tsx   | 43 ++++++++++++----------
 1 file changed, 23 insertions(+), 20 deletions(-)

(limited to 'sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx')

diff --git a/sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx b/sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx
index ed395d2e4..10721549c 100644
--- a/sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx
+++ b/sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx
@@ -33,14 +33,14 @@ import { PanelId } from '../models/panelId';
 
 import { createCurrentProblemsProperties, createCurrentProblemsActions, currentProblemsReloadAction } from '../handlers/currentProblemsHandler';
 import { createAlarmLogEntriesProperties, createAlarmLogEntriesActions, alarmLogEntriesReloadAction } from '../handlers/alarmLogEntriesHandler';
-import { setPanelAction, RememberCurrentPanelAction } from '../actions/panelChangeActions';
+import { setPanelAction } from '../actions/panelChangeActions';
 import { Tooltip, IconButton, AppBar, Tabs, Tab } from '@material-ui/core';
 import RefreshIcon from '@material-ui/icons/Refresh';
 import ClearStuckAlarmsDialog, { ClearStuckAlarmsDialogMode } from '../components/clearStuckAlarmsDialog';
+import { SetPartialUpdatesAction } from '../actions/partialUpdatesAction';
 
 const mapProps = (state: IApplicationStoreState) => ({
-  panelId: state.fault.currentOpenPanel.openPanel,
-  savedPanel: state.fault.currentOpenPanel.savedPanel,
+  panelId: state.fault.currentOpenPanel,
   currentProblemsProperties: createCurrentProblemsProperties(state),
   faultNotifications: state.fault.faultNotifications,
   alarmLogEntriesProperties: createAlarmLogEntriesProperties(state)
@@ -54,7 +54,7 @@ const mapDisp = (dispatcher: IDispatcher) => ({
   switchActivePanel: (panelId: PanelId) => {
     dispatcher.dispatch(setPanelAction(panelId));
   },
-  rememberCurrentPanel: (panelId: PanelId) => dispatcher.dispatch(new RememberCurrentPanelAction(panelId))
+  setPartialUpdates: (active: boolean) => dispatcher.dispatch(new SetPartialUpdatesAction(active))
 });
 
 type FaultApplicationComponentProps = RouteComponentProps & Connect<typeof mapProps, typeof mapDisp>;
@@ -68,6 +68,8 @@ type FaultApplicationState = {
 const FaultTable = MaterialTable as MaterialTableCtorType<Fault>;
 const FaultAlarmNotificationTable = MaterialTable as MaterialTableCtorType<FaultAlarmNotification>;
 
+let currentProblemsInitalSorted = false;
+let alarmLogInitialSorted = false;
 
 class FaultApplicationComponent extends React.Component<FaultApplicationComponentProps, FaultApplicationState>{
 
@@ -97,10 +99,20 @@ class FaultApplicationComponent extends React.Component<FaultApplicationComponen
     this.props.switchActivePanel(nextActivePanel);
     switch (nextActivePanel) {
       case 'CurrentProblem':
-        this.props.reloadCurrentProblems();
+        if (!currentProblemsInitalSorted) {
+          currentProblemsInitalSorted = true;
+          this.props.currentProblemsActions.onHandleExplicitRequestSort("timestamp", "desc");
+        } else {
+          this.props.reloadCurrentProblems();
+        }
         break;
       case 'AlarmLog':
-        this.props.reloadAlarmLogEntries();
+        if (!alarmLogInitialSorted) {
+          alarmLogInitialSorted = true;
+          this.props.alarmLogEntriesActions.onHandleExplicitRequestSort("timestamp", "desc");
+        } else {
+          this.props.reloadAlarmLogEntries();
+        }
         break;
       case 'AlarmNotifications':
       case null:
@@ -177,25 +189,16 @@ class FaultApplicationComponent extends React.Component<FaultApplicationComponen
   };
 
   componentWillUnmount() {
-    if (this.props.panelId) {
-      this.props.rememberCurrentPanel(this.props.panelId as PanelId);
-      this.props.switchActivePanel(null);
-    }
+    this.props.setPartialUpdates(false);
   }
 
   public componentDidMount() {
-
-    if (this.props.panelId === null && this.props.savedPanel === null) { //set default tab if none is set
+    if (this.props.panelId === null) { //set default tab if none is set
       this.onToggleTabs("CurrentProblem");
-    } else // load saved tab if possible
-      if (this.props.panelId === null && this.props.savedPanel !== null) {
-        this.onToggleTabs(this.props.savedPanel);
-        this.props.rememberCurrentPanel(null);
-      }
-
-    this.props.alarmLogEntriesActions.onToggleFilter();
-    this.props.currentProblemsActions.onToggleFilter();
+    }
+    this.props.setPartialUpdates(true);
   }
+
   private renderIcon = (props: { rowData: Fault | FaultAlarmNotification }) => {
     return (
       <FontAwesomeIcon icon={faExclamationTriangle} />
-- 
cgit 1.2.3-korg

