From 889c7fbc0f78eadc302e8849ea7e6cad795e0d6e Mon Sep 17 00:00:00 2001 From: Aijana Schumann Date: Fri, 28 Feb 2020 15:15:26 +0100 Subject: update odlux stage 3 PerformanceApp: Add filter to chart view add scrolling header to tables, add basic validation to editNetworkElementDialog bugfixes Issue-ID: SDNC-1087 Signed-off-by: Aijana Schumann Change-Id: I585bd6cfeb11b867cd630e96e6479170d2f92fe8 --- .../src/components/editNetworkElementDialog.tsx | 79 ++++++++++++++++++---- .../connectApp/src/components/networkElements.tsx | 4 +- .../src/models/networkElementConnection.ts | 9 ++- 3 files changed, 74 insertions(+), 18 deletions(-) (limited to 'sdnr/wt/odlux/apps/connectApp/src') diff --git a/sdnr/wt/odlux/apps/connectApp/src/components/editNetworkElementDialog.tsx b/sdnr/wt/odlux/apps/connectApp/src/components/editNetworkElementDialog.tsx index ce7f48cc9..e3b640120 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/components/editNetworkElementDialog.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/components/editNetworkElementDialog.tsx @@ -24,7 +24,7 @@ import DialogActions from '@material-ui/core/DialogActions'; import DialogContent from '@material-ui/core/DialogContent'; import DialogContentText from '@material-ui/core/DialogContentText'; import DialogTitle from '@material-ui/core/DialogTitle'; -import { FormControl, InputLabel, Select, MenuItem } from '@material-ui/core'; +import { FormControl, InputLabel, Select, MenuItem, Typography } from '@material-ui/core'; import { IDispatcher, connect, Connect } from '../../../../framework/src/flux/connect'; @@ -35,7 +35,7 @@ import { } from '../actions/networkElementsActions'; import { unmountNetworkElementAsyncActionCreator, mountNetworkElementAsyncActionCreator } from '../actions/mountedNetworkElementsActions'; -import { NetworkElementConnection, UpdateNetworkElement } from '../models/networkElementConnection'; +import { NetworkElementConnection, UpdateNetworkElement, propertyOf } from '../models/networkElementConnection'; import { removeWebUriAction } from '../actions/commonNetworkElementsActions'; export enum EditNetworkElementDialogMode { @@ -47,6 +47,8 @@ export enum EditNetworkElementDialogMode { UnmountNetworkElement = "unmountNetworkElement", } + + const mapDispatch = (dispatcher: IDispatcher) => ({ addNewNetworkElement: async (element: NetworkElementConnection) => { await dispatcher.dispatch(addNewNetworkElementAsyncActionCreator(element)); @@ -57,8 +59,21 @@ const mapDispatch = (dispatcher: IDispatcher) => ({ dispatcher.dispatch(unmountNetworkElementAsyncActionCreator(element && element.nodeId)); }, editNetworkElement: async (element: UpdateNetworkElement, mountElement: NetworkElementConnection) => { - await dispatcher.dispatch(editNetworkElementAsyncActionCreator(element)); - await dispatcher.dispatch(mountNetworkElementAsyncActionCreator(mountElement)); + + const values = Object.keys(element); + + //make sure properties are there in case they get renamed + const idProperty = propertyOf("id"); + const isRequiredProperty = propertyOf("isRequired"); + + if (values.length === 2 && values.includes(idProperty as string) && values.includes(isRequiredProperty as string)) { + // do not mount network element, if only isRequired is changed + await dispatcher.dispatch(editNetworkElementAsyncActionCreator(element)); + + } else { + await dispatcher.dispatch(editNetworkElementAsyncActionCreator(element)); + await dispatcher.dispatch(mountNetworkElementAsyncActionCreator(mountElement)); + } }, removeNetworkElement: async (element: UpdateNetworkElement) => { await dispatcher.dispatch(removeNetworkElementAsyncActionCreator(element)); @@ -140,7 +155,7 @@ type EditNetworkElementDialogComponentProps = Connect void; }; -type EditNetworkElementDialogComponentState = NetworkElementConnection; +type EditNetworkElementDialogComponentState = NetworkElementConnection & { isNameValid: boolean, isHostSet: boolean }; class EditNetworkElementDialogComponent extends React.Component { constructor(props: EditNetworkElementDialogComponentProps) { @@ -151,6 +166,8 @@ class EditNetworkElementDialogComponent extends React.Component { this.setState({ nodeId: event.target.value }); }} /> + {!this.state.isNameValid && Name cannot be empty.} { this.setState({ host: event.target.value }); }} /> + {!this.state.isHostSet && IP Adress cannot be empty.} { this.setState({ port: +event.target.value }); }} /> {setting.enableUsernameEditor && { this.setState({ username: event.target.value }); }} /> || null} {setting.enableUsernameEditor && { this.setState({ password: event.target.value }); }} /> || null} @@ -180,15 +199,18 @@ class EditNetworkElementDialogComponent extends React.Component @@ -230,10 +252,39 @@ class EditNetworkElementDialogComponent extends React.Component { this.props.onClose && this.props.onClose(); + this.setState({ password: '', username: '' }); + this.resetRequieredFields(); + } + + private resetRequieredFields() { + this.setState({ isNameValid: true, isHostSet: true }); + } + + private areRequieredFieldsValid() { + let areFieldsValid = true; + + if (this.state.nodeId == undefined || this.state.nodeId.trim().length === 0) { + this.setState({ isNameValid: false }); + areFieldsValid = false; + } else { + this.setState({ isNameValid: true }); + } + + if (this.state.host == undefined || this.state.host.trim().length === 0) { + this.setState({ isHostSet: false }); + areFieldsValid = false; + } else { + this.setState({ isHostSet: true }); + } + + return areFieldsValid; } static getDerivedStateFromProps(props: EditNetworkElementDialogComponentProps, state: EditNetworkElementDialogComponentState & { _initialNetworkElement: NetworkElementConnection }): EditNetworkElementDialogComponentState & { _initialNetworkElement: NetworkElementConnection } { diff --git a/sdnr/wt/odlux/apps/connectApp/src/components/networkElements.tsx b/sdnr/wt/odlux/apps/connectApp/src/components/networkElements.tsx index 45003e741..d50a81ed5 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/components/networkElements.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/components/networkElements.tsx @@ -110,9 +110,7 @@ export class NetworkElementsListComponent extends React.Component, this.onOpenInfoNetworkElementDialog(event, rowData)} disabled={rowData.status === "Connecting" || rowData.status === "Disconnected"} >Info, this.onOpenEditNetworkElementDialog(event, rowData)}>Edit, - !rowData.isRequired - ? this.onOpenAddNetworkElementDialog(event, rowData)} >Add - : this.onOpenRemoveNetworkElementDialog(event, rowData)} >Remove, + this.onOpenRemoveNetworkElementDialog(event, rowData)} >Remove, , this.props.navigateToApplication("inventory", rowData.nodeId)}>Inventory, , diff --git a/sdnr/wt/odlux/apps/connectApp/src/models/networkElementConnection.ts b/sdnr/wt/odlux/apps/connectApp/src/models/networkElementConnection.ts index f58dc58ab..b3586d693 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/models/networkElementConnection.ts +++ b/sdnr/wt/odlux/apps/connectApp/src/models/networkElementConnection.ts @@ -51,4 +51,11 @@ export type UpdateNetworkElement = { export type ConnectionStatus = { status: string -} \ No newline at end of file +} + +/** + * Checks if a object has a given propertyname, if yes, the name is returned as string. + * @throws at compile time if property is not available + * @param name propertyname + */ +export const propertyOf = (name: keyof TObj) => name; \ No newline at end of file -- cgit 1.2.3-korg