From 1a868116614dd9996c78e69941b537e9da19460b Mon Sep 17 00:00:00 2001 From: Aijana Schumann Date: Tue, 1 Feb 2022 13:18:42 +0100 Subject: Update ODLUX Updated to Material-ui 5, updated dashboard view, removed NetworkMap, LinkCalculator and LineOfSightApp, small bugfixes Issue-ID: CCSDK-3580 Signed-off-by: Aijana Schumann Change-Id: Id0fc148673e23a755cafc2be1c489248c38ff47c --- .../src/components/customize/customizationView.tsx | 291 --------- .../src/components/customize/themeElement.tsx | 47 -- .../networkMapApp/src/components/denseTable.tsx | 139 ---- .../src/components/details/details.tsx | 204 ------ .../src/components/details/linkDetails.tsx | 130 ---- .../src/components/details/siteDetails.tsx | 248 -------- .../src/components/details/stadokDetailsPopup.tsx | 274 -------- .../src/components/map/connectionInfo.tsx | 59 -- .../src/components/map/iconSwitch.tsx | 53 -- .../apps/networkMapApp/src/components/map/map.tsx | 697 --------------------- .../networkMapApp/src/components/map/mapPopup.tsx | 94 --- .../networkMapApp/src/components/map/searchBar.tsx | 161 ----- .../src/components/map/statistics.tsx | 57 -- 13 files changed, 2454 deletions(-) delete mode 100644 sdnr/wt/odlux/apps/networkMapApp/src/components/customize/customizationView.tsx delete mode 100644 sdnr/wt/odlux/apps/networkMapApp/src/components/customize/themeElement.tsx delete mode 100644 sdnr/wt/odlux/apps/networkMapApp/src/components/denseTable.tsx delete mode 100644 sdnr/wt/odlux/apps/networkMapApp/src/components/details/details.tsx delete mode 100644 sdnr/wt/odlux/apps/networkMapApp/src/components/details/linkDetails.tsx delete mode 100644 sdnr/wt/odlux/apps/networkMapApp/src/components/details/siteDetails.tsx delete mode 100644 sdnr/wt/odlux/apps/networkMapApp/src/components/details/stadokDetailsPopup.tsx delete mode 100644 sdnr/wt/odlux/apps/networkMapApp/src/components/map/connectionInfo.tsx delete mode 100644 sdnr/wt/odlux/apps/networkMapApp/src/components/map/iconSwitch.tsx delete mode 100644 sdnr/wt/odlux/apps/networkMapApp/src/components/map/map.tsx delete mode 100644 sdnr/wt/odlux/apps/networkMapApp/src/components/map/mapPopup.tsx delete mode 100644 sdnr/wt/odlux/apps/networkMapApp/src/components/map/searchBar.tsx delete mode 100644 sdnr/wt/odlux/apps/networkMapApp/src/components/map/statistics.tsx (limited to 'sdnr/wt/odlux/apps/networkMapApp/src/components') diff --git a/sdnr/wt/odlux/apps/networkMapApp/src/components/customize/customizationView.tsx b/sdnr/wt/odlux/apps/networkMapApp/src/components/customize/customizationView.tsx deleted file mode 100644 index 82e7b795b..000000000 --- a/sdnr/wt/odlux/apps/networkMapApp/src/components/customize/customizationView.tsx +++ /dev/null @@ -1,291 +0,0 @@ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2021 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 { Button, Grid, InputLabel, makeStyles, MenuItem, Select, Slider, TextField, Typography } from '@material-ui/core'; -import { NetworkMapSettings, ThemeElement } from '../../model/settings'; -import * as React from 'react' -import connect, { Connect, IDispatcher } from '../../../../../framework/src/flux/connect'; -import { IApplicationStoreState } from '../../../../../framework/src/store/applicationStore'; -import { updateSettings } from '../../actions/settingsAction'; -import ThemeEntry from './themeElement' -import * as mapboxgl from 'mapbox-gl'; -import { OSM_STYLE } from '../../config'; -import mapLayerService from '../../utils/mapLayers'; -import { requestRest } from '../../../../../framework/src/services/restService'; -import { NavigateToApplication } from '../../../../../framework/src/actions/navigationActions'; - -type props = Connect; -let map: mapboxgl.Map; -let myMapRef = React.createRef(); -const default_boundingbox = "12.882544785787754,52.21421979821472,13.775455214211949,52.80406241672602"; - - -const mapProps = (state: IApplicationStoreState) => ({ - settings: state.network.settings, -}); - -const mapDispatch = (dispatcher: IDispatcher) => ({ - updateSettings: (mapSettings: NetworkMapSettings) => dispatcher.dispatch(updateSettings(mapSettings)), - navigateToApplication: (applicationName: string) => dispatcher.dispatch(new NavigateToApplication(applicationName)), - - -}); - -const styles = makeStyles({ - sectionMargin: { - marginTop: "30px", - marginBottom: "15px" - }, - elementMargin: { - - marginLeft: "10px" - } -}); - -const CustomizationView: React.FunctionComponent = (props) => { - - const [opacity, setOpacity] = React.useState(Number(props.settings.mapSettings?.networkMap.tileOpacity) || 100); - const [theme, setTheme] = React.useState(props.settings.mapSettings?.networkMap.styling.theme || ''); - const [latitude, setLatitude] = React.useState(Number(props.settings.mapSettings?.networkMap.startupPosition.latitude)|| 52.5); - const [longitude, setLongitude] = React.useState(Number(props.settings.mapSettings?.networkMap.startupPosition.longitude)|| 13.35); - const [zoom, setZoom] = React.useState(Number(props.settings.mapSettings?.networkMap.startupPosition.zoom) || 10); - - - //used to make opacity available within the map event-listeners - //(hook state values are snapshotted at initalization and not updated afterwards, thus use a ref here) - const myOpacityRef = React.useRef(opacity); - const setOpacityState = (data:any) => { - myOpacityRef.current = data; - setOpacity(data); - }; - - const classes = styles(); - const currentTheme = props.settings.themes.networkMapThemes.themes.find(el => el.key === theme); - - - React.useEffect(() => { - mapLayerService.settings = props.settings.themes; - - map = new mapboxgl.Map({ - container: myMapRef.current!, - style: OSM_STYLE as any, - center: [longitude, latitude], - zoom: zoom, - accessToken: '' - }); - - map.on('load', (ev) => { - - mapLayerService.addBaseSources(map, null, null); - if(props.settings.mapSettings?.networkMap.styling.theme !== theme){ - mapLayerService.addBaseLayers(map, currentTheme); - - }else{ - mapLayerService.addBaseLayers(map); - } - - mapLayerService.changeMapOpacity(map, myOpacityRef.current); - - getData(); - }); - - map.on('moveend', () => { - const center = map.getCenter(); - setZoom(Number(map.getZoom().toFixed(4))); - setLatitude(Number(center.lat.toFixed(4))); - setLongitude(Number(center.lng.toFixed(4))); - }); - - }, []); - - React.useEffect(() => { - recenterMap(); - }, [latitude, longitude, zoom]); - - const setState = () => { - if (props.settings.mapSettings?.networkMap.styling) { - setTheme(props.settings.mapSettings.networkMap.styling.theme); - mapLayerService.changeTheme(map, props.settings.mapSettings.networkMap.styling.theme); - } - - const propOpacity = props.settings.mapSettings?.networkMap.tileOpacity; - if (propOpacity) { - setOpacityState(propOpacity); - } - } - - React.useEffect(() => { - setState(); - }, [props.settings.mapSettings]); - - const onOpacityChange = (event: React.ChangeEvent, newValue: number) => { - setOpacity(newValue); - mapLayerService.changeMapOpacity(map, newValue); - - }; - - const onChangeTheme = (e: any) => { - - const newTheme = e.target.value; - setTheme(newTheme); - mapLayerService.changeTheme(map, newTheme); - } - - const onCancel = (e: React.MouseEvent) => { - e.preventDefault(); - props.navigateToApplication("network"); - } - - const onSaveSettings = async (e: React.MouseEvent) => { - e.preventDefault(); - - const updatedSettings: NetworkMapSettings = { - networkMap: { - tileOpacity: opacity.toString(), - styling: { theme: theme }, - startupPosition: { - latitude: latitude.toString(), - longitude: longitude.toString(), - zoom: zoom.toString() - } - } - }; - - console.log(updatedSettings); - - await props.updateSettings(updatedSettings) - props.navigateToApplication("network"); - - } - - const recenterMap = () => { - - if (!isNaN(latitude) && !isNaN(longitude) && !isNaN(zoom)) - - map.flyTo({ - center: [ - longitude, - latitude - ], zoom: zoom, - essential: false - }); - } - - - - const getData = () => { - - //get data of boundingbox from networkmap - - const links = requestRest("/topology/network/links/geojson/" + default_boundingbox); - const sites = requestRest("/topology/network/sites/geojson/" + default_boundingbox); - - Promise.all([links, sites]).then(results => { - if (map.getSource('lines')) { - (map.getSource('lines') as mapboxgl.GeoJSONSource).setData(results[0]); - } - - if (map.getSource('points')) { - (map.getSource('points') as mapboxgl.GeoJSONSource).setData(results[1]); - } - - if (map.getSource('selectedPoints')) { - (map.getSource('selectedPoints') as mapboxgl.GeoJSONSource).setData(results[1].features[0]); - } - }); - } - - /** - * Style property names to readable text - * @param text propretyName - * @returns readable text - */ - const styleText = (text: string) => { - const textParts = text.split(/(?=[A-Z])/); //split on uppercase character - const newText = textParts.join(" "); - return newText.charAt(0).toUpperCase() + newText.slice(1); - } - - - return (<> -

Settings

-
-
- Startup Position -
- setLatitude(e.target.value as any)} style={{ marginLeft: 10 }} label="Latitude" /> - setLongitude(e.target.value as any)} style={{ marginLeft: 5 }} label="Longitude" /> - setZoom(e.target.value as any)} style={{ marginLeft: 5 }} label="Zoom" /> -
- - - Tile Opacity - - - 0 - - - - 100 - - - - Style of properties - - Theme - - - { - currentTheme &&
- { //skip the 'key' (theme name) entry - Object.keys(currentTheme).slice(1).map(el => ) - } -
- } - - -
- - - -
-
-
- -
-
- - ) - -} - -export default connect(mapProps, mapDispatch)(CustomizationView); - - diff --git a/sdnr/wt/odlux/apps/networkMapApp/src/components/customize/themeElement.tsx b/sdnr/wt/odlux/apps/networkMapApp/src/components/customize/themeElement.tsx deleted file mode 100644 index c991aaf63..000000000 --- a/sdnr/wt/odlux/apps/networkMapApp/src/components/customize/themeElement.tsx +++ /dev/null @@ -1,47 +0,0 @@ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2021 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 { Typography } from '@material-ui/core'; -import * as React from 'react' - - -type props={ - color: string, - text: string -}; - -const ThemeEntry = (props: props) =>{ - - var circleStyle = { - padding:10, - margin:20, - backgroundColor: props.color, - borderRadius: "50%", - width:10, - height:10, - left:0, - top:0}; - - return
-
- {props.text} -
- -} - -export default ThemeEntry; \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/networkMapApp/src/components/denseTable.tsx b/sdnr/wt/odlux/apps/networkMapApp/src/components/denseTable.tsx deleted file mode 100644 index e04fda547..000000000 --- a/sdnr/wt/odlux/apps/networkMapApp/src/components/denseTable.tsx +++ /dev/null @@ -1,139 +0,0 @@ -/** - * ============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[], - height: number, - navigate?(applicationName: string, path?: string): void, - onLinkClick?(id: string): void, data: any[], - hover: boolean, - ariaLabelRow: string, - ariaLabelColumn?: string[], - verticalTable?: 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 values = Object.keys(row).map(function (e) { return row[e]; }); - return ( - handleHover(e, row.name)} onClick={e => handleClick(e, row.name)}> - - { - values.map((data: any, i) => { - if (data !== undefined) { - - if (!props.verticalTable) { - const ariaLabel = props.ariaLabelColumn === undefined ? props.headers[i].toLowerCase() : props.ariaLabelColumn[i]; - if (ariaLabel.length > 0) { - return {data} - } else { - return {data} - } - } - else { - // skip adding aria label to 'header' column - if (i === 0) { - return {data} - } else { - const ariaLabel = props.ariaLabelColumn === undefined ? props.headers[index].toLowerCase() : props.ariaLabelColumn[index]; - return {data} - } - } - } - else - return null; - }) - } - { - - props.actions && -
- - - - - - -
-
- } -
) - }) - } - -
-
-
-
- ); - -} - -export default DenseTable; \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/networkMapApp/src/components/details/details.tsx b/sdnr/wt/odlux/apps/networkMapApp/src/components/details/details.tsx deleted file mode 100644 index 2540b20a7..000000000 --- a/sdnr/wt/odlux/apps/networkMapApp/src/components/details/details.tsx +++ /dev/null @@ -1,204 +0,0 @@ -/** - * ============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, { IDispatcher, Connect } from '../../../../../framework/src/flux/connect'; - -import { Site, Device } from '../../model/site'; -import Typography from '@material-ui/core/Typography'; -import { link } from '../../model/link'; -import { Breadcrumbs, Link, Paper } from '@material-ui/core'; -import SiteDetails from './siteDetails'; -import LinkDetails from './linkDetails'; -import { URL_API, URL_BASEPATH } from '../../config'; -import { SelectSiteAction, SelectLinkAction, AddToHistoryAction, ClearHistoryAction, CheckDeviceList, ClearDetailsAction } from '../../actions/detailsAction'; -import { HistoryEntry } from '../../model/historyEntry'; -import { HighlightLinkAction, HighlightSiteAction, RemoveHighlightingAction } from '../../actions/mapActions'; -import { isSite } from '../../utils/utils'; -import { IApplicationStoreState } from '../../../../../framework/src/store/applicationStore'; -import { NavigateToApplication } from '../../../../../framework/src/actions/navigationActions'; -import { RouteComponentProps, withRouter } from 'react-router-dom'; - - -const Details: React.FunctionComponent = (props) => { - - const [message, setMessage] = React.useState("No data selected."); - - - //on mount - React.useEffect(() => { - const detailsId = getDetailsIdFromUrl(); - if (detailsId !== null && props.data?.name !== detailsId) { - loadDetailsData(detailsId) - } - - }, []); - - // if url changed, load details data - React.useEffect(() => { - const detailsId = getDetailsIdFromUrl(); - if (detailsId !== null && props.data?.name !== detailsId) { - loadDetailsData(detailsId) - } - else if(detailsId===null){ - setMessage("No data selected."); - props.clearDetails(); - props.undoMapSelection(); - } - - }, [props.location.pathname]); - - //update url if new element loaded - React.useEffect(() => { - if (props.data !== null) { - const currentUrl = window.location.href; - const parts = currentUrl.split(URL_BASEPATH); - const detailsPath = parts[1].split("/details/"); - props.history.replace(`/${URL_BASEPATH}${detailsPath[0]}/details/${props.data.name}`) - } - - }, [props.data]) - - const onLinkClick = async (id: string) => { - const result = await fetch(`${URL_API}/links/${id}`); - if(result.ok){ - const resultAsJson = await result.json(); - const link = resultAsJson as link; - props.selectLink(link); - props.addHistory({ id: props.data!.name, data: props.data! }); - props.highlightLink(link); - - } - } - - const backClick = (e: any) => { - if (isSite(props.breadcrumbs[0].data)) { - props.selectSite(props.breadcrumbs[0].data) - props.highlightSite(props.breadcrumbs[0].data); - - } else { - props.selectLink(props.breadcrumbs[0].data); - props.highlightLink(props.breadcrumbs[0].data); - - } - - props.clearHistory(); - e.preventDefault(); - } - - const createDetailPanel = (data: Site | link) => { - if (isSite(data)) { - return - } else { - return - } - } - - const getDetailsIdFromUrl = () =>{ - const currentUrl = window.location.href; - const parts = currentUrl.split(URL_BASEPATH); - const detailsPath = parts[1].split("/details/") - return detailsPath[1] ? detailsPath[1] : null; - } - - const loadDetailsData = (id: string) =>{ - - fetch(`${URL_API}/links/${id}`) - .then(res => { - if (res.ok) - return res.json() - else - return Promise.reject() - - }) - .then(result => { - props.selectLink(result) - props.highlightLink(result); - - }) - .catch(error => { - - fetch(`${URL_API}/sites/name/${id}`) - .then(res => { - if (res.ok) - return res.json() - else return Promise.reject(); - }) - .then(result => { - props.selectSite(result); - props.highlightSite(result); - }) - .catch(error =>{ - setMessage("No element with name " + id + " found"); - props.clearDetails(); - props.undoMapSelection(); - }); - }) - } - - const panelId = props.data!== null ? (isSite(props.data) ? 'site-details-panel' : 'link-details-panel' ): 'details-panel'; - - return (
- - { - props.breadcrumbs.length > 0 && - - - {props.breadcrumbs[0].id} - - - {props.data?.name} - - - } - { - props.data !== null ? - createDetailPanel(props.data) - : {message} - - } - -
) -} - -type porps = RouteComponentProps & Connect; - -//select always via details? -const mapStateToProps = (state: IApplicationStoreState) => ({ - data: state.network.details?.data, - breadcrumbs: state.network.details.history, - updatedDevices: state.network.details.checkedDevices -}); - -const mapDispatchToProps = (dispatcher: IDispatcher) => ({ - selectSite: (site: Site) => dispatcher.dispatch(new SelectSiteAction(site)), - selectLink: (link: link) => dispatcher.dispatch(new SelectLinkAction(link)), - clearDetails: () => dispatcher.dispatch(new ClearDetailsAction()), - addHistory: (newEntry: HistoryEntry) => dispatcher.dispatch(new AddToHistoryAction(newEntry)), - clearHistory: () => dispatcher.dispatch(new ClearHistoryAction()), - highlightLink: (link: link) => dispatcher.dispatch(new HighlightLinkAction(link)), - highlightSite: (site: Site) => dispatcher.dispatch(new HighlightSiteAction(site)), - loadDevices: async (networkElements: Device[]) => { await dispatcher.dispatch(CheckDeviceList(networkElements)) }, - navigateToApplication: (applicationName: string, path?: string) => dispatcher.dispatch(new NavigateToApplication(applicationName, path, "test3")), - undoMapSelection: () => dispatcher.dispatch(new RemoveHighlightingAction()) - -}) - - -export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Details)); \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/networkMapApp/src/components/details/linkDetails.tsx b/sdnr/wt/odlux/apps/networkMapApp/src/components/details/linkDetails.tsx deleted file mode 100644 index 96727cc0d..000000000 --- a/sdnr/wt/odlux/apps/networkMapApp/src/components/details/linkDetails.tsx +++ /dev/null @@ -1,130 +0,0 @@ -/** - * ============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 { link } from '../../model/link'; -import { TextField, Tabs, Tab, Typography, AppBar, Button, Link } from '@material-ui/core'; -import DenseTable from '../denseTable'; -import { LatLonToDMS } from '../../utils/mapUtils'; - -type panelId = "siteA" | "siteB"; -type props = { link: link }; - -const LinkDetails: React.FunctionComponent = (props) => { - - const [value, setValue] = React.useState("siteA"); - const [height, setHeight] = React.useState(330); - - const handleResize = () =>{ - const el = document.getElementById('link-details-panel')?.getBoundingClientRect(); - const el2 = document.getElementById('site-tabs')?.getBoundingClientRect(); - - if(el && el2){ - if(props.link.type==="microwave") - setHeight(el!.height - el2!.y -50); - else - setHeight(el!.height - el2!.y +20); - - } - } - - //on mount - React.useEffect(()=>{ - handleResize(); - - //window.addEventListener("resize", handleResize); - },[]); - - React.useEffect(()=>{ - handleResize(); - }, [props.link]) - - const onHandleTabChange = (event: React.ChangeEvent<{}>, newValue: panelId) => { - setValue(newValue); - } - - const onCalculateLinkClick = (e: React.MouseEvent) =>{ - e.preventDefault(); - const siteA= props.link.locationA; - const siteB =props.link.locationB; - const nameA = props.link.siteA; - const nameB = props.link.siteB; - const distance = props.link.length > 0 ? props.link.length : props.link.calculatedLength; - const azimuthA = props.link.azimuthA; - const azimuthB = props.link.azimuthB; - const antennaA = props.link.locationA.antenna; - const antennaB = props.link.locationB.antenna; - - - let antennaData = ""; - if(antennaA!==null && antennaB!==null){ - antennaData = `&antennaNameA=${antennaA.name}&antennaGainA=${antennaA.gain}&waveguideLossA=${antennaA.waveguideLossIndB}&antennaNameB=${antennaB.name}&antennaGainB=${antennaB.gain}&waveguideLossB=${antennaB.waveguideLossIndB}`; - } - - - - const baseUrl = window.location.pathname.split('#')[0]; - window.open(`${baseUrl}#/linkCalculation?lat1=${siteA.lat}&lon1=${siteA.lon}&lat2=${siteB.lat}&lon2=${siteB.lon}&siteA=${nameA}&siteB=${nameB}&azimuthA=${azimuthA}&azimuthB=${azimuthB}&distance=${distance}&amslSiteA=${siteA.amsl}&AGLsiteA=${siteA.antennaHeight}&amslSiteB=${siteB.amsl}&AGLsiteB=${siteB.antennaHeight}${antennaData}`) - - } - - const onLineofSightClick = (e: React.MouseEvent) =>{ - e.preventDefault(); - - const siteA= props.link.locationA; - const siteB =props.link.locationB; - - //TODO: add check if available - let heightPart = `&amslA=${siteA.amsl}&antennaHeightA=${siteA.antennaHeight}&amslB=${siteB.amsl}&antennaHeightB=${siteB.antennaHeight}`; - - - const baseUrl = window.location.pathname.split('#')[0]; - window.open(`${baseUrl}#/lineofsight/los?lat1=${siteA.lat}&lon1=${siteA.lon}&lat2=${siteB.lat}&lon2=${siteB.lon}${heightPart}`); - } - - const data = [ - - {name:"Site Name", val1: props.link.siteA, val2: props.link.siteB}, - {name:"Latitude", val1: LatLonToDMS(props.link.locationA.lat), val2: LatLonToDMS(props.link.locationB.lat)}, - {name:"Longitude", val1: LatLonToDMS(props.link.locationA.lon, true), val2: LatLonToDMS(props.link.locationB.lon, true)}, - props.link.azimuthA!= null && props.link.azimuthB != null && {name:"Azimuth in °", val1: props.link.azimuthA.toFixed(2), val2: props.link.azimuthB.toFixed(2)} -]; - - return (
-

{props.link.name}

- - - - - - - SITE DETAILS - - - { - props.link.type==="microwave" &&<> - - - - - } -
) -} - -export default LinkDetails; \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/networkMapApp/src/components/details/siteDetails.tsx b/sdnr/wt/odlux/apps/networkMapApp/src/components/details/siteDetails.tsx deleted file mode 100644 index 7f0c1c926..000000000 --- a/sdnr/wt/odlux/apps/networkMapApp/src/components/details/siteDetails.tsx +++ /dev/null @@ -1,248 +0,0 @@ -/** - * ============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 { TextField, Tabs, Tab, Typography, AppBar, Button, Tooltip } from '@material-ui/core'; - - -import MaterialTable, { ColumnModel, ColumnType, MaterialTableCtorType } from "../../../../../framework/src/components/material-table"; - - -import { Site, Device, Address } from '../../model/site'; -import DenseTable from '../denseTable'; -import { LatLonToDMS } from '../../utils/mapUtils'; -import { CheckDeviceList, InitializeLoadedDevicesAction } from '../../actions/detailsAction'; -import { NavigateToApplication } from '../../../../../framework/src/actions/navigationActions'; -import connect, { Connect, IDispatcher } from '../../../../../framework/src/flux/connect'; -import { IApplicationStoreState } from '../../../../../framework/src/store/applicationStore'; -import StadokSite from '../../model/stadokSite'; -import { requestRest } from '../../../../../framework/src/services/restService'; -import StadokDetailsPopup from './stadokDetailsPopup'; - -type linkRow = { name: string, azimuth?: string} -type deviceRow = { id: string;type: string,name: string,manufacturer: string,owner: string,status?: string,port: number[]} - - -type panelId="links" | "nodes"; -type siteDetailProps = { - site: Site, - onLinkClick(id: string): void, -} & props; - -type props = Connect; - - -const SiteDetails: React.FunctionComponent = (props) => { - - const [value, setValue] = React.useState("links"); - const [height, setHeight] = React.useState(330); - const [openPopup, setOpenPopup] = React.useState(false); - const [staSite, setStaSite] = React.useState(null); - - const handleResize = () =>{ - const el = document.getElementById('site-details-panel')?.getBoundingClientRect(); - const el2 = document.getElementById('site-tabs')?.getBoundingClientRect(); - - if(el && el2){ - setHeight(el!.height - el2!.y +20); - } - - } - - //on mount - React.useEffect(()=>{ - handleResize(); - - window.addEventListener("resize", ()=>{console.log("really got resized.")}); - },[]); - - // on update - React.useEffect(()=>{ - - if(props.site.devices!== null && props.site.devices.length>0){ - props.initializeDevices(props.site.devices); - props.loadDevices(props.site.devices); - } - - handleResize(); - - }, [props.site]); - - const onHandleTabChange = (event: React.ChangeEvent<{}>, newValue: panelId) => { - setValue(newValue); - } - - const getFurtherInformation = (url: string) =>{ - - const request = requestRest(url, { method: "GET"}); - - request.then(result =>{ - if(result){ - setStaSite(result); - setOpenPopup(true); - }else{ - console.error(result); - } - - - }); - } - - const closePopup = () =>{ - setOpenPopup(false); - } - - //prepare link table - - let hasAzimuth = false; - const linkRows: linkRow[] = props.site.links?.map(link=> - { - if(link.azimuthB!==null){ - hasAzimuth=true; - return {name: link.name, azimuth: link.azimuthB.toFixed(2) } - - }else{ - return {name: link.name } - } - }); - - const linkTableHeader = hasAzimuth ? ["Link Name", "Azimuth in °"] : ["Link Name"]; - - //prepare device table - const deviceRows : deviceRow[] = props.updatedDevices?.map(device=>{ - return{ - id: device.id, - name: device.name, - type: device.type, - status: device.status, - manufacturer: device.manufacturer, - owner: device.owner, - port: device.port - } - }); - - - const adressString = props.site.address == null ? null : buildAdress(props.site.address); - - - return (
-

{props.site.name}

- { - props.site.operator !== '' && props.site.operator !== null ? - : - - } - { - props.site.type !== undefined && props.site.type.length > 0 && - - } - { - adressString !== null && - - } - { - props.site.heightAmslInMeters !== undefined && props.site.heightAmslInMeters > 0 && - - } - { - props.site.antennaHeightAmslInMeters !== undefined && props.site.antennaHeightAmslInMeters > 0 && - - } - - - - - - - - - - - { - value === "links" && - <> - { - props.site.links==null && - No links available. - } - - { - props.site.links?.length > 0 && - - } - - - - } - { - value === "nodes" && - <> - { - props.site.devices === null && - No nodes available. - } - - { - props.site.devices?.length>0 && props.updatedDevices !== null && - - } - - } - { - props.isSitedocReachable && props.site.furtherInformation!==null && props.site.furtherInformation.length>0 && - - } - - { - staSite !== null && openPopup && - } - -
- ) -} - -const buildAdress = (adress: Address) =>{ - - switch(adress.country){ - case "de": - return `${adress.streetAndNr}, ${adress.zipCode!== null? adress.zipCode : ''} ${adress.city}` - - case "us": - return `${adress.streetAndNr}, ${adress.city} ${adress.zipCode!== null? adress.zipCode : ''}` - - default: - console.log("address formatting for country {"+adress.country+"} not recognized, defaulting."); - return `${adress.streetAndNr}, ${adress.zipCode!== null? adress.zipCode : ''} ${adress.city}` - } - - -} - -const mapStateToProps = (state: IApplicationStoreState) => ({ - updatedDevices: state.network.details.checkedDevices, - isSitedocReachable: state.network.details.isSitedocReachable -}); - -const mapDispatchToProps = (dispatcher: IDispatcher) => ({ - initializeDevices: (devices: Device[]) => {dispatcher.dispatch(new InitializeLoadedDevicesAction(devices))}, - loadDevices: async (networkElements: Device[]) => { await dispatcher.dispatch(CheckDeviceList(networkElements)) }, - navigateToApplication: (applicationName: string, path?: string) => dispatcher.dispatch(new NavigateToApplication(applicationName, path, "test3")), - -}) - -export default connect(mapStateToProps, mapDispatchToProps)(SiteDetails); \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/networkMapApp/src/components/details/stadokDetailsPopup.tsx b/sdnr/wt/odlux/apps/networkMapApp/src/components/details/stadokDetailsPopup.tsx deleted file mode 100644 index 4f3235db7..000000000 --- a/sdnr/wt/odlux/apps/networkMapApp/src/components/details/stadokDetailsPopup.tsx +++ /dev/null @@ -1,274 +0,0 @@ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2021 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 MuiDialogTitle from '@material-ui/core/DialogTitle'; -import { AppBar, Dialog, DialogContent, IconButton, Tab, Tabs, TextField, Typography } from '@material-ui/core'; -import CloseIcon from '@material-ui/icons/Close'; -import { withStyles, WithStyles, createStyles, Theme, makeStyles } from '@material-ui/core/styles'; - - -import StadokSite from '../../model/stadokSite'; -import { LatLonToDMS } from '../../utils/mapUtils'; -import DenseTable from '../../components/denseTable'; -import { requestRest } from '../../../../../framework/src/services/restService'; -import { OrderToDisplay, StadokOrder } from '../../model/stadokOrder'; -import { CSSProperties } from '@material-ui/core/styles/withStyles'; -import { SITEDOC_URL } from '../../config'; - - -type props = { site: StadokSite; onClose(): void; open:boolean }; - -const styles = (theme: Theme) => createStyles({ - root: { - margin: 0, - padding: theme.spacing(2), - }, - closeButton: { - position: 'absolute', - right: theme.spacing(1), - top: theme.spacing(1), - color: theme.palette.grey[500], - }, -}); - -const useStyles = makeStyles({ - largeImage:{cursor:'pointer', width:300}, - smallImage:{cursor:'pointer', width: 50, marginTop:'10px', marginLeft:'10px'} -}); - -const StadokDetailsPopup: React.FunctionComponent = (props) => { - const classes = useStyles(); - - const [open, setOpen] = React.useState(props.open); - const [value, setValue] = React.useState("devices"); - const [orders, setOrders] = React.useState(null); - - const DialogTitle = withStyles(styles)((props: any) => { - const { children, classes, onClose, ...other } = props; - return ( - - {children} - {onClose ? ( - - - - ) : null} - - ); - }); - - const getContacts = (site: StadokSite) =>{ - const contacts = []; - - if(site.createdBy){ - contacts.push({h: "Site Creator",col1: site.createdBy.firstName, col2: site.createdBy.lastName, col3: site.createdBy.email, col4: site.createdBy.telephoneNumber }); - } - - if(site.contacts.manager){ - contacts.push({h: "Manager",col1: site.contacts.manager.firstName, col2: site.contacts.manager.lastName, col3: site.contacts.manager.email, col4: site.contacts.manager.telephoneNumber }); - } - - if(site.contacts.owner){ - contacts.push({h: "Owner",col1: site.contacts.owner.firstName, col2: site.contacts.owner.lastName, col3: site.contacts.owner.email, col4: site.contacts.owner.telephoneNumber }); - } - return contacts; - } - - const onClose = () =>{ - // setOpen(false); - props.onClose() - } - - //todo: use a set 'panelId' -> which values are allowed - const onHandleTabChange = (event: React.ChangeEvent<{}>, newValue: string) => { - setValue(newValue); -} -console.log(props.site) - const contacts = getContacts(props.site); - - const orderUrl=`${SITEDOC_URL}/site/${props.site.siteId}/orders`; - - if(orders==null){ - requestRest(orderUrl,{ method: "GET"}).then(result =>{ - if(result){ - const orderList = result.map(order =>{ - return OrderToDisplay.parse(order); - }); - setOrders(orderList); - - }else{ - setOrders([]); - } - }); - } - - const createOrderInfo = () => { - - if (orders === null) { - return (
- - Loading orders - -
) - } else if (orders.length === 0) { - return (
- - No orders available - -
) - } else { - return - } - } - - const displayImages = () => { - - if (props.site.images.length === 1) { - return stadokImage(props.site.siteId, props.site.images[0],"large") - } else { - return <> - { - stadokImage(props.site.siteId, props.site.images[0], "large") - } -
- - { - props.site.images.length<=9 ? - props.site.images.slice(1, props.site.images.length).map(image => - stadokImage(props.site.siteId, image, "small") - ) - : - <> - { - props.site.images.slice(1, 9).map(image => - stadokImage(props.site.siteId, image, "small") - ) - } - - - } -
- - } - - } - - const stadokImage = (siteId: string, imagename: string, size: 'large' | 'small') => { - const url = `${SITEDOC_URL}/site/${siteId}/files/${imagename}`; - const className = size === "small" ? classes.smallImage : classes.largeImage; - return window.open(url)} /> - - } - - - return ( - - {props.site.siteId} - - -
-
- - - - - { - props.site.type !== undefined && props.site.type.length > 0 && - - } - - - - - - - - - - - - - - - - - { - value == "devices" && (props.site.devices?.length>0 ? - - : -
- - No devices available - -
) - } - { - value == "contacts" && (contacts.length>0 ? - - : -
- - No contacts available - -
) - } - { - value == "safteyInfo" && (props.site.safteyNotices.length>0 ? - - : -
- - No saftey notices applicable - -
) - } - { - value == "logs" && (props.site.logs.length>0 ? - - : -
- - No activity log available - -
) - } - - { - value ==="orders" && createOrderInfo() - } - -
-
- { - props.site.images.length == 0 ? - - No images available - - : displayImages() - } -
-
- -
-
) - -} - -export default StadokDetailsPopup; \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/networkMapApp/src/components/map/connectionInfo.tsx b/sdnr/wt/odlux/apps/networkMapApp/src/components/map/connectionInfo.tsx deleted file mode 100644 index 3b5a15ce5..000000000 --- a/sdnr/wt/odlux/apps/networkMapApp/src/components/map/connectionInfo.tsx +++ /dev/null @@ -1,59 +0,0 @@ -/** - * ============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.isTopoServerReachable === false || props.isTileServerReachable === false )? -
-
Connection Error
- {props.isTileServerReachable === false && Tile data can't be loaded.} - {props.isTopoServerReachable === false && Network data can't be loaded.} -
-
: null -) - -} - -const mapStateToProps = (state: IApplicationStoreState) => ({ - isTopoServerReachable: state.network.connectivity.isToplogyServerAvailable, - isTileServerReachable: state.network.connectivity.isTileServerAvailable - -}); - - - -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/networkMapApp/src/components/map/iconSwitch.tsx b/sdnr/wt/odlux/apps/networkMapApp/src/components/map/iconSwitch.tsx deleted file mode 100644 index 221e7dab8..000000000 --- a/sdnr/wt/odlux/apps/networkMapApp/src/components/map/iconSwitch.tsx +++ /dev/null @@ -1,53 +0,0 @@ -/** - * ============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 { FormControlLabel, Switch, Paper } from "@material-ui/core"; -import connect, { Connect, IDispatcher } from '../../../../../framework/src/flux/connect'; -import { IApplicationStoreState } from '../../../../../framework/src/store/applicationStore'; -import { SetIconSwitchAction } from '../../actions/mapActions'; - -type props = Connect & {visible: boolean} - -const IconSwitch: React.FunctionComponent = (props) =>{ - - const toggleChecked = () => { - props.toogle(!props.areIconsEnabled) - }; - - return ( - props.visible ? - } - label="Show icons" - labelPlacement="end" - />: null) -} - -const mapStateToProps = (state: IApplicationStoreState) => ({ - areIconsEnabled: state.network.map.allowIconSwitch -}); - - -const mapDispatchToProps = (dispatcher: IDispatcher) => ({ - toogle : (enable:boolean) => dispatcher.dispatch(new SetIconSwitchAction(enable)) - -});; - -export default (connect(mapStateToProps,mapDispatchToProps)(IconSwitch)) diff --git a/sdnr/wt/odlux/apps/networkMapApp/src/components/map/map.tsx b/sdnr/wt/odlux/apps/networkMapApp/src/components/map/map.tsx deleted file mode 100644 index 1314edbba..000000000 --- a/sdnr/wt/odlux/apps/networkMapApp/src/components/map/map.tsx +++ /dev/null @@ -1,697 +0,0 @@ -/** - * ============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 * as mapboxgl from 'mapbox-gl'; -import { RouteComponentProps, withRouter } from 'react-router-dom'; - - -import { Site } from '../../model/site'; -import { SelectSiteAction, ClearHistoryAction, SelectLinkAction } from '../../actions/detailsAction'; -import { OSM_STYLE, URL_API, URL_BASEPATH, URL_TILE_API } from '../../config'; -import { link } from '../../model/link'; -import MapPopup from './mapPopup'; -import { SetPopupPositionAction, SelectMultipleLinksAction, SelectMultipleSitesAction } from '../../actions/popupActions'; -import { Feature } from '../../model/Feature'; -import { HighlightLinkAction, HighlightSiteAction, SetCoordinatesAction, SetStatistics } from '../../actions/mapActions'; -import { addDistance, getUniqueFeatures, increaseBoundingBox } from '../../utils/mapUtils'; -import { IApplicationStoreState } from '../../../../../framework/src/store/applicationStore'; -import connect, { IDispatcher, Connect } from '../../../../../framework/src/flux/connect'; -import SearchBar from './searchBar'; -import { verifyResponse, IsTileServerReachableAction, handleConnectionError, setTileServerReachableAction, IsBusycheckingConnectivityAction } from '../../actions/connectivityAction'; -import ConnectionInfo from './connectionInfo' -import mapLayerService from '../../utils/mapLayers'; -import Statistics from './statistics'; -import IconSwitch from './iconSwitch'; -import { addImages } from '../../services/mapImagesService'; -import { PopupElement } from '../../model/popupElements'; -import { Button } from '@material-ui/core'; -import { NavigateToApplication } from '../../../../../framework/src/actions/navigationActions'; -import customize from '../../../icons/customize.png'; - -type coordinates = { lat: number, lon: number, zoom: number } - -let alarmElements: Feature[] = []; -let map: mapboxgl.Map; -let isLoadingInProgress = false; -let notLoadedBoundingBoxes: mapboxgl.LngLatBounds[] = []; - -let lastBoundingBox: mapboxgl.LngLatBounds | null = null; -let myRef = React.createRef(); - -import 'mapbox-gl/dist/mapbox-gl.css'; - -class Map extends React.Component { - - constructor(props: mapProps) { - super(props); - //any state stuff - this.state = { isPopupOpen: false } - - } - - updateTheme(){ - mapLayerService.settings=this.props.settings.themes; - if(this.props.settings.mapSettings?.networkMap.styling.theme){ - mapLayerService.selectedTheme = this.props.settings.mapSettings?.networkMap.styling.theme; - } - } - - updateOpacity(){ - if(this.props.settings.mapSettings && this.props.settings.mapSettings.networkMap.tileOpacity){ - mapLayerService.changeMapOpacity(map, Number(this.props.settings.mapSettings.networkMap.tileOpacity)); - } - } - - async componentDidMount() { - - // resize the map, if menu gets collapsed - window.addEventListener("menu-resized", this.handleResize); - - //pass themes to mapLayerService - this.updateTheme(); - - // try if connection to tile + topologyserver are available - - try { - const tiles = await fetch(URL_TILE_API + '/10/0/0.png'); - if (tiles.ok) { - this.props.setTileServerLoaded(true); - }else{ - this.props.setTileServerLoaded(false); - } - - } catch (error) { - this.props.setTileServerLoaded(false); - console.error("tileserver " + URL_TILE_API + " can't be reached."); - } - - try { - const topology = await fetch(URL_API + "/info/count/all"); - verifyResponse(topology); - } catch (error) { - this.props.handleConnectionError(error) - } - - //both done - this.props.setConnectivityCheck(false); - //map loaded in componentDidUpdate - } - - setupMap = () => { - - let lat = this.props.lat; - let lon = this.props.lon; - let zoom = this.props.zoom; - - if(this.props.settings.mapSettings){ - if(this.props.settings.mapSettings.networkMap.startupPosition.latitude){ - lat = Number(this.props.settings.mapSettings.networkMap.startupPosition.latitude) - } - - if(this.props.settings.mapSettings.networkMap.startupPosition.longitude){ - lon = Number(this.props.settings.mapSettings.networkMap.startupPosition.longitude) - } - - if(this.props.settings.mapSettings.networkMap.startupPosition.zoom){ - zoom = Number(this.props.settings.mapSettings.networkMap.startupPosition.zoom) - } - - } - - const coordinates = this.extractCoordinatesFromUrl(); - // override lat/lon/zoom with coordinates from url, if available - if (this.areCoordinatesValid(coordinates)) { - lat = coordinates.lat; - lon = coordinates.lon; - zoom = !Number.isNaN(coordinates.zoom) ? coordinates.zoom : zoom; - } - - map = new mapboxgl.Map({ - container: myRef.current!, - style: OSM_STYLE as any, - center: [lon, lat], - zoom: zoom, - accessToken: '' - }); - - map.on('load', (ev) => { - - map.setMaxZoom(18); - const bbox = map.getBounds(); - this.props.updateMapPosition(bbox.getCenter().lat, bbox.getCenter().lng, map.getZoom()) - - mapLayerService.addBaseSources(map, this.props.selectedSite, this.props.selectedLink); - - addImages(map, (result: boolean)=>{ - if(map.getZoom()>11 && this.props.showIcons) - { - mapLayerService.addIconLayers(map, this.props.selectedSite?.properties.id) - }else{ - mapLayerService.addBaseLayers(map); - } - this.updateOpacity(); - - }); - - const boundingBox = increaseBoundingBox(map); - - fetch(`${URL_API}/links/geojson/${boundingBox.west},${boundingBox.south},${boundingBox.east},${boundingBox.north}`) - .then(result => verifyResponse(result)) - .then(result => result.json()) - .then(features => { - if (map.getSource('lines')) { - (map.getSource('lines') as mapboxgl.GeoJSONSource).setData(features); - } - }) - .catch(error => this.props.handleConnectionError(error)); - - - fetch(`${URL_API}/sites/geojson/${boundingBox.west},${boundingBox.south},${boundingBox.east},${boundingBox.north}`) - .then(result => verifyResponse(result)) - .then(result => result.json()) - .then(features => { - if (map.getSource('points')) { - (map.getSource('points') as mapboxgl.GeoJSONSource).setData(features); - } - }) - .catch(error => this.props.handleConnectionError(error)); - - map.on('click', this.mapClick); - map.on('moveend', this.mapMoveEnd); - map.on('move', this.mapMove); - - }); - } - - mapMove = () => { - - const mapZoom = map.getZoom(); - - const boundingBox = map.getBounds(); - - this.loadNetworkData(boundingBox); - if (mapZoom > 9) { - - if (map.getLayer('points')) { - map.setLayoutProperty('selectedPoints', 'visibility', 'visible'); - map.setPaintProperty('points', 'circle-radius', 7); - } - } else { - - // reduce size of points / lines if zoomed out - map.setPaintProperty('points', 'circle-radius', 2); - map.setLayoutProperty('selectedPoints', 'visibility', 'none'); - - if (mapZoom <= 4) { - map.setPaintProperty('fibre-lines', 'line-width', 1); - map.setPaintProperty('microwave-lines', 'line-width', 1); - - } else { - map.setPaintProperty('fibre-lines', 'line-width', 2); - map.setPaintProperty('microwave-lines', 'line-width', 2); - } - } - }; - - mapClick = (e: any) => { - - - if (map.getLayer('points')) { // data is shown as points - - var clickedLines = getUniqueFeatures(map.queryRenderedFeatures([[e.point.x - 5, e.point.y - 5], - [e.point.x + 5, e.point.y + 5]], { - layers: ['microwave-lines', 'fibre-lines'] - }), "id"); - - const clickedPoints = getUniqueFeatures(map.queryRenderedFeatures(e.point, { layers: ['points'] }), "id"); - const alarmedSites = getUniqueFeatures(map.queryRenderedFeatures(e.point, { layers: ['alarmedPoints'] }), "id"); - - if (clickedPoints.length != 0) { - - - if (alarmedSites.length > 0) { - alarmedSites.forEach(alarm => { - const index = clickedPoints.findIndex(item => item.properties!.id === alarm.properties!.id); - - if (index !== -1) { - clickedPoints[index].properties!.alarmed = true; - clickedPoints[index].properties!.type = "alarmed"; - } - }); - } - - this.showSitePopup(clickedPoints, e.point.x, e.point.y); - } else if (clickedLines.length != 0) { - this.showLinkPopup(clickedLines, e.point.x, e.point.y); - } - - - } else { // data is shown as icons - - const clickedSites = getUniqueFeatures(map.queryRenderedFeatures(e.point, { layers: ['point-lamps', 'point-building', 'point-data-center', 'point-factory', 'point-remaining'] }), "id"); - const clickedLines = getUniqueFeatures(map.queryRenderedFeatures([[e.point.x - 5, e.point.y - 5], - [e.point.x + 5, e.point.y + 5]], { - layers: ['microwave-lines', 'fibre-lines'] - }), "id"); - - if (clickedSites.length > 0) - this.showSitePopup(clickedSites, e.point.x, e.point.y); - else if (clickedLines.length != 0) { - this.showLinkPopup(clickedLines, e.point.x, e.point.y); - } - } - }; - - mapMoveEnd = () => { - - const mapZoom = Number(map.getZoom().toFixed(2)); - const lat = Number(map.getCenter().lat.toFixed(4)); - const lon = Number(map.getCenter().lng.toFixed(4)); - - - if (this.props.lat !== lat || this.props.lon !== lon || this.props.zoom !== mapZoom) { - this.props.updateMapPosition(lat, lon, mapZoom) - } - - // update the url to current lat,lon,zoom values - - const currentUrl = window.location.href; - const parts = currentUrl.split(URL_BASEPATH); - if (parts.length > 0) { - - const detailsPath = parts[1].split("/details/"); - - if (detailsPath[1] !== undefined && detailsPath[1].length > 0) { - this.props.history.replace(`/${URL_BASEPATH}/${map.getCenter().lat.toFixed(4)},${map.getCenter().lng.toFixed(4)},${mapZoom.toFixed(2)}/details/${detailsPath[1]}`) - } - else { - this.props.history.replace(`/${URL_BASEPATH}/${map.getCenter().lat.toFixed(4)},${map.getCenter().lng.toFixed(4)},${mapZoom.toFixed(2)}`) - } - } - - - //switch icon layers if applicable - - mapLayerService.showIconLayers(map, this.props.showIcons, this.props.selectedSite?.properties.id); - - //update statistics - const boundingBox = map.getBounds(); - - fetch(`${URL_API}/info/count/${boundingBox.getWest()},${boundingBox.getSouth()},${boundingBox.getEast()},${boundingBox.getNorth()}`) - .then(result => verifyResponse(result)) - .then(res => res.json()) - .then(result => { - if (result.links !== this.props.linkCount || result.sites !== this.props.siteCount) { - this.props.setStatistics(result.links, result.sites); - } - }) - .catch(error => this.props.handleConnectionError(error));; - } - - componentDidUpdate(prevProps: mapProps, prevState: {}) { - - if(prevProps !== this.props){ - //(load map) - //triggered if either settings were done loading or tile/topology server connectivity checked - if(prevProps.settings !== this.props.settings || this.props.isConnectivityCheckBusy !== prevProps.isConnectivityCheckBusy){ - - //update theme if settings changed - if(prevProps.settings !== this.props.settings){ - this.updateTheme(); - } - - //if everything done loading/reachable, load map - if(!this.props.isConnectivityCheckBusy && this.props.isTileServerReachable && !this.props.settings.isLoadingData && (prevProps.settings.isLoadingData !==this.props.settings.isLoadingData || prevProps.isConnectivityCheckBusy !== this.props.isConnectivityCheckBusy)){ - - if(map == undefined){ - this.setupMap(); - } - else - if(map.getContainer() !== myRef.current){ - // reload map, because the current container (fresh div) doesn't hold the map and changing containers isn't supported - map.remove(); - this.setupMap(); - } - } - } - - if (map !== undefined) { - if (prevProps.selectedSite?.properties.id !== this.props.selectedSite?.properties.id) { - - if (this.props.selectedSite != null) { - if (map.getSource("selectedLine") !== undefined) { - (map.getSource("selectedLine") as mapboxgl.GeoJSONSource).setData({ type: "FeatureCollection", features: [] }); - (map.getSource("selectedPoints") as mapboxgl.GeoJSONSource).setData({ type: "FeatureCollection", features: [this.props.selectedSite] }); - } - - - if (map.getLayer('point-lamps') !== undefined) { - - map.setFilter('point-lamps', ['==', 'type', 'street lamp']); - map.setFilter('point-data-center', ['==', 'type', 'data center']); - map.setFilter('point-building', ['==', 'type', 'high rise building']); - map.setFilter('point-factory', ['==', 'type', 'factory']); - - if (this.props.selectedSite?.properties.type !== undefined) { - switch (this.props.selectedSite?.properties.type) { - case 'street lamp': - map.setFilter('point-lamps', ["all", ['==', 'type', 'street lamp'], ['!=', 'id', this.props.selectedSite.properties.id]]); - break; - case 'data center': - map.setFilter('point-data-center', ["all", ['==', 'type', 'data center'], ['!=', 'id', this.props.selectedSite.properties.id]]); - break; - case 'high rise building': - map.setFilter('point-building', ["all", ['==', 'type', 'high rise building'], ['!=', 'id', this.props.selectedSite.properties.id]]) - break; - case 'factory': - map.setFilter('point-factory', ["all", ['==', 'type', 'factory'], ['!=', 'id', this.props.selectedSite.properties.id]]); - break; - } - } - } - - - } - else - { - if (map.getSource("selectedPoints") !== undefined) - (map.getSource("selectedPoints") as mapboxgl.GeoJSONSource).setData({ type: "FeatureCollection", features: [] }); - - } - } - - if (prevProps.selectedLink !== this.props.selectedLink) { - if (this.props.selectedLink != null) { - - if (map.getLayer('point-lamps') !== undefined) { - map.setFilter('point-lamps', ['==', 'type', 'street lamp']); - map.setFilter('point-data-center', ['==', 'type', 'data center']); - map.setFilter('point-building', ['==', 'type', 'high rise building']); - map.setFilter('point-factory', ['==', 'type', 'factory']); - } - - if (map.getSource("selectedLine") !== undefined) { - (map.getSource("selectedPoints") as mapboxgl.GeoJSONSource).setData({ type: "FeatureCollection", features: [] }); - (map.getSource("selectedLine") as mapboxgl.GeoJSONSource).setData({ type: "FeatureCollection", features: [this.props.selectedLink] }); - } - } - else - { - if (map.getSource("selectedLine") !== undefined) - (map.getSource("selectedLine") as mapboxgl.GeoJSONSource).setData({ type: "FeatureCollection", features: [] }); - } - } - - if (prevProps.location.pathname !== this.props.location.pathname) { - if (map) { - const coordinates = this.extractCoordinatesFromUrl(); - this.moveMapToCoordinates(coordinates); - } - } - - if (prevProps.alarmlement !== this.props.alarmlement) { - if (this.props.alarmlement !== null && !alarmElements.includes(this.props.alarmlement)) { - if (map.getSource("alarmedPoints")) - (map.getSource("alarmedPoints") as mapboxgl.GeoJSONSource).setData({ type: "FeatureCollection", features: alarmElements }); - alarmElements.push(this.props.alarmlement) - } - } - - if (prevProps.showIcons !== this.props.showIcons) { - if (map && map.getZoom() > 11) { - mapLayerService.showIconLayers(map, this.props.showIcons, this.props.selectedSite?.properties.id); - } - } - - if (prevProps.zoomToElement !== this.props.zoomToElement) { - if (this.props.zoomToElement !== null) { - const currentZoom = map?.getZoom(); - - map.flyTo({ - center: [ - this.props.zoomToElement.lon, - this.props.zoomToElement.lat - ], zoom: currentZoom < 10 ? 10 : currentZoom, - essential: true - }); - } - } - } - } - } - - componentWillUnmount(){ - - //unregister events - window.removeEventListener("menu-resized", this.handleResize); - - if(map){ - map.off('click', this.mapClick); - map.off('moveend', this.mapMoveEnd); - map.off('move', this.mapMove); - } - - lastBoundingBox=null; - - // will be checked again on next load - this.props.setConnectivityCheck(true); - } - - handleResize = () => { - if (map) { - // wait a moment until resizing actually happened - window.setTimeout(() => map.resize(), 500); - } - } - - extractCoordinatesFromUrl = (): coordinates => { - const currentUrl = window.location.href; - const mainPathParts = currentUrl.split(URL_BASEPATH); - const coordinatePathPart = mainPathParts[1].split("/details/"); // split by details if present - const allCoordinates = coordinatePathPart[0].replace("/", ""); - const coordinates = allCoordinates.split(","); - return { lat: Number(coordinates[0]), lon: Number(coordinates[1]), zoom: Number(coordinates[2]) } - } - - areCoordinatesValid = (coordinates: coordinates) => { - - if ((!Number.isNaN(coordinates.lat)) && (!Number.isNaN(coordinates.lon))) { - return true; - } else { - return false; - } - } - - moveMapToCoordinates = (coordinates: coordinates) => { - - if (this.areCoordinatesValid(coordinates)) { - let zoom = -1; - - if (!Number.isNaN(coordinates.zoom)) { - zoom = coordinates.zoom; - } - - map.flyTo({ - center: [ - coordinates.lon, - coordinates.lat - ], zoom: zoom !== -1 ? zoom : this.props.zoom, - essential: true - }) - } - } - - loadNetworkData = async (bbox: mapboxgl.LngLatBounds) => { - if (!isLoadingInProgress) { // only load data if loading not in progress - isLoadingInProgress = true; - - if (lastBoundingBox == null) { - lastBoundingBox = bbox; - await this.draw('lines', `${URL_API}/links/geojson/${lastBoundingBox.getWest()},${lastBoundingBox.getSouth()},${lastBoundingBox.getEast()},${lastBoundingBox.getNorth()}`); - await this.draw('points', `${URL_API}/sites/geojson/${lastBoundingBox.getWest()},${lastBoundingBox.getSouth()},${lastBoundingBox.getEast()},${lastBoundingBox.getNorth()}`); - } else { - - // new bbox is bigger than old one - if (bbox.contains(lastBoundingBox.getNorthEast()) && bbox.contains(lastBoundingBox.getSouthWest()) && lastBoundingBox !== bbox) { //if new bb is bigger than old one - - lastBoundingBox = bbox; - - //calculate new boundingBox - const increasedBoundingBox = increaseBoundingBox(map); - - await this.draw('lines', `${URL_API}/links/geojson/${increasedBoundingBox.west},${increasedBoundingBox.south},${increasedBoundingBox.east},${increasedBoundingBox.north}`); - await this.draw('points', `${URL_API}/sites/geojson/${increasedBoundingBox.west},${increasedBoundingBox.south},${increasedBoundingBox.east},${increasedBoundingBox.north}`); - - } else if (lastBoundingBox.contains(bbox.getNorthEast()) && lastBoundingBox.contains(bbox.getSouthWest())) { // last one contains new one - // bbox is contained in last one, do nothing - isLoadingInProgress = false; - - } else { // bbox is not fully contained in old one, extend - - lastBoundingBox.extend(bbox); - - await this.draw('lines', `${URL_API}/links/geojson/${lastBoundingBox.getWest()},${lastBoundingBox.getSouth()},${lastBoundingBox.getEast()},${lastBoundingBox.getNorth()}`); - await this.draw('points', `${URL_API}/sites/geojson/${lastBoundingBox.getWest()},${lastBoundingBox.getSouth()},${lastBoundingBox.getEast()},${lastBoundingBox.getNorth()}`); - } - - } - - - if (notLoadedBoundingBoxes.length > 0) { // load last not loaded boundingbox - this.loadNetworkData(notLoadedBoundingBoxes.pop()!) - notLoadedBoundingBoxes = []; - } - - } else { - notLoadedBoundingBoxes.push(bbox); - } - } - - showSitePopup = (sites: mapboxgl.MapboxGeoJSONFeature[], top: number, left: number) => { - if (sites.length > 1) { - const elements: PopupElement[] = sites.map(feature => {return {name: feature.properties!.name, id: feature.properties!.id}}); - - this.props.setPopupPosition(top, left); - this.props.selectMultipleSites(elements); //name, id object container - this.setState({ isPopupOpen: true }); - - } else { - const id = sites[0].properties!.id; - - fetch(`${URL_API}/sites/${id}`) - .then(result => verifyResponse(result)) - .then(res => res.json() as Promise) - .then(result => { - this.props.selectSite(result); - this.props.highlightSite(result); - this.props.clearDetailsHistory(); - }) - .catch(error => this.props.handleConnectionError(error));; - } - } - - showLinkPopup = (links: mapboxgl.MapboxGeoJSONFeature[], top: number, left: number) => { - - if (links.length > 1) { - - const elements: PopupElement[] = links.map(feature => {return {name: feature.properties!.name, id: feature.properties!.id}}); - - this.props.setPopupPosition(top, left); - this.props.selectMultipleLinks(elements); - this.setState({ isPopupOpen: true }); - - } else { - var id = links[0].properties!.id; - - fetch(`${URL_API}/links/${id}`) - .then(result => verifyResponse(result)) - .then(res => res.json() as Promise) - .then(result => { - this.props.selectLink(result); - this.props.highlightLink(result); - - this.props.clearDetailsHistory(); - }) - .catch(error => this.props.handleConnectionError(error));; - } - } - - draw = async (layer: string, url: string) => { - - fetch(url) - .then(result => verifyResponse(result)) - .then(res => res.json()) - .then(result => { - isLoadingInProgress = false; - if (map.getSource(layer)) { - (map.getSource(layer) as mapboxgl.GeoJSONSource).setData(result); - } - }) - .catch(error => this.props.handleConnectionError(error));; - } - - render() { - - return <> - -{ - !this.props.settings.isLoadingData ? - -
- { - this.state.isPopupOpen && - { this.setState({ isPopupOpen: false }); }} /> - } - - - 11} /> - - -
- :
- - } - - } - -} - -type mapProps = RouteComponentProps & Connect; - -const mapStateToProps = (state: IApplicationStoreState) => ({ - selectedLink: state.network.map.selectedLink, - selectedSite: state.network.map.selectedSite, - zoomToElement: state.network.map.zoomToElement, - alarmlement: state.network.map.alarmlement, - lat: state.network.map.lat, - lon: state.network.map.lon, - zoom: state.network.map.zoom, - linkCount: state.network.map.statistics.links, - siteCount: state.network.map.statistics.sites, - isTopoServerReachable: state.network.connectivity.isToplogyServerAvailable, - isTileServerReachable: state.network.connectivity.isTileServerAvailable, - isConnectivityCheckBusy: state.network.connectivity.isBusy, - showIcons: state.network.map.allowIconSwitch, - settings: state.network.settings, -}); - -const mapDispatchToProps = (dispatcher: IDispatcher) => ({ - selectSite: (site: Site) => dispatcher.dispatch(new SelectSiteAction(site)), - selectLink: (link: link) => dispatcher.dispatch(new SelectLinkAction(link)), - clearDetailsHistory: () => dispatcher.dispatch(new ClearHistoryAction()), - selectMultipleLinks: (ids: PopupElement[]) => dispatcher.dispatch(new SelectMultipleLinksAction(ids)), - selectMultipleSites: (ids: PopupElement[]) => dispatcher.dispatch(new SelectMultipleSitesAction(ids)), - setPopupPosition: (x: number, y: number) => dispatcher.dispatch(new SetPopupPositionAction(x, y)), - highlightLink: (link: link) => dispatcher.dispatch(new HighlightLinkAction(link)), - highlightSite: (site: Site) => dispatcher.dispatch(new HighlightSiteAction(site)), - updateMapPosition: (lat: number, lon: number, zoom: number) => dispatcher.dispatch(new SetCoordinatesAction(lat, lon, zoom)), - setStatistics: (linkCount: string, siteCount: string) => dispatcher.dispatch(new SetStatistics(siteCount, linkCount)), - setTileServerLoaded: (reachable: boolean) => dispatcher.dispatch(setTileServerReachableAction(reachable)), - handleConnectionError: (error: Error) => dispatcher.dispatch(handleConnectionError(error)), - navigateToApplication: (applicationName: string, path?: string) => dispatcher.dispatch(new NavigateToApplication(applicationName, path, "test3")), - setConnectivityCheck: (done: boolean) => dispatcher.dispatch(new IsBusycheckingConnectivityAction(done)), - -}) - -export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Map)); \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/networkMapApp/src/components/map/mapPopup.tsx b/sdnr/wt/odlux/apps/networkMapApp/src/components/map/mapPopup.tsx deleted file mode 100644 index 7a64f5a58..000000000 --- a/sdnr/wt/odlux/apps/networkMapApp/src/components/map/mapPopup.tsx +++ /dev/null @@ -1,94 +0,0 @@ -/** - * ============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 { Typography, Select, MenuItem, ClickAwayListener, Popper, Paper, FormGroup, Portal, Popover } from '@material-ui/core'; -import { SelectSiteAction, ClearHistoryAction, ClearDetailsAction } from '../../actions/detailsAction'; -import { Site } from '../../model/site'; -import { link } from '../../model/link'; -import { URL_API } from '../../config'; -import { HighlightLinkAction, HighlightSiteAction } from '../../actions/mapActions'; -import { IApplicationStoreState } from '../../../../../framework/src/store/applicationStore'; -import connect, { IDispatcher, Connect } from '../../../../../framework/src/flux/connect'; -import { verifyResponse, handleConnectionError } from '../../actions/connectivityAction'; - - - - -const MapPopup: React.FunctionComponent = (props) => { - - const [value, setValue] = React.useState(""); - - const handleChange = (event: any) => { - setValue(event.target.value); - - const id = event.target.value; - - - fetch(`${URL_API}/${props.type.toLocaleLowerCase()}s/${id}`) - .then(result => verifyResponse(result)) - .then(res => res.json()) - .then(result => { - props.clearDetailsHistory(); - props.selectElement(result); - props.type === "link" ? props.highlightLink(result) : props.highlightSite(result) - props.onClose(); - }) - .catch(error => { - props.handleConnectionError(error); - props.onClose(); - // props.clearDetails(); - }); - }; - - return <> - - - {`Multiple ${props.type.toLowerCase()}s were selected`} - Please select one. - - - - -} - -type props = Connect& { onClose(): void } - -const mapStateToProps = (state: IApplicationStoreState) => ({ - elements: state.network.popup.selectionPendingForElements, - type: state.network.popup.pendingDataType, - position: state.network.popup.position - -}); - -const mapDispatchToProps = (dispatcher: IDispatcher) => ({ - selectElement: (site: Site) => dispatcher.dispatch(new SelectSiteAction(site)), - clearDetailsHistory:()=> dispatcher.dispatch(new ClearHistoryAction()), - highlightLink: (link: link) => dispatcher.dispatch(new HighlightLinkAction(link)), - highlightSite: (site: Site) => dispatcher.dispatch(new HighlightSiteAction(site)), - handleConnectionError: (error:Error) => dispatcher.dispatch(handleConnectionError(error)), - clearDetails: () => dispatcher.dispatch(new ClearDetailsAction()), - -}); - -export default (connect(mapStateToProps, mapDispatchToProps))(MapPopup); \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/networkMapApp/src/components/map/searchBar.tsx b/sdnr/wt/odlux/apps/networkMapApp/src/components/map/searchBar.tsx deleted file mode 100644 index 307c5d203..000000000 --- a/sdnr/wt/odlux/apps/networkMapApp/src/components/map/searchBar.tsx +++ /dev/null @@ -1,161 +0,0 @@ -/** - * ============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 { makeStyles, Paper, InputBase, IconButton, Divider, Popover, Typography } from '@material-ui/core'; -import SearchIcon from '@material-ui/icons/Search'; - -import { URL_API } from '../../config'; -import { isSite } from '../../utils/utils'; -import { Site } from '../../model/site'; -import { link } from '../../model/link'; -import { SelectSiteAction, SelectLinkAction } from '../../actions/detailsAction'; -import { HighlightLinkAction, HighlightSiteAction, ZoomToSearchResultAction } from '../../actions/mapActions'; -import { calculateMidPoint } from '../../utils/mapUtils'; -import { SetSearchValueAction } from '../../actions/searchAction'; -import connect,{ Connect, IDispatcher } from '../../../../../framework/src/flux/connect'; -import { IApplicationStoreState } from '../../../../../framework/src/store/applicationStore'; - - - - - - -const styles = makeStyles({ - root: { - //{ padding:5, position: 'absolute', display:'flex', flexDirection:"column",top: 150, width: 200} - padding: '2px 4px', - position: 'absolute', - display:'flex', - alignItems: 'center', - top: 15, - marginLeft: 5, - width: 400, - zIndex:1 - }, - input: { - flex: 1, - marginLeft: 5 - }, - iconButton: { - padding: 10, - }, - divider: { - height: 28, - margin: 4, - }, - }); - - -const SearchBar: React.FunctionComponent = (props) =>{ - - const classes = styles(); - const [anchorEl, setAnchorEl] = React.useState(null); - const [errorMessage, setErrorMessage] = React.useState(""); - - const divRef = React.useRef(); - - const handleClick = (e: any) =>{ - - setAnchorEl(null); - if(props.searchterm.length>0){ - - const siteResult = fetch(`${URL_API}/sites/name/${props.searchterm}`) - - const linkResult = fetch(`${URL_API}/links/${props.searchterm}`); - - Promise.all([ siteResult, linkResult]).then((result)=>{ - const suceededResults = result.filter(el=> el.ok); - - if(suceededResults.length==0){ - setAnchorEl(divRef.current); - setErrorMessage("No element found.") - // hide message after 3 sec - window.setTimeout(()=>{setAnchorEl(null)}, 3000); - - }else{ - suceededResults[0].json().then(result =>{ - if(isSite(result)){ - props.selectSite(result); - props.highlightSite(result); - props.zoomToSearchResult(result.location.lat, result.location.lon); - }else{ - props.selectLink(result); - props.highlightLink(result); - const midPoint = calculateMidPoint(result.locationA.lat, result.locationA.lon, result.locationB.lat, result.locationB.lon); - props.zoomToSearchResult(midPoint[1], midPoint[0]) - } - }); - } - }); - } - e.preventDefault(); -} - - const open = Boolean(anchorEl); - - const reachabe = props.isTopoServerReachable && props.isTileServerReachable; - - return ( - <> - - props.setSearchTerm(e.currentTarget.value)} - /> - - - - - - setAnchorEl(null)} anchorEl={anchorEl} anchorOrigin={{ - vertical: "bottom", - horizontal: "left" - }}> - - {errorMessage} - - - - ); -} - -const mapStateToProps = (state: IApplicationStoreState) => ({ - searchterm: state.network.search.value, - isTopoServerReachable: state.network.connectivity.isToplogyServerAvailable, - isTileServerReachable: state.network.connectivity.isTileServerAvailable - -}); - -type searchBarProps = Connect; - - -const mapDispatchToProps = (dispatcher: IDispatcher) => ({ - selectSite:(site: Site)=> dispatcher.dispatch(new SelectSiteAction(site)), - selectLink:(link: link) => dispatcher.dispatch(new SelectLinkAction(link)), - highlightLink:(link: link)=> dispatcher.dispatch(new HighlightLinkAction(link)), - highlightSite: (site: Site) => dispatcher.dispatch(new HighlightSiteAction(site)), - setSearchTerm: (value: string) => dispatcher.dispatch(new SetSearchValueAction(value)), - zoomToSearchResult: (lat: number, lon: number) => dispatcher.dispatch(new ZoomToSearchResultAction(lat, lon)), -});; - -export default (connect(mapStateToProps,mapDispatchToProps)(SearchBar)) \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/networkMapApp/src/components/map/statistics.tsx b/sdnr/wt/odlux/apps/networkMapApp/src/components/map/statistics.tsx deleted file mode 100644 index 562689198..000000000 --- a/sdnr/wt/odlux/apps/networkMapApp/src/components/map/statistics.tsx +++ /dev/null @@ -1,57 +0,0 @@ -/** - * ============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 { Paper, Typography, Tooltip } from '@material-ui/core'; -import InfoIcon from '@material-ui/icons/Info'; - -import { IApplicationStoreState } from '../../../../../framework/src/store/applicationStore'; -import connect, { IDispatcher, Connect } from '../../../../../framework/src/flux/connect'; - -type props = Connect; - -const mapStateToProps = (state: IApplicationStoreState) => ({ - linkCount: state.network.map.statistics.links, - siteCount: state.network.map.statistics.sites, - isTopoServerReachable: state.network.connectivity.isToplogyServerAvailable, - isTileServerReachable: state.network.connectivity.isTileServerAvailable, - -}); - -const mapDispatchToProps = (dispatcher: IDispatcher) => ({ -}); - -const Statistics: React.FunctionComponent = (props: props) =>{ - - const reachabe = props.isTopoServerReachable && props.isTileServerReachable; - - - return ( -
- Statistics - - - -
- - Sites: {props.siteCount} - Links: {props.linkCount} -
) -} - -export default connect(mapStateToProps, mapDispatchToProps)(Statistics); -- cgit 1.2.3-korg