/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing * permissions and limitations under the License. */ import React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Form from 'nfvo-components/input/validation/Form.jsx'; import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; import ListEditorItemViewField from 'nfvo-components/listEditor/ListEditorItemViewField.jsx'; import Input from'nfvo-components/input/validation/Input.jsx'; class SoftwareProductComponentsNetworkView extends React.Component { state = { localFilter: '' }; render() { let {dataMap, qgenericFieldInfo, onQDataChanged, isReadOnlyMode} = this.props; return(
{ qgenericFieldInfo &&
this.save()} isReadOnlyMode={isReadOnlyMode} hasButtons={false}>

{i18n('Network Capacity')}

{ const selectedIndex = e.target.selectedIndex; const val = e.target.options[selectedIndex].value; onQDataChanged({'network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs' : val});} }> { qgenericFieldInfo['network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs'].enum.map(proto => ) }
onQDataChanged({'network/networkCapacity/networkTransactionsPerSecond' : ntps})} isValid={qgenericFieldInfo['network/networkCapacity/networkTransactionsPerSecond'].isValid} errorText={qgenericFieldInfo['network/networkCapacity/networkTransactionsPerSecond'].errorText} value={dataMap['network/networkCapacity/networkTransactionsPerSecond']} />
}
{this.renderNicList()}
); } renderNicList() { const {localFilter} = this.state; let {isReadOnlyMode, onAddNic, isManual} = this.props; return ( this.setState({localFilter: value})} onAdd={isManual ? onAddNic : null} plusButtonTitle={i18n('Add NIC')} twoColumns> {this.filterList().map(nic => this.renderNicListItem(nic, isReadOnlyMode))} ); } renderNicListItem(nic, isReadOnlyMode) { let {id, name, description, networkName = ''} = nic; let {onEditNicClick, version, isManual, onDeleteNic} = this.props; return ( onEditNicClick(nic, version, isReadOnlyMode)} onDelete={isManual ? () => onDeleteNic(nic, version) : null}>
{name}
{i18n('Purpose of NIC')}
{description &&
{description}
}
{!isManual &&
{i18n('Network')}
{networkName}
}
); } filterList() { let {nicList} = this.props; let {localFilter} = this.state; if (localFilter.trim()) { const filter = new RegExp(escape(localFilter), 'i'); return nicList.filter(({name = '', description = ''}) => { return escape(name).match(filter) || escape(description).match(filter); }); } else { return nicList; } } save() { let {onSubmit, qdata, version} = this.props; return onSubmit({qdata, version}); } } export default SoftwareProductComponentsNetworkView;