From ca007e933bcd9f63aa77801656ed9dd4142c432c Mon Sep 17 00:00:00 2001 From: ARULNA Date: Fri, 2 Jun 2017 16:27:25 -0400 Subject: Initial coomit for AAI-UI(sparky-fe) Change-Id: I9f8482824a52bac431c100939899e760c0fa4fdb Signed-off-by: ARULNA --- src/app/tierSupport/TierSupport.jsx | 211 +++++++++++++++++++++ src/app/tierSupport/TierSupportActions.js | 175 +++++++++++++++++ src/app/tierSupport/TierSupportConstants.js | 49 +++++ src/app/tierSupport/TierSupportReducer.js | 110 +++++++++++ .../selectedNodeDetails/SelectedNodeDetails.jsx | 104 ++++++++++ .../SelectedNodeDetailsConstants.js | 48 +++++ .../SelectedNodeDetailsReducer.js | 72 +++++++ 7 files changed, 769 insertions(+) create mode 100644 src/app/tierSupport/TierSupport.jsx create mode 100644 src/app/tierSupport/TierSupportActions.js create mode 100644 src/app/tierSupport/TierSupportConstants.js create mode 100644 src/app/tierSupport/TierSupportReducer.js create mode 100644 src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx create mode 100644 src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsConstants.js create mode 100644 src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.js (limited to 'src/app/tierSupport') diff --git a/src/app/tierSupport/TierSupport.jsx b/src/app/tierSupport/TierSupport.jsx new file mode 100644 index 0000000..d4b0f3b --- /dev/null +++ b/src/app/tierSupport/TierSupport.jsx @@ -0,0 +1,211 @@ +/* + * ============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 SplitPane from 'react-split-pane'; + +import ForceDirectedGraph from 'generic-components/graph/ForceDirectedGraph.jsx'; +import SelectedNodeDetails from 'app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx'; +import i18n from 'utils/i18n/i18n'; +import { + onNodeDetailsChange, + onNodeMenuChange, + splitPaneResize, + querySelectedNodeElement, + setNotificationText, + clearVIData +} from 'app/tierSupport/TierSupportActions.js'; +import { + TSUI_TITLE, + TSUI_NODE_DETAILS_INITIAL_WIDTH, + TSUI_NODE_DETAILS_MIN_WIDTH, + TSUI_GRAPH_MENU_NODE_DETAILS +} from './TierSupportConstants.js'; + +let mapStateToProps = ( + { + tierSupport: + { + tierSupportReducer, + globalAutoCompleteSearchBar + } + }) => { + + let { + forceDirectedGraphRawData = { + graphCounter: -1, + nodeDataArray: [], + linkDataArray: [], + graphMeta: {} + }, windowWidth = 500, + windowHeight = 500, + graphNodeSelectedMenu = TSUI_GRAPH_MENU_NODE_DETAILS, + feedbackMsgText = '', + feedbackMsgSeverity = '' + } = tierSupportReducer; + + let { + performPrepareVisualization = false, + selectedSuggestion = {} + } = globalAutoCompleteSearchBar; + return { + forceDirectedGraphRawData, + windowWidth, + windowHeight, + graphNodeSelectedMenu, + performPrepareVisualization, + selectedSuggestion, + feedbackMsgText, + feedbackMsgSeverity + }; +}; + +let mapActionToProps = (dispatch) => { + return { + onNodeSelected: (requestObject) => { + dispatch(onNodeDetailsChange(requestObject)); + }, + onNodeMenuSelect: (selectedMenu) => { + dispatch(onNodeMenuChange(selectedMenu.buttonId)); + }, + onSplitPaneResize: (initialLoad) => { + dispatch(splitPaneResize(initialLoad)); + }, + onNewVIParam: (param) => { + dispatch(querySelectedNodeElement(param)); + }, + onMessageStateChange: (msgText, msgSeverity) => { + dispatch(setNotificationText(msgText, msgSeverity)); + }, + onRequestClearData: () => { + dispatch(clearVIData()); + } + }; +}; + +class TierSupport extends Component { + static propTypes = { + forceDirectedGraphRawData: React.PropTypes.object, + windowWidth: React.PropTypes.number, + windowHeight: React.PropTypes.number, + graphNodeSelectedMenu: React.PropTypes.string, + feedbackMsgText: React.PropTypes.string, + feedbackMsgSeverity: React.PropTypes.string + }; + + componentWillReceiveProps(nextProps) { + if (nextProps.match.params.viParam && + nextProps.match.params.viParam !== + this.props.match.params.viParam) { + this.props.onNewVIParam(nextProps.match.params.viParam); + } + + if (nextProps.feedbackMsgText !== this.props.feedbackMsgText) { + this.props.onMessageStateChange(nextProps.feedbackMsgText, + nextProps.feedbackMsgSeverity); + } + } + + componentWillMount() { + if (this.props.match.params.viParam) { + this.props.onNewVIParam(this.props.match.params.viParam); + } else { + this.props.onRequestClearData(); + } + } + + componentDidMount() { + this.props.onSplitPaneResize(true); + } + + componentWillUnmount() { + // resetting to default (empty screen) + this.props.onRequestClearData(); + } + + render() { + const { + forceDirectedGraphRawData, + onNodeSelected, + windowWidth, + windowHeight, + onSplitPaneResize, + onNodeMenuSelect + } = this.props; + let currentSelectedMenu = this.getCurrentSelectedMenu(); + + //Temp code for a demo, will be removed as Vis library is updated + let currentNodeButton = 'NODE_DETAILS'; + // End temp code + + return ( +
+
+ {i18n(TSUI_TITLE)} +
+ { + onSplitPaneResize(false); + } } + defaultSize={TSUI_NODE_DETAILS_INITIAL_WIDTH} + minSize={TSUI_NODE_DETAILS_MIN_WIDTH} + maxSize={-200} + primary='second'> +
+ { + onNodeSelected(nodeData); + }} + nodeButtonSelectedCallback={(selectedMenuId) => { + onNodeMenuSelect(selectedMenuId); + }} + currentlySelectedNodeView={currentNodeButton}/> +
+
+ {currentSelectedMenu} +
+
+
+ ); + } + + getCurrentSelectedMenu() { + switch (this.props.graphNodeSelectedMenu) { + case TSUI_GRAPH_MENU_NODE_DETAILS: + if (!this.nodeDetails) { + this.nodeDetails = ; + } + return this.nodeDetails; + } + } +} + +export default connect(mapStateToProps, mapActionToProps)(TierSupport); diff --git a/src/app/tierSupport/TierSupportActions.js b/src/app/tierSupport/TierSupportActions.js new file mode 100644 index 0000000..d6f5e5a --- /dev/null +++ b/src/app/tierSupport/TierSupportActions.js @@ -0,0 +1,175 @@ +/* + * ============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 {tierSupportActionTypes, + TS_BACKEND_SEARCH_SELECTED_NODE_URL} from 'app/tierSupport/TierSupportConstants.js'; +import { + POST, + POST_HEADER, + ERROR_RETRIEVING_DATA, + NO_RESULTS_FOUND +} from 'app/networking/NetworkConstants.js'; +import networkCall from 'app/networking/NetworkCalls.js'; +import { + getSetGlobalMessageEvent, + getClearGlobalMessageEvent +} from 'app/GlobalInlineMessageBar/GlobalInlineMessageBarActions.js'; +import { + STATUS_CODE_204_NO_CONTENT, + STATUS_CODE_3XX_REDIRECTION, + STATUS_CODE_5XX_SERVER_ERROR +} from 'utils/GlobalConstants.js'; + +function createOnNodeDetailsChangeEvent(newDetails) { + return { + type: tierSupportActionTypes.TS_GRAPH_NODE_SELECTED, + data: newDetails + }; +} + +function createSplitPaneResizeEvent(initialLoad) { + return { + type: tierSupportActionTypes.SPLIT_PANE_RESIZE, + data: initialLoad + }; +} + +function createOnNodeMenuSelectEvent(selectedMenu) { + return { + type: tierSupportActionTypes.TS_GRAPH_NODE_MENU_SELECTED, + data: selectedMenu + }; +} + +export function onNodeDetailsChange(newDetails) { + return dispatch => { + dispatch(createOnNodeDetailsChangeEvent(newDetails)); + }; +} + +export function splitPaneResize(initialLoad) { + return dispatch => { + dispatch(createSplitPaneResizeEvent(initialLoad)); + }; +} + +export function onNodeMenuChange(selectedMenu) { + return dispatch => { + dispatch(createOnNodeMenuSelectEvent(selectedMenu)); + }; +} + +function createNodeDetailsFoundEvent(nodeDetails) { + return { + type: tierSupportActionTypes.TS_NODE_SEARCH_RESULTS, + data: nodeDetails + }; +} + +function noNodeDetailsFoundEvent(errorText) { + return { + type: tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS, + data: {errorMsg: errorText} + }; +} + +function getInvalidSelectedNodeSearchEvent(errorText) { + return { + type: tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR, + data: {value: errorText, errorMsg: ERROR_RETRIEVING_DATA} + }; +} + +export function clearVIData() { + return { + type: tierSupportActionTypes.TIER_SUPPORT_CLEAR_DATA + }; +} + +export function fetchSelectedNodeElement(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( + (responseJson) => { + if (responseJson.nodes.length > 0) { + dispatch(createNodeDetailsFoundEvent(responseJson)); + } else { + dispatch(noNodeDetailsFoundEvent(NO_RESULTS_FOUND)); + } + } + ).catch( + (errorCode) => { + if (errorCode.message >= STATUS_CODE_5XX_SERVER_ERROR) { + dispatch(getInvalidSelectedNodeSearchEvent(ERROR_RETRIEVING_DATA)); + } else { + // TODO - assuming 204 status, but should include additional + // statuses in the future with proper messaging in order to return + // better messaging + dispatch(noNodeDetailsFoundEvent(NO_RESULTS_FOUND)); + } + } + ); + }; +} + +export function querySelectedNodeElement( + searchHashId, selectedNodeFetchRequest) { + let payload = { + hashId: searchHashId + }; + + if (selectedNodeFetchRequest === undefined) { + let postBody = JSON.stringify(payload); + selectedNodeFetchRequest = + () => networkCall.fetchRequestObj(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST, + POST_HEADER, postBody); + } + + return dispatch => { + dispatch(fetchSelectedNodeElement(selectedNodeFetchRequest)); + }; +} + +export function setNotificationText(msgText, msgSeverity) { + if (msgText.length > 0) { + return dispatch => { + dispatch( + getSetGlobalMessageEvent(msgText, msgSeverity)); + }; + } else { + return dispatch => { + dispatch(getClearGlobalMessageEvent()); + }; + } +} diff --git a/src/app/tierSupport/TierSupportConstants.js b/src/app/tierSupport/TierSupportConstants.js new file mode 100644 index 0000000..ca7b512 --- /dev/null +++ b/src/app/tierSupport/TierSupportConstants.js @@ -0,0 +1,49 @@ +/* + * ============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 tierSupportActionTypes = keyMirror({ + TIER_SUPPORT_NETWORK_ERROR: null, + TS_NODE_SEARCH: null, + TS_NODE_SEARCH_RESULTS: null, + TS_NODE_SEARCH_NO_RESULTS: null, + TS_GRAPH_DATA_RESULTS: null, + TS_GRAPH_NODE_SELECTED: null, + TS_GRAPH_NODE_MENU_SELECTED: null, + SPLIT_PANE_RESIZE: null, + TIER_SUPPORT_CLEAR_DATA: null +}); + +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_TITLE = 'View & Inspect'; +export const TSUI_GRAPH_MENU_NODE_DETAILS = 'NODE_DETAILS'; +export const SEARCH_SELECTED_NODE_PATH = '/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 new file mode 100644 index 0000000..6e5e022 --- /dev/null +++ b/src/app/tierSupport/TierSupportReducer.js @@ -0,0 +1,110 @@ +/* + * ============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 ForceDirectedGraph from 'generic-components/graph/ForceDirectedGraph.jsx'; +import {aaiActionTypes} from 'app/MainScreenWrapperConstants.js'; +import { + tierSupportActionTypes, TSUI_GRAPH_MENU_NODE_DETAILS +} from 'app/tierSupport/TierSupportConstants.js'; +import SelectedNodeDetailsReducer from 'app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.js'; +import GlobalAutoCompleteSearchBarReducer from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.js'; +import { + MESSAGE_LEVEL_DANGER, MESSAGE_LEVEL_WARNING +} from 'utils/GlobalConstants.js'; +import { + globalAutoCompleteSearchBarActionTypes +} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js'; + +export default combineReducers({ + selectedNodeDetails: SelectedNodeDetailsReducer, + globalAutoCompleteSearchBar: GlobalAutoCompleteSearchBarReducer, + tierSupportReducer: (state = {}, action) => { + switch (action.type) { + case tierSupportActionTypes.TS_NODE_SEARCH_RESULTS: + let graphData = ForceDirectedGraph.generateNewProps(action.data.nodes, action.data.links, + action.data.graphMeta); + + return { + ...state, + forceDirectedGraphRawData: graphData, + feedbackMsgText: '', + feedbackMsgSeverity: '' + }; + case tierSupportActionTypes.TS_GRAPH_NODE_MENU_SELECTED: + return { + ...state, graphNodeSelectedMenu: action.data + }; + case tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS: + let emptyNodesAndLinksNoResults = ForceDirectedGraph.generateNewProps([], [], {}); + return { + ...state, + forceDirectedGraphRawData: emptyNodesAndLinksNoResults, + graphNodeSelectedMenu: TSUI_GRAPH_MENU_NODE_DETAILS, + feedbackMsgText: action.data.errorMsg, + feedbackMsgSeverity: MESSAGE_LEVEL_WARNING + }; + case tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR: + let emptyNodesAndLinksNetworkError = ForceDirectedGraph.generateNewProps([], [], {}); + return { + ...state, + forceDirectedGraphRawData: emptyNodesAndLinksNetworkError, + graphNodeSelectedMenu: TSUI_GRAPH_MENU_NODE_DETAILS, + feedbackMsgText: action.data.errorMsg, + feedbackMsgSeverity: MESSAGE_LEVEL_DANGER + }; + case tierSupportActionTypes.TIER_SUPPORT_CLEAR_DATA: + let emptyNodesAndLinksClearData = ForceDirectedGraph.generateNewProps([], [], {}); + return { + ...state, + forceDirectedGraphRawData: emptyNodesAndLinksClearData, + graphNodeSelectedMenu: TSUI_GRAPH_MENU_NODE_DETAILS, + feedbackMsgText: '', + feedbackMsgSeverity: '' + }; + case globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT: + let emptyNodesAndLinksWarningEvent = ForceDirectedGraph.generateNewProps([], [], {}); + return { + ...state, + forceDirectedGraphRawData: emptyNodesAndLinksWarningEvent, + graphNodeSelectedMenu: TSUI_GRAPH_MENU_NODE_DETAILS + }; + case aaiActionTypes.AAI_WINDOW_RESIZE: + case tierSupportActionTypes.SPLIT_PANE_RESIZE: + let splitPaneLeftSideElement = document.getElementsByClassName('Pane1'); + if (splitPaneLeftSideElement.length > 0) { + let width = splitPaneLeftSideElement[0].offsetWidth; + + return { + ...state, windowWidth: width, windowHeight: splitPaneLeftSideElement[0].offsetHeight + }; + } else { + return state; + } + } + + return state; + } +}); diff --git a/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx new file mode 100644 index 0000000..e04aca2 --- /dev/null +++ b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx @@ -0,0 +1,104 @@ +/* + * ============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 {connect} from 'react-redux'; +import React, {Component} from 'react'; +import Table from 'react-bootstrap/lib/Table'; +import i18n from 'utils/i18n/i18n'; +import { + SELECTED_NODE_TITLE, + NO_SELECTION, + SELECTED_NODE_TABLE_COLUMN_NAMES +} from 'app/tierSupport/selectedNodeDetails/SelectedNodeDetailsConstants.js'; + +let mapStateToProps = ({tierSupport: {selectedNodeDetails}}) => { + let {nodeData = [], nodeType = '', uid = ''} = selectedNodeDetails; + + return { + nodeData, + nodeType, + uid + }; +}; + +class SelectedNodeDetails extends Component { + static propTypes = { + nodeData: React.PropTypes.array, + nodeType: React.PropTypes.string, + uid: React.PropTypes.string + }; + + render() { + const {nodeData, nodeType, uid} = this.props; + + let tableClass = 'ts-selected-node-table'; + let noSelectionMessageClass = 'hidden'; + let tableColumns = []; + let tableRows = []; + + if (Object.keys(nodeData).length > 0) { + let cellClassName = ''; + for (let i = 1; i <= SELECTED_NODE_TABLE_COLUMN_NAMES.length; i++) { + cellClassName = (i % 2 ? 'left-column-cell' : 'right-column-cell'); + tableColumns.push( + {i18n(SELECTED_NODE_TABLE_COLUMN_NAMES[i - 1])} + ); + } + + for (var key in nodeData) { + let value = nodeData[key]; + tableRows.push( + + {key} + {value} + + ); + } + } else { + tableClass = 'hidden'; + noSelectionMessageClass = ''; + } + + return ( +
+

{i18n(SELECTED_NODE_TITLE)}

+

{nodeType}

+ {uid} + + + + {tableColumns} + + + + {tableRows} + +
+

{i18n(NO_SELECTION)}

+
+ ); + } +} +export default connect(mapStateToProps)(SelectedNodeDetails); diff --git a/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsConstants.js b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsConstants.js new file mode 100644 index 0000000..e12cbed --- /dev/null +++ b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsConstants.js @@ -0,0 +1,48 @@ +/* + * ============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 SELECTED_NODE_TITLE = 'Node Details'; +export const NO_SELECTION = 'Search for a service to view its details'; +export const SELECTED_NODE_TABLE_COLUMN_NAMES = ['Attribute', 'Value']; +export const TABLE_DATA = [ + ['equipment-role', 'UCPE'], + ['in-maint', 'false'], + ['ipv4-oam-addres', '1.22.1.5'], + ['is-closed-loop-disabled', 'false'], + ['management-option', 'ATT'], + ['nm-lan-v6-address', 'FE80:0000:0AB0:0000:0207:B3FF:FE1E:1202'], + ['operational-state', 'PROV'], + ['orchestration-status', 'created'], + ['resource-version', '146650180'], + ['service-id', 'Ud7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4CPE'], + ['vcpu', '1'], + ['vdisk', '20'], + ['vdisk-units', 'GB'], + ['vmemory', '12'], + ['vmemory-units', 'GB'], + ['vnf-id', 'b574e9e3-0a3d-4304-9c5-dd-su-gc21512'], + ['vnf-name', 'USETESORLFL0109UJSW01'], + ['vnf-type', 'SW'], +]; diff --git a/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.js b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.js new file mode 100644 index 0000000..e743a70 --- /dev/null +++ b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.js @@ -0,0 +1,72 @@ +/* + * ============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 {tierSupportActionTypes} from 'app/tierSupport/TierSupportConstants.js'; +import { + globalAutoCompleteSearchBarActionTypes +} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js'; + +export default (state = {}, action) => { + switch (action.type) { + case tierSupportActionTypes.TS_NODE_SEARCH_RESULTS: + for (const node of action.data.nodes) { + if (node.nodeMeta.searchTarget === true) { + return { + ...state, + nodeData: node.itemProperties, + nodeType: node.itemType, + uid: node.itemNameValue + }; + } + } + return { + ...state, + nodeData: [], + nodeType: '', + uid: '' + }; + + case tierSupportActionTypes.TS_GRAPH_NODE_SELECTED: + return { + ...state, + nodeData: action.data.itemProperties, + nodeType: action.data.itemType, + uid: action.data.itemNameValue + }; + + // else fall through to the TIER_SUPPORT_CLEAR_DATA case + case globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT: + case tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR: + case tierSupportActionTypes.TIER_SUPPORT_CLEAR_DATA: + case tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS: + return { + ...state, + nodeData: [], + nodeType: '', + uid: '' + }; + } + return state; +}; -- cgit 1.2.3-korg