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';
20 import { TextField, Tabs, Tab, Typography, AppBar, Button, Tooltip } from '@material-ui/core';
23 import MaterialTable, { ColumnModel, ColumnType, MaterialTableCtorType } from "../../../../../framework/src/components/material-table";
26 import { site, Device } from '../../model/site';
27 import DenseTable from '../denseTable';
28 import { LatLonToDMS } from '../../utils/mapUtils';
30 type minLinks = { name: string, azimuth: string}
32 const FaultAlarmNotificationTable = MaterialTable as MaterialTableCtorType<minLinks>;
35 type panelId="links" | "nodes";
36 type props = { site: site, updatedDevices: Device[]|null, navigate(applicationName: string, path?: string):void, onLinkClick(id: string): void, loadDevices(devices:Device[]): void };
38 const SiteDetails: React.FunctionComponent<props> = (props) => {
40 const [value, setValue] = React.useState<panelId>("links");
41 const [height, setHeight] = React.useState(330);
43 const handleResize = () =>{
44 const el = document.getElementById('site-details-panel')?.getBoundingClientRect();
45 const el2 = document.getElementById('site-tabs')?.getBoundingClientRect();
48 setHeight(el!.height - el2!.y +20);
57 window.addEventListener("resize", ()=>{console.log("really got resized.")});
63 props.loadDevices(props.site.devices);
68 const onHandleTabChange = (event: React.ChangeEvent<{}>, newValue: panelId) => {
72 const linkRows: minLinks[] = props.site.links.map(link=>
74 return {name: link.name, azimuth: link.azimuthB.toFixed(2) }
79 return (<div style={{ padding: '15px', display: "flex", flexDirection:"column", minWidth:0, minHeight:0 }}>
80 <h2 >{props.site.name}</h2>
82 props.site.operator !== '' && props.site.operator !== null ?
83 <TextField inputProps={{ 'aria-label': 'operator' }} disabled={true} value={props.site.operator} label="Operator" /> :
84 <TextField inputProps={{ 'aria-label': 'operator' }} disabled={true} value="Unkown" label="Operator" style={{ marginTop: "5px" }} />
87 props.site.type !== undefined && props.site.type.length > 0 &&
88 <TextField inputProps={{ 'aria-label': 'type' }} disabled={true} value={props.site.type} label="Type" style={{ marginTop: "5px" }} />
91 props.site.address !== undefined && props.site.address.length > 0 &&
92 <TextField inputProps={{ 'aria-label': 'adress' }} disabled={true} value={props.site.address} label="Adress" style={{ marginTop: "5px" }} />
95 props.site.heighAGLInMeters !== undefined && props.site.heighAGLInMeters > 0 &&
96 <TextField inputProps={{ 'aria-label': 'amsl-in-meters' }} disabled={true} value={props.site.heighAGLInMeters} label="AMSL in meters" style={{ marginTop: "5px" }} />
99 props.site.antennaHeightAGLInMeters !== undefined && props.site.antennaHeightAGLInMeters > 0 &&
100 <TextField inputProps={{ 'aria-label': 'antenna-above-ground-in-meters' }} disabled={true} value={props.site.antennaHeightAGLInMeters} label="Atenna above ground in meters" style={{ marginTop: "5px" }} />
103 <TextField inputProps={{ 'aria-label': 'latitude' }} style={{ marginTop: "5px" }} disabled={true} value={LatLonToDMS(props.site.geoLocation.lat)} label="Latitude" />
104 <TextField inputProps={{ 'aria-label': 'longitude' }} style={{ marginTop: "5px" }} disabled={true} value={LatLonToDMS(props.site.geoLocation.lon, true)} label="Longitude" />
106 <AppBar position="static" style={{ marginTop: "5px", background: '#2E3B55' }}>
107 <Tabs id="site-tabs" value={value} onChange={onHandleTabChange} aria-label="simple tabs example">
108 <Tab label="Links" value="links" />
109 <Tab label="Nodes" value="nodes" />
116 props.site.links.length === 0 &&
117 <Typography aria-label="no-links-available" variant="body1" style={{ marginTop: '10px' }}>No links available.</Typography>
121 props.site.links.length > 0 &&
122 <DenseTable ariaLabel="available-links-table-entry" height={height} hover={true} headers={["Link Name", "Azimuth in °"]} data={linkRows} onClick={props.onLinkClick} ></DenseTable>
137 props.site.devices.length === 0 &&
138 <Typography aria-label="no-nodes-avilable" variant="body1" style={{ marginTop: '10px' }}>No nodes available.</Typography>
142 props.site.devices.length>0 && props.updatedDevices !== null &&
143 <DenseTable ariaLabel="available-nodes-table-entry" navigate={props.navigate} height={height} hover={false} headers={["ID","Name","Type", "Manufacturer","Owner","Status", "Ports", "Actions"]} actions={true} data={props.updatedDevices!} />
152 export default SiteDetails;