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 -30);
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 window.open(`/#/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}`)
77 {name:"Site Name", val1: props.link.siteA, val2: props.link.siteB},
78 {name:"Latitude", val1: LatLonToDMS(props.link.locationA.lat), val2: LatLonToDMS(props.link.locationB.lat)},
79 {name:"Longitude", val1: LatLonToDMS(props.link.locationA.lon, true), val2: LatLonToDMS(props.link.locationB.lon, true)},
80 {name:"Azimuth in °", val1: props.link.azimuthA.toFixed(2), val2: props.link.azimuthB.toFixed(2)}
83 return (<div style={{ paddingLeft: "15px", paddingRight: "15px", paddingTop: "0px", display: 'flex', flexDirection: 'column' }}>
84 <h2>{props.link.name}</h2>
85 <TextField aria-label="operator" disabled style={{ marginTop: "5px" }} value="Unkown" label="Operator" />
86 <TextField aria-label="type" disabled style={{ marginTop: "5px" }} value={props.link.type} label="Type" />
87 <TextField aria-label="planned-distance-in-km" disabled style={{ marginTop: "5px" }} value={props.link.length.toFixed(2)} label="Distance planned in km" />
88 <TextField aria-label="calculated-distance-in-km" disabled style={{ marginTop: "5px" }} value={props.link.calculatedLength.toFixed(2)} label="Distance calculated in km" />
90 <AppBar position="static" id="site-tabs" style={{ marginTop: "20px", background: '#2E3B55' }}>
91 <Typography aria-label="details-of-link-sites" style={{ margin:"5px"}}>SITE DETAILS</Typography>
93 <DenseTable ariaLabel="site-information-table-entry" height={height} hover={false} headers={["", "Site A", "Site B"]} data={data} />
95 props.link.type==="microwave" && <Button style={{marginTop:20}} fullWidth variant="contained" color="primary" onClick={onCalculateLinkClick}>Calculate link</Button>
100 export default LinkDetails;