From 4bd84bebdaa0c2d82050fbedd1fa8260eb62146d Mon Sep 17 00:00:00 2001 From: Aijana Schumann Date: Thu, 27 Aug 2020 09:01:53 +0200 Subject: Add link calculation app Add link calculation app to odlux Issue-ID: CCSDK-2562 Signed-off-by: Aijana Schumann Change-Id: Ifc0a5b2a8bb974dfd85d70a9f05990b1f11925a3 Signed-off-by: Aijana Schumann --- sdnr/wt/odlux/apps/apiDemo/pom.xml | 5 + sdnr/wt/odlux/apps/app-feature/pom.xml | 10 + sdnr/wt/odlux/apps/app-installer/pom.xml | 6 + sdnr/wt/odlux/apps/configurationApp/pom.xml | 5 + .../configurationApp/src/components/baseProps.ts | 2 +- .../src/components/ifWhenTextInput.tsx | 73 ++-- .../src/components/uiElementBoolean.tsx | 21 +- .../src/components/uiElementNumber.tsx | 81 ++--- .../src/components/uiElementSelection.tsx | 6 +- .../src/components/uiElementString.tsx | 12 +- .../src/components/uiElementUnion.tsx | 100 +++--- .../src/views/configurationApplication.tsx | 10 +- sdnr/wt/odlux/apps/connectApp/pom.xml | 5 + .../apps/connectApp/src/views/connectView.tsx | 4 +- sdnr/wt/odlux/apps/demoApp/pom.xml | 5 + sdnr/wt/odlux/apps/eventLogApp/pom.xml | 5 + sdnr/wt/odlux/apps/faultApp/pom.xml | 5 + .../apps/faultApp/src/components/faultStatus.tsx | 10 +- .../apps/faultApp/src/views/faultApplication.tsx | 6 +- sdnr/wt/odlux/apps/helpApp/pom.xml | 5 + .../resources/OSGI-INF/blueprint/blueprint.xml | 2 +- sdnr/wt/odlux/apps/inventoryApp/pom.xml | 5 + sdnr/wt/odlux/apps/linkCalculationApp/.babelrc | 17 + sdnr/wt/odlux/apps/linkCalculationApp/package.json | 40 +++ sdnr/wt/odlux/apps/linkCalculationApp/pom.xml | 176 ++++++++++ .../src/actions/commonLinkCalculationActions.ts | 104 ++++++ .../src/components/connectionInfo.tsx | 55 +++ .../src/components/denseTable.tsx | 121 +++++++ .../src/handlers/linkCalculationAppRootHandler.ts | 115 ++++++ .../odlux/apps/linkCalculationApp/src/index.html | 27 ++ .../src/pluginLinkCalculation.tsx | 148 ++++++++ .../src/views/linkCalculationComponent.tsx | 246 +++++++++++++ .../sdnr/wt/odlux/bundles/MyOdluxBundle.java | 68 ++++ .../resources/OSGI-INF/blueprint/blueprint.xml | 9 + .../sdnr/wt/odlux/bundles/test/TestBundleRes.java | 46 +++ .../linkCalculationApp/src2/test/resources/test.js | 5 + .../wt/odlux/apps/linkCalculationApp/tsconfig.json | 37 ++ .../apps/linkCalculationApp/webpack.config.js | 159 +++++++++ sdnr/wt/odlux/apps/maintenanceApp/pom.xml | 5 + sdnr/wt/odlux/apps/mediatorApp/pom.xml | 5 + sdnr/wt/odlux/apps/minimumApp/pom.xml | 5 + sdnr/wt/odlux/apps/performanceHistoryApp/pom.xml | 5 + sdnr/wt/odlux/core/model/pom.xml | 5 + sdnr/wt/odlux/core/provider/pom.xml | 6 + sdnr/wt/odlux/framework/pom.xml | 2 +- .../src/components/material-table/index.tsx | 6 +- .../src/components/material-table/tableFilter.tsx | 6 +- .../src/components/material-ui/listItemLink.tsx | 36 +- .../framework/src/components/navigationMenu.tsx | 5 + .../wt/odlux/framework/src/components/titleBar.tsx | 4 +- .../framework/src/services/notificationService.ts | 386 ++++++++++----------- sdnr/wt/odlux/framework/src/views/about.tsx | 16 +- sdnr/wt/odlux/framework/src/views/login.tsx | 1 + sdnr/wt/odlux/framework/webpack.config.js | 10 +- sdnr/wt/odlux/installer/pom.xml | 207 +++++++++++ .../src/assembly/assemble_mvnrepo_zip.xml | 47 +++ sdnr/wt/odlux/pom.xml | 2 + sdnr/wt/odlux/yarn.lock | 259 +++++++++++++- 58 files changed, 2392 insertions(+), 382 deletions(-) create mode 100644 sdnr/wt/odlux/apps/linkCalculationApp/.babelrc create mode 100644 sdnr/wt/odlux/apps/linkCalculationApp/package.json create mode 100644 sdnr/wt/odlux/apps/linkCalculationApp/pom.xml create mode 100644 sdnr/wt/odlux/apps/linkCalculationApp/src/actions/commonLinkCalculationActions.ts create mode 100644 sdnr/wt/odlux/apps/linkCalculationApp/src/components/connectionInfo.tsx create mode 100644 sdnr/wt/odlux/apps/linkCalculationApp/src/components/denseTable.tsx create mode 100644 sdnr/wt/odlux/apps/linkCalculationApp/src/handlers/linkCalculationAppRootHandler.ts create mode 100644 sdnr/wt/odlux/apps/linkCalculationApp/src/index.html create mode 100644 sdnr/wt/odlux/apps/linkCalculationApp/src/pluginLinkCalculation.tsx create mode 100644 sdnr/wt/odlux/apps/linkCalculationApp/src/views/linkCalculationComponent.tsx create mode 100644 sdnr/wt/odlux/apps/linkCalculationApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java create mode 100644 sdnr/wt/odlux/apps/linkCalculationApp/src2/main/resources/OSGI-INF/blueprint/blueprint.xml create mode 100644 sdnr/wt/odlux/apps/linkCalculationApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java create mode 100644 sdnr/wt/odlux/apps/linkCalculationApp/src2/test/resources/test.js create mode 100644 sdnr/wt/odlux/apps/linkCalculationApp/tsconfig.json create mode 100644 sdnr/wt/odlux/apps/linkCalculationApp/webpack.config.js create mode 100644 sdnr/wt/odlux/installer/pom.xml create mode 100644 sdnr/wt/odlux/installer/src/assembly/assemble_mvnrepo_zip.xml (limited to 'sdnr/wt') diff --git a/sdnr/wt/odlux/apps/apiDemo/pom.xml b/sdnr/wt/odlux/apps/apiDemo/pom.xml index 52ff4bc1c..175630980 100644 --- a/sdnr/wt/odlux/apps/apiDemo/pom.xml +++ b/sdnr/wt/odlux/apps/apiDemo/pom.xml @@ -43,6 +43,11 @@ + + true + true + + ${project.groupId} diff --git a/sdnr/wt/odlux/apps/app-feature/pom.xml b/sdnr/wt/odlux/apps/app-feature/pom.xml index bad5196a1..2aaf573d1 100644 --- a/sdnr/wt/odlux/apps/app-feature/pom.xml +++ b/sdnr/wt/odlux/apps/app-feature/pom.xml @@ -46,6 +46,11 @@ + + true + true + + ${project.groupId} @@ -92,5 +97,10 @@ sdnr-wt-odlux-app-configurationApp ${project.version} + + ${project.groupId} + sdnr-wt-odlux-app-linkCalculationApp + ${project.version} + diff --git a/sdnr/wt/odlux/apps/app-installer/pom.xml b/sdnr/wt/odlux/apps/app-installer/pom.xml index 65ee9241c..1bf55ed30 100755 --- a/sdnr/wt/odlux/apps/app-installer/pom.xml +++ b/sdnr/wt/odlux/apps/app-installer/pom.xml @@ -122,6 +122,12 @@ sdnr-wt-odlux-app-configurationApp ${project.version} + + ${project.groupId} + sdnr-wt-odlux-app-linkCalculationApp + ${project.version} + + diff --git a/sdnr/wt/odlux/apps/configurationApp/pom.xml b/sdnr/wt/odlux/apps/configurationApp/pom.xml index f02644a96..9f92c9920 100644 --- a/sdnr/wt/odlux/apps/configurationApp/pom.xml +++ b/sdnr/wt/odlux/apps/configurationApp/pom.xml @@ -43,6 +43,11 @@ + + true + true + + ${project.groupId} diff --git a/sdnr/wt/odlux/apps/configurationApp/src/components/baseProps.ts b/sdnr/wt/odlux/apps/configurationApp/src/components/baseProps.ts index ec49191ce..8f7300cfb 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/components/baseProps.ts +++ b/sdnr/wt/odlux/apps/configurationApp/src/components/baseProps.ts @@ -18,4 +18,4 @@ import { ViewElement } from "../models/uiModels"; -export type baseProps = { value: ViewElement, inputValue: string, readOnly: boolean, disabled: boolean, onChange(newValue: string): void }; \ No newline at end of file +export type BaseProps = { value: ViewElement, inputValue: TValue, readOnly: boolean, disabled: boolean, onChange(newValue: TValue): void }; \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/configurationApp/src/components/ifWhenTextInput.tsx b/sdnr/wt/odlux/apps/configurationApp/src/components/ifWhenTextInput.tsx index 67358885c..62ddeb22d 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/components/ifWhenTextInput.tsx +++ b/sdnr/wt/odlux/apps/configurationApp/src/components/ifWhenTextInput.tsx @@ -24,38 +24,59 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { InputProps } from "@material-ui/core/Input"; const useStyles = makeStyles((theme: Theme) => - createStyles({ - iconDark: { - color: '#ff8800' - }, - iconLight: { - color: 'orange' - }, - padding: { - paddingLeft: 10, - paddingRight: 10 - }, - }), + createStyles({ + iconDark: { + color: '#ff8800' + }, + iconLight: { + color: 'orange' + }, + padding: { + paddingLeft: 10, + paddingRight: 10 + }, + }), ); -type ifwhenProps = { element: ViewElementBase, id: any, label: any, style: any, helperText: string, error: boolean, toogleTooltip(value: boolean): void, [x: string]: any }; +type IfwhenProps = InputProps & { + label: string; + element: ViewElementBase; + helperText: string; + error: boolean; + onChangeTooltipVisuability(value: boolean): void; +}; -export const IfWhenTextInput = (props: ifwhenProps) => { +export const IfWhenTextInput = (props: IfwhenProps) => { - const { element, toogleTooltip, id, label, helperText: errorText, error, style, ...otherProps } = props; - const classes = useStyles(); + const { element, onChangeTooltipVisuability: toogleTooltip, id, label, helperText: errorText, error, style, ...otherProps } = props; + const classes = useStyles(); - const ifFeature = element.ifFeature ? props.toogleTooltip(false)} onMouseOut={e => props.toogleTooltip(true)} title={element.ifFeature}> : null; - const whenFeature = element.when ? ( props.toogleTooltip(false)} onMouseOut={e => props.toogleTooltip(true)} title={element.when}> - ) : null; + const ifFeature = element.ifFeature + ? ( + props.onChangeTooltipVisuability(false)} onMouseOut={e => props.onChangeTooltipVisuability(true)} title={element.ifFeature}> + + + + + ) + : null; - return ( - - {label} - {ifFeature}{whenFeature}} /> - {errorText} - + const whenFeature = element.when + ? ( + props.onChangeTooltipVisuability(false)} onMouseOut={() => props.onChangeTooltipVisuability(true)} title={element.when}> + + + + + ) + : null; - ); + return ( + + {label} + {ifFeature}{whenFeature}} {...otherProps} /> + {errorText} + + ); } \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementBoolean.tsx b/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementBoolean.tsx index cc141ee35..2fbbf956f 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementBoolean.tsx +++ b/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementBoolean.tsx @@ -16,29 +16,28 @@ * ============LICENSE_END========================================================================== */ -import { ViewElementBoolean } from "../models/uiModels"; import * as React from "react" import { MenuItem, FormHelperText, Select, FormControl, InputLabel } from "@material-ui/core"; -import { baseProps } from "./baseProps"; -type booleanInputProps = baseProps; +import { ViewElementBoolean } from "../models/uiModels"; +import { BaseProps } from "./baseProps"; + +type BooleanInputProps = BaseProps; -export const UiElementBoolean = (props: booleanInputProps) => { +export const UiElementBoolean = (props: BooleanInputProps) => { const element = props.value as ViewElementBoolean; - let error = ""; const value = String(props.inputValue).toLowerCase(); - if (element.mandatory && value !== "true" && value !== "false") { - error = "Error"; - } + const mandetoryError = element.mandatory && value !== 'true' && value !== 'false'; + return (!props.readOnly || element.id != null ? ( {element.label} - {error} + {mandetoryError ? "Value is mandetory" : ""} ) : null ); diff --git a/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementNumber.tsx b/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementNumber.tsx index cf462052e..ac4afc1d9 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementNumber.tsx +++ b/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementNumber.tsx @@ -19,59 +19,52 @@ import { ViewElementNumber } from "models/uiModels"; import { Tooltip, InputAdornment } from "@material-ui/core"; import * as React from 'react'; -import { baseProps } from "./baseProps"; +import { BaseProps } from "./baseProps"; import { IfWhenTextInput } from "./ifWhenTextInput"; import { checkRange } from "./verifyer"; -type numberInputProps = baseProps; +type numberInputProps = BaseProps; export const UiElementNumber = (props: numberInputProps) => { - const [error, setError] = React.useState(false); - const [helperText, setHelperText] = React.useState(""); - const [isTooltipVisible, setTooltipVisibility] = React.useState(true); + const [error, setError] = React.useState(false); + const [helperText, setHelperText] = React.useState(""); + const [isTooltipVisible, setTooltipVisibility] = React.useState(true); - const element = props.value as ViewElementNumber; + const element = props.value as ViewElementNumber; - const verifyValue = (data: string) => { - - if (data.trim().length > 0) { - const num = Number(data); - if (!isNaN(num)) { - const result = checkRange(element, num); - if (result.length > 0) { - setError(true); - setHelperText(result); - } else { - setError(false); - setHelperText(""); - } - } else { - setError(true); - setHelperText("Input is not a number."); - } - } else { - setError(false); - setHelperText(""); - } - - props.onChange(data); + const verifyValue = (data: string) => { + const num = Number(data); + if (!isNaN(num)) { + const result = checkRange(element, num); + if (result.length > 0) { + setError(true); + setHelperText(result); + } else { + setError(false); + setHelperText(""); + } + } else { + setError(true); + setHelperText("Input is not a number."); } + props.onChange(num); + } - return ( - - setTooltipVisibility(val)} - spellCheck={false} autoFocus margin="dense" - id={element.id} label={element.label} type="text" value={props.inputValue} - style={{ width: 485, marginLeft: 20, marginRight: 20 }} - onChange={(e: any) => { verifyValue(e.target.value) }} - error={error} - readOnly={props.readOnly} - disabled={props.disabled} - helperText={helperText} - startAdornment={element.units != null ? {element.units} : undefined} - /> - - ); + return ( + + { verifyValue(e.target.value) }} + error={error} + readOnly={props.readOnly} + disabled={props.disabled} + helperText={helperText} + startAdornment={element.units != null ? {element.units} : undefined} + /> + + ); } \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementSelection.tsx b/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementSelection.tsx index 8b0b890d0..1cec754ab 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementSelection.tsx +++ b/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementSelection.tsx @@ -17,13 +17,11 @@ */ import * as React from 'react'; -import { baseProps } from './baseProps'; +import { BaseProps } from './baseProps'; import { ViewElementSelection } from '../models/uiModels' import { FormControl, InputLabel, Select, FormHelperText, MenuItem } from '@material-ui/core'; - - -type selectionProps = baseProps; +type selectionProps = BaseProps; export const UiElementSelection = (props: selectionProps) => { diff --git a/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementString.tsx b/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementString.tsx index 43c60b502..95841b75d 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementString.tsx +++ b/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementString.tsx @@ -16,14 +16,14 @@ * ============LICENSE_END========================================================================== */ +import * as React from "react" import { Tooltip, TextField } from "@material-ui/core"; import { ViewElementString } from "../models/uiModels"; -import * as React from "react" -import { baseProps } from "./baseProps"; +import { BaseProps } from "./baseProps"; import { IfWhenTextInput } from "./ifWhenTextInput"; import { checkRange, checkPattern } from "./verifyer"; -type stringEntryProps = baseProps & { isKey: boolean }; +type stringEntryProps = BaseProps & { isKey: boolean }; export const UiElementString = (props: stringEntryProps) => { @@ -40,9 +40,9 @@ export const UiElementString = (props: stringEntryProps) => { let errorMessage = ""; const result = checkRange(element, data.length); - if (result.length > 0) + if (result.length > 0) { errorMessage += result; - + } const patternResult = checkPattern(element.pattern, data) @@ -69,7 +69,7 @@ export const UiElementString = (props: stringEntryProps) => { return ( - setTooltipVisibility(val)} + { - const [isError, setError] = React.useState(false); - const [helperText, setHelperText] = React.useState(""); - const [isTooltipVisible, setTooltipVisibility] = React.useState(true); + const [isError, setError] = React.useState(false); + const [helperText, setHelperText] = React.useState(""); + const [isTooltipVisible, setTooltipVisibility] = React.useState(true); - const element = props.value as ViewElementUnion; + const element = props.value as ViewElementUnion; - const verifyValues = (data: string) => { + const verifyValues = (data: string) => { - let foundObjectElements = 0; - let errorMessage = ""; - let isPatternCorrect = null; + let foundObjectElements = 0; + let errorMessage = ""; + let isPatternCorrect = null; - for (let i = 0; i < element.elements.length; i++) { - const unionElement = element.elements[i]; + for (let i = 0; i < element.elements.length; i++) { + const unionElement = element.elements[i]; - if (isViewElementNumber(unionElement)) { + if (isViewElementNumber(unionElement)) { - errorMessage = checkRange(unionElement, Number(data)); + errorMessage = checkRange(unionElement, Number(data)); - } else if (isViewElementString(unionElement)) { - errorMessage += checkRange(unionElement, data.length); - isPatternCorrect = checkPattern(unionElement.pattern, data).isValid; + } else if (isViewElementString(unionElement)) { + errorMessage += checkRange(unionElement, data.length); + isPatternCorrect = checkPattern(unionElement.pattern, data).isValid; - } else if (isViewElementObject(unionElement)) { - foundObjectElements++; - } + } else if (isViewElementObject(unionElement)) { + foundObjectElements++; + } - if (isPatternCorrect || errorMessage.length === 0) { - break; - } - } + if (isPatternCorrect || errorMessage.length === 0) { + break; + } + } - if (errorMessage.length > 0 || isPatternCorrect !== null && !isPatternCorrect) { - setError(true); - setHelperText("Input is wrong."); - } else { - setError(false); - setHelperText(""); - } + if (errorMessage.length > 0 || isPatternCorrect !== null && !isPatternCorrect) { + setError(true); + setHelperText("Input is wrong."); + } else { + setError(false); + setHelperText(""); + } - if (foundObjectElements > 0 && foundObjectElements != element.elements.length) { - throw new Error(`The union element ${element.id} can't be changed.`); + if (foundObjectElements > 0 && foundObjectElements != element.elements.length) { + throw new Error(`The union element ${element.id} can't be changed.`); - } else { - props.onChange(data); - } - }; + } else { + props.onChange(data); + } + }; - - - return - setTooltipVisibility(val)} - spellCheck={false} autoFocus margin="dense" - id={element.id} label={props.isKey ? "🔑 " + element.label : element.label} type="text" value={props.inputValue} - onChange={(e: any) => { verifyValues(e.target.value) }} - error={isError} - style={{ width: 485, marginLeft: 20, marginRight: 20 }} - readOnly={props.readOnly} - disabled={props.disabled} - helperText={helperText} - /> - ; + return + { verifyValues(e.target.value) }} + error={isError} + style={{ width: 485, marginLeft: 20, marginRight: 20 }} + readOnly={props.readOnly} + disabled={props.disabled} + helperText={helperText} + /> + ; } \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/configurationApp/src/views/configurationApplication.tsx b/sdnr/wt/odlux/apps/configurationApp/src/views/configurationApplication.tsx index 385f3b52f..6465feb4e 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/views/configurationApplication.tsx +++ b/sdnr/wt/odlux/apps/configurationApp/src/views/configurationApplication.tsx @@ -284,8 +284,12 @@ class ConfigurationApplicationComponent extends React.Component { const isKey = (uiElement.label === keyProperty); const canEdit = editMode && (isNew || (uiElement.config && !isKey)); - if (isViewElementEmpty(uiElement)) { + + // do not show elements w/o any value from the backend + if (viewData[uiElement.id] == null && !editMode) { return null; + } else if (isViewElementEmpty(uiElement)) { + return null; } else if (isViewElementSelection(uiElement)) { return + + true + true + + ${project.groupId} diff --git a/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx b/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx index a7feae923..86861fabb 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx @@ -106,8 +106,8 @@ class ConnectApplicationComponent extends React.Component - - + + {activePanelId === 'NetworkElements' diff --git a/sdnr/wt/odlux/apps/demoApp/pom.xml b/sdnr/wt/odlux/apps/demoApp/pom.xml index 414c71f2e..bb0384b6b 100644 --- a/sdnr/wt/odlux/apps/demoApp/pom.xml +++ b/sdnr/wt/odlux/apps/demoApp/pom.xml @@ -43,6 +43,11 @@ + + true + true + + ${project.groupId} diff --git a/sdnr/wt/odlux/apps/eventLogApp/pom.xml b/sdnr/wt/odlux/apps/eventLogApp/pom.xml index 70a25e484..7b762c6f3 100644 --- a/sdnr/wt/odlux/apps/eventLogApp/pom.xml +++ b/sdnr/wt/odlux/apps/eventLogApp/pom.xml @@ -43,6 +43,11 @@ + + true + true + + ${project.groupId} diff --git a/sdnr/wt/odlux/apps/faultApp/pom.xml b/sdnr/wt/odlux/apps/faultApp/pom.xml index 00b758ef4..7818eaaf3 100644 --- a/sdnr/wt/odlux/apps/faultApp/pom.xml +++ b/sdnr/wt/odlux/apps/faultApp/pom.xml @@ -43,6 +43,11 @@ + + true + true + + ${project.groupId} diff --git a/sdnr/wt/odlux/apps/faultApp/src/components/faultStatus.tsx b/sdnr/wt/odlux/apps/faultApp/src/components/faultStatus.tsx index 1ec463f47..b711b0375 100644 --- a/sdnr/wt/odlux/apps/faultApp/src/components/faultStatus.tsx +++ b/sdnr/wt/odlux/apps/faultApp/src/components/faultStatus.tsx @@ -57,12 +57,20 @@ class FaultStatusComponent extends React.Component { const { classes, faultStatus } = this.props; return ( - + <> + Alarm Status: { faultStatus.critical } | + + { faultStatus.major } | + + { faultStatus.minor } | + + { faultStatus.warning } | + ); }; } diff --git a/sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx b/sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx index 10721549c..7c29fec56 100644 --- a/sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx +++ b/sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx @@ -138,9 +138,9 @@ class FaultApplicationComponent extends React.Component - - - + + + { diff --git a/sdnr/wt/odlux/apps/helpApp/pom.xml b/sdnr/wt/odlux/apps/helpApp/pom.xml index 3c8410b77..6ada28086 100644 --- a/sdnr/wt/odlux/apps/helpApp/pom.xml +++ b/sdnr/wt/odlux/apps/helpApp/pom.xml @@ -43,6 +43,11 @@ + + true + true + + ${project.groupId} diff --git a/sdnr/wt/odlux/apps/helpApp/src2/main/resources/OSGI-INF/blueprint/blueprint.xml b/sdnr/wt/odlux/apps/helpApp/src2/main/resources/OSGI-INF/blueprint/blueprint.xml index 0fe9cd0e0..aaf395c79 100644 --- a/sdnr/wt/odlux/apps/helpApp/src2/main/resources/OSGI-INF/blueprint/blueprint.xml +++ b/sdnr/wt/odlux/apps/helpApp/src2/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -25,6 +25,6 @@ - + \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/inventoryApp/pom.xml b/sdnr/wt/odlux/apps/inventoryApp/pom.xml index fe4ffcd58..11843197e 100644 --- a/sdnr/wt/odlux/apps/inventoryApp/pom.xml +++ b/sdnr/wt/odlux/apps/inventoryApp/pom.xml @@ -43,6 +43,11 @@ + + true + true + + ${project.groupId} diff --git a/sdnr/wt/odlux/apps/linkCalculationApp/.babelrc b/sdnr/wt/odlux/apps/linkCalculationApp/.babelrc new file mode 100644 index 000000000..3d8cd1260 --- /dev/null +++ b/sdnr/wt/odlux/apps/linkCalculationApp/.babelrc @@ -0,0 +1,17 @@ +{ + "presets": [ + ["@babel/preset-react"], + ["@babel/preset-env", { + "targets": { + "chrome": "66" + }, + "spec": true, + "loose": false, + "modules": false, + "debug": false, + "useBuiltIns": "usage", + "forceAllTransforms": true + }] + ], + "plugins": [] +} diff --git a/sdnr/wt/odlux/apps/linkCalculationApp/package.json b/sdnr/wt/odlux/apps/linkCalculationApp/package.json new file mode 100644 index 000000000..40e1be913 --- /dev/null +++ b/sdnr/wt/odlux/apps/linkCalculationApp/package.json @@ -0,0 +1,40 @@ +{ + "name": "@odlux/linkcalculation-app", + "version": "0.1.0", + "description": "A react based modular UI to do link analysis.", + "main": "index.js", + "scripts": { + "start": "webpack-dev-server --env debug", + "build": "webpack --env release --config webpack.config.js", + "build:dev": "webpack --env debug --config webpack.config.js" + }, + "repository": { + "type": "git", + "url": "https://git.mfico.de/highstreet-technologies/odlux.git" + }, + "keywords": [ + "reactjs", + "redux", + "ui", + "framework" + ], + "author": "Mohammad Boroon", + "license": "Apache-2.0", + "dependencies": { + "@odlux/framework": "*" + }, + "peerDependencies": { + "@types/react": "16.9.19", + "@types/react-dom": "16.9.5", + "@types/react-router-dom": "4.3.1", + "@material-ui/core": "4.9.0", + "@material-ui/icons": "4.5.1", + "@types/classnames": "2.2.6", + "@types/flux": "3.1.8", + "@types/jquery": "3.3.10", + "jquery": "3.3.1", + "react": "16.12.0", + "react-dom": "16.12.0", + "react-router-dom": "4.3.1" + } +} \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/linkCalculationApp/pom.xml b/sdnr/wt/odlux/apps/linkCalculationApp/pom.xml new file mode 100644 index 000000000..8f057bd56 --- /dev/null +++ b/sdnr/wt/odlux/apps/linkCalculationApp/pom.xml @@ -0,0 +1,176 @@ + + + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent + 2.0.1-SNAPSHOT + + + + org.onap.ccsdk.features.sdnr.wt + sdnr-wt-odlux-app-linkCalculationApp + 1.0.1-SNAPSHOT + bundle + + ccsdk-features :: ${project.artifactId} + + + Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0 + + + + + true + true + + + + + ${project.groupId} + sdnr-wt-odlux-core-model + ${project.version} + + + ${project.groupId} + sdnr-wt-odlux-core-provider + ${project.version} + test + + + junit + junit + test + + + + + src2/main/java + + + dist + odlux + + + src2/main/resources + + + src2/test/resources + + + + + maven-clean-plugin + + + + dist + false + + + node + false + + + node_modules + false + + + ../node_modules + false + + + + bin + false + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-test-source + generate-test-sources + + add-test-source + + + + src2/test/java + + + + + + + de.jacks-it-lab + frontend-maven-plugin + 1.7.2 + + + install node and yarn + + install-node-and-yarn + + + initialize + + v10.16.3 + v1.19.0 + + + + yarn build + + yarn + + + run build + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + org.apache.felix + maven-bundle-plugin + true + + + org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.* + + + + + + + diff --git a/sdnr/wt/odlux/apps/linkCalculationApp/src/actions/commonLinkCalculationActions.ts b/sdnr/wt/odlux/apps/linkCalculationApp/src/actions/commonLinkCalculationActions.ts new file mode 100644 index 000000000..555954d15 --- /dev/null +++ b/sdnr/wt/odlux/apps/linkCalculationApp/src/actions/commonLinkCalculationActions.ts @@ -0,0 +1,104 @@ +/** + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt odlux + * ================================================================================================= + * Copyright (C) 2020 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 { Action } from "../../../../framework/src/flux/action"; +import { Dispatch } from "../../../../framework/src/flux/store"; +import { IApplicationStoreState } from "../../../../framework/src/store/applicationStore"; + + +export class UpdateLinkIdAction extends Action{ + constructor(public linkId: string){ + super(); + } +} + +export class UpdateFrequencyAction extends Action{ + constructor(public frequency: number){ + super(); + } +} +export class UpdateSiteAction extends Action{ + constructor( + public siteA?: any, + public siteB?: any + ){ + super(); + } +} +export class UpdateRainAttAction extends Action{ + + constructor(public rainAtt: number){ + super(); + } +} +export class UpdateRainValAction extends Action{ + constructor(public rainVal: number){ + super(); + } +} + +export class updateHideForm extends Action{ + constructor(public formView: boolean){ + super(); + } +} +export class UpdateDistanceAction extends Action{ + constructor(public distance: number){ + super(); + } +} + +export class UpdateFslCalculation extends Action{ + constructor(public fsl: number){ + super(); + } +} + + +export class UpdateLatLonAction extends Action{ + constructor( + public Lat1: number, + public Lon1:number, + public Lat2: number, + public Lon2: number + ){ + super(); + + } +} +export class isCalculationServerReachableAction extends Action{ + constructor(public reachable: boolean){ + super(); + } +} + +// export const checkCalculationsServerConnectivityAction = (callback: Promise) => (dispatcher: Dispatch, getState: () => IApplicationStoreState)=>{ +// callback +// .then(res =>{ +// const {linkCalculation:{calculations: {isCalculationServerAvailable}}} = getState(); +// if(!isToplogyServerAvailable){ +// dispatcher(new IsTopologyServerReachableAction(true)) +// } +// }) +// .catch(error=>{ +// const {network:{connectivity: {isToplogyServerAvailable}}} = getState(); +// if(isToplogyServerAvailable){ +// dispatcher(new IsTopologyServerReachableAction(false)) +// } +// }) +// } diff --git a/sdnr/wt/odlux/apps/linkCalculationApp/src/components/connectionInfo.tsx b/sdnr/wt/odlux/apps/linkCalculationApp/src/components/connectionInfo.tsx new file mode 100644 index 000000000..c798e481f --- /dev/null +++ b/sdnr/wt/odlux/apps/linkCalculationApp/src/components/connectionInfo.tsx @@ -0,0 +1,55 @@ +/** + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt odlux + * ================================================================================================= + * Copyright (C) 2020 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 { IApplicationStoreState } from "../../../../framework/src/store/applicationStore"; +import connect, { IDispatcher, Connect } from "../../../../framework/src/flux/connect"; +import { Paper, Typography } from "@material-ui/core"; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons'; + + +type props = Connect; + +const ConnectionInfo: React.FunctionComponent = (props) => { + + return ( + (props.isCalculationServerReachable === false)? +
+
Connection Error
+ {props.isCalculationServerReachable === false && Calculation data can't be loaded.} +
+
: null +)} + +const mapStateToProps = (state: IApplicationStoreState) => ({ + isCalculationServerReachable: state.linkCalculation.calculations.reachable +}); + + + +const mapDispatchToProps = (dispatcher: IDispatcher) => ({ + + //zoomToSearchResult: (lat: number, lon: number) => dispatcher.dispatch(new ZoomToSearchResultAction(lat, lon)) + +});; + + +export default connect(mapStateToProps,mapDispatchToProps)(ConnectionInfo) + diff --git a/sdnr/wt/odlux/apps/linkCalculationApp/src/components/denseTable.tsx b/sdnr/wt/odlux/apps/linkCalculationApp/src/components/denseTable.tsx new file mode 100644 index 000000000..96d6f4ed1 --- /dev/null +++ b/sdnr/wt/odlux/apps/linkCalculationApp/src/components/denseTable.tsx @@ -0,0 +1,121 @@ +/** + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt odlux + * ================================================================================================= + * Copyright (C) 2020 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 Table from '@material-ui/core/Table'; +import TableBody from '@material-ui/core/TableBody'; +import TableCell from '@material-ui/core/TableCell'; +import TableContainer from '@material-ui/core/TableContainer'; +import TableHead from '@material-ui/core/TableHead'; +import TableRow from '@material-ui/core/TableRow'; +import Paper from '@material-ui/core/Paper'; +import { makeStyles, Button, Tooltip } from '@material-ui/core'; + +type props = { headers: string[], width: number, height:number, navigate?(applicationName: string, path?: string):void, onLinkClick?(id: string): void, data: any[], hover: boolean, onClick?(id: string): void, actions?:boolean }; + + +const styles = makeStyles({ + container: { + overflow:"auto" + }, + button: { + margin: 0, + padding: "6px 6px", + minWidth: 'unset' + } + + }); + + +const DenseTable: React.FunctionComponent = (props) => { + + const classes = styles(); + + const handleClick = (event: any, id: string) =>{ + event.preventDefault(); + props.onClick !== undefined && props.onClick(id); + + } + + const handleHover = (event: any, id: string) =>{ + event.preventDefault(); + + } + + return ( + + + + + + { + props.headers.map((data) => { + return {data} + }) + } + + + + {props.data.map((row, index) => { + + + var filteredRows = Object.keys(row).filter(function(e) { if(e!=="simulatorId") return row }); + + //var filteredRows = Object.keys(row).filter(function(e) { if(e!=="simulatorId") return row[e] }); + var values = Object.keys(row).map(function(e) { if(e!=="simulatorId"){ return row[e];} else return undefined }); + + + return ( + handleHover(e,row.name)} onClick={ e => handleClick(e, row.name)}> + + { + values.map((data:any) => { + + if(data!== undefined) + return {data} + else + return null; + }) + } + { + + props.actions && +
+ + + + + + +
+
+ + } +
) + }) + } + +
+
+ +
+ ); + +} + +export default DenseTable; \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/linkCalculationApp/src/handlers/linkCalculationAppRootHandler.ts b/sdnr/wt/odlux/apps/linkCalculationApp/src/handlers/linkCalculationAppRootHandler.ts new file mode 100644 index 000000000..00dd48d45 --- /dev/null +++ b/sdnr/wt/odlux/apps/linkCalculationApp/src/handlers/linkCalculationAppRootHandler.ts @@ -0,0 +1,115 @@ +/** +* ============LICENSE_START======================================================================== +* ONAP : ccsdk feature sdnr wt odlux +* ================================================================================================= +* Copyright (C) 2020 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========================================================================== +*/ +// main state handler + +import { combineActionHandler } from '../../../../framework/src/flux/middleware'; + +// ** do not remove ** +import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore'; +import { IActionHandler } from '../../../../framework/src/flux/action';; +import { UpdateLinkIdAction, UpdateFrequencyAction , UpdateLatLonAction, UpdateRainAttAction, UpdateRainValAction, updateHideForm, UpdateFslCalculation, UpdateSiteAction, UpdateDistanceAction, isCalculationServerReachableAction} from '../actions/commonLinkCalculationActions'; + +declare module '../../../../framework/src/store/applicationStore' { + interface IApplicationStoreState { + linkCalculation: ICalculationsState; + } +} + +type ICalculationsState = { + calculations:ILinkCalculationAppStateState +} + +export type ILinkCalculationAppStateState= { + linkId: string | null, + frequency: number, + formView:boolean, + fsl:number, + distance:number, + Lat1: number, + Lon1: number, + Lat2: number, + Lon2: number, + rainVal : number, + rainAtt : number, + siteA: any, + siteB: any, + reachable: boolean +} + +const initialState: ILinkCalculationAppStateState ={ + linkId: null, + frequency: 0, + Lat1: 0, + Lon1: 0, + Lat2: 0, + Lon2: 0, + formView : false, + fsl:0, + distance:0, + siteA : '', + siteB: '', + rainVal : 0, + rainAtt: 0, + reachable : true +} + + + +export const LinkCalculationHandler: IActionHandler = (state=initialState, action) => { + + if(action instanceof UpdateLinkIdAction){ + state = Object.assign({}, state, {linkId:action.linkId}) + } + else if(action instanceof updateHideForm){ + + state = Object.assign({}, state, {formView:action.formView}) + } + else if (action instanceof UpdateDistanceAction){ + state = Object.assign({}, state, {distance:action.distance}) + } + else if (action instanceof UpdateFrequencyAction){ + state = Object.assign({}, state, {frequency:action.frequency}) +} + else if (action instanceof UpdateFslCalculation){ + state = Object.assign({}, state, {fsl:action.fsl}) + } + else if (action instanceof UpdateLatLonAction){ + state = Object.assign({}, state, {Lat1:action.Lat1, Lon1:action.Lon1, Lat2:action.Lat2, Lon2:action.Lon2}) + } + else if (action instanceof UpdateRainAttAction){ + state = Object.assign({}, state, {rainAtt:action.rainAtt}) + } + else if (action instanceof UpdateRainValAction){ + state = Object.assign({}, state, {rainVal:action.rainVal}) + } + else if (action instanceof UpdateSiteAction){ + state = Object.assign({}, state, {siteA:action.siteA, siteB:action.siteB}) + } + else if(action instanceof isCalculationServerReachableAction){ + state = Object.assign({}, state, { reachable: action.reachable }); +} + return state +} + +const actionHandlers = { + calculations: LinkCalculationHandler +} + +export const LinkCalculationAppRootHandler = combineActionHandler(actionHandlers); +export default LinkCalculationAppRootHandler; + diff --git a/sdnr/wt/odlux/apps/linkCalculationApp/src/index.html b/sdnr/wt/odlux/apps/linkCalculationApp/src/index.html new file mode 100644 index 000000000..c1cb3f9f3 --- /dev/null +++ b/sdnr/wt/odlux/apps/linkCalculationApp/src/index.html @@ -0,0 +1,27 @@ + + + + + + + + + Link Calculation App + + + +
+ + + + + + \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/linkCalculationApp/src/pluginLinkCalculation.tsx b/sdnr/wt/odlux/apps/linkCalculationApp/src/pluginLinkCalculation.tsx new file mode 100644 index 000000000..fc72f5ab3 --- /dev/null +++ b/sdnr/wt/odlux/apps/linkCalculationApp/src/pluginLinkCalculation.tsx @@ -0,0 +1,148 @@ +/** +* ============LICENSE_START======================================================================== +* ONAP : ccsdk feature sdnr wt odlux +* ================================================================================================= +* Copyright (C) 2020 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========================================================================== +*/ +// app configuration and main entry point for the app + +import * as React from "react"; +import { withRouter, RouteComponentProps, Route, Switch, Redirect } from 'react-router-dom'; + +import { faBookOpen } from '@fortawesome/free-solid-svg-icons'; // select app icon +import applicationManager from '../../../framework/src/services/applicationManager'; + +import LinkCalculation from './views/linkCalculationComponent'; +import LinkCalculationAppRootHandler from './handlers/linkCalculationAppRootHandler'; +import connect, { Connect, IDispatcher } from '../../../framework/src/flux/connect'; +import { IApplicationStoreState } from "../../../framework/src/store/applicationStore"; +import { UpdateLinkIdAction, UpdateLatLonAction, updateHideForm, UpdateSiteAction, UpdateDistanceAction } from "./actions/commonLinkCalculationActions"; + + +let currentLinkId: string | null = null; +let lastUrl: string = "/linkCalculation"; + +const mapProps = (state: IApplicationStoreState) => ({ +}); + +const mapDisp = (dispatcher: IDispatcher) => ({ + updateLinkId: (mountId: string) => dispatcher.dispatch(new UpdateLinkIdAction(mountId)), + + updateSiteName: (siteNameA?:any, siteNameB?:any)=>{ + dispatcher.dispatch(new UpdateSiteAction(siteNameA, siteNameB)) + }, + updateDistance :(distance:number) =>{ + dispatcher.dispatch(new UpdateDistanceAction(distance)) + }, + updateLatLon : (Lat1:number, Lon1:number, Lat2:number, Lon2:number)=> { + + dispatcher.dispatch(new UpdateLatLonAction(Lat1, Lon1, Lat2, Lon2)) + dispatcher.dispatch(new updateHideForm (true)) + }, +}); + + +const LinkCalculationRouteAdapter = connect(mapProps, mapDisp)((props: RouteComponentProps<{ mountId?: string }> & Connect) => { + let linkId: string = ""; + + // called when component finshed mounting + React.useEffect(() => { + + lastUrl = props.location.pathname; + linkId = getLinkId(lastUrl); + + const data= props.location.search + + + + if (data !== undefined && data.length>0){ + + + + const lat1 = data.split('&')[0].split('=')[1] + const lon1 = data.split('&')[1].split('=')[1] + const lat2 = data.split('&')[2].split('=')[1] + const lon2 = data.split('&')[3].split('=')[1] + + const siteNameA = data.split('&')[4].split('=')[1] + const siteNameB = data.split('&')[5].split('=')[1] + + const distance = data.split('&')[8].split('=')[1] + + + props.updateSiteName(String(siteNameA), String(siteNameB)) + props.updateDistance(Number(distance)) + + + props.updateLatLon(Number(lat1),Number(lon1),Number(lat2),Number(lon2)) + + } + + + if (currentLinkId !== linkId) { // new element is loaded + currentLinkId = linkId; + props.updateLinkId(currentLinkId); + } + }, []); + + // called when component gets updated + React.useEffect(() => { + + lastUrl = props.location.pathname; + linkId = getLinkId(lastUrl); + + if (currentLinkId !== linkId) { + currentLinkId = linkId; + props.updateLinkId(currentLinkId); + } + }); + + const getLinkId = (lastUrl: string) => { + let index = lastUrl.lastIndexOf("linkCalculation/"); + if (index >= 0) { + linkId = lastUrl.substr(index+16); + } else { + linkId = ""; + } + + return linkId; + } + + + return ( + + ); +}); + +const App = withRouter((props: RouteComponentProps) => { + props.history.action = "POP"; + return ( + + + + + + ) +}); + +export function register() { + applicationManager.registerApplication({ + name: "linkCalculation", + icon: faBookOpen, + rootActionHandler: LinkCalculationAppRootHandler, + rootComponent: App, + menuEntry: "Link Calculation" + }); +} + diff --git a/sdnr/wt/odlux/apps/linkCalculationApp/src/views/linkCalculationComponent.tsx b/sdnr/wt/odlux/apps/linkCalculationApp/src/views/linkCalculationComponent.tsx new file mode 100644 index 000000000..97219b6d8 --- /dev/null +++ b/sdnr/wt/odlux/apps/linkCalculationApp/src/views/linkCalculationComponent.tsx @@ -0,0 +1,246 @@ +/** + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt odlux + * ================================================================================================= + * Copyright (C) 2020 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 { Connect, connect, IDispatcher } from '../../../../framework/src/flux/connect'; +import { MaterialTable, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; +import { TextField, Tabs, Tab, Typography, AppBar, Button, Tooltip } from '@material-ui/core'; +import DenseTable from '../components/denseTable' + +import { IApplicationStoreState } from "../../../../framework/src/store/applicationStore"; +import { UpdateFrequencyAction, UpdateLatLonAction, UpdateRainAttAction, UpdateRainValAction, UpdateFslCalculation, isCalculationServerReachableAction } from "../actions/commonLinkCalculationActions"; +import { faPlaneArrival } from "@fortawesome/free-solid-svg-icons"; + +const mapProps = (state: IApplicationStoreState) => ({ + linkId: state.linkCalculation.calculations.linkId, + frequency: state.linkCalculation.calculations.frequency, + lat1: state.linkCalculation.calculations.Lat1, + lon1: state.linkCalculation.calculations.Lon1, + lat2: state.linkCalculation.calculations.Lat2, + lon2: state.linkCalculation.calculations.Lon2, + rainAtt: state.linkCalculation.calculations.rainAtt, + rainVal: state.linkCalculation.calculations.rainVal, + formView: state.linkCalculation.calculations.formView, + fsl:state.linkCalculation.calculations.fsl, + siteA: state.linkCalculation.calculations.siteA, + siteB: state.linkCalculation.calculations.siteB, + distance: state.linkCalculation.calculations.distance, + reachable :state.linkCalculation.calculations.reachable +}); + +const BASE_URL="/topology/services" + +const mapDispatch = (dispatcher: IDispatcher) => ({ + + updateFrequency: (frequency: number) => { + dispatcher.dispatch(new UpdateFrequencyAction(frequency)) + + }, + updateLatLon: (Lat1: number, Lon1: number, Lat2: number, Lon2: number) => { + + dispatcher.dispatch(new UpdateLatLonAction(Lat1, Lon1, Lat2, Lon2)) + + }, + + updateRainValue: (rainVal: number) => { + dispatcher.dispatch(new UpdateRainValAction(rainVal)) + }, + + UpdateRainAtt: (rainAtt: number) => { + dispatcher.dispatch(new UpdateRainAttAction(rainAtt)) + }, + + specificRain: (rainAtt: number) => { + dispatcher.dispatch(new UpdateRainAttAction(rainAtt)) + + }, + + FSL :(free:number)=> { + dispatcher.dispatch(new UpdateFslCalculation (free)) + }, + + UpdateConectivity : (reachable:boolean) => { + dispatcher.dispatch (new isCalculationServerReachableAction (reachable)) + } +}); + +class LinkCalculation extends React.Component, { rainMethodDisplay: boolean }> { + constructor(props: any) { + super(props) + this.state = { rainMethodDisplay: true } + } + + handleChange = (e: number) => { + this.props.updateFrequency(e) + } + + updateLatLon = (e: any) => { + + if (e.target.id == 'Lat1') this.props.updateLatLon(e.target.value, this.props.lon1, this.props.lat2, this.props.lon2) + if (e.target.id == 'Lon1') this.props.updateLatLon(this.props.lat1, e.target.value, this.props.lat2, this.props.lon2) + if (e.target.id == 'Lat2') this.props.updateLatLon(this.props.lat1, this.props.lon1, e.target.value, this.props.lon2) + if (e.target.id == 'Lon2') this.props.updateLatLon(this.props.lat1, this.props.lon1, this.props.lat2, e.target.value) + + } + + LatLonToDMS = (value: number, isLon: boolean = false) => { + const absoluteValue = Math.abs(value); + const d = Math.floor(absoluteValue); + const m = Math.floor((absoluteValue - d) * 60); + const s = (absoluteValue - d - m / 60) * 3600; + const dms = `${d}° ${m}' ${s.toFixed(2)}"` + + const sign = Math.sign(value); + + if (isLon) { + return (sign === -1 || sign === -0) ? dms + " W" : dms + " E"; + } else { + return (sign === -1 || sign === -0) ? dms + " S" : dms + " N"; + } + } + + calRain = (lat1: any, lon1: any, lat2: any, lon2: any, frequency: any) => { + fetch(BASE_URL+'/calculations/rain/' + lat1 + '/' + lon1 + '/' + lat2 + '/' + lon2 + '/' + frequency) + .then(res => res.json()) + .then(result => { this.props.UpdateRainAtt(result.RainAtt) }) + } + + + updateRainValue = (lat1: any, lon1: any, lat2: any, lon2: any) => { + fetch(BASE_URL+'/calculations/rain/' + lat1 + '/' + lon1 + '/' + lat2 + '/' + lon2) + .then(res => res.json()) + .then(result => { this.props.updateRainValue(result.RainAtt) }) + } + + + specificRain = (rainfall: number, frequency: number) => { + fetch(BASE_URL+'/calculations/rain/' + rainfall + '/' + frequency) + .then(res => res.json()) + .then(result => { this.props.specificRain(result.RainAtt) }) + } + + FSL = (distance:number, frequency:number) => { + fetch(BASE_URL+'/calculations/FSL/' + distance + '/' + frequency) + .then(res=>res.json()) + .then (result => {this.props.FSL(result.free)}) + } + + buttonHandler =() => { + this.FSL(this.props.distance, this.props.frequency) + + if (this.state.rainMethodDisplay === true){ + + this.specificRain(this.props.rainVal, this.props.frequency); + } + else { + this.calRain(this.props.lat1, this.props.lon1, this.props.lat2, this.props.lon2, this.props.frequency); + this.updateRainValue(this.props.lat1, this.props.lon1, this.props.lat2, this.props.lon2) + } + } + + componentDidMount = () => { + fetch (BASE_URL+'/calculations/fsl/0/0') + .then(res => {if (res.ok) {this.props.reachable===false && this.props.UpdateConectivity(true)}else {this.props.reachable===true && this.props.UpdateConectivity(false)} }) + .catch (res => {this.props.reachable===true && this.props.UpdateConectivity(false)} ) + } + + render() { + console.log(this.props); + const data = [ + + { name: "Site Name", val1: this.props.siteA, val2: '', val3: this.props.siteB}, + { name: "Latitude", val1: this.props.lat1 && this.LatLonToDMS(this.props.lat1), val2:'', val3: this.props.lat2 && this.LatLonToDMS(this.props.lat2) }, + { name: "Longitude", val1: this.props.lon1 && this.LatLonToDMS(this.props.lon1, true), val2:'', val3: this.props.lon2 && this.LatLonToDMS(this.props.lon2, true) }, + { name: "Azimuth in °", val1: '', val2: '' , val3:''}, + { name: "", val1: '', val2: '' , val3:''}, + { name: "Distance (km)", val1: '', val2: (this.props.distance).toFixed(3) ,val3:'' }, + {name: 'Polarization', val1:'', val2:
Horizontal
+ Vertical +
, val3:''}, + {name : 'Frequency (GHz)', val1: '', val2:
+
,val3: ''}, + {name: 'Free Space Loss (dB)' ,val1: '', val2: this.props.fsl,val3: ''}, + {name:'Rain Model', val1:'', val2:
+
, val3:''}, + {name: 'Rainfall Rate (mm/h)', val1: '', val2:, val3:''}, + {name: 'Rain Loss (dB/km)', val1: '', val2: this.props.rainAtt, val3: ''}, + {name: '', val1:'', val2:, val3:'' } + + ]; + + + return
+ Link Calculation app. LinkId: {this.props.linkId}
+ + {!this.props.formView &&
+
+ +
Site A +
Site Id: + +

+ +
+

Site B
Site Id: + + +
+
+
+ } + + + + + + +
+ + } + + +} + +export default connect(mapProps, mapDispatch)(LinkCalculation); diff --git a/sdnr/wt/odlux/apps/linkCalculationApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java b/sdnr/wt/odlux/apps/linkCalculationApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java new file mode 100644 index 000000000..43b072c4b --- /dev/null +++ b/sdnr/wt/odlux/apps/linkCalculationApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java @@ -0,0 +1,68 @@ +/* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * 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========================================================================== + */ +package org.onap.ccsdk.features.sdnr.wt.odlux.bundles; + +import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundle; +import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundleLoader; + +public class MyOdluxBundle extends OdluxBundle { + + @Override + public void initialize() { + super.initialize(); + } + + @Override + public void clean() { + super.clean(); + } + + @Override + public String getResourceFileContent(String filename) { + return super.getResourceFileContent(filename); + } + + @Override + public boolean hasResource(String filename) { + return super.hasResource(filename); + } + + @Override + public void setBundleName(String bundleName) { + super.setBundleName(bundleName); + } + + @Override + public void setLoader(OdluxBundleLoader loader) { + super.setLoader(loader); + } + + @Override + public String getBundleName() { + return super.getBundleName(); + } + + @Override + public OdluxBundleLoader getLoader() { + return super.getLoader(); + } + + public MyOdluxBundle() { + super(); + } +} diff --git a/sdnr/wt/odlux/apps/linkCalculationApp/src2/main/resources/OSGI-INF/blueprint/blueprint.xml b/sdnr/wt/odlux/apps/linkCalculationApp/src2/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 000000000..8eb652e2d --- /dev/null +++ b/sdnr/wt/odlux/apps/linkCalculationApp/src2/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/linkCalculationApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/linkCalculationApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java new file mode 100644 index 000000000..c319bb189 --- /dev/null +++ b/sdnr/wt/odlux/apps/linkCalculationApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java @@ -0,0 +1,46 @@ +/* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * 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========================================================================== + */ +package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.odlux.OdluxBundleLoaderImpl; +import org.onap.ccsdk.features.sdnr.wt.odlux.bundles.MyOdluxBundle; + +public class TestBundleRes { + + @Test + public void test() { + OdluxBundleLoaderImpl loader = OdluxBundleLoaderImpl.getInstance(); + MyOdluxBundle b = new MyOdluxBundle(); + b.setLoader(loader); + b.setIndex(0); + b.setBundleName("abc"); + b.initialize(); + assertTrue(loader.getNumberOfBundles()==1); + assertNotNull(b.getLoader()); + assertEquals("abc",b.getBundleName()); + assertTrue(b.hasResource("test.js")); + assertNotNull(b.getResourceFileContent("test.js")); + b.clean(); + assertTrue(loader.getNumberOfBundles()==0); + } + +} diff --git a/sdnr/wt/odlux/apps/linkCalculationApp/src2/test/resources/test.js b/sdnr/wt/odlux/apps/linkCalculationApp/src2/test/resources/test.js new file mode 100644 index 000000000..b47fdc39f --- /dev/null +++ b/sdnr/wt/odlux/apps/linkCalculationApp/src2/test/resources/test.js @@ -0,0 +1,5 @@ +asdac sad +as +d +sad + sadfa \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/linkCalculationApp/tsconfig.json b/sdnr/wt/odlux/apps/linkCalculationApp/tsconfig.json new file mode 100644 index 000000000..a66b5d828 --- /dev/null +++ b/sdnr/wt/odlux/apps/linkCalculationApp/tsconfig.json @@ -0,0 +1,37 @@ +{ + "compilerOptions": { + "baseUrl": "./src", + "outDir": "./dist", + "sourceMap": true, + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": false, + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "strictNullChecks": true, + "pretty": true, + "newLine": "LF", + "module": "es2015", + "target": "es2016", + "moduleResolution": "node", + "experimentalDecorators": true, + "jsx": "preserve", + "lib": [ + "dom", + "es2015", + "es2016" + ], + "types": [ + "prop-types", + "react", + "react-dom" + ] + }, + "exclude": [ + "dist", + "node_modules" + ] +} diff --git a/sdnr/wt/odlux/apps/linkCalculationApp/webpack.config.js b/sdnr/wt/odlux/apps/linkCalculationApp/webpack.config.js new file mode 100644 index 000000000..4f2bd2ec9 --- /dev/null +++ b/sdnr/wt/odlux/apps/linkCalculationApp/webpack.config.js @@ -0,0 +1,159 @@ +/** + * Webpack 4 configuration file + * see https://webpack.js.org/configuration/ + * see https://webpack.js.org/configuration/dev-server/ + */ + +"use strict"; + +const path = require("path"); +const webpack = require("webpack"); +const CopyWebpackPlugin = require("copy-webpack-plugin"); +const TerserPlugin = require('terser-webpack-plugin'); + +// const __dirname = (path => path.replace(/^([a-z]\:)/, c => c.toUpperCase()))(process.__dirname()); + +module.exports = (env) => { + const distPath = path.resolve(__dirname, env === "release" ? "." : "../..", "dist"); + const frameworkPath = path.resolve(__dirname, env === "release" ? "../../framework" : "../..", "dist"); + return [{ + name: "App", + + mode: "none", //disable default behavior + + target: "web", + + context: path.resolve(__dirname, "src"), + + entry: { + linkCalculationApp: ["./pluginLinkCalculation.tsx"] + }, + + devtool: env === "release" ? false : "source-map", + + resolve: { + extensions: [".ts", ".tsx", ".js", ".jsx"] + }, + + output: { + path: distPath, + filename: "[name].js", + library: "[name]", + libraryTarget: "umd2", + chunkFilename: "[name].js" + }, + module: { + rules: [{ + test: /\.tsx?$/, + exclude: /node_modules/, + use: [{ + loader: "babel-loader" + }, { + loader: "ts-loader" + }] + }, { + test: /\.jsx?$/, + exclude: /node_modules/, + use: [{ + loader: "babel-loader" + }] + }] + }, + + optimization: { + noEmitOnErrors: true, + namedModules: env !== "release", + minimize: env === "release", + minimizer: env !== "release" ? [] : [new TerserPlugin({ + terserOptions: { + warnings: false, // false, true, "verbose" + compress: { + drop_console: true, + drop_debugger: true, + } + } + })], + }, + + plugins: [ + new webpack.DllReferencePlugin({ + context: path.resolve(__dirname, "../../framework/src"), + manifest: require(path.resolve(frameworkPath, "vendor-manifest.json")), + sourceType: "umd2" + }), + new webpack.DllReferencePlugin({ + context: path.resolve(__dirname, "../../framework/src"), + manifest: require(path.resolve(frameworkPath, "app-manifest.json")), + sourceType: "umd2" + }), + ...(env === "release") ? [ + new webpack.DefinePlugin({ + "process.env": { + NODE_ENV: "'production'", + VERSION: JSON.stringify(require("./package.json").version) + } + }), + ] : [ + new webpack.DefinePlugin({ + "process.env": { + NODE_ENV: "'development'", + VERSION: JSON.stringify(require("./package.json").version) + } + }), + new CopyWebpackPlugin([{ + from: 'index.html', + to: distPath + }]), + ] + ], + + devServer: { + public: "http://localhost:3100", + contentBase: frameworkPath, + + compress: true, + headers: { + "Access-Control-Allow-Origin": "*" + }, + host: "0.0.0.0", + port: 3100, + disableHostCheck: true, + historyApiFallback: true, + inline: true, + hot: false, + quiet: false, + stats: { + colors: true + }, + proxy: { + "/oauth2/": { + target: "http://10.20.6.29:8181", + secure: false + }, + "/database/": { + target: "http://10.20.6.29:8181", + secure: false + }, + "/restconf/": { + target: "http://10.20.6.29:8181", + secure: false + }, + "/topology/": { + target: "http://localhost:3001", + secure: false + }, + "/help/": { + target: "http://10.20.6.29:8181", + secure: false + }, + "/websocket/": { + target: "http://10.20.6.29:8181", + ws: true, + changeOrigin: true, + secure: false + } + } + + } + }]; +} diff --git a/sdnr/wt/odlux/apps/maintenanceApp/pom.xml b/sdnr/wt/odlux/apps/maintenanceApp/pom.xml index 874d17c8e..e66404cc8 100644 --- a/sdnr/wt/odlux/apps/maintenanceApp/pom.xml +++ b/sdnr/wt/odlux/apps/maintenanceApp/pom.xml @@ -43,6 +43,11 @@ + + true + true + + ${project.groupId} diff --git a/sdnr/wt/odlux/apps/mediatorApp/pom.xml b/sdnr/wt/odlux/apps/mediatorApp/pom.xml index 21d5d61eb..6accabe5c 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/pom.xml +++ b/sdnr/wt/odlux/apps/mediatorApp/pom.xml @@ -43,6 +43,11 @@ + + true + true + + ${project.groupId} diff --git a/sdnr/wt/odlux/apps/minimumApp/pom.xml b/sdnr/wt/odlux/apps/minimumApp/pom.xml index 55bdf9787..813542686 100644 --- a/sdnr/wt/odlux/apps/minimumApp/pom.xml +++ b/sdnr/wt/odlux/apps/minimumApp/pom.xml @@ -43,6 +43,11 @@ + + true + true + + ${project.groupId} diff --git a/sdnr/wt/odlux/apps/performanceHistoryApp/pom.xml b/sdnr/wt/odlux/apps/performanceHistoryApp/pom.xml index 819c74242..5ace21fab 100644 --- a/sdnr/wt/odlux/apps/performanceHistoryApp/pom.xml +++ b/sdnr/wt/odlux/apps/performanceHistoryApp/pom.xml @@ -43,6 +43,11 @@ + + true + true + + ${project.groupId} diff --git a/sdnr/wt/odlux/core/model/pom.xml b/sdnr/wt/odlux/core/model/pom.xml index 39a09ffe1..895734fd8 100644 --- a/sdnr/wt/odlux/core/model/pom.xml +++ b/sdnr/wt/odlux/core/model/pom.xml @@ -43,6 +43,11 @@ + + true + true + + org.osgi diff --git a/sdnr/wt/odlux/core/provider/pom.xml b/sdnr/wt/odlux/core/provider/pom.xml index afe14f4b1..70cd2446c 100644 --- a/sdnr/wt/odlux/core/provider/pom.xml +++ b/sdnr/wt/odlux/core/provider/pom.xml @@ -43,6 +43,11 @@ + + true + true + + org.onap.ccsdk.features.sdnr.wt @@ -59,6 +64,7 @@ jetty-server test + org.osgi org.osgi.core diff --git a/sdnr/wt/odlux/framework/pom.xml b/sdnr/wt/odlux/framework/pom.xml index db42ef1ac..a7c81ebb1 100644 --- a/sdnr/wt/odlux/framework/pom.xml +++ b/sdnr/wt/odlux/framework/pom.xml @@ -46,7 +46,7 @@ ${maven.build.timestamp} ONAP Frankfurt (Neon, mdsal ${odl.mdsal.version}) - 57.3e1d5cf(20/08/11) + 62.ad364be(20/08/21) ONAP SDN-R | ONF Wireless for ${distversion} - Build: ${buildtime} ${buildno} ${project.version} diff --git a/sdnr/wt/odlux/framework/src/components/material-table/index.tsx b/sdnr/wt/odlux/framework/src/components/material-table/index.tsx index 3dfbe0b91..c5be81914 100644 --- a/sdnr/wt/odlux/framework/src/components/material-table/index.tsx +++ b/sdnr/wt/odlux/framework/src/components/material-table/index.tsx @@ -234,7 +234,7 @@ class MaterialTableComponent extends React.Component extends React.Component - + None - {col.labels ? col.labels["true"] : "true"} - {col.labels ? col.labels["false"] : "false"} + {col.labels ? col.labels["true"] : "true"} + {col.labels ? col.labels["false"] : "false"} : } diff --git a/sdnr/wt/odlux/framework/src/components/material-ui/listItemLink.tsx b/sdnr/wt/odlux/framework/src/components/material-ui/listItemLink.tsx index 1a7e58f77..23bad66ea 100644 --- a/sdnr/wt/odlux/framework/src/components/material-ui/listItemLink.tsx +++ b/sdnr/wt/odlux/framework/src/components/material-ui/listItemLink.tsx @@ -1,20 +1,20 @@ -/** - * ============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========================================================================== - */ +/** + * ============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 { NavLink, Link, Route } from 'react-router-dom'; @@ -50,7 +50,7 @@ export const ListItemLink = withStyles(styles)((props: IListItemLinkProps) => { : null } { typeof Primary === 'string' - ? + ? : } diff --git a/sdnr/wt/odlux/framework/src/components/navigationMenu.tsx b/sdnr/wt/odlux/framework/src/components/navigationMenu.tsx index 620abd708..790677ae3 100644 --- a/sdnr/wt/odlux/framework/src/components/navigationMenu.tsx +++ b/sdnr/wt/odlux/framework/src/components/navigationMenu.tsx @@ -120,6 +120,11 @@ export const NavigationMenu = withStyles(styles)(connect()(({ classes, state, di } }) + React.useEffect(()=>{ + // trigger a resize if menu changed in case elements have to re-arrange + window.dispatchEvent(new Event('menu-resized')); + }, [isOpen]) + return ( Notifications |
: Notifications |) - : Notifications N/A |; + Notifications | : Notifications |) + : Notifications N/A |; // add notificationInfo element before help diff --git a/sdnr/wt/odlux/framework/src/services/notificationService.ts b/sdnr/wt/odlux/framework/src/services/notificationService.ts index c90da0946..4bcc05cc3 100644 --- a/sdnr/wt/odlux/framework/src/services/notificationService.ts +++ b/sdnr/wt/odlux/framework/src/services/notificationService.ts @@ -1,193 +1,193 @@ -/** - * ============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 X2JS from 'x2js'; -import { ApplicationStore } from '../store/applicationStore'; -import { SetWebsocketAction } from '../actions/websocketAction'; - -const socketUrl = [location.protocol === 'https:' ? 'wss://' : 'ws://', 'admin', ':', 'admin', '@', location.hostname, ':', location.port, '/websocket'].join(''); -const subscriptions: { [scope: string]: SubscriptionCallback[] } = {}; -let socketReady: Promise; -let userLoggedOut = false; -let wasWebsocketConnectionEstablished: undefined | boolean; -let applicationStore: ApplicationStore | null; - - -export interface IFormatedMessage { - notifType: string | null; - time: string; -} - -export type SubscriptionCallback = (msg: TMessage) => void; - -function formatData(event: MessageEvent): IFormatedMessage | undefined { - - var x2js = new X2JS(); - var jsonObj: { [key: string]: IFormatedMessage } = x2js.xml2js(event.data); - if (jsonObj && typeof (jsonObj) === 'object') { - - const notifType = Object.keys(jsonObj)[0]; - const formated = jsonObj[notifType]; - formated.notifType = notifType; - formated.time = new Date().toISOString(); - return formated; - } - return undefined; - -} - -export function subscribe(scope: string | string[], callback: SubscriptionCallback): boolean { - const scopes = scope instanceof Array ? scope : [scope]; - - // send all new scopes to subscribe - const newScopesToSubscribe: string[] = scopes.reduce((acc: string[], cur: string) => { - const currentCallbacks = subscriptions[cur]; - if (currentCallbacks) { - if (!currentCallbacks.some(c => c === callback)) { - currentCallbacks.push(callback); - } - } else { - subscriptions[cur] = [callback]; - acc.push(cur); - } - return acc; - }, []); - - if (newScopesToSubscribe.length === 0) { - return true; - } - - return true; -} - - -export function unsubscribe(scope: string | string[], callback: SubscriptionCallback): Promise { - return socketReady.then((notificationSocket) => { - const scopes = scope instanceof Array ? scope : [scope]; - scopes.forEach(s => { - const callbacks = subscriptions[s]; - const index = callbacks && callbacks.indexOf(callback); - if (index > -1) { - callbacks.splice(index, 1); - } - if (callbacks.length === 0) { - subscriptions[s] === undefined; - } - }); - - // send a subscription to all active scopes - const scopesToSubscribe = Object.keys(subscriptions); - if (notificationSocket.readyState === notificationSocket.OPEN) { - const data = { - 'data': 'scopes', - 'scopes': scopesToSubscribe - }; - notificationSocket.send(JSON.stringify(data)); - return true; - } - return false; - }); -} - -export const startNotificationService = (store: ApplicationStore) => { - applicationStore = store; -} - -const connect = (): Promise => { - return new Promise((resolve, reject) => { - const notificationSocket = new WebSocket(socketUrl); - - notificationSocket.onmessage = (event) => { - // process received event - if (typeof event.data === 'string') { - const formated = formatData(event); - if (formated && formated.notifType) { - const callbacks = subscriptions[formated.notifType]; - if (callbacks) { - callbacks.forEach(cb => { - // ensure all callbacks will be called - try { - return cb(formated); - } catch (reason) { - console.error(reason); - } - }); - } - } - } - }; - - notificationSocket.onerror = function (error) { - console.log("Socket error:"); - console.log(error); - reject("Socket error: " + error); - if (applicationStore) { - applicationStore.dispatch(new SetWebsocketAction(false)); - } - }; - - notificationSocket.onopen = function (event) { - if (applicationStore) { - applicationStore.dispatch(new SetWebsocketAction(true)); - } - console.log("Socket connection opened."); - resolve(notificationSocket); - - // send a subscription to all active scopes - const scopesToSubscribe = Object.keys(subscriptions); - if (notificationSocket.readyState === notificationSocket.OPEN) { - const data = { - 'data': 'scopes', - 'scopes': scopesToSubscribe - }; - notificationSocket.send(JSON.stringify(data)); - }; - }; - - notificationSocket.onclose = function (event) { - console.log("socket connection closed"); - if (applicationStore) { - applicationStore.dispatch(new SetWebsocketAction(false)); - } - if (!userLoggedOut) { - socketReady = connect(); - } - }; - }); -} - - - - -export const startWebsocketSession = () => { - socketReady = connect(); - userLoggedOut = false; -} - -export const endWebsocketSession = () => { - if (socketReady) { - socketReady.then(websocket => { - websocket.close(); - userLoggedOut = true; - }); - } - -} - - - - +/** + * ============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 X2JS from 'x2js'; +import { ApplicationStore } from '../store/applicationStore'; +import { SetWebsocketAction } from '../actions/websocketAction'; + +const socketUrl = [location.protocol === 'https:' ? 'wss://' : 'ws://', 'admin', ':', 'admin', '@', location.hostname, ':', location.port, '/websocket'].join(''); +const subscriptions: { [scope: string]: SubscriptionCallback[] } = {}; +let socketReady: Promise; +let userLoggedOut = false; +let wasWebsocketConnectionEstablished: undefined | boolean; +let applicationStore: ApplicationStore | null; + + +export interface IFormatedMessage { + notifType: string | null; + time: string; +} + +export type SubscriptionCallback = (msg: TMessage) => void; + +function formatData(event: MessageEvent): IFormatedMessage | undefined { + + var x2js = new X2JS(); + var jsonObj: { [key: string]: IFormatedMessage } = x2js.xml2js(event.data); + if (jsonObj && typeof (jsonObj) === 'object') { + + const notifType = Object.keys(jsonObj)[0]; + const formated = jsonObj[notifType]; + formated.notifType = notifType; + formated.time = new Date().toISOString(); + return formated; + } + return undefined; + +} + +export function subscribe(scope: string | string[], callback: SubscriptionCallback): boolean { + const scopes = scope instanceof Array ? scope : [scope]; + + // send all new scopes to subscribe + const newScopesToSubscribe: string[] = scopes.reduce((acc: string[], cur: string) => { + const currentCallbacks = subscriptions[cur]; + if (currentCallbacks) { + if (!currentCallbacks.some(c => c === callback)) { + currentCallbacks.push(callback); + } + } else { + subscriptions[cur] = [callback]; + acc.push(cur); + } + return acc; + }, []); + + if (newScopesToSubscribe.length === 0) { + return true; + } + + return true; +} + + +export function unsubscribe(scope: string | string[], callback: SubscriptionCallback): Promise { + return socketReady.then((notificationSocket) => { + const scopes = scope instanceof Array ? scope : [scope]; + scopes.forEach(s => { + const callbacks = subscriptions[s]; + const index = callbacks && callbacks.indexOf(callback); + if (index > -1) { + callbacks.splice(index, 1); + } + if (callbacks.length === 0) { + subscriptions[s] === undefined; + } + }); + + // send a subscription to all active scopes + const scopesToSubscribe = Object.keys(subscriptions); + if (notificationSocket.readyState === notificationSocket.OPEN) { + const data = { + 'data': 'scopes', + 'scopes': scopesToSubscribe + }; + notificationSocket.send(JSON.stringify(data)); + return true; + } + return false; + }); +} + +export const startNotificationService = (store: ApplicationStore) => { + applicationStore = store; +} + +const connect = (): Promise => { + return new Promise((resolve, reject) => { + const notificationSocket = new WebSocket(socketUrl); + + notificationSocket.onmessage = (event) => { + // process received event + if (typeof event.data === 'string') { + const formated = formatData(event); + if (formated && formated.notifType) { + const callbacks = subscriptions[formated.notifType]; + if (callbacks) { + callbacks.forEach(cb => { + // ensure all callbacks will be called + try { + return cb(formated); + } catch (reason) { + console.error(reason); + } + }); + } + } + } + }; + + notificationSocket.onerror = function (error) { + console.log("Socket error:"); + console.log(error); + reject("Socket error: " + error); + if (applicationStore) { + applicationStore.dispatch(new SetWebsocketAction(false)); + } + }; + + notificationSocket.onopen = function (event) { + if (applicationStore) { + applicationStore.dispatch(new SetWebsocketAction(true)); + } + console.log("Socket connection opened."); + resolve(notificationSocket); + + // send a subscription to all active scopes + const scopesToSubscribe = Object.keys(subscriptions); + if (notificationSocket.readyState === notificationSocket.OPEN) { + const data = { + 'data': 'scopes', + 'scopes': scopesToSubscribe + }; + notificationSocket.send(JSON.stringify(data)); + }; + }; + + notificationSocket.onclose = function (event) { + console.log("socket connection closed"); + if (applicationStore) { + applicationStore.dispatch(new SetWebsocketAction(false)); + } + if (!userLoggedOut) { + socketReady = connect(); + } + }; + }); +} + + + + +export const startWebsocketSession = () => { + socketReady = connect(); + userLoggedOut = false; +} + +export const endWebsocketSession = () => { + if (socketReady) { + socketReady.then(websocket => { + websocket.close(); + userLoggedOut = true; + }); + } + +} + + + + diff --git a/sdnr/wt/odlux/framework/src/views/about.tsx b/sdnr/wt/odlux/framework/src/views/about.tsx index c4a5488e0..f97d6ffb3 100644 --- a/sdnr/wt/odlux/framework/src/views/about.tsx +++ b/sdnr/wt/odlux/framework/src/views/about.tsx @@ -40,11 +40,23 @@ class AboutComponent extends React.Component { this.textarea = React.createRef(); this.loadAboutContent(); } + private getMarkOdluxVersionMarkdownTable(data:{version:string,build:string}|null|undefined):string{ + if(!data) { + return ""; + } + return `| | |\n| --- | --- |\n| Version | ${data.version} |\n| Build timestamp | ${data.build}|` + } private loadAboutContent(): void { - requestRestExt('/about').then((response) => { + const baseUri = window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/")+1); + const p1 = requestRestExt('/about'); + const p2 = requestRestExt<{version:string,build:string}>(`${baseUri}version.json`); + Promise.all([p1,p2]).then((responses) => { + const response = responses[0]; + const response2 = responses[1]; const content = response.status == 200 ? response.data : `${response.status} ${response.message}` || "Server error"; + const content2 = `\n## ODLUX Version Info\n`+(response2.status == 200 ? this.getMarkOdluxVersionMarkdownTable(response2.data) : `${response2.status} ${response2.message}` || "ODLUX Server error"); const loadedSucessfully = response.status == 200 ? true : false; - this.setState({ content: content || null, isContentLoadedSucessfully: loadedSucessfully }); + this.setState({ content: (content + content2) || null, isContentLoadedSucessfully: loadedSucessfully }); }).catch((error) => { this.setState({ content: error }) }) diff --git a/sdnr/wt/odlux/framework/src/views/login.tsx b/sdnr/wt/odlux/framework/src/views/login.tsx index 30b9c85a2..b06cf7631 100644 --- a/sdnr/wt/odlux/framework/src/views/login.tsx +++ b/sdnr/wt/odlux/framework/src/views/login.tsx @@ -142,6 +142,7 @@ class LoginComponent extends React.Component { label="Remember me" />