From: Laurence Maultsby Date: Tue, 10 Jan 2017 02:25:23 +0000 (-0500) Subject: RIFT-15154: Config parameter map X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=commitdiff_plain;h=1065d361f1c1b0c4f1334efe736f2e6e940e7035 RIFT-15154: Config parameter map Signed-off-by: Laurence Maultsby --- diff --git a/skyquake/plugins/composer/src/src/components/CanvasPanel.js b/skyquake/plugins/composer/src/src/components/CanvasPanel.js index 96904ea16..dda1372b7 100644 --- a/skyquake/plugins/composer/src/src/components/CanvasPanel.js +++ b/skyquake/plugins/composer/src/src/components/CanvasPanel.js @@ -34,9 +34,9 @@ import CanvasPanelTray from './CanvasPanelTray' import EditForwardingGraphPaths from './EditorForwardingGraph/EditForwardingGraphPaths' import SelectionManager from '../libraries/SelectionManager' import DescriptorModelIconFactory from '../libraries/model/IconFactory' - import FileManager from './filemanager/FileManager.jsx'; +import ConfigPrimitiveParameters from './ConfigPrimitiveParameters/ConfigPrimitiveParameters' import '../styles/CanvasPanel.scss' const CanvasPanel = React.createClass({ @@ -87,6 +87,13 @@ const CanvasPanel = React.createClass({ ) + //CanvasPanelTray panel to display + let displayedPanel = null; + switch (this.props.displayedPanel) { + case 'forwarding' : displayedPanel = (); break; + case 'parameter' : displayedPanel = (); break; + default: displayedPanel = (

Please select a tab

); break; + } return (
@@ -104,8 +111,8 @@ const CanvasPanel = React.createClass({ : null } - - + + {displayedPanel}
); diff --git a/skyquake/plugins/composer/src/src/components/CanvasPanelTray.js b/skyquake/plugins/composer/src/src/components/CanvasPanelTray.js index 57f29a05e..5fde578af 100644 --- a/skyquake/plugins/composer/src/src/components/CanvasPanelTray.js +++ b/skyquake/plugins/composer/src/src/components/CanvasPanelTray.js @@ -16,13 +16,17 @@ export default function (props) { right: props.layout.right, display: props.show ? false : 'none' }; + const PANEL = { + FORWARD: 'forwarding', + PARAMETER: 'parameter' + } const classNames = ClassNames('CanvasPanelTray', {'-with-transitions': !document.body.classList.contains('resizing')}); function onClickToggleOpenClose(event) { if (event.defaultPrevented) return; event.preventDefault(); // don't toggle if the user was resizing if (!uiTransient.isResizing) { - CanvasPanelTrayActions.toggleOpenClose(); + CanvasPanelTrayActions.toggleOpenClose(event); } event.target.removeEventListener('mousemove', onMouseMove, true); } @@ -37,10 +41,29 @@ export default function (props) { const isOpen = style.height > 25; return (
-

Forwarding Graphs

+
+ + + +
+ +
+
{props.children}
); -} \ No newline at end of file +} diff --git a/skyquake/plugins/composer/src/src/components/ComposerApp.js b/skyquake/plugins/composer/src/src/components/ComposerApp.js index b5cfa7528..e2cf2840f 100644 --- a/skyquake/plugins/composer/src/src/components/ComposerApp.js +++ b/skyquake/plugins/composer/src/src/components/ComposerApp.js @@ -212,6 +212,7 @@ const ComposerApp = React.createClass({ filesState={self.state.filesState} item={self.state.item} type={self.state.filterCatalogByTypeValue} + displayedPanel={self.state.displayedPanel} /> { (self.state.panelTabShown == 'descriptor') ? diff --git a/skyquake/plugins/composer/src/src/components/ConfigPrimitiveParameters/ConfigPrimitiveParameters.js b/skyquake/plugins/composer/src/src/components/ConfigPrimitiveParameters/ConfigPrimitiveParameters.js new file mode 100644 index 000000000..362106175 --- /dev/null +++ b/skyquake/plugins/composer/src/src/components/ConfigPrimitiveParameters/ConfigPrimitiveParameters.js @@ -0,0 +1,236 @@ + +/* + * + * 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. + * + */ + + +'use strict'; + +import d3 from 'd3' +import React from 'react' +import Range from '../Range' +import Button from '../Button' +import ClassNames from 'classnames' +import changeCase from 'change-case' +import LayoutRow from '../LayoutRow' +import SelectionManager from '../../libraries/SelectionManager' +import PureRenderMixin from 'react-addons-pure-render-mixin' +import CatalogItemsActions from '../../actions/CatalogItemsActions' +import CanvasEditorActions from '../../actions/CanvasEditorActions' +import DescriptorModelFactory from '../../libraries/model/DescriptorModelFactory' +import ComposerAppActions from '../../actions/ComposerAppActions' +import DescriptorModelMetaFactory from '../../libraries/model/DescriptorModelMetaFactory' +import ComposerAppStore from '../../stores/ComposerAppStore' +import DeletionManager from '../../libraries/DeletionManager' +import ContentEditableDiv from '../ContentEditableDiv' +import TooltipManager from '../../libraries/TooltipManager' +import HighlightRecordServicePaths from '../../libraries/graph/HighlightRecordServicePaths' + +import '../../styles/EditForwardingGraphPaths.scss' + +import imgNSD from '../../images/default-catalog-icon.svg' +import imgFG from '../../../../node_modules/open-iconic/svg/infinity.svg' +import imgRemove from '../../../../node_modules/open-iconic/svg/trash.svg' +import imgAdd from '../../../../node_modules/open-iconic/svg/plus.svg' +import imgConnection from '../../../../node_modules/open-iconic/svg/random.svg' +import imgClassifier from '../../../../node_modules/open-iconic/svg/spreadsheet.svg' +import imgReorder from '../../../../node_modules/open-iconic/svg/menu.svg' +import EditDescriptorModelProperties from '../EditDescriptorModelProperties' +function configParameterMapMap(ap, i) { + + const context = this; + context.vnfapMap = ap; + return ( +
+
{ap.id}
+
{ap.capability['member-vnf-index']}
+
{ap.capability['capability-ref']}
+ +
+ ) + /* + // const colors = fg.colors; + // const stylePrimary = {borderColor: colors.primary}; + // const styleSecondary = {borderColor: colors.secondary}; + + // context.stylePrimary = stylePrimary; + // context.styleSecondary = styleSecondary; + + // const rspMap = fg.rsp.reduce((map, rsp) => { + // map[rsp.id] = rsp; + // rsp.classifier = []; + // return map; + // }, {}); + + // fg.classifier.forEach(classifier => { + // const rsp = rspMap[classifier.model['rsp-id-ref']]; + // if (rsp) { + // rsp.classifier.push(classifier); + // } + // }); + + // function onClickRemoveForwardingGraph(fg, event) { + // event.preventDefault(); + // const root = fg.getRoot(); + // fg.remove(); + // CatalogItemsActions.catalogItemDescriptorChanged(root); + // } + + // function onClickAddClassifier(context, fg, event) { + // event.preventDefault(); + // fg.createClassifier(); + // CatalogItemsActions.catalogItemDescriptorChanged(fg.getRoot()); + // } + + // function onClickToggleShowAllFGPaths(fg, event) { + // //event.preventDefault(); + // event.stopPropagation(); + // fg.uiState.showPaths = event.target.checked; + // fg.rsp.forEach(rsp => rsp.uiState.showPath = event.target.checked); + // CatalogItemsActions.catalogItemMetaDataChanged(fg.getRoot().model); + // } + + // if (!fg.uiState.hasOwnProperty('showPaths')) { + // fg.uiState.showPaths = true; + // fg.rsp.forEach(d => d.uiState.showPath = true); + // } + + // const toggleSelectAllPaths = ( + // {}} onClick={onClickToggleShowAllFGPaths.bind(null, fg)} /> + // ); + + // const srpFactory = DescriptorModelFactory.newRecordServicePathFactory({}, fg); + // srpFactory.uid = fg.uid + i; + + // const hasServiceFunctionVNFDs = context.containers.filter(d => DescriptorModelFactory.isConstituentVnfdWithServiceChain(d, 'SF')).length > 0; + + // return ( + //
+ //
+ //
+ //
+ // }> + // {fg.title} + // + //
+ //

Rendered Service Paths

+ // {hasServiceFunctionVNFDs ? fg.recordServicePaths.concat(srpFactory).map(mapRecordServicePath.bind(null, context)) : A VNFD with the chain SF is required to build Rendered Service Paths.} + //
+ //
+ //

Classifiers

+ // {fg.classifier.map(mapClassifier.bind(null, context))} + //
+ //
+ //
+ //
+ //
+ //
+ // ); + */ + +} + +function mapNSD(nsd, i) { + + const context = this; + context.nsd = nsd; + + function onClickAddConfigParameterMap(nsd, event) { + event.preventDefault(); + nsd.createConfigParameterMap(); + CatalogItemsActions.catalogItemDescriptorChanged(nsd.getRoot()); + } + + const forwardingGraphs = nsd.configParameterMap.map(configParameterMap.bind(context)); + if (forwardingGraphs.length === 0) { + forwardingGraphs.push( +
+ No Forwarding Graphs to model. +
+ ); + } + + return ( +
+ {forwardingGraphs} +
+
+
+
+
+ ); + +} + +const ConfigPrimitiveParameters = React.createClass({ + mixins: [PureRenderMixin], + getInitialState: function () { + return ComposerAppStore.getState(); + }, + getDefaultProps: function () { + return { + containers: [] + }; + }, + componentWillMount: function () { + }, + componentDidMount: function () { + }, + componentDidUpdate: function () { + }, + componentWillUnmount: function () { + }, + render() { + const self = this; + const containers = this.props.containers; + const context = { + component: this, + containers: containers + }; + + const networkService = containers.filter(d => d.type === 'nsd'); + if (networkService.length === 0) { + return

No NSD open in the canvas. Try opening an NSD.

; + } + return ( +
+ { + containers.map(function(c, i) { + if(c.className == 'ConfigParameterMap') { + return + } + }) + } +
+ ) + // return ( + //
+ //
+ // {containers.filter(d => d.type === 'nsd').map(mapNSD.bind(context))} + //
+ // ); + + } +}); + + + +export default ConfigPrimitiveParameters; +// diff --git a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js index 4ee4345b7..2a5da2191 100644 --- a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js +++ b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js @@ -46,6 +46,8 @@ import imgRemove from '../../../node_modules/open-iconic/svg/trash.svg' import '../styles/EditDescriptorModelProperties.scss' + + function getDescriptorMetaBasicForType(type) { const basicPropertiesFilter = d => _.includes(DESCRIPTOR_MODEL_FIELDS[type], d.name); return DescriptorModelMetaFactory.getModelMetaForType(type, basicPropertiesFilter) || {properties: []}; @@ -70,16 +72,7 @@ function getTitle(model = {}) { return model.id; } } - -export default function EditDescriptorModelProperties(props) { - - const container = props.container; - - if (!(DescriptorModelFactory.isContainer(container))) { - return - } - - function startEditing() { +function startEditing() { DeletionManager.removeEventListeners(); } @@ -262,7 +255,7 @@ export default function EditDescriptorModelProperties(props) { }); } - function buildChoice(container, property, path, value, key) { + function buildChoice(container, property, path, value, key, props={}) { function onFormFieldValueChanged(event) { if (DescriptorModelFactory.isContainer(this)) { @@ -516,15 +509,15 @@ export default function EditDescriptorModelProperties(props) { if (isMissingDescriptorMeta) { field = No Descriptor Meta for {property.name}; } else if (property.type === 'choice') { - field = buildChoice(container, property, valuePath, value, key.join(':')); + field = buildChoice(container, property, valuePath, value, key.join(':'), props); } else if (isSimpleListView) { - field = buildSimpleListItem(container, property, valuePath, value, key, index); + field = buildSimpleListItem(container, property, valuePath, value, key, index, props); } else if (isLeafList) { - field = buildLeafListItem(container, property, valuePath, value, key, index); + field = buildLeafListItem(container, property, valuePath, value, key, index, props); } else if (hasProperties) { - field = buildElement(container, property, valuePath, value, key.join(':')) + field = buildElement(container, property, valuePath, value, key.join(':'), props) } else { - field = buildField(container, property, valuePath, value, key.join(':')); + field = buildField(container, property, valuePath, value, key.join(':'), props); } function onClickLeaf(property, path, value, event) { @@ -594,8 +587,17 @@ export default function EditDescriptorModelProperties(props) { ); } +export default function EditDescriptorModelProperties(props, type) { + + const container = props.container; + + if (!(DescriptorModelFactory.isContainer(container))) { + return + } + + - const containerType = container.uiState['qualified-type'] || container.uiState.type; + const containerType = (_.isEmpty(type) ? false : type)|| container.uiState['qualified-type'] || container.uiState.type; const basicProperties = getDescriptorMetaBasicForType(containerType).properties; function buildBasicGroup() { @@ -633,7 +635,7 @@ export default function EditDescriptorModelProperties(props) { {properties.map(property => { const path = [property.name]; const value = container.model[property.name]; - return build(container, property, path, value, {toggle: true, width: props.width}); + return build(container, property, path, value, _.assign({toggle: true, width: props.width}, props)); })}
We need this so when the user closes the panel it won't shift away and scare the bj out of them!
@@ -665,3 +667,6 @@ export default function EditDescriptorModelProperties(props) { ); } +export {build} +// export buildElement; +// export buildChoice; diff --git a/skyquake/plugins/composer/src/src/components/EditDescriptorModelPropertiesBkUp.js b/skyquake/plugins/composer/src/src/components/EditDescriptorModelPropertiesBkUp.js new file mode 100644 index 000000000..c8e664a83 --- /dev/null +++ b/skyquake/plugins/composer/src/src/components/EditDescriptorModelPropertiesBkUp.js @@ -0,0 +1,671 @@ +/* + * + * 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. + * + */ +/** + * Created by onvelocity on 1/18/16. + * + * This class generates the form fields used to edit the CONFD JSON model. + */ +'use strict'; + +import _ from 'lodash' +import utils from '../libraries/utils' +import React from 'react' +import ClassNames from 'classnames' +import changeCase from 'change-case' +import toggle from '../libraries/ToggleElementHandler' +import Button from './Button' +import Property from '../libraries/model/DescriptorModelMetaProperty' +import ComposerAppActions from '../actions/ComposerAppActions' +import CatalogItemsActions from '../actions/CatalogItemsActions' +import DESCRIPTOR_MODEL_FIELDS from '../libraries/model/DescriptorModelFields' +import DescriptorModelFactory from '../libraries/model/DescriptorModelFactory' +import DescriptorModelMetaFactory from '../libraries/model/DescriptorModelMetaFactory' +import SelectionManager from '../libraries/SelectionManager' +import DeletionManager from '../libraries/DeletionManager' +import DescriptorModelIconFactory from '../libraries/model/IconFactory' +import getEventPath from '../libraries/getEventPath' +import CatalogDataStore from '../stores/CatalogDataStore' + +import imgAdd from '../../../node_modules/open-iconic/svg/plus.svg' +import imgRemove from '../../../node_modules/open-iconic/svg/trash.svg' + +import '../styles/EditDescriptorModelProperties.scss' + + + +function getDescriptorMetaBasicForType(type) { + const basicPropertiesFilter = d => _.contains(DESCRIPTOR_MODEL_FIELDS[type], d.name); + return DescriptorModelMetaFactory.getModelMetaForType(type, basicPropertiesFilter) || {properties: []}; +} + +function getDescriptorMetaAdvancedForType(type) { + const advPropertiesFilter = d => !_.contains(DESCRIPTOR_MODEL_FIELDS[type], d.name); + return DescriptorModelMetaFactory.getModelMetaForType(type, advPropertiesFilter) || {properties: []}; +} + +function getTitle(model = {}) { + if (typeof model['short-name'] === 'string' && model['short-name']) { + return model['short-name']; + } + if (typeof model.name === 'string' && model.name) { + return model.name; + } + if (model.uiState && typeof model.uiState.displayName === 'string' && model.uiState.displayName) { + return model.uiState.displayName + } + if (typeof model.id === 'string') { + return model.id; + } +} + +export default function EditDescriptorModelProperties(props) { + + const container = props.container; + + if (!(DescriptorModelFactory.isContainer(container))) { + return + } + + function startEditing() { + DeletionManager.removeEventListeners(); + } + + function endEditing() { + DeletionManager.addEventListeners(); + } + + function onClickSelectItem(property, path, value, event) { + event.preventDefault(); + const root = this.getRoot(); + if (SelectionManager.select(value)) { + CatalogItemsActions.catalogItemMetaDataChanged(root.model); + } + } + + function onFocusPropertyFormInputElement(property, path, value, event) { + + event.preventDefault(); + startEditing(); + + function removeIsFocusedClass(event) { + event.target.removeEventListener('blur', removeIsFocusedClass); + Array.from(document.querySelectorAll('.-is-focused')).forEach(d => d.classList.remove('-is-focused')); + } + + removeIsFocusedClass(event); + + const propertyWrapper = getEventPath(event).reduce((parent, element) => { + if (parent) { + return parent; + } + if (!element.classList) { + return false; + } + if (element.classList.contains('property')) { + return element; + } + }, false); + + if (propertyWrapper) { + propertyWrapper.classList.add('-is-focused'); + event.target.addEventListener('blur', removeIsFocusedClass); + } + + } + + function buildAddPropertyAction(container, property, path) { + function onClickAddProperty(property, path, event) { + event.preventDefault(); + //SelectionManager.resume(); + const create = Property.getContainerCreateMethod(property, this); + if (create) { + const model = null; + create(model, path, property); + } else { + const name = path.join('.'); + const value = Property.createModelInstance(property); + utils.assignPathValue(this.model, name, value); + } + CatalogItemsActions.catalogItemDescriptorChanged(this.getRoot()); + } + return ( +