2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt odlux
4 * =================================================================================================
5 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
19 import * as React from 'react';
21 import { link } from '../../model/link';
22 import { TextField, Tabs, Tab, Typography, AppBar, Button, Link } from '@material-ui/core';
23 import DenseTable from '../denseTable';
24 import { LatLonToDMS } from '../../utils/mapUtils';
26 type panelId = "siteA" | "siteB";
27 type props = { link: link };
29 const LinkDetails: React.FunctionComponent<props> = (props) => {
31 const [value, setValue] = React.useState<panelId>("siteA");
32 const [height, setHeight] = React.useState(330);
34 const handleResize = () =>{
35 const el = document.getElementById('link-details-panel')?.getBoundingClientRect();
36 const el2 = document.getElementById('site-tabs')?.getBoundingClientRect();
39 if(props.link.type==="microwave")
40 setHeight(el!.height - el2!.y -50);
42 setHeight(el!.height - el2!.y +20);
51 //window.addEventListener("resize", handleResize);
58 const onHandleTabChange = (event: React.ChangeEvent<{}>, newValue: panelId) => {
62 const onCalculateLinkClick = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) =>{
64 const siteA= props.link.locationA;
65 const siteB =props.link.locationB;
66 const nameA = props.link.siteA;
67 const nameB = props.link.siteB;
68 const distance = props.link.length > 0 ? props.link.length : props.link.calculatedLength;
69 const azimuthA = props.link.azimuthA;
70 const azimuthB = props.link.azimuthB;
71 const antennaA = props.link.locationA.antenna;
72 const antennaB = props.link.locationB.antenna;
76 if(antennaA!==null && antennaB!==null){
77 antennaData = `&antennaNameA=${antennaA.name}&antennaGainA=${antennaA.gain}&waveguideLossA=${antennaA.waveguideLossIndB}&antennaNameB=${antennaB.name}&antennaGainB=${antennaB.gain}&waveguideLossB=${antennaB.waveguideLossIndB}`;
82 const baseUrl = window.location.pathname.split('#')[0];
83 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}`)
87 const onLineofSightClick = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) =>{
90 const siteA= props.link.locationA;
91 const siteB =props.link.locationB;
93 //TODO: add check if available
94 let heightPart = `&amslA=${siteA.amsl}&antennaHeightA=${siteA.antennaHeight}&amslB=${siteB.amsl}&antennaHeightB=${siteB.antennaHeight}`;
97 const baseUrl = window.location.pathname.split('#')[0];
98 window.open(`${baseUrl}#/lineofsight/los?lat1=${siteA.lat}&lon1=${siteA.lon}&lat2=${siteB.lat}&lon2=${siteB.lon}${heightPart}`);
103 {name:"Site Name", val1: props.link.siteA, val2: props.link.siteB},
104 {name:"Latitude", val1: LatLonToDMS(props.link.locationA.lat), val2: LatLonToDMS(props.link.locationB.lat)},
105 {name:"Longitude", val1: LatLonToDMS(props.link.locationA.lon, true), val2: LatLonToDMS(props.link.locationB.lon, true)},
106 props.link.azimuthA!= null && props.link.azimuthB != null && {name:"Azimuth in °", val1: props.link.azimuthA.toFixed(2), val2: props.link.azimuthB.toFixed(2)}
109 return (<div style={{ paddingLeft: "15px", paddingRight: "15px", paddingTop: "0px", display: 'flex', flexDirection: 'column' }}>
110 <h2>{props.link.name}</h2>
111 <TextField inputProps={{ 'aria-label': 'operator' }} disabled style={{ marginTop: "5px" }} value="Unkown" label="Operator" />
112 <TextField inputProps={{ 'aria-label': 'type' }} disabled style={{ marginTop: "5px" }} value={props.link.type} label="Type" />
113 <TextField inputProps={{ 'aria-label': 'planned-distance-in-km' }} disabled style={{ marginTop: "5px" }} value={props.link.length.toFixed(2)} label="Distance planned in km" />
114 <TextField inputProps={{ 'aria-label': 'calculated-distance-in-km' }} disabled style={{ marginTop: "5px" }} value={props.link.calculatedLength.toFixed(2)} label="Distance calculated in km" />
116 <AppBar position="static" id="site-tabs" style={{ marginTop: "20px", background: '#2E3B55' }}>
117 <Typography aria-label="details-of-link-sites" style={{ margin:"5px"}}>SITE DETAILS</Typography>
119 <DenseTable ariaLabelRow="site-information-table-entry" ariaLabelColumn={["site-name", "latitude", "longitude", "azimuth"]} verticalTable height={height} hover={false} headers={["", "Site A", "Site B"]} data={data} />
121 props.link.type==="microwave" &&<>
122 <Button style={{marginTop:20}} fullWidth variant="contained" color="primary" onClick={onCalculateLinkClick}>Calculate link</Button>
123 <Button style={{marginTop:20}} fullWidth variant="contained" color="primary" onClick={onLineofSightClick}>Line of Sight</Button>
130 export default LinkDetails;