Merge "SDN-R add updated featureaggregator"
[ccsdk/features.git] / sdnr / wt / odlux / apps / configurationApp / src / views / networkElementSelector.tsx
1 /**
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt odlux
4  * =================================================================================================
5  * Copyright (C) 2019 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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18
19 import * as React from 'react';
20 import { RouteComponentProps, withRouter } from 'react-router-dom';
21
22 import connect, { IDispatcher, Connect } from "../../../../framework/src/flux/connect";
23 import { IApplicationStoreState } from "../../../../framework/src/store/applicationStore";
24 import { MaterialTable, MaterialTableCtorType, ColumnType } from "../../../../framework/src/components/material-table";
25 import { createConnectedNetworkElementsProperties, createConnectedNetworkElementsActions } from "../../../configurationApp/src/handlers/connectedNetworkElementsHandler";
26
27 import { NetworkElementConnection } from "../models/networkElementConnection";
28 import { Tooltip, Button, IconButton } from "@material-ui/core";
29
30 const mapProps = (state: IApplicationStoreState) => ({
31   connectedNetworkElementsProperties: createConnectedNetworkElementsProperties(state),
32 });
33
34 const mapDispatch = (dispatcher: IDispatcher) => ({
35   connectedNetworkElementsActions: createConnectedNetworkElementsActions(dispatcher.dispatch),
36 });
37
38 const ConnectedElementTable = MaterialTable as MaterialTableCtorType<NetworkElementConnection>;
39
40 type NetworkElementSelectorComponentProps = RouteComponentProps & Connect<typeof mapProps, typeof mapDispatch>;
41
42 class NetworkElementSelectorComponent extends React.Component<NetworkElementSelectorComponentProps> {
43
44   componentDidMount() {
45     this.props.connectedNetworkElementsActions.onRefresh();
46   }
47
48   render() {
49     return (
50       <ConnectedElementTable onHandleClick={(e, row) => { this.props.history.push(`${this.props.match.path}/${row.nodeId}`) }} columns={[
51         { property: "nodeId", title: "Name", type: ColumnType.text },
52         { property: "isRequired", title: "Required ?", type: ColumnType.boolean },
53         { property: "host", title: "Host", type: ColumnType.text },
54         { property: "port", title: "Port", type: ColumnType.numeric },
55         { property: "coreModelCapability", title: "Core Model", type: ColumnType.text },
56         { property: "deviceType", title: "Type", type: ColumnType.text },
57       ]} idProperty="id" {...this.props.connectedNetworkElementsActions} {...this.props.connectedNetworkElementsProperties} asynchronus >
58       </ConnectedElementTable>
59     );
60   }
61 }
62
63 export const NetworkElementSelector = withRouter(connect(mapProps, mapDispatch)(NetworkElementSelectorComponent));
64 export default NetworkElementSelector;
65