2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
16 import React from 'react';
17 import i18n from 'nfvo-utils/i18n/i18n.js';
18 import Form from 'nfvo-components/input/validation/Form.jsx';
20 import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx';
21 import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx';
22 import ListEditorItemViewField from 'nfvo-components/listEditor/ListEditorItemViewField.jsx';
23 import Input from'nfvo-components/input/validation/Input.jsx';
26 class SoftwareProductComponentsNetworkView extends React.Component {
33 let {dataMap, qgenericFieldInfo, onQDataChanged, isReadOnlyMode} = this.props;
36 <div className='vsp-components-network'>
37 <div className='network-data'>
39 { qgenericFieldInfo && <Form
42 onSubmit={() => this.save()}
43 isReadOnlyMode={isReadOnlyMode}
45 <h3 className='section-title'>{i18n('Network Capacity')}</h3>
46 <div className='rows-section'>
47 <div className='row-flex-components'>
48 <div className='single-col'>
50 data-test-id='protocolWithHighestTrafficProfileAcrossAllNICs'
51 label={i18n('Protocol with Highest Traffic Profile across all NICs')}
53 groupClassName='bootstrap-input-options'
54 className='input-options-select'
55 isValid={qgenericFieldInfo['network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs'].isValid}
56 errorText={qgenericFieldInfo['network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs'].errorText}
57 value={dataMap['network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs']}
59 const selectedIndex = e.target.selectedIndex;
60 const val = e.target.options[selectedIndex].value;
61 onQDataChanged({'network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs' : val});}
63 <option key='placeholder' value=''>{i18n('Select...')}</option>
64 { qgenericFieldInfo['network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs'].enum.map(proto =>
65 <option value={proto.enum} key={proto.enum}>{proto.title}</option>) }
68 <div className='single-col add-line-break'>
70 data-test-id='networkTransactionsPerSecond'
71 label={i18n('Network Transactions per Second')}
73 onChange={(ntps) => onQDataChanged({'network/networkCapacity/networkTransactionsPerSecond' : ntps})}
74 isValid={qgenericFieldInfo['network/networkCapacity/networkTransactionsPerSecond'].isValid}
75 errorText={qgenericFieldInfo['network/networkCapacity/networkTransactionsPerSecond'].errorText}
76 value={dataMap['network/networkCapacity/networkTransactionsPerSecond']} />
78 <div className='empty-two-col' />
84 {this.renderNicList()}
92 const {localFilter} = this.state;
93 let {isReadOnlyMode, onAddNic, isManual} = this.props;
96 title={i18n('Interfaces')}
97 filterValue={localFilter}
98 placeholder={i18n('Filter NICs by Name')}
99 isReadOnlyMode={isReadOnlyMode}
100 onFilter={value => this.setState({localFilter: value})}
101 onAdd={isManual ? onAddNic : null}
102 plusButtonTitle={i18n('Add NIC')}
104 {this.filterList().map(nic => this.renderNicListItem(nic, isReadOnlyMode))}
109 renderNicListItem(nic, isReadOnlyMode) {
110 let {id, name, description, networkName = ''} = nic;
111 let {onEditNicClick, version, isManual, onDeleteNic} = this.props;
115 isReadOnlyMode={isReadOnlyMode}
116 onSelect={() => onEditNicClick(nic, version, isReadOnlyMode)}
117 onDelete={isManual ? () => onDeleteNic(nic, version) : null}>
119 <ListEditorItemViewField>
120 <div className='name'>{name}</div>
121 </ListEditorItemViewField>
122 <ListEditorItemViewField>
123 <div className={isManual ? 'details-col' : 'details'}>
124 <div className={isManual ? 'manual-title' : 'title'}>{i18n('Purpose of NIC')}</div>
125 <div className={isManual ? 'description' : ''}>{description ? description : i18n('N/A')}</div>
127 {!isManual && <div className='details'>
128 <div className='title'>{i18n('Network')}</div>
129 <div className='artifact-name'>{networkName}</div>
131 </ListEditorItemViewField>
133 </ListEditorItemView>
138 let {nicList} = this.props;
139 let {localFilter} = this.state;
140 if (localFilter.trim()) {
141 const filter = new RegExp(escape(localFilter), 'i');
142 return nicList.filter(({name = '', description = ''}) => {
143 return escape(name).match(filter) || escape(description).match(filter);
152 let {onSubmit, qdata, version} = this.props;
153 return onSubmit({qdata, version});
157 export default SoftwareProductComponentsNetworkView;