diff options
Diffstat (limited to 'sdnr/wt/odlux/apps/connectApp')
12 files changed, 146 insertions, 70 deletions
diff --git a/sdnr/wt/odlux/apps/connectApp/pom.xml b/sdnr/wt/odlux/apps/connectApp/pom.xml index cfc7720c8..619c02a2d 100644 --- a/sdnr/wt/odlux/apps/connectApp/pom.xml +++ b/sdnr/wt/odlux/apps/connectApp/pom.xml @@ -14,7 +14,7 @@ <version>0.7.1-SNAPSHOT</version> <packaging>bundle</packaging> - <name>ccsdk-features :: ${project.artifactId}</name> + <name>sdnr-wt-odlux-app-connectApp</name> <licenses> <license> <name>Apache License, Version 2.0</name> @@ -103,10 +103,10 @@ </executions> </plugin> <plugin> - <groupId>de.jacks-it-lab</groupId> - <artifactId>frontend-maven-plugin</artifactId> - <version>1.7.2</version> - <executions> + <groupId>de.jacks-it-lab</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <version>1.7.2</version> + <executions> <execution> <id>install node and yarn</id> <goals> diff --git a/sdnr/wt/odlux/apps/connectApp/src/actions/commonNetworkElementsActions.ts b/sdnr/wt/odlux/apps/connectApp/src/actions/commonNetworkElementsActions.ts index bf4778b5b..a6d81c10c 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/actions/commonNetworkElementsActions.ts +++ b/sdnr/wt/odlux/apps/connectApp/src/actions/commonNetworkElementsActions.ts @@ -23,7 +23,7 @@ import { Action } from '../../../../framework/src/flux/action'; import { Dispatch } from '../../../../framework/src/flux/store'; import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore'; -import { networkElementsReloadAction } from '../handlers/networkElementsHandler'; +import { networkElementsReloadAction, networkElementsReloadActionAsync } from '../handlers/networkElementsHandler'; import { connectionStatusLogReloadAction } from '../handlers/connectionStatusLogHandler'; import { PanelId } from '../models/panelId'; @@ -38,7 +38,7 @@ export class SetPanelAction extends Action { } export class AddWebUriList extends Action { - constructor(public element: guiCutThrough[], public knownElements: string[]) { + constructor(public searchedElements: guiCutThrough[], public notSearchedElements: string[], public newlySearchedElements?: string[]) { super(); } } @@ -53,58 +53,65 @@ export const removeWebUriAction = (nodeId: string) => { return new RemoveWebUri(nodeId); } +export class SetWeburiSearchBusy extends Action { + constructor(public isbusy: boolean) { + super(); + } +} + let isBusy = false; -export const findWebUrisForGuiCutThroughAsyncAction = (dispatcher: Dispatch) => (networkElements: NetworkElementConnection[], knownElements: string[]) => { +export const findWebUrisForGuiCutThroughAsyncAction = (networkElements: NetworkElementConnection[]) => async (dispatcher: Dispatch, getState: () => IApplicationStoreState) => { // keep method from executing simultanously; state not used because change of iu isn't needed if (isBusy) return; isBusy = true; - const nodeIds = networkElements.map(element => { return element.id as string }); + const { connect: { guiCutThrough } } = getState(); - if (knownElements.length > 0) { + let notConnectedElements: string[] = []; + let elementsToSearch: string[] = []; + let prevFoundElements: string[] = []; - let elementsToSearch: string[] = []; - nodeIds.forEach(element => { - // find index of nodeId - const index = knownElements.indexOf(element); + networkElements.forEach(item => { + const id = item.id as string; + if (item.status === "Connected") { - // if element dosen't exist, add it to list - if (index === -1) { - elementsToSearch.push(element) + // element is connected and is added to search list, if it doesn't exist already + const exists = guiCutThrough.searchedElements.filter(element => element.nodeId === id).length > 0; + if (!exists) { + elementsToSearch.push(id); + + //element was found previously, but not searched for a weburi + if (guiCutThrough.notSearchedElements.length > 0 && guiCutThrough.notSearchedElements.includes(id)) { + prevFoundElements.push(id); + } + } + } + else { + // element isn't connected and cannot be searched for a weburi + if (!guiCutThrough.notSearchedElements.includes(id)) { + notConnectedElements.push(item.id as string); } - }); - - // if new elements were found, search for weburi - if (elementsToSearch.length > 0) { - const foundWebUris = connectService.getAllWebUriExtensionsForNetworkElementListAsync(elementsToSearch); - foundWebUris.then(result => { - dispatcher(new AddWebUriList(result, elementsToSearch)); - isBusy = false; - }) - - } else { - isBusy = false; } + }); - } else { - connectService.getAllWebUriExtensionsForNetworkElementListAsync(nodeIds).then(result => { - dispatcher(new AddWebUriList(result, nodeIds)); - isBusy = false; - }) + if (elementsToSearch.length > 0 || notConnectedElements.length > 0) { + const result = await connectService.getAllWebUriExtensionsForNetworkElementListAsync(elementsToSearch); + dispatcher(new AddWebUriList(result, notConnectedElements, prevFoundElements)); } + isBusy = false; } export const setPanelAction = (panelId: PanelId) => { return new SetPanelAction(panelId); } -export const updateCurrentViewAsyncAction = () => (dispatch: Dispatch, getState: () => IApplicationStoreState) => { +export const updateCurrentViewAsyncAction = () => async (dispatch: Dispatch, getState: () => IApplicationStoreState) => { const { connect: { currentOpenPanel } } = getState(); if (currentOpenPanel === "NetworkElements") { - return dispatch(networkElementsReloadAction); + return await dispatch(networkElementsReloadActionAsync); } else { return dispatch(connectionStatusLogReloadAction); diff --git a/sdnr/wt/odlux/apps/connectApp/src/actions/networkElementsActions.ts b/sdnr/wt/odlux/apps/connectApp/src/actions/networkElementsActions.ts index 1a86f94b1..1e569a196 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/actions/networkElementsActions.ts +++ b/sdnr/wt/odlux/apps/connectApp/src/actions/networkElementsActions.ts @@ -43,7 +43,7 @@ export const editNetworkElementAsyncActionCreator = (element: UpdateNetworkEleme const res = await connectService.deleteNetworkElement(element); } else { - const res = await connectService.updateNetworkElement(element); + const res = await connectService.updateNetworkElement(element); } dispatch(updateCurrentViewAsyncAction()); dispatch(new AddSnackbarNotification({ message: `Successfully modified [${element.id}]`, options: { variant: 'success' } })); @@ -54,7 +54,7 @@ export const editNetworkElementAsyncActionCreator = (element: UpdateNetworkEleme export const removeNetworkElementAsyncActionCreator = (element: UpdateNetworkElement) => async (dispatch: Dispatch) => { const res = await connectService.deleteNetworkElement(element); await dispatch(unmountNetworkElementAsyncActionCreator(element && element.id)); - dispatch(updateCurrentViewAsyncAction()); + await dispatch(updateCurrentViewAsyncAction()); }; diff --git a/sdnr/wt/odlux/apps/connectApp/src/components/editNetworkElementDialog.tsx b/sdnr/wt/odlux/apps/connectApp/src/components/editNetworkElementDialog.tsx index 1e1f11523..ce7f48cc9 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/components/editNetworkElementDialog.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/components/editNetworkElementDialog.tsx @@ -60,8 +60,8 @@ const mapDispatch = (dispatcher: IDispatcher) => ({ await dispatcher.dispatch(editNetworkElementAsyncActionCreator(element)); await dispatcher.dispatch(mountNetworkElementAsyncActionCreator(mountElement)); }, - removeNetworkElement: (element: UpdateNetworkElement) => { - dispatcher.dispatch(removeNetworkElementAsyncActionCreator(element)); + removeNetworkElement: async (element: UpdateNetworkElement) => { + await dispatcher.dispatch(removeNetworkElementAsyncActionCreator(element)); dispatcher.dispatch(removeWebUriAction(element.id)); } }); @@ -158,7 +158,7 @@ class EditNetworkElementDialogComponent extends React.Component<EditNetworkEleme const setting = settings[this.props.mode]; return ( <Dialog open={this.props.mode !== EditNetworkElementDialogMode.None}> - <DialogTitle id="form-dialog-title">{setting.dialogTitle}</DialogTitle> + <DialogTitle id="form-dialog-title" aria-label={`${setting.dialogTitle.replace(/ /g, "-").toLowerCase()}-dialog`}>{setting.dialogTitle}</DialogTitle> <DialogContent> <DialogContentText> {setting.dialogDescription} @@ -179,7 +179,7 @@ class EditNetworkElementDialogComponent extends React.Component<EditNetworkEleme </FormControl> </DialogContent> <DialogActions> - <Button onClick={(event) => { + <Button aria-label="dialog-confirm-button" onClick={(event) => { this.onApply({ isRequired: this.state.isRequired, id: this.state.nodeId, @@ -192,7 +192,7 @@ class EditNetworkElementDialogComponent extends React.Component<EditNetworkEleme event.preventDefault(); event.stopPropagation(); }} > {setting.applyButtonText} </Button> - <Button onClick={(event) => { + <Button aria-label="dialog-cancel-button" onClick={(event) => { this.onCancel(); event.preventDefault(); event.stopPropagation(); diff --git a/sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.ts b/sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.ts index 1440599fd..23a801424 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.ts +++ b/sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.ts @@ -21,7 +21,7 @@ import { combineActionHandler } from '../../../../framework/src/flux/middleware' import { INetworkElementsState, networkElementsActionHandler } from './networkElementsHandler'; import { IConnectionStatusLogState, connectionStatusLogActionHandler } from './connectionStatusLogHandler'; import { IInfoNetworkElementsState, infoNetworkElementsActionHandler } from './infoNetworkElementHandler'; -import { SetPanelAction, AddWebUriList, RemoveWebUri } from '../actions/commonNetworkElementsActions'; +import { SetPanelAction, AddWebUriList, RemoveWebUri, SetWeburiSearchBusy } from '../actions/commonNetworkElementsActions'; import { PanelId } from '../models/panelId'; import { guiCutThrough } from '../models/guiCutTrough'; @@ -41,26 +41,33 @@ const currentOpenPanelHandler: IActionHandler<PanelId> = (state = null, action) } interface guiCutThroughState { - availableWebUris: guiCutThrough[]; - knownElements: string[]; + searchedElements: guiCutThrough[]; + notSearchedElements: string[]; } -const guiCutThroughHandler: IActionHandler<guiCutThroughState> = (state = { availableWebUris: [], knownElements: [] }, action) => { +const guiCutThroughHandler: IActionHandler<guiCutThroughState> = (state = { searchedElements: [], notSearchedElements: [] }, action) => { if (action instanceof AddWebUriList) { - let knownElements: string[]; - let availableWebUris: guiCutThrough[]; + let notSearchedElements: string[]; + let searchedElements: guiCutThrough[]; - knownElements = state.knownElements.concat(action.knownElements); + notSearchedElements = state.notSearchedElements.concat(action.notSearchedElements); - availableWebUris = state.availableWebUris.concat(action.element); + //remove elements, which were just searched + if (action.newlySearchedElements) { + action.newlySearchedElements.forEach(item => { + notSearchedElements = notSearchedElements.filter(id => id !== item); + }) + } - state = { availableWebUris: availableWebUris, knownElements: knownElements } + searchedElements = state.searchedElements.concat(action.searchedElements); + + state = { searchedElements: searchedElements, notSearchedElements: notSearchedElements } } else if (action instanceof RemoveWebUri) { const nodeId = action.element; - const webUris = state.availableWebUris.filter(item => item.nodeId !== nodeId); - const knownElements = state.knownElements.filter(item => item !== nodeId); - state = { knownElements: knownElements, availableWebUris: webUris }; + const webUris = state.searchedElements.filter(item => item.nodeId !== nodeId); + const knownElements = state.notSearchedElements.filter(item => item !== nodeId); + state = { notSearchedElements: knownElements, searchedElements: webUris }; } return state; } diff --git a/sdnr/wt/odlux/apps/connectApp/src/handlers/networkElementsHandler.ts b/sdnr/wt/odlux/apps/connectApp/src/handlers/networkElementsHandler.ts index 78c7000d2..4fe858c69 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/handlers/networkElementsHandler.ts +++ b/sdnr/wt/odlux/apps/connectApp/src/handlers/networkElementsHandler.ts @@ -31,11 +31,13 @@ export const { createActions: createNetworkElementsActions, createProperties: createNetworkElementsProperties, reloadAction: networkElementsReloadAction, + reloadActionAsync: networkElementsReloadActionAsync // set value action, to change a value } = createExternal<NetworkElementConnection>(networkElementsSearchHandler, appState => { - const webUris = appState.connect.guiCutThrough.availableWebUris; + const webUris = appState.connect.guiCutThrough.searchedElements; + // add weburi links, if element is connected & weburi available if (appState.connect.networkElements.rows && webUris.length > 0) { appState.connect.networkElements.rows.forEach(element => { diff --git a/sdnr/wt/odlux/apps/connectApp/src/models/guiCutTrough.ts b/sdnr/wt/odlux/apps/connectApp/src/models/guiCutTrough.ts index 4b443bac8..d44eea685 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/models/guiCutTrough.ts +++ b/sdnr/wt/odlux/apps/connectApp/src/models/guiCutTrough.ts @@ -1 +1,19 @@ -export type guiCutThrough = { webUri: string, nodeId: string }
\ No newline at end of file +/** + * ============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========================================================================== + */ + +export type guiCutThrough = { webUri?: string, nodeId: string }
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/connectApp/src/models/networkElementConnection.ts b/sdnr/wt/odlux/apps/connectApp/src/models/networkElementConnection.ts index 4c2dc9b09..f58dc58ab 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/models/networkElementConnection.ts +++ b/sdnr/wt/odlux/apps/connectApp/src/models/networkElementConnection.ts @@ -1,3 +1,21 @@ +/** + * ============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========================================================================== + */ + export type NetworkElementConnection = { id?: string; nodeId: string; diff --git a/sdnr/wt/odlux/apps/connectApp/src/models/panelId.ts b/sdnr/wt/odlux/apps/connectApp/src/models/panelId.ts index b51412055..2000d9407 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/models/panelId.ts +++ b/sdnr/wt/odlux/apps/connectApp/src/models/panelId.ts @@ -1 +1,19 @@ +/** + * ============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========================================================================== + */ + export type PanelId = null | "NetworkElements" | "ConnectionStatusLog";
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts b/sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts index 7a410f4ae..41449e83f 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts +++ b/sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts @@ -188,14 +188,20 @@ class ConnectService { promises.push(requestRest<any>(path, { method: "GET" }) .then(result => { - if (result['network-element'] && result['network-element'].extension) { + if (result != null && result['network-element'] && result['network-element'].extension) { const webUri = result['network-element'].extension.find((item: any) => item['value-name'] === "webUri") if (webUri) { webUris.push({ webUri: webUri.value, nodeId: nodeId }); + } else { + webUris.push({ webUri: undefined, nodeId: nodeId }); } + } else { + webUris.push({ webUri: undefined, nodeId: nodeId }); } }) - .catch(error => console.log("network element is unreachable: " + error))) + .catch(error => { + webUris.push({ webUri: undefined, nodeId: nodeId }); + })) }) diff --git a/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx b/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx index aa3391c47..f8c0f3a82 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx @@ -25,7 +25,7 @@ import { connectionStatusLogReloadAction, createConnectionStatusLogActions } fro import { NetworkElementsList } from '../components/networkElements'; import { ConnectionStatusLog } from '../components/connectionStatusLog'; -import { setPanelAction, findWebUrisForGuiCutThroughAsyncAction } from '../actions/commonNetworkElementsActions'; +import { setPanelAction, findWebUrisForGuiCutThroughAsyncAction, SetWeburiSearchBusy } from '../actions/commonNetworkElementsActions'; import { PanelId } from '../models/panelId'; import { NetworkElementConnection } from 'models/networkElementConnection'; @@ -42,7 +42,8 @@ const mapDispatcher = (dispatcher: IDispatcher) => ({ onLoadNetworkElements: () => { dispatcher.dispatch(networkElementsReloadAction); }, - loadWebUris: findWebUrisForGuiCutThroughAsyncAction(dispatcher.dispatch), + loadWebUris: async (networkElements: NetworkElementConnection[]) => { await dispatcher.dispatch(findWebUrisForGuiCutThroughAsyncAction(networkElements)) }, + isBusy: (busy: boolean) => dispatcher.dispatch(new SetWeburiSearchBusy(busy)), onLoadConnectionStatusLog: () => { dispatcher.dispatch(connectionStatusLogReloadAction); }, @@ -55,13 +56,12 @@ type ConnectApplicationComponentProps = Connect<typeof mapProps, typeof mapDispa class ConnectApplicationComponent extends React.Component<ConnectApplicationComponentProps>{ - componentDidUpdate = () => { + componentDidUpdate = async () => { // search for guicutthroughs after networkelements were found const networkElements = this.props.netWorkElements; - const guiCuttrough = this.props.availableGuiCutroughs; - if (networkElements.rows.length > 0 && networkElements.total !== guiCuttrough.knownElements.length) { - this.props.loadWebUris(networkElements.rows, guiCuttrough.knownElements); + if (networkElements.rows.length > 0) { + await this.props.loadWebUris(networkElements.rows); } } diff --git a/sdnr/wt/odlux/apps/connectApp/webpack.config.js b/sdnr/wt/odlux/apps/connectApp/webpack.config.js index 6d70b04b0..aa3acf00c 100644 --- a/sdnr/wt/odlux/apps/connectApp/webpack.config.js +++ b/sdnr/wt/odlux/apps/connectApp/webpack.config.js @@ -126,23 +126,23 @@ module.exports = (env) => { }, proxy: { "/oauth2/": { - target: "http://10.20.6.29:28181", + target: "http://10.20.6.29:48181", secure: false }, "/database/": { - target: "http://10.20.6.29:28181", + target: "http://10.20.6.29:48181", secure: false }, "/restconf/": { - target: "http://10.20.6.29:28181", + target: "http://10.20.6.29:48181", secure: false }, "/help/": { - target: "http://10.20.6.29:28181", + target: "http://10.20.6.29:48181", secure: false }, "/websocket": { - target: "http://10.20.6.29:28181", + target: "http://10.20.6.29:48181", ws: true, changeOrigin: true, secure: false |