X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=skyquake%2Fplugins%2Flaunchpad%2Fsrc%2Flaunchpad_card%2FnsrConfigPrimitives.jsx;fp=skyquake%2Fplugins%2Flaunchpad%2Fsrc%2Flaunchpad_card%2FnsrConfigPrimitives.jsx;h=b44b3d94bef01d26b94573479258281139ae0bfb;hb=e29efc315df33d546237e270470916e26df391d6;hp=0000000000000000000000000000000000000000;hpb=9c5e457509ba5a1822c316635c6308874e61b4b9;p=osm%2FUI.git
diff --git a/skyquake/plugins/launchpad/src/launchpad_card/nsrConfigPrimitives.jsx b/skyquake/plugins/launchpad/src/launchpad_card/nsrConfigPrimitives.jsx
new file mode 100644
index 000000000..b44b3d94b
--- /dev/null
+++ b/skyquake/plugins/launchpad/src/launchpad_card/nsrConfigPrimitives.jsx
@@ -0,0 +1,371 @@
+
+/*
+ *
+ * Copyright 2016 RIFT.IO Inc
+ *
+ * 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 {Tab, Tabs, TabList, TabPanel} from 'react-tabs';
+import RecordViewStore from '../recordViewer/recordViewStore.js';
+import Button from 'widgets/button/rw.button.js';
+import './nsConfigPrimitives.scss';
+import TextInput from 'widgets/form_controls/textInput.jsx';
+import SkyquakeComponent from 'widgets/skyquake_container/skyquakeComponent.jsx';
+
+class NsrConfigPrimitives extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {};
+ this.state.vnfrMap = null;
+ this.state.nsConfigPrimitives = null;
+ }
+
+ componentWillReceiveProps(props) {
+ let vnfrs = props.data['vnfrs'];
+ let vnfrMap = {};
+ let nsConfigPrimitives = [];
+ let vnfList = [];
+ if (vnfrs && !this.state.nsConfigPrimitives) {
+ vnfrs.map((vnfr) => {
+ let vnfrConfigPrimitive = {};
+ vnfrConfigPrimitive.name = vnfr['short-name'];
+ vnfrConfigPrimitive['vnfr-id-ref'] = vnfr['id'];
+ //input references
+ let configPrimitives = vnfr['vnf-configuration']['service-primitive'];
+ //input references by key
+ let vnfrConfigPrimitives = {}
+
+ if (configPrimitives) {
+ let vnfPrimitiveList = [];
+ configPrimitives.map((configPrimitive) => {
+ vnfrConfigPrimitives[configPrimitive.name] = configPrimitive;
+ vnfPrimitiveList.push({
+ name: configPrimitive.name,
+ parameter: configPrimitive.parameter
+ })
+ });
+ vnfrConfigPrimitive['service-primitives'] = vnfrConfigPrimitives;
+ vnfrMap[vnfr['member-vnf-index-ref']] = vnfrConfigPrimitive;
+ }
+ });
+ //nsr service-primitives
+ props.data['service-primitive'] && props.data['service-primitive'].map((nsConfigPrimitive, nsConfigPrimitiveIndex) => {
+ //Add optional field to group. Necessary for driving state.
+ let optionalizedNsConfigPrimitiveGroup = nsConfigPrimitive['parameter-group'] && nsConfigPrimitive['parameter-group'].map((parameterGroup)=>{
+ if(parameterGroup && parameterGroup.mandatory != "true") {
+ parameterGroup.optionalChecked = true;
+ };
+ return parameterGroup;
+ });
+ let nscp = {
+ name: nsConfigPrimitive.name,
+ 'nsr_id_ref': props.data.id,
+ 'parameter': nsConfigPrimitive.parameter,
+ 'parameter-group': optionalizedNsConfigPrimitiveGroup,
+ 'vnf-primitive-group':[]
+ }
+
+ nsConfigPrimitive['vnf-primitive-group'] && nsConfigPrimitive['vnf-primitive-group'].map((vnfPrimitiveGroup, vnfPrimitiveGroupIndex) => {
+ let vnfMap = vnfrMap[vnfPrimitiveGroup['member-vnf-index-ref']];
+ let vnfGroup = {};
+ vnfGroup.name = vnfMap.name;
+ vnfGroup['member-vnf-index-ref'] = vnfPrimitiveGroup['member-vnf-index-ref'];
+ vnfGroup['vnfr-id-ref'] = vnfMap['vnfr-id-ref'];
+ vnfGroup.inputs = [];
+ vnfPrimitiveGroup.primitive.map((primitive, primitiveIndex) => {
+ console.log(primitive);
+ primitive.index = primitiveIndex;
+ primitive.parameter = [];
+ vnfMap['service-primitives'][primitive.name].parameter.map(function(p) {
+ p.index = primitiveIndex;
+ let paramCopy = p;
+ paramCopy.value = undefined;
+ primitive.parameter.push(paramCopy);
+ });
+ vnfGroup.inputs.push(primitive);
+ });
+ nscp['vnf-primitive-group'].push(vnfGroup);
+ });
+ nsConfigPrimitives.push(nscp);
+ });
+ this.setState({
+ vnfrMap: vnfrMap,
+ data: props.data,
+ nsConfigPrimitives: nsConfigPrimitives
+ });
+ }
+ }
+
+ handleParamChange = (parameterIndex, vnfPrimitiveIndex, vnfListIndex, nsConfigPrimitiveIndex, event) => {
+ let nsConfigPrimitives = this.state.nsConfigPrimitives;
+ nsConfigPrimitives[nsConfigPrimitiveIndex]['vnf-primitive-group'][vnfListIndex]['inputs'][vnfPrimitiveIndex]['parameter'][parameterIndex]['value'] = event.target.value;
+ this.setState({
+ nsConfigPrimitives: nsConfigPrimitives
+ });
+ }
+
+ handleNsParamChange = (parameterIndex, nsConfigPrimitiveIndex, event) => {
+ let nsConfigPrimitives = this.state.nsConfigPrimitives;
+ nsConfigPrimitives[nsConfigPrimitiveIndex]['parameter'][parameterIndex]['value'] = event.target.value;
+ this.setState({
+ nsConfigPrimitives: nsConfigPrimitives
+ });
+ }
+
+ handleNsParamGroupParamChange = (parameterIndex, parameterGroupIndex, nsConfigPrimitiveIndex, event) => {
+ let nsConfigPrimitives = this.state.nsConfigPrimitives;
+ nsConfigPrimitives[nsConfigPrimitiveIndex]['parameter-group'][parameterGroupIndex]['parameter'][parameterIndex]['value'] = event.target.value;
+ this.setState({
+ nsConfigPrimitives: nsConfigPrimitives
+ });
+ }
+
+ handleExecuteClick = (nsConfigPrimitiveIndex, event) => {
+ var isValid = RecordViewStore.validateInputs({
+ nsConfigPrimitives: this.state.nsConfigPrimitives,
+ nsConfigPrimitiveIndex: nsConfigPrimitiveIndex
+ });
+ if(isValid) {
+ RecordViewStore.constructAndTriggerNsConfigPrimitive({
+ nsConfigPrimitives: this.state.nsConfigPrimitives,
+ nsConfigPrimitiveIndex: nsConfigPrimitiveIndex
+ });
+ //Need a better way to reset
+ //Reset disabled per TEF request
+ // this.setState({
+ // nsConfigPrimitives: null
+ // })
+ } else {
+ this.props.actions.showNotification('Could not execute service config. Please review your parameters');
+ }
+ }
+ handleOptionalCheck = (parameterGroupIndex, nsConfigPrimitiveIndex, event) => {
+ let nsConfigPrimitives = this.state.nsConfigPrimitives;
+ let optionalChecked = nsConfigPrimitives[nsConfigPrimitiveIndex]['parameter-group'][parameterGroupIndex].optionalChecked;
+ nsConfigPrimitives[nsConfigPrimitiveIndex]['parameter-group'][parameterGroupIndex].optionalChecked = !optionalChecked;
+ console.log(nsConfigPrimitives)
+ this.setState({
+ nsConfigPrimitives: nsConfigPrimitives
+ });
+ }
+ constructConfigPrimitiveTabs = (tabList, tabPanels) => {
+ let self = this;
+ let defaultFromRpc = '';
+ //coded here for dev purposes
+ let mandatoryFieldValue = 'true';
+ if (self.state.vnfrMap) {
+ this.state.nsConfigPrimitives && this.state.nsConfigPrimitives.map((nsConfigPrimitive, nsConfigPrimitiveIndex) => {
+ tabList.push(
+ {nsConfigPrimitive.name}
+
+ {
+
+ {parameterGroup.name} {optionalField}
+
+
+
+ {
+
+ {vnfGroup.name}
+
+ {vnfGroup.inputs.map((inputGroup, inputGroupIndex) => {
+ return (
+ {inputGroup.name}
+
+ {
+ inputGroup.parameter.map((input, inputIndex) => {
+ let optionalField = '';
+ let displayField = '';
+ let defaultValue = input['default-value'] || '';
+ let isFieldHidden = (input['hidden'] && input['hidden'] == 'true') || false;
+ let isFieldReadOnly = (input['read-only'] && input['read-only'] == 'true') || false;
+ if (input.mandatory == mandatoryFieldValue) {
+ optionalField = *
+ }
+ if (isFieldReadOnly) {
+ displayField =
+