From 21e4a946cd24b8a03ea577352f0271ebf7669ffa Mon Sep 17 00:00:00 2001 From: Michael DÜrre Date: Thu, 8 Apr 2021 07:27:18 +0200 Subject: update odlux for notification change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update due new notification protocol Issue-ID: CCSDK-3253 Signed-off-by: Michael DÜrre Change-Id: Iad65459fdc18603cd1ddbd97bb2211308744bd8b --- .../src/components/refreshInventoryDialog.tsx | 117 +++++++++++++++++++++ sdnr/wt/odlux/apps/inventoryApp/src/index.html | 3 +- .../apps/inventoryApp/src/views/dashboard.tsx | 80 ++++++++++---- .../odlux/apps/inventoryApp/src/views/treeview.tsx | 17 +-- 4 files changed, 185 insertions(+), 32 deletions(-) create mode 100644 sdnr/wt/odlux/apps/inventoryApp/src/components/refreshInventoryDialog.tsx (limited to 'sdnr/wt/odlux/apps/inventoryApp/src') diff --git a/sdnr/wt/odlux/apps/inventoryApp/src/components/refreshInventoryDialog.tsx b/sdnr/wt/odlux/apps/inventoryApp/src/components/refreshInventoryDialog.tsx new file mode 100644 index 000000000..d2efb4e97 --- /dev/null +++ b/sdnr/wt/odlux/apps/inventoryApp/src/components/refreshInventoryDialog.tsx @@ -0,0 +1,117 @@ +/** + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt odlux + * ================================================================================================= + * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + */ +import * as React from 'react'; + +import Button from '@material-ui/core/Button'; +import Dialog from '@material-ui/core/Dialog'; +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 { inventoryElementsReloadAction } from '../handlers/inventoryElementsHandler'; +import { IDispatcher, connect, Connect } from '../../../../framework/src/flux/connect'; + +import { InventoryType } from '../models/inventory'; + +export enum RefreshInventoryDialogMode { + None = "none", + RefreshInventoryTable = "RefreshInventoryTable", +} + +const mapDispatch = (dispatcher: IDispatcher) => ({ + refreshInventory: () => dispatcher.dispatch(inventoryElementsReloadAction) +}); + +type DialogSettings = { + dialogTitle: string, + dialogDescription: string, + applyButtonText: string, + cancelButtonText: string, + enableMountIdEditor: boolean, + enableUsernameEditor: boolean, + enableExtendedEditor: boolean, +} + +const settings: { [key: string]: DialogSettings } = { + [RefreshInventoryDialogMode.None]: { + dialogTitle: "", + dialogDescription: "", + applyButtonText: "", + cancelButtonText: "", + enableMountIdEditor: false, + enableUsernameEditor: false, + enableExtendedEditor: false, + }, + [RefreshInventoryDialogMode.RefreshInventoryTable]: { + dialogTitle: "Do you want to refresh the Inventory table?", + dialogDescription: "", + applyButtonText: "Yes", + cancelButtonText: "Cancel", + enableMountIdEditor: true, + enableUsernameEditor: true, + enableExtendedEditor: true, + } +} + +type RefreshInventoryDialogComponentProps = Connect & { + mode: RefreshInventoryDialogMode; + onClose: () => void; +}; + +type RefreshInventoryDialogComponentState = InventoryType & { isNameValid: boolean, isHostSet: boolean }; + +class RefreshInventoryDialogComponent extends React.Component { + constructor(props: RefreshInventoryDialogComponentProps) { + super(props); + } + + render(): JSX.Element { + const setting = settings[this.props.mode]; + return ( + + {setting.dialogTitle} + + + {setting.dialogDescription} + + + + + + + + ) + } + + private onRefresh = () => { + this.props.refreshInventory(); + this.props.onClose(); + }; + + private onCancel = () => { + this.props.onClose(); + } +} + +export const RefreshInventoryDialog = connect(undefined, mapDispatch)(RefreshInventoryDialogComponent); +export default RefreshInventoryDialog; \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/inventoryApp/src/index.html b/sdnr/wt/odlux/apps/inventoryApp/src/index.html index 75531ec1b..21f31300f 100644 --- a/sdnr/wt/odlux/apps/inventoryApp/src/index.html +++ b/sdnr/wt/odlux/apps/inventoryApp/src/index.html @@ -15,9 +15,10 @@ diff --git a/sdnr/wt/odlux/apps/inventoryApp/src/views/dashboard.tsx b/sdnr/wt/odlux/apps/inventoryApp/src/views/dashboard.tsx index f5ada22ab..11427fba9 100644 --- a/sdnr/wt/odlux/apps/inventoryApp/src/views/dashboard.tsx +++ b/sdnr/wt/odlux/apps/inventoryApp/src/views/dashboard.tsx @@ -23,6 +23,7 @@ import connect, { IDispatcher, Connect } from "../../../../framework/src/flux/co import { IApplicationStoreState } from "../../../../framework/src/store/applicationStore"; import { MaterialTable, MaterialTableCtorType, ColumnType } from "../../../../framework/src/components/material-table"; import { AppBar, Tabs, Tab, MenuItem, Typography } from "@material-ui/core"; +import Refresh from '@material-ui/icons/Refresh'; import { PanelId } from "../models/panelId"; import { setPanelAction } from "../actions/panelActions"; @@ -36,6 +37,7 @@ import { InventoryType } from '../models/inventory'; import { createInventoryElementsProperties, createInventoryElementsActions } from "../handlers/inventoryElementsHandler"; import { NavigateToApplication } from '../../../../framework/src/actions/navigationActions'; import { updateInventoryTreeAsyncAction } from '../actions/inventoryTreeActions'; +import RefreshInventoryDialog, { RefreshInventoryDialogMode } from '../components/refreshInventoryDialog'; const InventoryTable = MaterialTable as MaterialTableCtorType; @@ -49,7 +51,7 @@ const mapProps = (state: IApplicationStoreState) => ({ const mapDispatch = (dispatcher: IDispatcher) => ({ connectedNetworkElementsActions: createConnectedNetworkElementsActions(dispatcher.dispatch), switchActivePanel: (panelId: PanelId) => { - dispatcher.dispatch(setPanelAction(panelId)); + dispatcher.dispatch(setPanelAction(panelId)); }, inventoryElementsActions: createInventoryElementsActions(dispatcher.dispatch), navigateToApplication: (applicationName: string, path?: string) => dispatcher.dispatch(new NavigateToApplication(applicationName, path)), @@ -62,8 +64,18 @@ let inventoryInitialSorted = false; const ConnectedElementTable = MaterialTable as MaterialTableCtorType; type DashboardComponentProps = RouteComponentProps & Connect; +type DashboardComponentState = { + refreshInventoryEditorMode: RefreshInventoryDialogMode +} + +class DashboardSelectorComponent extends React.Component { + constructor(props: DashboardComponentProps) { + super(props); -class DashboardSelectorComponent extends React.Component { + this.state = { + refreshInventoryEditorMode: RefreshInventoryDialogMode.None + }; + } private onHandleTabChange = (event: React.ChangeEvent<{}>, newValue: PanelId) => { this.onTogglePanel(newValue); @@ -111,6 +123,13 @@ class DashboardSelectorComponent extends React.Component { + this.setState({ + refreshInventoryEditorMode: RefreshInventoryDialogMode.RefreshInventoryTable + }); + } + }; const { panelId: activePanelId } = this.props; return ( <> @@ -124,32 +143,42 @@ class DashboardSelectorComponent extends React.Component { - - return this.getContextMenu(rowData); - }} > - + <> + { + + return this.getContextMenu(rowData); + }} > + + + } { activePanelId === "TreeviewTable" && - { this.props.history.push(`${this.props.match.path}/${row.nodeId}`) }} columns={[ + { + this.props.history.push(`${this.props.match.path}/${row.nodeId}`); + this.props.updateInventoryTree(row.nodeId, '*'); + }} + columns={[ { property: "nodeId", title: "Node Name", type: ColumnType.text }, { property: "isRequired", title: "Required", type: ColumnType.boolean }, { property: "host", title: "Host", type: ColumnType.text }, @@ -163,6 +192,11 @@ class DashboardSelectorComponent extends React.Component { + this.setState({ + refreshInventoryEditorMode: RefreshInventoryDialogMode.None + }); + } componentDidMount() { if (this.props.panelId === null) { //set default tab if none is set diff --git a/sdnr/wt/odlux/apps/inventoryApp/src/views/treeview.tsx b/sdnr/wt/odlux/apps/inventoryApp/src/views/treeview.tsx index 5ba82abe7..9544861ef 100644 --- a/sdnr/wt/odlux/apps/inventoryApp/src/views/treeview.tsx +++ b/sdnr/wt/odlux/apps/inventoryApp/src/views/treeview.tsx @@ -24,7 +24,7 @@ import { TreeView, TreeViewCtorType, SearchMode } from '../../../../framework/sr import { IApplicationStoreState } from "../../../../framework/src/store/applicationStore"; -import { updateInventoryTreeAsyncAction, selectInventoryNodeAsyncAction, UpdateSelectedNodeAction, UpdateExpandedNodesAction, setSearchTermAction} from "../actions/inventoryTreeActions"; +import { updateInventoryTreeAsyncAction, selectInventoryNodeAsyncAction, UpdateSelectedNodeAction, UpdateExpandedNodesAction, setSearchTermAction } from "../actions/inventoryTreeActions"; import { TreeDemoItem } from "../models/inventory"; import { RouteComponentProps } from "react-router-dom"; @@ -66,7 +66,7 @@ const InventoryTree = TreeView as any as TreeViewCtorType; -type TreeviewComponentProps = RouteComponentProps<{ mountId: string}> & WithStyles & Connect +type TreeviewComponentProps = RouteComponentProps<{ mountId: string }> & WithStyles & Connect type TreeviewComponentState = { [propsChache]: { @@ -78,7 +78,7 @@ type TreeviewComponentState = { class DashboardComponent extends React.Component { - constructor (props: TreeviewComponentProps) { + constructor(props: TreeviewComponentProps) { super(props); this.state = { @@ -89,15 +89,16 @@ class DashboardComponent extends React.Component +
updateInventoryTree(mountId, searchTerm)} expandedItems={expendedItems} onFolderClick={(item) => { const indexOfItemToToggle = expendedItems.indexOf(item); @@ -119,11 +120,11 @@ class DashboardComponent extends React.Component