diff options
author | Shawn Severin <shawn.severin@amdocs.com> | 2017-12-07 15:19:25 -0500 |
---|---|---|
committer | Shawn Severin <shawn.severin@amdocs.com> | 2017-12-07 15:19:46 -0500 |
commit | a7b4b96afee33a2ff458f906742d88cd306ed961 (patch) | |
tree | dcf2b16fdc4f52368327d372112cebaf126a1ded /src/app/MainScreenWrapper.jsx | |
parent | 6ac2e7c0bef5ee478b36181b8bb384119ad3d937 (diff) |
Adding filter bar
Issue-ID: AAI-543
Change-Id: I18ec69f4585a9f01feafd009fcd30493a039b064
Signed-off-by: Shawn Severin <shawn.severin@amdocs.com>
Diffstat (limited to 'src/app/MainScreenWrapper.jsx')
-rw-r--r-- | src/app/MainScreenWrapper.jsx | 102 |
1 files changed, 74 insertions, 28 deletions
diff --git a/src/app/MainScreenWrapper.jsx b/src/app/MainScreenWrapper.jsx index 054450b..b5ce3bf 100644 --- a/src/app/MainScreenWrapper.jsx +++ b/src/app/MainScreenWrapper.jsx @@ -1,34 +1,36 @@ /* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ============LICENSE_START=================================================== + * SPARKY (AAI UI service) + * ============================================================================ + * Copyright © 2017 AT&T Intellectual Property. * Copyright © 2017 Amdocs - * ================================================================================ + * 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 + * 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. - * ============LICENSE_END========================================================= + * ============LICENSE_END===================================================== * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. */ + import React, {Component} from 'react'; import {connect} from 'react-redux'; - +import * as Extensibility from './extensibility/index.js'; import TierSupport from './tierSupport/TierSupport.jsx'; import VnfSearch from './vnfSearch/VnfSearch.jsx'; import MainScreenHeader from './MainScreenHeader.jsx'; +import {decryptParamsForView, changeUrlAddress} from 'utils/Routes.js'; -import DynamicViewLoader from - 'generic-components/dynamicViewLoader/dynamicViewLoader.jsx'; import { Route, @@ -38,26 +40,36 @@ import { } from 'react-router-dom'; import { - windowResize + windowResize, + extensibleViewNetworkCallback, + extensibleViewMessageCallback } from './MainScreenWrapperActionHelper.js'; -import customViews from 'resources/views/customViews.json'; +import extensibleViews from 'resources/views/extensibleViews.json'; const mapStateToProps = ({mainWrapper}) => { let { - showMenu = false, - toggleButtonActive = false - } = mainWrapper; + showMenu = false, + toggleButtonActive = false, + extensibleViewNetworkCallbackData = {} + } = mainWrapper; return { showMenu, - toggleButtonActive + toggleButtonActive, + extensibleViewNetworkCallbackData }; }; const mapActionsToProps = (dispatch) => { return { - onWindowSizeChange: () => dispatch(windowResize()) + onWindowSizeChange: () => dispatch(windowResize()), + onExtensibleViewNetworkCallback: (apiUrl,body,viewName,curViewData) => { + dispatch(extensibleViewNetworkCallback(apiUrl,body,viewName,curViewData)); + }, + onExtensibleViewMessageCallback: (message, messageSevirity) => { + dispatch(extensibleViewMessageCallback(message, messageSevirity)); + } }; }; @@ -68,28 +80,62 @@ class MainScreenWrapper extends Component { window.addEventListener('resize', () => { this.props.onWindowSizeChange(); }); + } + render() { + + const { + onExtensibleViewNetworkCallback, + extensibleViewNetworkCallbackData, + onExtensibleViewMessageCallback + } = this.props; + let customViewList = []; + extensibleViews.forEach(function(view,key){ + var renderComponent = (props) => { + let viewParams = {}; + if(props.match.params.extensibleViewParams !== undefined) { + viewParams = decryptParamsForView(props.match.params.extensibleViewParams); + } + + if (Extensibility.default.hasOwnProperty(view.componentName)) { + let Component = Extensibility.default[view.componentName]; + return ( + <Component + {...props} + networkingCallback={(apiUrl, body, paramName,curViewData) => { + onExtensibleViewNetworkCallback(apiUrl, body, paramName, curViewData); + }} + messagingCallback ={(message, messageSevirity) => { + onExtensibleViewMessageCallback(message, messageSevirity); + }} + changeRouteCallback = {(routeParam, historyObj) => { + changeUrlAddress(routeParam, historyObj); + }} + viewName={view.displayName} + viewData={extensibleViewNetworkCallbackData} + viewParams={viewParams}/> + ); + } + }; - // add all custom views - for (let view in customViews) { customViewList.push( - <Route path={'/' + customViews[view]['viewName']} - component={DynamicViewLoader}/> + <Route key={extensibleViews[key]['viewName'] + 'Route'} path={'/' + extensibleViews[key]['viewName'] + '/:extensibleViewParams?' } + render={renderComponent}/> ); - } + }); return ( <Router> - <div> + <div className='main-app-container'> <Switch> - <Redirect from='/' exact to='/viewInspect'/> + <Redirect from='/' exact to='/schema'/> </Switch> - <Route path='/' component={MainScreenHeader}/> - <Route path='/viewInspect/:viParam?' component={TierSupport}/> - <Route path='/vnfSearch/:vnfParam?' component={VnfSearch}/> + <Route key='MainScreenHeaderRoute' path='/:externalUrl?' component={MainScreenHeader}/> + <Route key='TierSupportRoue' path='/schema/:viParam?' component={TierSupport}/> + <Route key='VnfSearchRoute' path='/vnfSearch/:filters?' component={VnfSearch}/> {customViewList} </div> </Router> |