From a7b4b96afee33a2ff458f906742d88cd306ed961 Mon Sep 17 00:00:00 2001 From: Shawn Severin Date: Thu, 7 Dec 2017 15:19:25 -0500 Subject: [PATCH] Adding filter bar Issue-ID: AAI-543 Change-Id: I18ec69f4585a9f01feafd009fcd30493a039b064 Signed-off-by: Shawn Severin --- src/app/AppStore.js | 27 +- .../GlobalInlineMessageBarActions.js | 20 +- .../GlobalInlineMessageBarReducer.js | 20 +- src/app/MainScreenHeader.jsx | 184 +++++--- src/app/MainScreenWrapper.jsx | 102 +++-- src/app/MainScreenWrapperActionHelper.js | 102 ++++- src/app/MainScreenWrapperConstants.js | 24 +- src/app/MainScreenWrapperReducer.js | 67 ++- src/app/contextHandler/ContextHandlerActions.js | 137 ++++++ src/app/contextHandler/ContextHandlerConstants.js | 41 ++ src/app/extensibility/ExtensibilityReducer.js | 8 + src/app/extensibility/index.js | 7 + .../GlobalAutoCompleteSearchBar.jsx | 21 +- .../GlobalAutoCompleteSearchBarActions.js | 21 +- .../GlobalAutoCompleteSearchBarConstants.js | 21 +- src/app/inventory/Inventory.jsx | 32 +- src/app/inventory/InventoryConstants.js | 25 +- src/app/main.app.jsx | 25 +- src/app/networking/NetworkConstants.js | 21 +- src/app/networking/NetworkUtil.js | 129 +----- src/app/overlays/OverlayImports.js | 4 + src/app/tierSupport/TierSupport.jsx | 108 +++-- src/app/tierSupport/TierSupportActions.js | 36 +- src/app/tierSupport/TierSupportConstants.js | 23 +- src/app/tierSupport/TierSupportReducer.js | 30 +- .../selectedNodeDetails/SelectedNodeDetails.jsx | 23 +- src/app/vnfSearch/VnfSearch.jsx | 237 ++++++++--- src/app/vnfSearch/VnfSearchActions.js | 299 +++++++------ src/app/vnfSearch/VnfSearchConstants.js | 65 ++- src/app/vnfSearch/VnfSearchNfRoleVisualization.jsx | 98 +++++ src/app/vnfSearch/VnfSearchNfTypeVisualization.jsx | 96 +++++ .../VnfSearchOrchestratedStatusVisualization.jsx | 26 +- .../vnfSearch/VnfSearchProvStatusVisualization.jsx | 28 +- src/app/vnfSearch/VnfSearchReducer.js | 96 +++-- .../vnfSearch/VnfSearchTotalCountVisualization.jsx | 25 +- src/editAttributes/AppStore.js | 56 +++ src/editAttributes/Application.jsx | 42 ++ src/editAttributes/EditAttributeActions.js | 97 +++++ src/editAttributes/EditAttributeConstants.js | 50 +++ src/editAttributes/EditAttributeReducer.js | 56 +++ src/editAttributes/EditAttributes.jsx | 116 ++++++ .../changeAttributeForm/ChangeAttributeForm.jsx | 161 +++++++ .../ChangeAttributeFormConstants.js | 46 ++ .../ChangeAttributeFormReducer.js | 38 ++ src/editAttributes/changeAttributeForm/validate.js | 51 +++ src/editAttributes/index.html | 12 + src/editAttributes/main.app.jsx | 38 ++ src/editAttributes/networking/NetworkCalls.js | 37 ++ src/editAttributes/networking/NetworkConstants.js | 39 ++ src/editAttributes/networking/NetworkUtils.js | 34 ++ .../AutoCompleteSearchBar.jsx | 21 +- .../dynamicViewLoader/DynamicViewLoaderReducer.js | 21 +- .../filterBar/FilterBarConstants.js | 58 +++ src/generic-components/filterBar/FilterBarUtils.js | 352 ++++++++++++++++ .../graph/ForceDirectedGraph.jsx | 262 +++++++----- src/generic-components/graph/NodeFactory.js | 46 +- .../graph/NodeVisualElementConstants.js | 22 +- .../graph/TempCreateAttributes.js | 464 +++++++++++++++++++++ src/generic-components/treeNode/TreeNode.jsx | 79 ++++ src/index.html | 25 +- src/utils/Crypto.js | 22 + src/utils/DateTimeChartUtil.js | 33 +- src/utils/Routes.js | 112 +++-- 63 files changed, 3763 insertions(+), 855 deletions(-) create mode 100644 src/app/contextHandler/ContextHandlerActions.js create mode 100644 src/app/contextHandler/ContextHandlerConstants.js create mode 100644 src/app/extensibility/ExtensibilityReducer.js create mode 100644 src/app/extensibility/index.js create mode 100644 src/app/overlays/OverlayImports.js create mode 100644 src/app/vnfSearch/VnfSearchNfRoleVisualization.jsx create mode 100644 src/app/vnfSearch/VnfSearchNfTypeVisualization.jsx create mode 100644 src/editAttributes/AppStore.js create mode 100644 src/editAttributes/Application.jsx create mode 100644 src/editAttributes/EditAttributeActions.js create mode 100644 src/editAttributes/EditAttributeConstants.js create mode 100644 src/editAttributes/EditAttributeReducer.js create mode 100644 src/editAttributes/EditAttributes.jsx create mode 100644 src/editAttributes/changeAttributeForm/ChangeAttributeForm.jsx create mode 100644 src/editAttributes/changeAttributeForm/ChangeAttributeFormConstants.js create mode 100644 src/editAttributes/changeAttributeForm/ChangeAttributeFormReducer.js create mode 100644 src/editAttributes/changeAttributeForm/validate.js create mode 100644 src/editAttributes/index.html create mode 100644 src/editAttributes/main.app.jsx create mode 100644 src/editAttributes/networking/NetworkCalls.js create mode 100644 src/editAttributes/networking/NetworkConstants.js create mode 100644 src/editAttributes/networking/NetworkUtils.js create mode 100644 src/generic-components/filterBar/FilterBarConstants.js create mode 100644 src/generic-components/filterBar/FilterBarUtils.js create mode 100644 src/generic-components/graph/TempCreateAttributes.js create mode 100644 src/generic-components/treeNode/TreeNode.jsx create mode 100644 src/utils/Crypto.js 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( - ); // add VNF view - // 2172a3c25ae56e4995038ffbc1f055692bfc76c0b8ceda1205bc745a9f7a805d is - // the hash for 'VNFs' ... ensures VNF Search screen defaults to the - // aggregate VNF results menuOptions.push( - ); // add all custom view menu options - for (let view in customViews) { + for (let view in extensibleViews) { menuOptions.push( - + ); } + let secondaryTitleClass = 'secondary-header'; + if (secondaryTitle === undefined || secondaryTitle === '') { + secondaryTitleClass = secondaryTitleClass + ' hidden'; + } + return ( -
-
-
- - - - {menuOptions} - - - {AAI_TITLE} - -
- +
+
+ + + + {menuOptions} + + + {AAI_TITLE} + +
+ +
+ {secondaryTitle}
- ); } } 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 ( + { + 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( - + ); - } + }); return ( -
+
- + - - - + + + {customViewList}
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 { }}> + tickFormatter={dateFormatLocalTimeZoneYYYYMMDD}/> - + , 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 (
-
- {i18n(TSUI_TITLE)} -
{ onNodeMenuSelect(selectedMenuId); }} + dataOverlayButtons={dataOverlayButtons} currentlySelectedNodeView={currentNodeButton}/> +
{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 = ; + 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 = ; + } + return this.nodeDetails; + } + else { + if (this.isNotEmpty(this.props.nodeData) && overlayComponent) { + if (Overlays.default.hasOwnProperty(overlayComponent)) { + let OverlayComponent = Overlays.default[overlayComponent]; + secondOverlay = ; } - 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 ( + + this.props.onFilterSelection(selectedFilters, this.props.vnfFilters)} /> ); } render() { + let filterBar = this.getFilterBar(); + return ( -
-
- {i18n(VNF_TITLE)} -
- - - +
+ +
+ + + + + +
+
); } 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 ( +
+
+
+

{i18n(CHART_NF_ROLE.title)}

+ + + + + + + + + +
+
+
+ ); + } +} + +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 ( +
+
+
+

{i18n(CHART_NF_TYPE.title)}

+ + + + + + + + + +
+
+
+ ); + } + +} +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 {

{i18n(CHART_ORCH_STATUS.title)}

- + 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 {

{i18n(CHART_PROV_STATUS.title)}

+ data={processedProvStatusCountChartData.values}> 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() { diff --git a/src/editAttributes/AppStore.js b/src/editAttributes/AppStore.js new file mode 100644 index 0000000..cc626a0 --- /dev/null +++ b/src/editAttributes/AppStore.js @@ -0,0 +1,56 @@ +/* + * ============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 {combineReducers, createStore, compose, applyMiddleware} from 'redux'; +import thunkMiddleware from 'redux-thunk'; +import {reducer as formReducer} from 'redux-form'; + +import SetAttributeReducer from './EditAttributeReducer.js'; + +function createCompose() { + if (window.devToolsExtension) { + return compose( + applyMiddleware(thunkMiddleware), + window.devToolsExtension()); + } + else { + return applyMiddleware(thunkMiddleware); + } +} + +export const storeCreator = (initialState) => createStore( + combineReducers({ + setAttributes: SetAttributeReducer, + form: formReducer + }), + initialState, + createCompose() +); + + +const store = storeCreator(); + +export default store; + diff --git a/src/editAttributes/Application.jsx b/src/editAttributes/Application.jsx new file mode 100644 index 0000000..99a4d8d --- /dev/null +++ b/src/editAttributes/Application.jsx @@ -0,0 +1,42 @@ +/* + * ============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 {Provider} from 'react-redux'; +import store from 'editAttributes/AppStore.js'; + + +class Application extends Component { + + render() { + return ( + + {this.props.children} + + ); + } +} + +export default Application; diff --git a/src/editAttributes/EditAttributeActions.js b/src/editAttributes/EditAttributeActions.js new file mode 100644 index 0000000..871260a --- /dev/null +++ b/src/editAttributes/EditAttributeActions.js @@ -0,0 +1,97 @@ +/* + * ============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 NetworkCalls from './networking/NetworkCalls.js'; +import { + POST, + BACKEND_POST_HEADER, + CREDENTIALS +} from './networking/NetworkConstants.js'; +import { + createEditEntityAttributeRequestObject +} from './networking/NetworkUtils.js'; +import { + setAttributesActionTypes, + EDIT_ENTITY_ATTRIBUTES_URL, + RESPONSE_CODE_SUCCESS, + RESPONSE_CODE_NOT_AUTHORIZED, + RESPONSE_MESSAGE_SUCCESS, + RESPONSE_MESSAGE_NOT_AUTHORIZED, + RESPONSE_MESSAGE_FAILURE, + RESPONSE_MESSAGE_NETWORK_ERROR +} from './EditAttributeConstants.js'; + +function errorReturnedEvent(errorMsg) { + return { + type: setAttributesActionTypes.SET_ATTRIBUTE_ERROR, + data: {errorMsg: errorMsg} + }; +} + +function successReturnedEvent() { + return { + type: setAttributesActionTypes.SET_ATTRIBUTE_SUCCESS, + data: {successMsg: RESPONSE_MESSAGE_SUCCESS} + }; +} + +function clearFeedbackMessageEvent() { + return { + type: setAttributesActionTypes.CLEAR_FEEDBACK_MESSAGE, + data: {} + }; +} + +export function clearFeebackMessage() { + return dispatch => { + dispatch(clearFeedbackMessageEvent()); + }; +} + +export function requestEditEntityAttributes(entityURI, entityAttributes) { + + let postBody = JSON.stringify( + createEditEntityAttributeRequestObject(entityURI, entityAttributes)); + return dispatch => { + return NetworkCalls.fetchRequest(EDIT_ENTITY_ATTRIBUTES_URL, + CREDENTIALS, POST, BACKEND_POST_HEADER, postBody).then( + (responseJson) => { + if (responseJson) { + if (responseJson.resultCode === RESPONSE_CODE_SUCCESS) { + dispatch(successReturnedEvent()); + } else if (responseJson.resultCode === RESPONSE_CODE_NOT_AUTHORIZED) { + dispatch(errorReturnedEvent(RESPONSE_MESSAGE_NOT_AUTHORIZED)); + } else { + dispatch(errorReturnedEvent(RESPONSE_MESSAGE_FAILURE)); + } + } + } + ).catch( + () => { + dispatch(errorReturnedEvent(RESPONSE_MESSAGE_NETWORK_ERROR)); + } + ); + }; +} diff --git a/src/editAttributes/EditAttributeConstants.js b/src/editAttributes/EditAttributeConstants.js new file mode 100644 index 0000000..3371091 --- /dev/null +++ b/src/editAttributes/EditAttributeConstants.js @@ -0,0 +1,50 @@ +/* + * ============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 './networking/NetworkConstants.js'; + +export const SET_ATTRIBUTE_TITLE = 'A&AI'; +export const ATTRIBUTE_MODIFICATION = 'ATTRIBUTE MODIFICATION'; + + + +export const EDIT_ENTITY_ATTRIBUTES_URL = BASE_URL + '/editEntity/editAttributes'; + +export const RESPONSE_CODE_SUCCESS = 200; +export const RESPONSE_CODE_NOT_AUTHORIZED = 403; + +export const RESPONSE_MESSAGE_SUCCESS = 'Success'; +export const RESPONSE_MESSAGE_NOT_AUTHORIZED = 'User not authorized'; +export const RESPONSE_MESSAGE_FAILURE = 'Failed to update entity'; +export const RESPONSE_MESSAGE_NETWORK_ERROR = 'Network error'; + +export const setAttributesActionTypes = keyMirror({ + SET_ATTRIBUTE_ERROR: null, + SET_ATTRIBUTE_SUCCESS: null, + CLEAR_FEEDBACK_MESSAGE: null +}); diff --git a/src/editAttributes/EditAttributeReducer.js b/src/editAttributes/EditAttributeReducer.js new file mode 100644 index 0000000..5c55435 --- /dev/null +++ b/src/editAttributes/EditAttributeReducer.js @@ -0,0 +1,56 @@ +/* + * ============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 {setAttributesActionTypes} from './EditAttributeConstants.js'; +import { + MESSAGE_LEVEL_SUCCESS, + MESSAGE_LEVEL_DANGER +} from 'utils/GlobalConstants.js'; + +export default (state = {}, action) => { + switch (action.type) { + case setAttributesActionTypes.SET_ATTRIBUTE_ERROR: + return { + ...state, + feedbackMsgText: action.data.errorMsg, + feedbackMsgSeverity: MESSAGE_LEVEL_DANGER + }; + + case setAttributesActionTypes.SET_ATTRIBUTE_SUCCESS: + return { + ...state, + feedbackMsgText: action.data.successMsg, + feedbackMsgSeverity: MESSAGE_LEVEL_SUCCESS + }; + + case setAttributesActionTypes.CLEAR_FEEDBACK_MESSAGE: + return { + ...state, + feedbackMsgText: '', + feedbackMsgSeverity: '' + }; + } + return state; +}; diff --git a/src/editAttributes/EditAttributes.jsx b/src/editAttributes/EditAttributes.jsx new file mode 100644 index 0000000..ab2d391 --- /dev/null +++ b/src/editAttributes/EditAttributes.jsx @@ -0,0 +1,116 @@ +/* + * ============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 i18n from 'utils/i18n/i18n'; + +import InlineMessage from 'generic-components/InlineMessage/InlineMessage.jsx'; +import { + clearFeebackMessage, + requestEditEntityAttributes +} from './EditAttributeActions.js'; +import { + SET_ATTRIBUTE_TITLE, + ATTRIBUTE_MODIFICATION +} from './EditAttributeConstants.js'; +import ChangeAttributeForm from 'editAttributes/changeAttributeForm/ChangeAttributeForm.jsx'; +import {NO_VALUE_SELECTED} from 'editAttributes/changeAttributeForm/ChangeAttributeFormConstants.js'; + +let mapStateToProps = ({setAttributes}) => { + let { + feedbackMsgText = '', + feedbackMsgSeverity = '' + } = setAttributes; + + return { + feedbackMsgText, + feedbackMsgSeverity + }; +}; + +let mapActionToProps = (dispatch) => { + return { + handleSubmit: (values) => { + let uri = values.uri; + let attrMap = new Map(); + attrMap.set('provStatus', 'prov-status'); + attrMap.set('inMaint', 'in-maint'); + attrMap.set('isClosedLoopDisabled', 'is-closed-loop-disabled'); + + let attributes = {}; + let valueString = JSON.stringify(values); + JSON.parse(valueString, (key, value) => { + if(value !== NO_VALUE_SELECTED) { + let formattedKey = attrMap.get(key); + if(formattedKey !== undefined) { + attributes = { + ...attributes, [formattedKey]: value + }; + } + return value; + } + }); + + dispatch(requestEditEntityAttributes(uri, attributes)); + }, + clearFeedbackMessage: () => { + dispatch(clearFeebackMessage()); + } + }; +}; + +class SetAttribute extends Component { + render() { + let { + feedbackMsgText, + feedbackMsgSeverity, + handleSubmit, + clearFeedbackMessage} = this.props; + return ( +
+
+
{i18n(SET_ATTRIBUTE_TITLE)}
+
+
+ {i18n(ATTRIBUTE_MODIFICATION)} + +
+ + { + handleSubmit(values); + }} + buttonSelected={() => { + clearFeedbackMessage(); + }}/> +
+ ); + } +} + +export default connect(mapStateToProps, mapActionToProps)(SetAttribute); diff --git a/src/editAttributes/changeAttributeForm/ChangeAttributeForm.jsx b/src/editAttributes/changeAttributeForm/ChangeAttributeForm.jsx new file mode 100644 index 0000000..34ba98d --- /dev/null +++ b/src/editAttributes/changeAttributeForm/ChangeAttributeForm.jsx @@ -0,0 +1,161 @@ +/* + * ============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 {Field, Fields, reduxForm, propTypes} from 'redux-form'; +import i18n from 'utils/i18n/i18n'; + +import { + LABEL_NODE_URI, + LABEL_PROV_STATUS, + LABEL_ATTRIBUTES, + LABEL_IN_MAINT, + LABEL_IS_CLOSED_LOOP, + BUTTON_SUBMIT, + BUTTON_CLEAR, + NO_VALUE_SELECTED, + PREPROV, + NVTPROV, + DECOM, + PROV, + CAPPED, + RETIRED, + TRUE, + FALSE +} from './ChangeAttributeFormConstants.js'; +import validate from './validate.js'; + +class ChangeAttributeForm extends Component { + + static propTypes = { + ...propTypes + }; + + renderTextField = ({input, label, type, meta: {touched, error}}) => ( +
+ +
+ input.value === '' ? input.onBlur(' ') : input.onBlur()}/> + {touched && ((error && {error}))} +
+
+ ); + + + booleanOptions = [ + , + , + + ]; + + provStatusOptions = [ + , + , + , + , + , + , + + ]; + + renderAttributeFields = (fields) => ( +
+
+ {(fields.provStatus.meta.touched || + fields.inMaint.meta.touched || + fields.isClosedLoopDisabled.meta.touched) && + fields.provStatus.meta.error && + {fields.provStatus.meta.error}} +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ ); + + render() { + const { + handleSubmit, + buttonSelected, + pristine, + reset, + submitting} = this.props; + + return ( +
+ +

{i18n(LABEL_ATTRIBUTES)}

+ +
+ + +
+ + ); + } +} + +export default reduxForm({ + form: 'changeAttributeForm', + validate +})(ChangeAttributeForm); + diff --git a/src/editAttributes/changeAttributeForm/ChangeAttributeFormConstants.js b/src/editAttributes/changeAttributeForm/ChangeAttributeFormConstants.js new file mode 100644 index 0000000..02e8996 --- /dev/null +++ b/src/editAttributes/changeAttributeForm/ChangeAttributeFormConstants.js @@ -0,0 +1,46 @@ +/* + * ============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. + */ + +export const LABEL_NODE_URI = 'Target Entity URI'; +export const LABEL_PROV_STATUS = 'prov-status'; +export const LABEL_IN_MAINT = 'in-maint'; +export const LABEL_IS_CLOSED_LOOP = 'is-closed-loop-disabled'; +export const LABEL_ATTRIBUTES = 'ATTRIBUTES'; + +export const BUTTON_SUBMIT = 'Submit'; +export const BUTTON_CLEAR = 'Clear'; + +export const NO_VALUE_SELECTED = 'No Value Selected'; +export const PREPROV = 'PREPROV'; +export const NVTPROV = 'NVTPROV'; +export const PROV = 'PROV'; +export const CAPPED = 'CAPPED'; +export const DECOM = 'DECOM'; +export const RETIRED = 'RETIRED'; +export const TRUE = 'TRUE'; +export const FALSE = 'FALSE'; + +export const ERROR_MISSING_ATTR = 'At least one attribute must be set'; +export const ERROR_REQUIRED = 'Required'; diff --git a/src/editAttributes/changeAttributeForm/ChangeAttributeFormReducer.js b/src/editAttributes/changeAttributeForm/ChangeAttributeFormReducer.js new file mode 100644 index 0000000..0778a0e --- /dev/null +++ b/src/editAttributes/changeAttributeForm/ChangeAttributeFormReducer.js @@ -0,0 +1,38 @@ +/* + * ============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 { combineReducers } from 'redux' + import { reducer as formReducer } from 'redux-form' + + + + const reducer = combineReducers({ + form: formReducer.validation({ + changeAttributeForm: validate + }) + }); + + export default reducer; + */ diff --git a/src/editAttributes/changeAttributeForm/validate.js b/src/editAttributes/changeAttributeForm/validate.js new file mode 100644 index 0000000..d6a8d99 --- /dev/null +++ b/src/editAttributes/changeAttributeForm/validate.js @@ -0,0 +1,51 @@ +/* + * ============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 i18n from 'utils/i18n/i18n'; + +import { + ERROR_MISSING_ATTR, + ERROR_REQUIRED, + NO_VALUE_SELECTED +} from './ChangeAttributeFormConstants.js'; + +const validate = (values) => { + const errors = {}; + + if (!values.uri || values.uri.replace(/\s/g, '') === '') { + errors.uri = i18n(ERROR_REQUIRED); + } + if ((!values.provStatus || values.provStatus === NO_VALUE_SELECTED) && + (!values.inMaint || values.inMaint === NO_VALUE_SELECTED) && + (!values.isClosedLoopDisabled || + values.isClosedLoopDisabled === + NO_VALUE_SELECTED)) { + errors.provStatus = i18n(ERROR_MISSING_ATTR); + } + + return errors; +}; + +export default validate; diff --git a/src/editAttributes/index.html b/src/editAttributes/index.html new file mode 100644 index 0000000..45c0d04 --- /dev/null +++ b/src/editAttributes/index.html @@ -0,0 +1,12 @@ + + + + Edit Attributes + + + +
+ + + + diff --git a/src/editAttributes/main.app.jsx b/src/editAttributes/main.app.jsx new file mode 100644 index 0000000..b760db0 --- /dev/null +++ b/src/editAttributes/main.app.jsx @@ -0,0 +1,38 @@ +/* + * ============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 from 'react'; +import ReactDOM from 'react-dom'; + +import 'resources/scss/bootstrap.scss'; +import 'resources/css/font-awesome.min.css'; +import 'resources/scss/style.scss'; + +import Application from './Application.jsx'; +import SetAttribute from './EditAttributes.jsx'; + +ReactDOM.render( + , + document.getElementById('set-attribute-app')); diff --git a/src/editAttributes/networking/NetworkCalls.js b/src/editAttributes/networking/NetworkCalls.js new file mode 100644 index 0000000..a107aa6 --- /dev/null +++ b/src/editAttributes/networking/NetworkCalls.js @@ -0,0 +1,37 @@ +/* + * ============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. + */ + +export default { + fetchRequest(URL, CREDENTIALS, METHOD, HEADER, BODY) { + return fetch(URL, { + credentials: CREDENTIALS, + method: METHOD, + headers: HEADER, + body: BODY + }).then( + (response) => response.json() + ); + } +}; diff --git a/src/editAttributes/networking/NetworkConstants.js b/src/editAttributes/networking/NetworkConstants.js new file mode 100644 index 0000000..d20882d --- /dev/null +++ b/src/editAttributes/networking/NetworkConstants.js @@ -0,0 +1,39 @@ +/* + * ============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. + */ + +export const POST = 'POST'; +export const POST_HEADER = { + 'Accept': 'application/json' +}; +export const BACKEND_POST_HEADER = { + 'Accept': 'application/json', + 'Content-Type': 'application/json' +}; +export const CREDENTIALS = 'same-origin'; +export const ERROR_RETRIEVING_DATA = 'Error fetching data from server'; +const BACKEND_IP_ADDRESS = document.location.hostname; +const BACKEND_PORT_NUMBER = window.location.port; +const PROTOCOL = window.location.protocol; +export const BASE_URL = PROTOCOL + '//' + BACKEND_IP_ADDRESS + ':' + BACKEND_PORT_NUMBER; diff --git a/src/editAttributes/networking/NetworkUtils.js b/src/editAttributes/networking/NetworkUtils.js new file mode 100644 index 0000000..8fa50b8 --- /dev/null +++ b/src/editAttributes/networking/NetworkUtils.js @@ -0,0 +1,34 @@ +/* + * ============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. + */ + + +export function createEditEntityAttributeRequestObject(uri, attributes) { + return { + 'entity-uri': uri, + 'attributes': { + ...attributes + } + }; +} diff --git a/src/generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.jsx b/src/generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.jsx index 455a3ab..bd71e66 100644 --- a/src/generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.jsx +++ b/src/generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.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 {Button} from 'react-bootstrap'; import AutoSuggest from 'react-autosuggest'; @@ -120,6 +123,7 @@ export default class AutoCompleteSearchBar extends Component { onSuggestionsClearRequested={onSuggestionsClearRequested} onSuggestionSelected={(event, {suggestion}) => { this.newSearchSelected(suggestion, onInvalidSearch, dispatchAnalytics, value); + this.props.onClearSuggestionsTextFieldRequested(); }} renderSuggestion={this.renderSuggestion} inputProps={inputProps} @@ -134,6 +138,7 @@ export default class AutoCompleteSearchBar extends Component {