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 | |
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')
35 files changed, 1573 insertions, 655 deletions
diff --git a/src/app/AppStore.js b/src/app/AppStore.js index 0270b47..0a49c68 100644 --- a/src/app/AppStore.js +++ b/src/app/AppStore.js @@ -1,25 +1,28 @@ /* - * ============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 {combineReducers, createStore, compose, applyMiddleware} from 'redux'; import thunkMiddleware from 'redux-thunk'; import GlobalAutoCompleteSearchBarReducer from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.js'; @@ -28,7 +31,10 @@ import MainScreenWrapperReducer from './MainScreenWrapperReducer.js'; import InventoryReducer from './inventory/InventoryReducer.js'; import DynamicViewLoaderReducer from 'generic-components/dynamicViewLoader/DynamicViewLoaderReducer.js'; import VnfSearchReducer from './vnfSearch/VnfSearchReducer.js'; -import GlobalInlineMessageBarReducer from 'app/GlobalInlineMessageBar/GlobalInlineMessageBarReducer.js'; +import GlobalInlineMessageBarReducer from 'app/globalInlineMessageBar/GlobalInlineMessageBarReducer.js'; +import ExtensibilityReducer from 'app/extensibility/ExtensibilityReducer.js'; + + function createCompose() { return window.devToolsExtension @@ -45,7 +51,8 @@ export const storeCreator = (initialState) => createStore( inventoryReducer: InventoryReducer, dynamicViewReducer: DynamicViewLoaderReducer, vnfSearch: VnfSearchReducer, - globalInlineMessageBar: GlobalInlineMessageBarReducer + globalInlineMessageBar: GlobalInlineMessageBarReducer, + extensibility: ExtensibilityReducer }), initialState, createCompose() diff --git a/src/app/GlobalInlineMessageBar/GlobalInlineMessageBarActions.js b/src/app/GlobalInlineMessageBar/GlobalInlineMessageBarActions.js index 1447f68..7b41644 100644 --- a/src/app/GlobalInlineMessageBar/GlobalInlineMessageBarActions.js +++ b/src/app/GlobalInlineMessageBar/GlobalInlineMessageBarActions.js @@ -1,28 +1,30 @@ /* - * ============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 { globalInlineMessageBarActionTypes -} from 'app/GlobalInlineMessageBar/GlobalInlineMessageBarConstants.js'; +} from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants.js'; export function getSetGlobalMessageEvent(msgText, msgSeverity) { return { diff --git a/src/app/GlobalInlineMessageBar/GlobalInlineMessageBarReducer.js b/src/app/GlobalInlineMessageBar/GlobalInlineMessageBarReducer.js index 48fdcdf..93dde7e 100644 --- a/src/app/GlobalInlineMessageBar/GlobalInlineMessageBarReducer.js +++ b/src/app/GlobalInlineMessageBar/GlobalInlineMessageBarReducer.js @@ -1,28 +1,30 @@ /* - * ============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 { globalInlineMessageBarActionTypes -} from 'app/GlobalInlineMessageBar/GlobalInlineMessageBarConstants.js'; +} from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants.js'; export default (state = {}, action) => { switch (action.type) { diff --git a/src/app/MainScreenHeader.jsx b/src/app/MainScreenHeader.jsx index af71a97..856a08d 100644 --- a/src/app/MainScreenHeader.jsx +++ b/src/app/MainScreenHeader.jsx @@ -1,25 +1,28 @@ /* - * ============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 FontAwesome from 'react-fontawesome'; @@ -28,7 +31,8 @@ import Modal from 'react-bootstrap/lib/Modal.js'; import GlobalAutoCompleteSearchBar from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.jsx'; import {postAnalyticsData} from 'app/analytics/AnalyticsActions.js'; import GlobalInlineMessageBar from 'app/GlobalInlineMessageBar/GlobalInlineMessageBar.jsx'; -import {getClearGlobalMessageEvent} from 'app/GlobalInlineMessageBar/GlobalInlineMessageBarActions.js'; +import {getClearGlobalMessageEvent} from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js'; +import {externalUrlRequest, externalMessageRequest} from 'app/contextHandler/ContextHandlerActions.js'; import { Route, @@ -42,25 +46,32 @@ import { } from './MainScreenWrapperConstants.js'; import { - showMainMenu + showMainMenu, + clearExtensibleViewData, + setSecondaryTitle } from './MainScreenWrapperActionHelper.js'; import {clearSuggestionsTextField} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarActions.js'; - -import customViews from 'resources/views/customViews.json'; - +import {changeUrlAddress} from 'utils/Routes.js'; +import extensibleViews from 'resources/views/extensibleViews.json'; +import {clearFilters} from 'generic-components/filterBar/FilterBarUtils.js'; const mapStateToProps = ({mainWrapper}) => { let { - showMenu = false, - toggleButtonActive = false - } = mainWrapper; + showMenu = false, + toggleButtonActive = false, + externalRequestFound = {}, + secondaryTitle = '' + } = mainWrapper; return { showMenu, - toggleButtonActive + toggleButtonActive, + externalRequestFound, + secondaryTitle }; }; + const mapActionsToProps = (dispatch) => { return { onShowMenu: () => dispatch(showMainMenu(true)), @@ -72,6 +83,15 @@ const mapActionsToProps = (dispatch) => { onRouteChange: () => { dispatch(getClearGlobalMessageEvent()); dispatch(clearSuggestionsTextField()); + dispatch(clearExtensibleViewData()); + dispatch(clearFilters()); + dispatch(setSecondaryTitle(undefined)); + }, + onExternalUrlRequest: (urlParamString) => { + dispatch(externalUrlRequest(urlParamString)); + }, + onExternalMessageRecieved: (messageJson) => { + dispatch(externalMessageRequest(messageJson)); } }; }; @@ -79,7 +99,9 @@ const mapActionsToProps = (dispatch) => { class MainScreenHeader extends Component { static propTypes = { showMenu: React.PropTypes.bool, - toggleButtonActive: React.PropTypes.bool + toggleButtonActive: React.PropTypes.bool, + externalRequestFound: React.PropTypes.object, + secondaryTitle: React.PropTypes.string }; navigationLinkAndCurrentPathMatch(location, to) { @@ -101,10 +123,23 @@ class MainScreenHeader extends Component { return false; } } - + isValidExternalURL(url) { + if(decodeURIComponent(url).indexOf('&') > 0 ) { + return true; + } else { + return false; + } + } + componentWillMount() { + if(this.props.match.params.externalUrl !== undefined && + this.isValidExternalURL(this.props.match.params.externalUrl)) { + this.props.onExternalUrlRequest(this.props.match.params.externalUrl); + } + } componentWillReceiveProps(nextProps) { if (this.props.location && - this.props.location.pathname !== nextProps.location.pathname) { + this.props.location.pathname !== + nextProps.location.pathname) { // update analytics this.props.dispatchAnalyticsData(); @@ -113,15 +148,50 @@ class MainScreenHeader extends Component { this.props.onRouteChange(); } } + + if(nextProps.match.params.externalUrl !== undefined && + nextProps.match.params.externalUrl !== this.props.match.params.externalUrl && + this.isValidExternalURL(nextProps.match.params.externalUrl)) { + this.props.onExternalUrlRequest(nextProps.match.params.externalUrl); + } + /* if the externalURL is not valid, we do not add any message as other proper + views will get that messages since the route will be this parameter.*/ + + if(this.props.externalRequestFound !== nextProps.externalRequestFound && + nextProps.externalRequestFound !== undefined && nextProps.externalRequestFound.suggestion !== undefined) { + changeUrlAddress(nextProps.externalRequestFound.suggestion, nextProps.history); + } + } + + receiveMessage(event) { + function isJson(str) { + try { + JSON.parse(str); + } catch (e) { + return false; + } + return true; + } + let messageData = event.data.message; + if(isJson(messageData)) { + this.props.onExternalMessageRecieved(JSON.parse(messageData)); + } + } + componentDidMount() { + window.addEventListener('message', this.receiveMessage, false); + } + componentWillUnmount() { + window.removeEventListener('message', this.receiveMessage); } render() { let { - showMenu, - onShowMenu, - onHideMenu, - toggleButtonActive - } = this.props; + showMenu, + onShowMenu, + onHideMenu, + toggleButtonActive, + secondaryTitle + } = this.props; let menuOptions = []; @@ -138,54 +208,56 @@ class MainScreenHeader extends Component { // add Tier Support view menuOptions.push( - <MenuItem to='/viewInspect' label={MENU_ITEM_TIER_SUPPORT} + <MenuItem key='schemaMenu' to='/schema' label={MENU_ITEM_TIER_SUPPORT} iconClass='button-icon view-inspect-button-icon'/> ); // add VNF view - // 2172a3c25ae56e4995038ffbc1f055692bfc76c0b8ceda1205bc745a9f7a805d is - // the hash for 'VNFs' ... ensures VNF Search screen defaults to the - // aggregate VNF results menuOptions.push( - <MenuItem - to='/vnfSearch/2172a3c25ae56e4995038ffbc1f055692bfc76c0b8ceda1205bc745a9f7a805d' + <MenuItem key='vnfSearchMenu' + to='/vnfSearch' label={MENU_ITEM_VNF_SEARCH} iconClass='button-icon vnf-search-button-icon'/> ); // add all custom view menu options - for (let view in customViews) { + for (let view in extensibleViews) { menuOptions.push( - <MenuItem to={customViews[view]['viewName']} - label={customViews[view]['displayName']} - iconClass='button-icon inventory-button-icon'/> + <MenuItem key={extensibleViews[view]['viewName'] + 'Menu'} to={'/' + extensibleViews[view]['viewName']} + label={extensibleViews[view]['displayName']} + iconClass={'button-icon ' + extensibleViews[view]['iconClass']}/> ); } + let secondaryTitleClass = 'secondary-header'; + if (secondaryTitle === undefined || secondaryTitle === '') { + secondaryTitleClass = secondaryTitleClass + ' hidden'; + } + return ( - <div> - <div className='header'> - <div> - <Button - bsClass={(toggleButtonActive) - ? 'toggle-view-button-active' - : 'toggle-view-button'} - onClick={onShowMenu}> - <FontAwesome name='bars'/> - </Button> - <Modal show={showMenu} onHide={onHideMenu} - dialogClassName='modal-main-menu'> - <Modal.Body> - {menuOptions} - </Modal.Body> - </Modal> - <span className='application-title'>{AAI_TITLE}</span> - <GlobalAutoCompleteSearchBar history={this.props.history}/> - </div> - <GlobalInlineMessageBar /> + <div className='header'> + <div> + <Button + bsClass={(toggleButtonActive) + ? 'toggle-view-button-active' + : 'toggle-view-button'} + onClick={onShowMenu}> + <FontAwesome name='bars'/> + </Button> + <Modal show={showMenu} onHide={onHideMenu} + dialogClassName='modal-main-menu'> + <Modal.Body> + {menuOptions} + </Modal.Body> + </Modal> + <span className='application-title'>{AAI_TITLE}</span> + <GlobalAutoCompleteSearchBar history={this.props.history}/> + </div> + <GlobalInlineMessageBar /> + <div className={secondaryTitleClass}> + <span className='secondary-title'>{secondaryTitle}</span> </div> </div> - ); } } 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> diff --git a/src/app/MainScreenWrapperActionHelper.js b/src/app/MainScreenWrapperActionHelper.js index 7918ec9..bcf78e3 100644 --- a/src/app/MainScreenWrapperActionHelper.js +++ b/src/app/MainScreenWrapperActionHelper.js @@ -1,26 +1,44 @@ /* - * ============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 {aaiActionTypes} from './MainScreenWrapperConstants.js'; +import { + POST, + POST_HEADER, + BASE_URL, + ERROR_RETRIEVING_DATA +} from 'app/networking/NetworkConstants.js'; +import { + MESSAGE_LEVEL_DANGER +} from 'utils/GlobalConstants.js'; +import {fetchRequestObj} from 'app/networking/NetworkCalls.js'; + +import { + getSetGlobalMessageEvent, + getClearGlobalMessageEvent +} from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js'; function createWindowSizeChangeEvent() { return { @@ -48,3 +66,71 @@ export function showMainMenu(show) { dispatch(createShowMenuEvent(show)); }; } + +function createViewDataFoundEvent(viewData, paramName, curViewData) { + var obj = {}; + obj['data'] = {}; + obj['data']['paramName'] = paramName; + obj['data']['viewData'] = viewData; + obj['data']['curViewData'] = curViewData; + obj['type'] = aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_RESPONSE_RECEIVED; + + return obj; +} + +function extensibleViewData(dataFetchRequest, paramName, curViewData) { + return dispatch => { + return dataFetchRequest().then( + (response) => { + return response.json(); + } + ).then( + (responseJson) => { + dispatch(createViewDataFoundEvent(responseJson, paramName, curViewData)); + }).catch( + () => { + dispatch(getSetGlobalMessageEvent(ERROR_RETRIEVING_DATA, MESSAGE_LEVEL_DANGER)); + dispatch(createViewDataFoundEvent({}, paramName, curViewData)); + //To-do: If need to send a flag later on to the view, add a function to have the flag + }); + }; +} + +export function extensibleViewNetworkCallback(urlApi, postBody, paramName, curViewData) { + + let dataFetchRequest = + () => fetchRequestObj(BASE_URL + urlApi, POST, + POST_HEADER, postBody); + + + return dispatch => { + dispatch(extensibleViewData(dataFetchRequest, paramName, curViewData)); + }; +} + +export function extensibleViewMessageCallback(msgText, msgSeverity) { + if (msgText.length > 0) { + return dispatch => { + dispatch( + getSetGlobalMessageEvent(msgText, msgSeverity)); + }; + } else { + return dispatch => { + dispatch(getClearGlobalMessageEvent()); + }; + } +} + +export function clearExtensibleViewData() { + return { + type: aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_CLEAR_DATA, + data: {} + }; +} + +export function setSecondaryTitle(title) { + return { + type: aaiActionTypes.SET_SECONDARY_TITLE, + data: title + }; +} diff --git a/src/app/MainScreenWrapperConstants.js b/src/app/MainScreenWrapperConstants.js index 5b69cc2..36efb1f 100644 --- a/src/app/MainScreenWrapperConstants.js +++ b/src/app/MainScreenWrapperConstants.js @@ -1,31 +1,37 @@ /* - * ============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 keyMirror from 'utils/KeyMirror.js'; export const aaiActionTypes = keyMirror({ SET_CURRENT_SCREEN: null, AAI_WINDOW_RESIZE: null, - AAI_SHOW_MENU: null + AAI_SHOW_MENU: null, + EXTENSIBLE_VIEW_NETWORK_CALLBACK_RESPONSE_RECEIVED: null, + EXTENSIBLE_VIEW_NETWORK_CALLBACK_CLEAR_DATA: null, + SET_SECONDARY_TITLE: null }); export const screens = keyMirror({ diff --git a/src/app/MainScreenWrapperReducer.js b/src/app/MainScreenWrapperReducer.js index 8314115..3d3098a 100644 --- a/src/app/MainScreenWrapperReducer.js +++ b/src/app/MainScreenWrapperReducer.js @@ -1,35 +1,74 @@ /* - * ============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 {aaiActionTypes} from './MainScreenWrapperConstants.js'; +import { + globalAutoCompleteSearchBarActionTypes +} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js'; +import { + contextHandlerActionTypes +} from 'app/contextHandler/ContextHandlerConstants.js'; export default (state = {}, action) => { - if (action.type === aaiActionTypes.AAI_SHOW_MENU) { - return { - ...state, - showMenu: action.data.showMenu, - toggleButtonActive: action.data.showMenu // if showing menu, then toggle + switch (action.type) { + case aaiActionTypes.AAI_SHOW_MENU: + return { + ...state, + showMenu: action.data.showMenu, + toggleButtonActive: action.data.showMenu // if showing menu, then toggle // is active - }; + }; + case aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_RESPONSE_RECEIVED: + let obj = {...state}; + obj['extensibleViewNetworkCallbackData'] = {}; + obj['extensibleViewNetworkCallbackData'][action.data.paramName] = action.data.viewData; + // If there are some current viewData that need to be kept: + for(var vData in action.data.curViewData) { + obj['extensibleViewNetworkCallbackData'][vData] = action.data.curViewData[vData]; + } + return obj; + case aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_CLEAR_DATA: + return { + ...state, + extensibleViewNetworkCallbackData : {} + }; + case globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT: + return { + ...state, + extensibleViewNetworkCallbackData: {clearView: true} + }; + case contextHandlerActionTypes.SINGLE_SUGGESTION_FOUND: + return { + ...state, + externalRequestFound: action.data + }; + case aaiActionTypes.SET_SECONDARY_TITLE: + return { + ...state, + secondaryTitle: action.data + }; } return state; }; diff --git a/src/app/contextHandler/ContextHandlerActions.js b/src/app/contextHandler/ContextHandlerActions.js new file mode 100644 index 0000000..3cd57f7 --- /dev/null +++ b/src/app/contextHandler/ContextHandlerActions.js @@ -0,0 +1,137 @@ +/* + * ============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 + * + * 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===================================================== + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ + +import { + POST, + POST_HEADER +} from 'app/networking/NetworkConstants.js'; +import networkCall from 'app/networking/NetworkCalls.js'; +import {EXTERNAL_REQ_ENTITY_SEARCH_URL, +WRONG_EXTERNAL_REQUEST_MESSAGE, + WRONG_RESULT +} from 'app/contextHandler/ContextHandlerConstants'; +import { + getSetGlobalMessageEvent, + getClearGlobalMessageEvent +} from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js'; + +import { STATUS_CODE_204_NO_CONTENT, + STATUS_CODE_3XX_REDIRECTION, + MESSAGE_LEVEL_DANGER +} from 'utils/GlobalConstants.js'; + + +import { + contextHandlerActionTypes +} from 'app/contextHandler/ContextHandlerConstants.js'; + +function getExternalParamValues(urlParams) { + var pairs = decodeURIComponent(urlParams).replace('?','').replace(/\r\n|\n/,'').split('&'); + + var externalparamObject = {}; + pairs.forEach(function(pair) { + pair = pair.split('='); + externalparamObject[pair[0]] = pair[1] || ''; + }); + return externalparamObject; + +} + +function validateExternalParams(externalURLParams) { + if(externalURLParams.view && externalURLParams.entityId && externalURLParams.entityType) { + return true; + } + return false; + +} + + +function createSuggestionFoundEvent(suggestion) { + return { + type: contextHandlerActionTypes.SINGLE_SUGGESTION_FOUND, + data: suggestion + }; +} + + +function fetchDataForExternalRequest(fetchRequestCallback) { + return dispatch => { + return fetchRequestCallback().then( + (response) => { + if (response.status === STATUS_CODE_204_NO_CONTENT || response.status >= STATUS_CODE_3XX_REDIRECTION) { + return Promise.reject(new Error(response.status)); + } else { + // assume 200 status + return response.json(); + } + } + ).then( + (results)=> { + if (results.suggestions !== undefined && results.suggestions.length === 1) { + dispatch(getClearGlobalMessageEvent()); + dispatch(createSuggestionFoundEvent({suggestion: results.suggestions[0]})); + } else { + dispatch(getSetGlobalMessageEvent(WRONG_RESULT , MESSAGE_LEVEL_DANGER)); + } + } + ).catch( + () => { + dispatch(getSetGlobalMessageEvent(WRONG_RESULT , MESSAGE_LEVEL_DANGER)); + } + ); + }; +} + +function validateAndFetchExternalParams(externalParams) { + if(!validateExternalParams(externalParams)) { + return dispatch => { + dispatch( + getSetGlobalMessageEvent(WRONG_EXTERNAL_REQUEST_MESSAGE, MESSAGE_LEVEL_DANGER)); + }; + } else { + let postBody = JSON.stringify(externalParams); + let externalfetchRequest = + () => networkCall.fetchRequestObj(EXTERNAL_REQ_ENTITY_SEARCH_URL, POST, + POST_HEADER, postBody); + return dispatch => { + dispatch(fetchDataForExternalRequest(externalfetchRequest)); + }; + } +} +export function externalUrlRequest(urlParams) { + let externalURLParams = getExternalParamValues(urlParams); + return dispatch => { + dispatch( + validateAndFetchExternalParams(externalURLParams)); + }; +} +export function externalMessageRequest(jsonParams) { + return dispatch => { + dispatch( + validateAndFetchExternalParams(jsonParams)); + }; + +} + diff --git a/src/app/contextHandler/ContextHandlerConstants.js b/src/app/contextHandler/ContextHandlerConstants.js new file mode 100644 index 0000000..4a0137f --- /dev/null +++ b/src/app/contextHandler/ContextHandlerConstants.js @@ -0,0 +1,41 @@ +/* + * ============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 + * + * 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===================================================== + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ + + +import keyMirror from 'utils/KeyMirror.js'; +import {BASE_URL} from 'app/networking/NetworkConstants.js'; + +export const contextHandlerActionTypes = keyMirror({ + SINGLE_SUGGESTION_FOUND: null, + INVALID_SUGGESTION_FOUND: null +}); + +export const EXTERNAL_REQ_ENTITY_SEARCH_URL = BASE_URL + '/rest/search/externalRequestEntitySearch'; +export const WRONG_EXTERNAL_REQUEST_MESSAGE = 'External parameter request is incorrect'; +export const WRONG_RESULT = 'Invalid result for the requested external params.'; + + + + diff --git a/src/app/extensibility/ExtensibilityReducer.js b/src/app/extensibility/ExtensibilityReducer.js new file mode 100644 index 0000000..83f963a --- /dev/null +++ b/src/app/extensibility/ExtensibilityReducer.js @@ -0,0 +1,8 @@ +import {combineReducers} from 'redux'; + + +export default combineReducers({ + extensible: (state = {}) => { + return state; + } +}); diff --git a/src/app/extensibility/index.js b/src/app/extensibility/index.js new file mode 100644 index 0000000..49adff8 --- /dev/null +++ b/src/app/extensibility/index.js @@ -0,0 +1,7 @@ +// Import section (used as anchor to add extension imports) + +let components = {}; + +// Components section (used as an anchor to add extension components) + +export default components; diff --git a/src/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.jsx b/src/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.jsx index f29de3e..1410fd4 100644 --- a/src/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.jsx +++ b/src/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.jsx @@ -1,30 +1,33 @@ /* - * ============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 {connect} from 'react-redux'; import React, {Component} from 'react'; import AutoCompleteSearchBar from 'generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.jsx'; import {postAnalyticsData} from 'app/analytics/AnalyticsActions.js'; -import {getClearGlobalMessageEvent} from 'app/GlobalInlineMessageBar/GlobalInlineMessageBarActions.js'; +import {getClearGlobalMessageEvent} from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js'; import { queryRequestedValues, clearSuggestionsTextField, diff --git a/src/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarActions.js b/src/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarActions.js index d04e7a1..d4ec356 100644 --- a/src/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarActions.js +++ b/src/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarActions.js @@ -1,25 +1,28 @@ /* - * ============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 {getTSUIElasticSearchQueryString} from 'app/networking/NetworkUtil.js'; import networkCall from 'app/networking/NetworkCalls.js'; import { @@ -36,7 +39,7 @@ import { import { getSetGlobalMessageEvent, getClearGlobalMessageEvent -} from 'app/GlobalInlineMessageBar/GlobalInlineMessageBarActions.js'; +} from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js'; function createSuggestionFoundEvent({suggestions}) { diff --git a/src/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js b/src/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js index 448466a..0fca9e8 100644 --- a/src/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js +++ b/src/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js @@ -1,26 +1,29 @@ /* - * ============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 keyMirror from 'utils/KeyMirror.js'; import {BASE_URL} from 'app/networking/NetworkConstants.js'; @@ -36,7 +39,7 @@ export const globalAutoCompleteSearchBarActionTypes = keyMirror({ SEARCH_INVALID_TERMS: null }); -export const GLOBAL_SEARCH_URL = BASE_URL + '/search/querysearch/'; +export const GLOBAL_SEARCH_URL = BASE_URL + '/rest/search/querysearch/'; export const NO_MATCHES_FOUND = 'No Matches Found'; export const ERROR_INVALID_SEARCH_TERMS = 'Invalid search terms'; diff --git a/src/app/inventory/Inventory.jsx b/src/app/inventory/Inventory.jsx index b323446..106619f 100644 --- a/src/app/inventory/Inventory.jsx +++ b/src/app/inventory/Inventory.jsx @@ -1,25 +1,28 @@ /* - * ============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 Grid from 'react-bootstrap/lib/Grid'; @@ -46,7 +49,10 @@ import { import InlineMessage from 'generic-components/InlineMessage/InlineMessage.jsx'; import PaginatedTable from 'generic-components/paginatedTable/PaginatedTable.jsx'; import { - dateFormatLocalTimeZoneMMDDYYYY, getTicks, getTicksData, sortDataByField + dateFormatLocalTimeZoneYYYYMMDD, + getTicks, + getTicksData, + sortDataByField } from 'utils/DateTimeChartUtil.js'; import TitledContainer from 'generic-components/titledContainer/TitledContainer.jsx'; import {COLOR_BLUE} from 'utils/GlobalConstants.js'; @@ -114,7 +120,7 @@ class Inventory extends Component { let lastDate = ''; if (sortedData.length > 0) { lastDate = - dateFormatLocalTimeZoneMMDDYYYY(sortedData[sortedData.length - 1] + dateFormatLocalTimeZoneYYYYMMDD(sortedData[sortedData.length - 1] .date); totalEntities = sortedData[sortedData.length - 1].count; } @@ -159,12 +165,12 @@ class Inventory extends Component { }}> <XAxis dataKey={xAxisAttrName} ticks={ticksArr} tickCount={ticksArr.length} - tickFormatter={dateFormatLocalTimeZoneMMDDYYYY}/> + tickFormatter={dateFormatLocalTimeZoneYYYYMMDD}/> <YAxis/> <CartesianGrid strokeDasharray='3 3'/> - <Tooltip labelFormatter={dateFormatLocalTimeZoneMMDDYYYY}/> + <Tooltip labelFormatter={dateFormatLocalTimeZoneYYYYMMDD}/> <Brush dataKey={xAxisAttrName} - tickFormatter={dateFormatLocalTimeZoneMMDDYYYY} + tickFormatter={dateFormatLocalTimeZoneYYYYMMDD} height={20} stroke={COLOR_BLUE}/> <Line name={i18n(TOTAL_ENTITY_COUNTS_BY_DATE_CHART.yAxisLabel)} diff --git a/src/app/inventory/InventoryConstants.js b/src/app/inventory/InventoryConstants.js index c67fbba..9c289c2 100644 --- a/src/app/inventory/InventoryConstants.js +++ b/src/app/inventory/InventoryConstants.js @@ -1,25 +1,28 @@ /* - * ============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 keyMirror from 'utils/KeyMirror.js'; import {BASE_URL} from 'app/networking/NetworkConstants.js'; @@ -37,9 +40,9 @@ export const COMPLEX_BY_LOCATION_TITLE = 'Complexes By Location'; export const TOTAL_ENTITY_COUNT_TITLE = 'Total Entities'; export const ENTITIES_BY_TYPE_TITLE = 'Entities By Type'; -export const INVENTORY_COUNT_BY_TYPE_SEARCH_URL = BASE_URL + '/visualization/entityCountHistory?type=table'; -export const INVENTORY_COUNT_BY_DATE_SEARCH_URL = BASE_URL + '/visualization/entityCountHistory?type=graph'; -export const INVENTORY_GEO_VISUALIZATION_SEARCH_URL = BASE_URL + '/visualization/geovisualization'; +export const INVENTORY_COUNT_BY_TYPE_SEARCH_URL = BASE_URL + '/rest/visualization/entityCountHistory?type=table'; +export const INVENTORY_COUNT_BY_DATE_SEARCH_URL = BASE_URL + '/rest/visualization/entityCountHistory?type=graph'; +export const INVENTORY_GEO_VISUALIZATION_SEARCH_URL = BASE_URL + '/rest/visualization/geovisualization'; export const GEO_VISUALIZATION_QUERY_STRING_PARAMETERS = '/?entity='; export const TOTAL_ENTITY_COUNTS_BY_DATE_CHART = { diff --git a/src/app/main.app.jsx b/src/app/main.app.jsx index c92c11f..db86af9 100644 --- a/src/app/main.app.jsx +++ b/src/app/main.app.jsx @@ -1,29 +1,32 @@ /* - * ============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 'resources/scss/bootstrap.scss'; import 'resources/css/font-awesome.min.css'; import 'resources/css/react-datepicker.min.css'; -import 'resources/scss/style.scss'; +import 'resources/scss/customViews.scss'; import React from 'react'; import ReactDOM from 'react-dom'; @@ -31,6 +34,10 @@ import ReactDOM from 'react-dom'; import Application from './Application.jsx'; import MainScreenWrapper from './MainScreenWrapper.jsx'; +// Import Style Section +import 'resources/scss/style.scss'; + + ReactDOM.render( <Application><MainScreenWrapper /></Application>, document.getElementById('main-app')); diff --git a/src/app/networking/NetworkConstants.js b/src/app/networking/NetworkConstants.js index 9ff92c4..2ae5ef0 100644 --- a/src/app/networking/NetworkConstants.js +++ b/src/app/networking/NetworkConstants.js @@ -1,25 +1,28 @@ /* - * ============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. */ + export const POST = 'POST'; export const GET = 'GET'; export const POST_HEADER = {'Accept': 'application/json'}; @@ -28,8 +31,6 @@ export const BACKEND_POST_HEADER = { 'Accept': 'application/json', 'Content-Type': 'application/json' }; -export const AUDIT_SEARCH_DATE_FORMAT = 'YYYY-MM-DDTHH:mm:ss.SSSZ'; -export const AUDIT_SEARCH_DATE_TIME_ZONE = 'Z'; export const ERROR_RETRIEVING_DATA = 'Error fetching data from server'; export const NO_RESULTS_FOUND = 'No Results Found'; const BACKEND_IP_ADDRESS = document.location.hostname; diff --git a/src/app/networking/NetworkUtil.js b/src/app/networking/NetworkUtil.js index d3e772c..63f4eb6 100644 --- a/src/app/networking/NetworkUtil.js +++ b/src/app/networking/NetworkUtil.js @@ -1,47 +1,27 @@ /* - * ============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 { - AUDIT_SEARCH_DATE_FORMAT, - AUDIT_SEARCH_DATE_TIME_ZONE -} from './NetworkConstants.js'; - -export function getTableDateQueryString(requestObject) { - return { - 'queryParameters': { - 'startDate': requestObject.dateRange.startDate.format( - AUDIT_SEARCH_DATE_FORMAT), - 'endDate': requestObject.dateRange.endDate.format( - AUDIT_SEARCH_DATE_FORMAT), - 'time_zone': requestObject.dateRange.startDate.format( - AUDIT_SEARCH_DATE_TIME_ZONE), - 'typeData': { - 'type': 'pagination', - 'from': requestObject.startIndex, - 'size': requestObject.resultCount - } - } - }; -} export function getTSUIElasticSearchQueryString(query) { // Create the query request @@ -57,92 +37,3 @@ export function getTSUIElasticSearchQueryString(query) { 'queryStr': newQuery }; } -export function getSeverityVisualizationQueryString(requestObject) { - return { - 'queryParameters': { - 'startDate': requestObject.dateRange.startDate.format( - AUDIT_SEARCH_DATE_FORMAT), - 'endDate': requestObject.dateRange.endDate.format( - AUDIT_SEARCH_DATE_FORMAT), - 'time_zone': requestObject.dateRange.startDate.format( - AUDIT_SEARCH_DATE_TIME_ZONE), - 'typeData': { - 'type': 'groupBy', - 'groupByField': 'severity' - } - } - }; -} - -export function getStatusVisualizationQueryString(requestObject) { - return { - 'queryParameters': { - 'startDate': requestObject.dateRange.startDate.format( - AUDIT_SEARCH_DATE_FORMAT), - 'endDate': requestObject.dateRange.endDate.format( - AUDIT_SEARCH_DATE_FORMAT), - 'time_zone': requestObject.dateRange.startDate.format( - AUDIT_SEARCH_DATE_TIME_ZONE), - 'typeData': { - 'type': 'groupBy', - 'groupByField': 'category' - } - } - }; -} - -export function getEntityTypeVisualizationQueryString(requestObject) { - return { - 'queryParameters': { - 'startDate': requestObject.dateRange.startDate.format( - AUDIT_SEARCH_DATE_FORMAT), - 'endDate': requestObject.dateRange.endDate.format( - AUDIT_SEARCH_DATE_FORMAT), - 'time_zone': requestObject.dateRange.startDate.format( - AUDIT_SEARCH_DATE_TIME_ZONE), - 'typeData': { - 'type': 'groupBy', - 'groupByField': 'entityType' - } - } - }; -} - -export function getDateVisualizationQueryString(requestObject) { - return { - 'queryParameters': { - 'startDate': requestObject.dateRange.startDate.format( - AUDIT_SEARCH_DATE_FORMAT), - 'endDate': requestObject.dateRange.endDate.format( - AUDIT_SEARCH_DATE_FORMAT), - 'time_zone': requestObject.dateRange.startDate.format( - AUDIT_SEARCH_DATE_TIME_ZONE), - 'typeData': { - 'type': 'dateHistogram' - } - } - }; -} - -export function getVnfOrchStatusQueryString(requestObject) { - return { - 'hashId': requestObject, - 'groupby': 'orchestration-status' - }; -} -export function getVnfProvStatusQueryString(requestObject) { - return { - 'hashId': requestObject, - 'groupby': 'prov-status' - }; -} -export function getVnfCountQueryString(requestObject) { - return { - 'hashId': requestObject - }; -} - - - - - diff --git a/src/app/overlays/OverlayImports.js b/src/app/overlays/OverlayImports.js new file mode 100644 index 0000000..eabe9a5 --- /dev/null +++ b/src/app/overlays/OverlayImports.js @@ -0,0 +1,4 @@ +// Import section (used as anchor to add overlay imports) +let overlays = {}; +// Overlays section (used as an anchor to add overlay components) +export default overlays; diff --git a/src/app/tierSupport/TierSupport.jsx b/src/app/tierSupport/TierSupport.jsx index e6c479e..e38b43d 100644 --- a/src/app/tierSupport/TierSupport.jsx +++ b/src/app/tierSupport/TierSupport.jsx @@ -1,31 +1,40 @@ /* - * ============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 SplitPane from 'react-split-pane'; +import {setSecondaryTitle} from 'app/MainScreenWrapperActionHelper.js'; import ForceDirectedGraph from 'generic-components/graph/ForceDirectedGraph.jsx'; import SelectedNodeDetails from 'app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx'; + + +import overlaysDetails from 'resources/overlays/overlaysDetails.json'; +import * as Overlays from 'app/overlays/OverlayImports.js'; + import i18n from 'utils/i18n/i18n'; import { onNodeDetailsChange, @@ -39,7 +48,7 @@ import { TSUI_TITLE, TSUI_NODE_DETAILS_INITIAL_WIDTH, TSUI_NODE_DETAILS_MIN_WIDTH, - TSUI_GRAPH_MENU_NODE_DETAILS + TSUI_GRAPH_MENU_NODE_DETAILS, } from './TierSupportConstants.js'; let mapStateToProps = ( @@ -61,7 +70,8 @@ let mapStateToProps = ( windowHeight = 500, graphNodeSelectedMenu = TSUI_GRAPH_MENU_NODE_DETAILS, feedbackMsgText = '', - feedbackMsgSeverity = '' + feedbackMsgSeverity = '', + nodeData = {} } = tierSupportReducer; let { @@ -76,12 +86,16 @@ let mapStateToProps = ( performPrepareVisualization, selectedSuggestion, feedbackMsgText, - feedbackMsgSeverity + feedbackMsgSeverity, + nodeData }; }; let mapActionToProps = (dispatch) => { return { + onSetViewTitle: (title) => { + dispatch(setSecondaryTitle(title)); + }, onNodeSelected: (requestObject) => { dispatch(onNodeDetailsChange(requestObject)); }, @@ -110,7 +124,8 @@ class TierSupport extends Component { windowHeight: React.PropTypes.number, graphNodeSelectedMenu: React.PropTypes.string, feedbackMsgText: React.PropTypes.string, - feedbackMsgSeverity: React.PropTypes.string + feedbackMsgSeverity: React.PropTypes.string, + nodeData: React.PropTypes.object }; componentWillReceiveProps(nextProps) { @@ -119,6 +134,10 @@ class TierSupport extends Component { this.props.match.params.viParam) { this.props.onNewVIParam(nextProps.match.params.viParam); } + if(nextProps.match.params.viParam === undefined && nextProps.match.params.viParam !== + this.props.match.params.viParam) { + this.props.onRequestClearData(); + } if (nextProps.feedbackMsgText !== this.props.feedbackMsgText) { this.props.onMessageStateChange(nextProps.feedbackMsgText, @@ -127,6 +146,7 @@ class TierSupport extends Component { } componentWillMount() { + this.props.onSetViewTitle(i18n(TSUI_TITLE)); if (this.props.match.params.viParam) { this.props.onNewVIParam(this.props.match.params.viParam); } else { @@ -144,6 +164,7 @@ class TierSupport extends Component { } render() { + const { forceDirectedGraphRawData, onNodeSelected, @@ -152,17 +173,35 @@ class TierSupport extends Component { onSplitPaneResize, onNodeMenuSelect } = this.props; - let currentSelectedMenu = this.getCurrentSelectedMenu(); + + + let availableOverlay; + let overlayComponent; + // Currently only ONE overlay can be added to each view. + // todo: need to make it array if more than one overlay can be used. No need now. + overlaysDetails.forEach(function(overlay){ + if(overlay.view === 'schema') { + availableOverlay = overlay.key; + overlayComponent = overlay.componentName; + } + }); //Temp code for a demo, will be removed as Vis library is updated - let currentNodeButton = 'NODE_DETAILS'; + let currentNodeButton; + if(this.props.graphNodeSelectedMenu === + TSUI_GRAPH_MENU_NODE_DETAILS ) { + currentNodeButton = 'NODE_DETAILS'; + } else if(availableOverlay) { + currentNodeButton = availableOverlay; + } // End temp code - + let dataOverlayButtons = ['NODE_DETAILS']; + if(availableOverlay) { + dataOverlayButtons.push(availableOverlay); + } + let currentSelectedMenu = this.getCurrentSelectedMenu(overlayComponent); return ( <div className='tier-support-ui'> - <div className='secondary-header'> - <span className='secondary-title'>{i18n(TSUI_TITLE)}</span> - </div> <SplitPane split='vertical' enableResizing='true' @@ -184,7 +223,9 @@ class TierSupport extends Component { nodeButtonSelectedCallback={(selectedMenuId) => { onNodeMenuSelect(selectedMenuId); }} + dataOverlayButtons={dataOverlayButtons} currentlySelectedNodeView={currentNodeButton}/> + </div> <div> {currentSelectedMenu} @@ -194,15 +235,34 @@ class TierSupport extends Component { ); } - getCurrentSelectedMenu() { - switch (this.props.graphNodeSelectedMenu) { - case TSUI_GRAPH_MENU_NODE_DETAILS: - if (!this.nodeDetails) { - this.nodeDetails = <SelectedNodeDetails/>; + isNotEmpty(obj) { + for(var prop in obj) { + if(obj.hasOwnProperty(prop)) { + return true; + } + } + return false; + } + + getCurrentSelectedMenu(overlayComponent) { + let secondOverlay; + if (this.props.graphNodeSelectedMenu === TSUI_GRAPH_MENU_NODE_DETAILS) { + if (!this.nodeDetails) { + this.nodeDetails = <SelectedNodeDetails/>; + } + return this.nodeDetails; + } + else { + if (this.isNotEmpty(this.props.nodeData) && overlayComponent) { + if (Overlays.default.hasOwnProperty(overlayComponent)) { + let OverlayComponent = Overlays.default[overlayComponent]; + secondOverlay = <OverlayComponent nodeDetails={this.props.nodeData}/>; } - return this.nodeDetails; + } + return secondOverlay; } } + } export default connect(mapStateToProps, mapActionToProps)(TierSupport); diff --git a/src/app/tierSupport/TierSupportActions.js b/src/app/tierSupport/TierSupportActions.js index 4261360..6de6ab0 100644 --- a/src/app/tierSupport/TierSupportActions.js +++ b/src/app/tierSupport/TierSupportActions.js @@ -1,26 +1,29 @@ /* - * ============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 {tierSupportActionTypes, TS_BACKEND_SEARCH_SELECTED_NODE_URL} from 'app/tierSupport/TierSupportConstants.js'; import { @@ -33,7 +36,7 @@ import networkCall from 'app/networking/NetworkCalls.js'; import { getSetGlobalMessageEvent, getClearGlobalMessageEvent -} from 'app/GlobalInlineMessageBar/GlobalInlineMessageBarActions.js'; +} from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js'; import { STATUS_CODE_204_NO_CONTENT, STATUS_CODE_3XX_REDIRECTION, @@ -86,6 +89,20 @@ function createNodeDetailsFoundEvent(nodeDetails) { }; } +function createSelectedNodeDetails(nodeDetails) { + var selectedNodeDetail; + for(let i = 0; i < nodeDetails.nodes.length; i++) { + if(nodeDetails.nodes[i].nodeMeta.className === 'selectedSearchedNodeClass') { + selectedNodeDetail = nodeDetails.nodes[i]; + break; + } + } + return { + type: tierSupportActionTypes.TS_GRAPH_NODE_SELECTED, + data: selectedNodeDetail + }; +} + function noNodeDetailsFoundEvent(errorText) { return { type: tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS, @@ -121,6 +138,7 @@ export function fetchSelectedNodeElement(fetchRequestCallback) { (responseJson) => { if (responseJson.nodes.length > 0) { dispatch(createNodeDetailsFoundEvent(responseJson)); + dispatch(createSelectedNodeDetails(responseJson)); } else { dispatch(noNodeDetailsFoundEvent(NO_RESULTS_FOUND)); } diff --git a/src/app/tierSupport/TierSupportConstants.js b/src/app/tierSupport/TierSupportConstants.js index 9383d65..1a525b1 100644 --- a/src/app/tierSupport/TierSupportConstants.js +++ b/src/app/tierSupport/TierSupportConstants.js @@ -1,25 +1,28 @@ /* - * ============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 keyMirror from 'utils/KeyMirror.js'; import {BASE_URL} from 'app/networking/NetworkConstants.js'; @@ -37,10 +40,10 @@ export const tierSupportActionTypes = keyMirror({ export const TSUI_NODE_DETAILS_INITIAL_WIDTH = 300; export const TSUI_NODE_DETAILS_MIN_WIDTH = 200; -export const TSUI_SEARCH_URL = BASE_URL + '/search/viuiSearch/'; +export const TSUI_SEARCH_URL = BASE_URL + '/rest/search/viuiSearch/'; export const TSUI_TITLE = 'View & Inspect'; export const TSUI_GRAPH_MENU_NODE_DETAILS = 'NODE_DETAILS'; -export const SEARCH_SELECTED_NODE_PATH = '/visualization/prepareVisualization'; +export const SEARCH_SELECTED_NODE_PATH = '/rest/visualization/prepareVisualization'; export const TS_BACKEND_SEARCH_SELECTED_NODE_URL = BASE_URL + SEARCH_SELECTED_NODE_PATH; diff --git a/src/app/tierSupport/TierSupportReducer.js b/src/app/tierSupport/TierSupportReducer.js index 3c4e83e..7dd6ab0 100644 --- a/src/app/tierSupport/TierSupportReducer.js +++ b/src/app/tierSupport/TierSupportReducer.js @@ -1,25 +1,28 @@ /* - * ============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 {combineReducers} from 'redux'; import ForceDirectedGraph from 'generic-components/graph/ForceDirectedGraph.jsx'; import {aaiActionTypes} from 'app/MainScreenWrapperConstants.js'; @@ -43,7 +46,7 @@ export default combineReducers({ case tierSupportActionTypes.TS_NODE_SEARCH_RESULTS: let graphData = ForceDirectedGraph.generateNewProps(action.data.nodes, action.data.links, action.data.graphMeta); - + return { ...state, forceDirectedGraphRawData: graphData, @@ -81,6 +84,11 @@ export default combineReducers({ feedbackMsgText: '', feedbackMsgSeverity: '' }; + case tierSupportActionTypes.TS_GRAPH_NODE_SELECTED: + return { + ...state, + nodeData: action.data + }; case globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT: let emptyNodesAndLinksWarningEvent = ForceDirectedGraph.generateNewProps([], [], {}); return { @@ -93,7 +101,7 @@ export default combineReducers({ let splitPaneLeftSideElement = document.getElementsByClassName('Pane1'); if (splitPaneLeftSideElement.length > 0) { let width = splitPaneLeftSideElement[0].offsetWidth; - + return { ...state, windowWidth: width, windowHeight: splitPaneLeftSideElement[0].offsetHeight }; @@ -101,7 +109,7 @@ export default combineReducers({ return state; } } - + return state; } }); diff --git a/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx index 97fa4ec..267a1c3 100644 --- a/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx +++ b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx @@ -1,25 +1,28 @@ /* - * ============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 {connect} from 'react-redux'; import React, {Component} from 'react'; import Table from 'react-bootstrap/lib/Table'; @@ -31,7 +34,7 @@ import { } from 'app/tierSupport/selectedNodeDetails/SelectedNodeDetailsConstants.js'; let mapStateToProps = ({tierSupport: {selectedNodeDetails}}) => { - let {nodeData = [], nodeType = '', uid = ''} = selectedNodeDetails; + let {nodeData = {}, nodeType = '', uid = ''} = selectedNodeDetails; return { nodeData, @@ -42,7 +45,7 @@ let mapStateToProps = ({tierSupport: {selectedNodeDetails}}) => { class SelectedNodeDetails extends Component { static propTypes = { - nodeData: React.PropTypes.array, + nodeData: React.PropTypes.object, nodeType: React.PropTypes.string, uid: React.PropTypes.string }; diff --git a/src/app/vnfSearch/VnfSearch.jsx b/src/app/vnfSearch/VnfSearch.jsx index 5a35be3..d04bbd4 100644 --- a/src/app/vnfSearch/VnfSearch.jsx +++ b/src/app/vnfSearch/VnfSearch.jsx @@ -1,62 +1,142 @@ /* - * ============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 { + isEqual, + isEmpty +} from 'lodash'; +import {VerticalFilterBar} from 'vertical-filter-bar'; +import {CollapsibleSlidingPanel} from 'collapsible-sliding-panel'; + +import {setSecondaryTitle} from 'app/MainScreenWrapperActionHelper.js'; +import { + vnfActionTypes, VNF_TITLE, VNFS_ROUTE, - DEFAULT_VNFS_SEARCH_HASH + VNF_SEARCH_FILTER_NAME } from 'app/vnfSearch/VnfSearchConstants.js'; import { - processTotalVnfVisualizationOnSearchChange, - processOrchStatusVisualizationOnSearchChange, - processProvStatusVisualizationOnSearchChange, - setNotificationText + processVnfVisualizationsOnFilterChange, + processVnfFilterPanelCollapse, + setNotificationText, + clearVnfSearchData } from 'app/vnfSearch/VnfSearchActions.js'; import VnfSearchOrchStatusVisualizations from 'app/vnfSearch/VnfSearchOrchestratedStatusVisualization.jsx'; import VnfSearchProvStatusVisualizations from 'app/vnfSearch/VnfSearchProvStatusVisualization.jsx'; +import VnfSearchNfTypeVisualizations from 'app/vnfSearch/VnfSearchNfTypeVisualization.jsx'; +import VnfSearchNfRoleVisualizations from 'app/vnfSearch/VnfSearchNfRoleVisualization.jsx'; import VnfSearchTotalCountVisualization from 'app/vnfSearch/VnfSearchTotalCountVisualization.jsx'; import i18n from 'utils/i18n/i18n'; -import {changeUrlAddress, buildRouteObj} from 'utils/Routes.js'; +import {changeUrlAddress, buildRouteObjWithFilters} from 'utils/Routes.js'; +import { + getUnifiedFilters, + processFilterSelection, + setNonConvertedFilterValues, + convertNonConvertedValues, + buildFilterValueMap, + setFilterSelectionsToDefaults, + FILTER_BAR_TITLE +} from 'generic-components/filterBar/FilterBarUtils.js'; const mapStateToProps = ({vnfSearch}) => { let { feedbackMsgText = '', - feedbackMsgSeverity = '' + feedbackMsgSeverity = '', + vnfFilters = {}, + selectedFilterValues = {}, + vnfFilterValues = {}, + vnfVisualizationPanelClass = 'collapsible-panel-main-panel', + unifiedFilterValues = {}, + nonConvertedFilters = {} } = vnfSearch; return { feedbackMsgText, - feedbackMsgSeverity + feedbackMsgSeverity, + vnfFilters, + selectedFilterValues, + vnfFilterValues, + vnfVisualizationPanelClass, + unifiedFilterValues, + nonConvertedFilters }; }; let mapActionToProps = (dispatch) => { return { - onReceiveNewParams: (vnfParam) => { - dispatch(processTotalVnfVisualizationOnSearchChange(vnfParam)); - dispatch(processOrchStatusVisualizationOnSearchChange(vnfParam)); - dispatch(processProvStatusVisualizationOnSearchChange(vnfParam)); + onSetViewTitle: (title) => { + dispatch(setSecondaryTitle(title)); + }, + onInitializeVnfSearchFilters: () => { + // first time to the page, need to get the list of available filters + dispatch(getUnifiedFilters(VNF_SEARCH_FILTER_NAME, vnfActionTypes.VNF_SEARCH_FILTERS_RECEIVED)); + }, + onFilterPanelCollapse: (isOpen) => { + // expand/collapse the filter panel + dispatch(processVnfFilterPanelCollapse(isOpen)); + }, + onFilterSelection: (selectedFilters, allFilters) => { + // callback for filter bar whenever a selection is made... need to + // convert and save the selected value(s) + if (Object.keys(allFilters).length > 0) { + // only process the selection if allFilters has values (possible that + // filter bar is sending back the default filter selections before + // we have received the list of available filters i.e. allFilters) + dispatch(processFilterSelection(selectedFilters, allFilters)); + } + }, + onFilterValueChange: (convertedFilterValues) => { + // filter values have been converted, now update the VNF visualizations + dispatch(processVnfVisualizationsOnFilterChange(convertedFilterValues)); + }, + onReceiveNewFilterValueParams: (filterValueString) => { + // new filter values have been received as URL parameters, save the + // non-converted values (later to be converted and sent to filter bar) + // and update the VNF visualizations + let filterValueMap = buildFilterValueMap(filterValueString); + + dispatch(setNonConvertedFilterValues(filterValueMap)); + dispatch(processVnfVisualizationsOnFilterChange(filterValueMap)); + + // incase url param was changed manually, need to update vnfFilterValues + }, + onResetFilterBarToDefaults: (filters, filterValues) => { + dispatch(setFilterSelectionsToDefaults(filters, filterValues)); + }, + onPrepareToUnmount: () => { + // clean things up: + // 1- clear the VNF data + // 2- ensure filter bar is closed + dispatch(clearVnfSearchData()); + dispatch(processVnfFilterPanelCollapse(false)); + }, + onConvertFilterValues: (nonConvertedValues, allFilters, currentlySetFilterValues) => { + // we have saved non-converted filter values received from URL params, + // time to convert them so can update filter bar selections programatically + dispatch(convertNonConvertedValues(nonConvertedValues, allFilters, currentlySetFilterValues)); }, onMessageStateChange: (msgText, msgSeverity) => { dispatch(setNotificationText(msgText, msgSeverity)); @@ -65,16 +145,25 @@ let mapActionToProps = (dispatch) => { }; class vnfSearch extends Component { + static propTypes = { + feedbackMsgText: React.PropTypes.string, + feedbackSeverity: React.PropTypes.string, + vnfFilters: React.PropTypes.object, + selectedFilterValues: React.PropTypes.object, + vnfFilterValues: React.PropTypes.object, + vnfVisualizationPanelClass: React.PropTypes.string, + unifiedFilterValues: React.PropTypes.object, + nonConvertedFilters: React.PropTypes.object + }; + componentWillMount() { + this.props.onSetViewTitle(i18n(VNF_TITLE)); + this.props.onInitializeVnfSearchFilters(); + if (this.props.match && this.props.match.params && - this.props.match.params.vnfParam) { - this.props.onReceiveNewParams(this.props.match.params.vnfParam); - } else { - // render using default search params (hash for "VNFs") - this.props.onReceiveNewParams(DEFAULT_VNFS_SEARCH_HASH); - changeUrlAddress(buildRouteObj(VNFS_ROUTE, DEFAULT_VNFS_SEARCH_HASH), - this.props.history); + this.props.match.params.filters) { + this.props.onReceiveNewFilterValueParams(this.props.match.params.filters); } if (this.props.feedbackMsgText) { @@ -84,42 +173,90 @@ class vnfSearch extends Component { } componentWillReceiveProps(nextProps) { - if (nextProps.match.params.vnfParam) { - if (nextProps.match.params.vnfParam !== - this.props.match.params.vnfParam) { - this.props.onReceiveNewParams(nextProps.match.params.vnfParam); - } - } else if (this.props.match.params.vnfParam) { - // currently on VNF page and somebody has clicked the VNF NavLink - // want to reload the view with the default params (hash for "NFVs") - this.props.onReceiveNewParams(DEFAULT_VNFS_SEARCH_HASH); - changeUrlAddress(buildRouteObj(VNFS_ROUTE, DEFAULT_VNFS_SEARCH_HASH), - this.props.history); - } - if (nextProps.feedbackMsgText && nextProps.feedbackMsgText !== this.props.feedbackMsgText) { this.props.onMessageStateChange(nextProps.feedbackMsgText, nextProps.feedbackMsgSeverity); } + + if (nextProps.vnfFilterValues && + !isEqual(nextProps.vnfFilterValues, this.props.vnfFilterValues) && + this.props.vnfFilters) { + this.props.onFilterValueChange(nextProps.vnfFilterValues); + changeUrlAddress(buildRouteObjWithFilters(VNFS_ROUTE, nextProps.vnfFilterValues), + this.props.history); + } + + if (nextProps.match && + nextProps.match.params && + nextProps.match.params.filters && + !isEqual(nextProps.match.params.filters, this.props.match.params.filters)) { + // added line below to reload the filters if filter changes, this will load new filters + this.props.onInitializeVnfSearchFilters(); + this.props.onReceiveNewFilterValueParams(nextProps.match.params.filters); + } else if (Object.keys(nextProps.nonConvertedFilters).length > 0 && + !isEqual(this.props.nonConvertedFilters, nextProps.nonConvertedFilters)) { + if (Object.keys(this.props.vnfFilters).length > 0) { + this.props.onConvertFilterValues( + nextProps.nonConvertedFilters, this.props.vnfFilters, this.props.vnfFilterValues); + } + } else if ((!nextProps.match || !nextProps.match.params || !nextProps.match.params.filters) && + this.props.match.params.filters && this.props.vnfFilters && this.props.vnfFilterValues) { + // VNF Search navigation button was pressed while the view is still visible ... need to reset + // the filter bar selections to the default values + this.props.onResetFilterBarToDefaults(this.props.vnfFilters, this.props.vnfFilterValues); + } + + if (nextProps.vnfFilters && !isEqual(nextProps.vnfFilters, this.props.vnfFilters) && + Object.keys(this.props.nonConvertedFilters).length > 0) { + // just received list of available filters and there is are nonConvertedFilters (previously + // set from url params), need to convert those values and update the filter bar selections + this.props.onConvertFilterValues( + this.props.nonConvertedFilters, nextProps.vnfFilters, this.props.vnfFilterValues); + } else if (nextProps.vnfFilters && !isEqual(nextProps.vnfFilters, this.props.vnfFilters) && + isEmpty(this.props.vnfFilterValues)) { + // filter bar previously returned the default filter selections (but we didn't have the list + // of available filters at the time, so couldn't do anything. Now receiving the list of + // available filters, so triger the filter selection action in order to load the visualization data + this.props.onResetFilterBarToDefaults(nextProps.vnfFilters, this.props.vnfFilterValues); + } } componentWillUnmount() { - // resetting to default params so on relaunch there will be no - // visibility of old searches - this.props.onReceiveNewParams(DEFAULT_VNFS_SEARCH_HASH); + // set the data to 'NO DATA' so upon return, the view is rendered with + // no data until the request for new data is returned + this.props.onPrepareToUnmount(); + } + + getFilterBar() { + return ( + <VerticalFilterBar + filtersConfig={this.props.vnfFilters} + filterValues={this.props.unifiedFilterValues} + filterTitle={FILTER_BAR_TITLE} + onFilterChange={(selectedFilters) => + this.props.onFilterSelection(selectedFilters, this.props.vnfFilters)} /> ); } render() { + let filterBar = this.getFilterBar(); + return ( - <div> - <div className='secondary-header'> - <span className='secondary-title'>{i18n(VNF_TITLE)}</span> - </div> - <VnfSearchTotalCountVisualization /> - <VnfSearchProvStatusVisualizations /> - <VnfSearchOrchStatusVisualizations /> + <div className='view-container'> + <CollapsibleSlidingPanel + slidingPanelClassName='collapsible-sliding-panel' + slidingPanelClosedClassName='collapsible-sliding-panel-is-closed' + expanderHandleClassName='collapsible-sliding-panel-expander' + slidingPanelContent={filterBar}> + <div className={this.props.vnfVisualizationPanelClass}> + <VnfSearchTotalCountVisualization /> + <VnfSearchProvStatusVisualizations /> + <VnfSearchOrchStatusVisualizations /> + <VnfSearchNfTypeVisualizations /> + <VnfSearchNfRoleVisualizations /> + </div> + </CollapsibleSlidingPanel> </div> ); } diff --git a/src/app/vnfSearch/VnfSearchActions.js b/src/app/vnfSearch/VnfSearchActions.js index b28ab66..ce09b2a 100644 --- a/src/app/vnfSearch/VnfSearchActions.js +++ b/src/app/vnfSearch/VnfSearchActions.js @@ -1,35 +1,38 @@ /* - * ============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 { vnfActionTypes, - VNF_RESULT_URL + VNF_FILTER_AGGREGATION_URL, + CHART_PROV_STATUS, + CHART_ORCH_STATUS, + CHART_NF_TYPE, + CHART_NF_ROLE, + TOTAL_VNF_COUNT, + VNF_FILTER_EMPTY_RESULT } from 'app/vnfSearch/VnfSearchConstants.js'; - -import { - getVnfProvStatusQueryString, - getVnfOrchStatusQueryString, - getVnfCountQueryString -} from 'app/networking/NetworkUtil.js'; import { POST, POST_HEADER, @@ -38,7 +41,8 @@ import { import { getSetGlobalMessageEvent, getClearGlobalMessageEvent -} from 'app/GlobalInlineMessageBar/GlobalInlineMessageBarActions.js'; +} from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js'; +import {MESSAGE_LEVEL_WARNING} from 'utils/GlobalConstants.js'; let fetch = require('node-fetch'); fetch.Promise = require('es6-promise').Promise; @@ -52,143 +56,174 @@ function getInvalidQueryEvent() { data: {errorMsg: ERROR_RETRIEVING_DATA} }; } -/*it is a vertical bar chart then y and x are switched */ -function getProvStatusEvent(responseJson) { - if (responseJson && responseJson.groupby_aggregation && - responseJson.groupby_aggregation.buckets && - responseJson.groupby_aggregation.buckets.length > 0) { - let groupByProvStatusBucket; - let dataPoints = []; - for (groupByProvStatusBucket of - responseJson.groupby_aggregation.buckets) { - dataPoints.push({ - 'x': groupByProvStatusBucket[itemKeyWord].split('=', 1)[0], - 'y': groupByProvStatusBucket[countKeyWord] - }); - } - let newProvStatusChartData = [ +function processProvData(provDataList) { + let dataPoints = []; + let newProvStatusChartData = CHART_PROV_STATUS.emptyData; + for (let provData of provDataList) { + dataPoints.push( { - 'values': dataPoints + 'x': provData[itemKeyWord], + 'y': provData[countKeyWord] } - ]; - - let provStatusCountChartData = { - chartData: newProvStatusChartData - }; - return { - type: vnfActionTypes.COUNT_BY_PROV_STATUS_RECEIVED, - data: {provStatusCountChartData} - }; + ); } - else { - return { - type: vnfActionTypes.ERROR_NO_DATA_FOR_PROV_STATUS_IN_SEARCH_RANGE_RECEIVED + + if (dataPoints.length > 0) { + newProvStatusChartData = { + 'values': dataPoints }; } -} -function getOrchStatusEvent(responseJson) { - if (responseJson && responseJson.groupby_aggregation && - responseJson.groupby_aggregation.buckets && - responseJson.groupby_aggregation.buckets.length > 0) { - let groupByOrchStatusBucket; - let dataPoints = []; - for (groupByOrchStatusBucket of - responseJson.groupby_aggregation.buckets) { - dataPoints.push({ - 'x': groupByOrchStatusBucket[itemKeyWord].split('=', 1)[0], - 'y': groupByOrchStatusBucket[countKeyWord] - }); - } + return newProvStatusChartData; +} - let newOrchStatusChartData = [ +function processOrchData(orchDataList) { + let dataPoints = []; + let newOrchStatusChartData = CHART_ORCH_STATUS.emptyData; + for (let orchData of orchDataList) { + dataPoints.push( { - 'values': dataPoints + 'x': orchData[itemKeyWord], + 'y': orchData[countKeyWord] } - ]; - - let orchStatusCountChartData = { - chartData: newOrchStatusChartData - }; - return { - type: vnfActionTypes.COUNT_BY_ORCH_STATUS_RECEIVED, - data: {orchStatusCountChartData} - }; + ); } - else { - return { - type: vnfActionTypes.ERROR_NO_DATA_FOR_ORCH_STATUS_IN_SEARCH_RANGE_RECEIVED + + if (dataPoints.length > 0) { + newOrchStatusChartData = { + 'values': dataPoints }; } + + return newOrchStatusChartData; } -function getTotalVnfEvent(responseJson) { - if (responseJson && responseJson.count && responseJson.count > 0) { - return { - type: vnfActionTypes.TOTAL_VNF_COUNT_RECEIVED, - data: {count: responseJson.count} - }; +function processNfTypeData(nfDataList) { + let dataPoints = []; + let newNfTypeChartData = CHART_NF_TYPE.emptyData; + for (let nfData of nfDataList) { + dataPoints.push( + { + 'x': nfData[itemKeyWord], + 'y': nfData[countKeyWord] + } + ); } - else { - return { - type: vnfActionTypes.ERROR_NO_COUNT_RECEIVED + + if (dataPoints.length > 0) { + newNfTypeChartData = { + 'values': dataPoints }; } + + return newNfTypeChartData; } -export function processProvStatusVisualizationOnSearchChange(requestObject) { - return dispatch => { - return fetch(VNF_RESULT_URL, { - method: POST, - headers: POST_HEADER, - body: JSON.stringify(getVnfProvStatusQueryString(requestObject)) - }).then( - (response) => response.json() - ).then( - (responseJson) => { - dispatch(getProvStatusEvent(responseJson)); - } - ).catch( - () => { - dispatch(getInvalidQueryEvent()); +function processNfRoleData(nfDataList) { + let dataPoints = []; + let newNfRoleChartData = CHART_NF_ROLE.emptyData; + for (let nfData of nfDataList) { + dataPoints.push( + { + 'x': nfData[itemKeyWord], + 'y': nfData[countKeyWord] } ); + } + + if (dataPoints.length > 0) { + newNfRoleChartData = { + 'values': dataPoints + }; + } + + return newNfRoleChartData; +} + +function getVnfFilterAggregationQueryString(filterValueMap) { + let filterList = []; + + for (let filter in filterValueMap) { + if (filterValueMap[filter] !== '') { + filterList.push( + { + 'filterId': filter, + 'filterValue': filterValueMap[filter] + } + ); + } else { + filterList.push( + { + 'filterId': filter + } + ); + } + } + + return { + 'filters': filterList }; } -export function processOrchStatusVisualizationOnSearchChange(requestObject) { - return dispatch => { - return fetch(VNF_RESULT_URL, { - method: POST, - headers: POST_HEADER, - body: JSON.stringify(getVnfOrchStatusQueryString(requestObject)) - }).then( - (response) => response.json() - ).then( - (responseJson) => { - dispatch(getOrchStatusEvent(responseJson)); - } - ).catch( - () => { - dispatch(getInvalidQueryEvent()); - } - ); +function getVnfVisualizationsResultsEvent(results) { + let count = TOTAL_VNF_COUNT.emptyData; + let provData = CHART_PROV_STATUS.emptyData; + let orchData = CHART_ORCH_STATUS.emptyData; + let netFuncTypeData = CHART_NF_TYPE.emptyData; + let netFuncRoleData = CHART_NF_ROLE.emptyData; + + if (results.total) { + count = results.total; + } + + if (results['aggregations'] && results['aggregations']['prov-status']) { + provData = processProvData(results['aggregations']['prov-status']); + } + + if (results['aggregations'] && + results['aggregations']['orchestration-status']) { + orchData = processOrchData(results['aggregations']['orchestration-status']); + } + + if (results['aggregations'] && + results['aggregations']['nf-type']) { + netFuncTypeData = processNfTypeData(results['aggregations']['nf-type']); + } + + if (results['aggregations'] && + results['aggregations']['nf-role']) { + netFuncRoleData = processNfRoleData(results['aggregations']['nf-role']); + } + + return { + type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED, + data: { + count: count, + provStatusData: provData, + orchStatusData: orchData, + nfTypeData: netFuncTypeData, + nfRoleData: netFuncRoleData + } }; } -export function processTotalVnfVisualizationOnSearchChange(requestObject) { +export function processVnfVisualizationsOnFilterChange(filterValueMap) { return dispatch => { - return fetch(VNF_RESULT_URL + '/count', { + return fetch(VNF_FILTER_AGGREGATION_URL, { method: POST, headers: POST_HEADER, - body: JSON.stringify( - getVnfCountQueryString(requestObject)) + body: JSON.stringify(getVnfFilterAggregationQueryString(filterValueMap)) }).then( (response) => response.json() ).then( (responseJson) => { - dispatch(getTotalVnfEvent(responseJson)); + if(responseJson.total === 0) { + dispatch(getSetGlobalMessageEvent(VNF_FILTER_EMPTY_RESULT, MESSAGE_LEVEL_WARNING)); + } else { + dispatch(getClearGlobalMessageEvent()); + } + dispatch(getVnfVisualizationsResultsEvent(responseJson)); } ).catch( () => { @@ -198,6 +233,21 @@ export function processTotalVnfVisualizationOnSearchChange(requestObject) { }; } +export function processVnfFilterPanelCollapse(isOpen) { + let vnfVisualizationPanelClass = 'collapsible-panel-main-panel'; + + if (isOpen) { + vnfVisualizationPanelClass += ' vertical-filter-panel-is-open'; + } + + return { + type: vnfActionTypes.VNF_FILTER_PANEL_TOGGLED, + data: { + vnfVisualizationPanelClass: vnfVisualizationPanelClass + } + }; +} + export function setNotificationText(msgText, msgSeverity) { if (msgText.length > 0) { return dispatch => { @@ -210,3 +260,16 @@ export function setNotificationText(msgText, msgSeverity) { }; } } + +export function clearVnfSearchData() { + return { + type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED, + data: { + count: '', + provStatusData: CHART_PROV_STATUS.emptyData, + orchStatusData: CHART_ORCH_STATUS.emptyData, + nfTypeData: CHART_NF_TYPE.emptyData, + nfRoleData: CHART_NF_ROLE.emptyData + } + }; +} diff --git a/src/app/vnfSearch/VnfSearchConstants.js b/src/app/vnfSearch/VnfSearchConstants.js index 5f920fd..604c96f 100644 --- a/src/app/vnfSearch/VnfSearchConstants.js +++ b/src/app/vnfSearch/VnfSearchConstants.js @@ -1,69 +1,92 @@ /* - * ============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 keyMirror from 'utils/KeyMirror.js'; import {BASE_URL} from 'app/networking/NetworkConstants.js'; export const VNF_TITLE = 'VNFs'; +export const VNF_SEARCH_FILTER_NAME = 'vnfSearch'; export const vnfActionTypes = keyMirror({ - COUNT_BY_PROV_STATUS_RECEIVED: null, - ERROR_NO_DATA_FOR_PROV_STATUS_IN_SEARCH_RANGE_RECEIVED: null, - COUNT_BY_ORCH_STATUS_RECEIVED: null, - ERROR_NO_DATA_FOR_ORCH_STATUS_IN_SEARCH_RANGE_RECEIVED: null, - TOTAL_VNF_COUNT_RECEIVED: null, - ERROR_NO_COUNT_RECEIVED: null, - VNF_NETWORK_ERROR: null + VNF_NETWORK_ERROR: null, + VNF_SEARCH_RESULTS_RECEIVED: null, + VNF_SEARCH_FILTERS_RECEIVED: null, + VNF_FILTER_PANEL_TOGGLED: null }); export const CHART_PROV_STATUS = { title: 'VNFs By Provisioning Status', yAxisLabel: 'VNFs', xAxisLabel: 'VNFs', - emptyData: [{'values': [ + emptyData: {'values': [ { 'x': 'No data discovered for Provisioning Status', 'y': 0 } - ]}] + ]} }; export const CHART_ORCH_STATUS = { title: 'VNFs By Orchestration Status', yAxisLabel: 'VNFs', - emptyData: [{'values': [ + emptyData: {'values': [ { 'x': 'No data discovered for Orchestration Status', 'y': 0 } - ]}] + ]} +}; + +export const CHART_NF_TYPE = { + title: 'VNFs By Network Function Type', + yAxisLabel: 'VNFs', + emptyData: {'values': [ + { + 'x': 'No data discovered for Network Function Type', + 'y': 0 + } + ]} +}; + +export const CHART_NF_ROLE = { + title: 'VNFs By Network Function Role', + yAxisLabel: 'VNFs', + emptyData: {'values': [ + { + 'x': 'No data discovered for Network Function Role', + 'y': 0 + } + ]} }; export const TOTAL_VNF_COUNT = { title: 'Total VNFs', - emptyValue: 0 + emptyValue: '' }; -export const VNF_RESULT_URL = BASE_URL + '/search/summarybyentitytype'; +export const VNF_FILTER_AGGREGATION_URL = BASE_URL + '/rest/search/filterAggregation'; export const DEFAULT_VNFS_SEARCH_HASH = '2172a3c25ae56e4995038ffbc1f055692bfc76c0b8ceda1205bc745a9f7a805d'; export const VNFS_ROUTE = 'vnfSearch'; +export const VNF_FILTER_EMPTY_RESULT = 'No data for the specified filters'; diff --git a/src/app/vnfSearch/VnfSearchNfRoleVisualization.jsx b/src/app/vnfSearch/VnfSearchNfRoleVisualization.jsx new file mode 100644 index 0000000..ee8dd4f --- /dev/null +++ b/src/app/vnfSearch/VnfSearchNfRoleVisualization.jsx @@ -0,0 +1,98 @@ +/* eslint-disable max-len,max-len,max-len,max-len,max-len,max-len */ +/* + * ============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 + * + * 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===================================================== + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ + +import React, {Component} from 'react'; +import {connect} from 'react-redux'; +import { + BarChart, + Bar, + XAxis, + YAxis, + CartesianGrid, + Tooltip, + ResponsiveContainer, +} from 'recharts'; + +import i18n from 'utils/i18n/i18n'; + +import {CHART_NF_ROLE} from 'app/vnfSearch/VnfSearchConstants.js'; +import {COLOR_BLUE} from 'utils/GlobalConstants.js'; + +let mapStateToProps = ({vnfSearch}) => { + let { + processedNfRoleCountChartData = CHART_NF_ROLE.emptyData + } = vnfSearch; + + return { + processedNfRoleCountChartData + }; +}; + +class VnfSearchNfRoleVisualization extends Component { + static propTypes = { + processedNfRoleCountChartData: React.PropTypes.object + }; + + render() { + let { + processedNfRoleCountChartData + } = this.props; + + let visualizationClass = 'visualizations'; + + if (processedNfRoleCountChartData.values === + null || + processedNfRoleCountChartData.values.size <= + 0) { + visualizationClass = 'visualizations hidden'; + } + + const xAxisAttrName = 'x'; + const yAxisAttrName = 'y'; + + return ( + <div id='audit-visualizations' className={visualizationClass}> + <div className='visualization-charts'> + <div> + <h3>{i18n(CHART_NF_ROLE.title)}</h3> + <ResponsiveContainer width='100%' height={300}> + <BarChart data={processedNfRoleCountChartData.values}> + <XAxis dataKey={xAxisAttrName}/> + <YAxis/> + <CartesianGrid strokeDasharray='3 3'/> + <Tooltip/> + <Bar name={i18n(CHART_NF_ROLE.yAxisLabel)} + dataKey={yAxisAttrName} fill={COLOR_BLUE}/> + </BarChart> + </ResponsiveContainer> + </div> + </div> + </div> + ); + } +} + +export default connect(mapStateToProps)(VnfSearchNfRoleVisualization); diff --git a/src/app/vnfSearch/VnfSearchNfTypeVisualization.jsx b/src/app/vnfSearch/VnfSearchNfTypeVisualization.jsx new file mode 100644 index 0000000..292a68a --- /dev/null +++ b/src/app/vnfSearch/VnfSearchNfTypeVisualization.jsx @@ -0,0 +1,96 @@ +/* eslint-disable max-len,max-len,max-len,max-len,max-len,max-len */ +/* + * ============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 + * + * 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===================================================== + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ + +import React, {Component} from 'react'; +import {connect} from 'react-redux'; +import { + BarChart, + Bar, + XAxis, + YAxis, + CartesianGrid, + Tooltip, + ResponsiveContainer, +} from 'recharts'; + +import i18n from 'utils/i18n/i18n'; + +import {CHART_NF_TYPE} from 'app/vnfSearch/VnfSearchConstants.js'; +import {COLOR_BLUE} from 'utils/GlobalConstants.js'; + +let mapStateToProps = ({vnfSearch}) => { + let { + processedNfTypeCountChartData = CHART_NF_TYPE.emptyData + } = vnfSearch; + + return { + processedNfTypeCountChartData + }; +}; + +class VnfSearchNfTypeVisualization extends Component { + static propTypes = { + processedNfTypeCountChartData: React.PropTypes.object + }; + + render() { + let { + processedNfTypeCountChartData + } = this.props; + + let visualizationClass = 'visualizations'; + if (processedNfTypeCountChartData.values === + null || + processedNfTypeCountChartData.values.size <= + 0) { + visualizationClass = 'visualizations hidden'; + } + const xAxisAttrName = 'x'; + const yAxisAttrName = 'y'; + + return ( + <div id='audit-visualizations' className={visualizationClass}> + <div className='visualization-charts'> + <div > + <h3>{i18n(CHART_NF_TYPE.title)}</h3> + <ResponsiveContainer width='100%' height={300}> + <BarChart data={processedNfTypeCountChartData.values}> + <XAxis dataKey={xAxisAttrName}/> + <YAxis /> + <CartesianGrid strokeDasharray='3 3'/> + <Tooltip/> + <Bar name={i18n(CHART_NF_TYPE.yAxisLabel)} + dataKey={yAxisAttrName} fill={COLOR_BLUE}/> + </BarChart> + </ResponsiveContainer> + </div> + </div> + </div> + ); + } + +} +export default connect(mapStateToProps)(VnfSearchNfTypeVisualization); diff --git a/src/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.jsx b/src/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.jsx index 7e101b3..59f43eb 100644 --- a/src/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.jsx +++ b/src/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.jsx @@ -1,26 +1,28 @@ +/* eslint-disable max-len,max-len,max-len,max-len,max-len,max-len */ /* - * ============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. */ -/* eslint-disable max-len,max-len,max-len,max-len,max-len,max-len */ import React, {Component} from 'react'; import {connect} from 'react-redux'; @@ -58,9 +60,9 @@ class VnfSearchOrchStatusVisualizations extends Component { } = this.props; let visualizationClass = 'visualizations'; - if (processedOrchStatusCountChartData[0].values === + if (processedOrchStatusCountChartData.values === null || - processedOrchStatusCountChartData[0].values.size <= + processedOrchStatusCountChartData.values.size <= 0) { visualizationClass = 'visualizations hidden'; } @@ -73,7 +75,7 @@ class VnfSearchOrchStatusVisualizations extends Component { <div > <h3>{i18n(CHART_ORCH_STATUS.title)}</h3> <ResponsiveContainer width='100%' height={300}> - <BarChart data={processedOrchStatusCountChartData[0].values}> + <BarChart data={processedOrchStatusCountChartData.values}> <XAxis dataKey={xAxisAttrName}/> <YAxis /> <CartesianGrid strokeDasharray='3 3'/> diff --git a/src/app/vnfSearch/VnfSearchProvStatusVisualization.jsx b/src/app/vnfSearch/VnfSearchProvStatusVisualization.jsx index d889d20..5295e35 100644 --- a/src/app/vnfSearch/VnfSearchProvStatusVisualization.jsx +++ b/src/app/vnfSearch/VnfSearchProvStatusVisualization.jsx @@ -1,26 +1,28 @@ +/* eslint-disable max-len,max-len,max-len,max-len,max-len,max-len */ /* - * ============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. */ -/* eslint-disable max-len,max-len,max-len,max-len,max-len,max-len */ import React, {Component} from 'react'; import {connect} from 'react-redux'; @@ -51,7 +53,7 @@ let mapStateToProps = ({vnfSearch}) => { class VnfSearchProvStatusVisualization extends Component { static propTypes = { - processedProvStatusCountChartData: React.PropTypes.array + processedProvStatusCountChartData: React.PropTypes.object }; render() { @@ -60,9 +62,9 @@ class VnfSearchProvStatusVisualization extends Component { } = this.props; let visualizationClass = 'visualizations'; - if (processedProvStatusCountChartData[0].values === + if (processedProvStatusCountChartData.values === null || - processedProvStatusCountChartData[0].values.size <= + processedProvStatusCountChartData.values.size <= 0) { visualizationClass = 'visualizations hidden'; } @@ -76,7 +78,7 @@ class VnfSearchProvStatusVisualization extends Component { <h3>{i18n(CHART_PROV_STATUS.title)}</h3> <ResponsiveContainer width='100%' height={300}> <BarChart - data={processedProvStatusCountChartData[0].values}> + data={processedProvStatusCountChartData.values}> <XAxis dataKey={xAxisAttrName}/> <YAxis /> <CartesianGrid strokeDasharray='3 3'/> diff --git a/src/app/vnfSearch/VnfSearchReducer.js b/src/app/vnfSearch/VnfSearchReducer.js index 6dfc412..4c8337f 100644 --- a/src/app/vnfSearch/VnfSearchReducer.js +++ b/src/app/vnfSearch/VnfSearchReducer.js @@ -1,29 +1,33 @@ /* - * ============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 {vnfActionTypes} from 'app/vnfSearch/VnfSearchConstants.js'; import { CHART_ORCH_STATUS, CHART_PROV_STATUS, + CHART_NF_ROLE, + CHART_NF_TYPE, TOTAL_VNF_COUNT } from 'app/vnfSearch/VnfSearchConstants.js'; import {ERROR_RETRIEVING_DATA} from 'app/networking/NetworkConstants.js'; @@ -31,63 +35,85 @@ import {MESSAGE_LEVEL_DANGER} from 'utils/GlobalConstants.js'; import { globalAutoCompleteSearchBarActionTypes } from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js'; +import { + filterBarActionTypes +} from 'generic-components/filterBar/FilterBarConstants.js'; export default (state = {}, action) => { let data = action.data; switch (action.type) { - - case vnfActionTypes.COUNT_BY_PROV_STATUS_RECEIVED: + case vnfActionTypes.VNF_NETWORK_ERROR: return { ...state, - processedProvStatusCountChartData: data.provStatusCountChartData.chartData, - feedbackMsgText: '', - feedbackMsgSeverity: '' + processedProvStatusCountChartData: CHART_PROV_STATUS.emptyData, + processedOrchStatusCountChartData: CHART_ORCH_STATUS.emptyData, + processedNfTypeCountChartData: CHART_NF_TYPE.emptyData, + processedNfRoleCountChartData: CHART_NF_ROLE.emptyData, + count: TOTAL_VNF_COUNT.emptyValue, + feedbackMsgText: ERROR_RETRIEVING_DATA, + feedbackMsgSeverity: MESSAGE_LEVEL_DANGER }; - - case vnfActionTypes.COUNT_BY_ORCH_STATUS_RECEIVED: + case globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT: return { ...state, - processedOrchStatusCountChartData: data.orchStatusCountChartData.chartData, - feedbackMsgText: '', - feedbackMsgSeverity: '' + processedProvStatusCountChartData: CHART_PROV_STATUS.emptyData, + processedOrchStatusCountChartData: CHART_ORCH_STATUS.emptyData, + processedNfTypeCountChartData: CHART_NF_TYPE.emptyData, + processedNfRoleCountChartData: CHART_NF_ROLE.emptyData, + count: TOTAL_VNF_COUNT.emptyValue + }; + case filterBarActionTypes.NEW_SELECTIONS: + return { + ...state, + vnfFilterValues: data.selectedValuesMap, + unifiedFilterValues: data.unifiedValues + }; + case filterBarActionTypes.SET_UNIFIED_VALUES: + return { + ...state, + unifiedFilterValues: data }; - case vnfActionTypes.TOTAL_VNF_COUNT_RECEIVED: + case vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED: return { ...state, count: data.count, + processedProvStatusCountChartData: data.provStatusData, + processedOrchStatusCountChartData: data.orchStatusData, + processedNfTypeCountChartData: data.nfTypeData, + processedNfRoleCountChartData: data.nfRoleData, feedbackMsgText: '', feedbackMsgSeverity: '' }; - case vnfActionTypes.ERROR_NO_DATA_FOR_PROV_STATUS_IN_SEARCH_RANGE_RECEIVED: + case vnfActionTypes.VNF_FILTER_PANEL_TOGGLED: return { ...state, - processedProvStatusCountChartData: CHART_PROV_STATUS.emptyData, + vnfVisualizationPanelClass: data.vnfVisualizationPanelClass }; - case vnfActionTypes.ERROR_NO_DATA_FOR_ORCH_STATUS_IN_SEARCH_RANGE_RECEIVED: + case vnfActionTypes.VNF_SEARCH_FILTERS_RECEIVED: return { ...state, - processedOrchStatusCountChartData: CHART_ORCH_STATUS.emptyData, + vnfFilters: data }; - case vnfActionTypes.ERROR_NO_COUNT_RECEIVED: + case filterBarActionTypes.SET_NON_CONVERTED_VALUES: return { ...state, - count: TOTAL_VNF_COUNT.emptyValue, + nonConvertedFilters: data }; - case vnfActionTypes.VNF_NETWORK_ERROR: + case filterBarActionTypes.SET_CONVERTED_VALUES: return { ...state, - processedProvStatusCountChartData: CHART_PROV_STATUS.emptyData, - processedOrchStatusCountChartData: CHART_ORCH_STATUS.emptyData, - count: TOTAL_VNF_COUNT.emptyValue, - feedbackMsgText: ERROR_RETRIEVING_DATA, - feedbackMsgSeverity: MESSAGE_LEVEL_DANGER + nonConvertedFilters: {}, + unifiedFilterValues: data.convertedValues, + vnfFilterValues: data.nonConvertedValues // launching DI view via menu button requires this + // to be set so visualizations and table will populate themselves }; - case globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT: + case filterBarActionTypes.CLEAR_FILTERS: return { ...state, - processedProvStatusCountChartData: CHART_PROV_STATUS.emptyData, - processedOrchStatusCountChartData: CHART_ORCH_STATUS.emptyData, - count: TOTAL_VNF_COUNT.emptyValue + vnfFilters: {}, + vnfFilterValues: {}, + nonConvertedFilters: {}, + unifiedFilterValues: {} }; } diff --git a/src/app/vnfSearch/VnfSearchTotalCountVisualization.jsx b/src/app/vnfSearch/VnfSearchTotalCountVisualization.jsx index 690b5ee..5d3f1f2 100644 --- a/src/app/vnfSearch/VnfSearchTotalCountVisualization.jsx +++ b/src/app/vnfSearch/VnfSearchTotalCountVisualization.jsx @@ -1,26 +1,28 @@ +/* eslint-disable max-len,max-len,max-len,max-len,max-len,max-len */ /* - * ============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. */ -/* eslint-disable max-len,max-len,max-len,max-len,max-len,max-len */ import React, {Component} from 'react'; import {connect} from 'react-redux'; @@ -41,7 +43,10 @@ let mapStateToProps = ({vnfSearch}) => { class VnfSearchTotalCountVisualization extends Component { static propTypes = { - count: React.PropTypes.number + count: React.PropTypes.oneOfType([ + React.PropTypes.string, + React.PropTypes.number + ]) }; render() { |