Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 1 | /*- |
| 2 | * ============LICENSE_START======================================================= |
| 3 | * SDC |
| 4 | * ================================================================================ |
| 5 | * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
| 6 | * ================================================================================ |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | * ============LICENSE_END========================================================= |
| 19 | */ |
| 20 | |
| 21 | import LicenseModelActionHelper from './licenseModel/LicenseModelActionHelper.js'; |
| 22 | import LicenseAgreementActionHelper from './licenseModel/licenseAgreement/LicenseAgreementActionHelper.js'; |
| 23 | import FeatureGroupsActionHelper from './licenseModel/featureGroups/FeatureGroupsActionHelper.js'; |
| 24 | import LicenseKeyGroupsActionHelper from './licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js'; |
| 25 | import EntitlementPoolsActionHelper from './licenseModel/entitlementPools/EntitlementPoolsActionHelper.js'; |
| 26 | import SoftwareProductActionHelper from './softwareProduct/SoftwareProductActionHelper.js'; |
| 27 | import SoftwareProductProcessesActionHelper from './softwareProduct/processes/SoftwareProductProcessesActionHelper.js'; |
| 28 | import SoftwareProductNetworksActionHelper from './softwareProduct/networks/SoftwareProductNetworksActionHelper.js'; |
| 29 | import SoftwareProductComponentsActionHelper from './softwareProduct/components/SoftwareProductComponentsActionHelper.js'; |
| 30 | import SoftwareProductComponentProcessesActionHelper from './softwareProduct/components/processes/SoftwareProductComponentProcessesActionHelper.js'; |
| 31 | import SoftwareProductComponentsNetworkActionHelper from './softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.js'; |
| 32 | import SoftwareProductComponentsMonitoringAction from './softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringActionHelper.js'; |
| 33 | import {actionTypes, enums} from './OnboardingConstants.js'; |
| 34 | import {navigationItems as SoftwareProductNavigationItems, actionTypes as SoftwareProductActionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; |
| 35 | import store from 'sdc-app/AppStore.js'; |
| 36 | |
| 37 | function setCurrentScreen(dispatch, screen, props = {}) { |
| 38 | dispatch({ |
| 39 | type: actionTypes.SET_CURRENT_SCREEN, |
| 40 | currentScreen: { |
| 41 | screen, |
| 42 | props |
| 43 | } |
| 44 | }); |
| 45 | } |
| 46 | |
| 47 | function getCurrentLicenseModelVersion(licenseModelId) { |
| 48 | return store.getState().licenseModelList.find(({id}) => id === licenseModelId).version; |
| 49 | } |
| 50 | |
| 51 | export default { |
| 52 | |
| 53 | navigateToOnboardingCatalog(dispatch) { |
| 54 | LicenseModelActionHelper.fetchLicenseModels(dispatch); |
| 55 | SoftwareProductActionHelper.fetchSoftwareProductList(dispatch); |
| 56 | setCurrentScreen(dispatch, enums.SCREEN.ONBOARDING_CATALOG); |
| 57 | }, |
| 58 | |
| 59 | navigateToLicenseAgreements(dispatch, {licenseModelId, version}) { |
| 60 | if(!version) { |
| 61 | version = getCurrentLicenseModelVersion(licenseModelId); |
| 62 | } |
| 63 | LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version}); |
| 64 | LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => { |
| 65 | setCurrentScreen(dispatch, enums.SCREEN.LICENSE_AGREEMENTS, {licenseModelId}); |
| 66 | }); |
| 67 | }, |
| 68 | |
| 69 | navigateToFeatureGroups(dispatch, {licenseModelId, version}) { |
| 70 | if(!version) { |
| 71 | version = getCurrentLicenseModelVersion(licenseModelId); |
| 72 | } |
| 73 | FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version}); |
| 74 | setCurrentScreen(dispatch, enums.SCREEN.FEATURE_GROUPS, {licenseModelId}); |
| 75 | }, |
| 76 | |
| 77 | navigateToEntitlementPools(dispatch, {licenseModelId, version}) { |
| 78 | if(!version) { |
| 79 | version = getCurrentLicenseModelVersion(licenseModelId); |
| 80 | } |
| 81 | EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}); |
| 82 | setCurrentScreen(dispatch, enums.SCREEN.ENTITLEMENT_POOLS, {licenseModelId}); |
| 83 | }, |
| 84 | |
| 85 | navigateToLicenseKeyGroups(dispatch, {licenseModelId, version}) { |
| 86 | if(!version) { |
| 87 | version = getCurrentLicenseModelVersion(licenseModelId); |
| 88 | } |
| 89 | LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}); |
| 90 | setCurrentScreen(dispatch, enums.SCREEN.LICENSE_KEY_GROUPS, {licenseModelId}); |
| 91 | }, |
| 92 | |
| 93 | navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, licenseModelId, version, licensingVersion}) { |
| 94 | SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}).then(response => { |
| 95 | if(!licensingVersion) { |
| 96 | licensingVersion = response[0].licensingVersion; |
| 97 | } |
| 98 | if (!licenseModelId) { |
| 99 | licenseModelId = response[0].vendorId; |
| 100 | } |
| 101 | |
| 102 | SoftwareProductActionHelper.loadSoftwareProductDetailsData(dispatch, {licenseModelId, licensingVersion}); |
| 103 | SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version}); |
| 104 | |
| 105 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, {softwareProductId, licenseModelId, version}); |
| 106 | }); |
| 107 | }, |
| 108 | |
| 109 | navigateToSoftwareProductDetails(dispatch, {softwareProductId}) { |
| 110 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, {softwareProductId}); |
| 111 | }, |
| 112 | |
| 113 | navigateToSoftwareProductAttachments(dispatch, {softwareProductId}) { |
| 114 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, {softwareProductId}); |
| 115 | }, |
| 116 | |
| 117 | navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version}) { |
| 118 | if (softwareProductId) { |
| 119 | SoftwareProductProcessesActionHelper.fetchProcessesList(dispatch, {softwareProductId, version}); |
| 120 | } |
| 121 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES, {softwareProductId}); |
| 122 | }, |
| 123 | |
| 124 | navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version}) { |
| 125 | if (softwareProductId) { |
| 126 | SoftwareProductNetworksActionHelper.fetchNetworksList(dispatch, {softwareProductId, version}); |
| 127 | } |
| 128 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS, {softwareProductId}); |
| 129 | }, |
| 130 | |
| 131 | navigateToSoftwareProductComponents(dispatch, {softwareProductId}) { |
| 132 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, {softwareProductId}); |
| 133 | }, |
| 134 | |
| 135 | navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId, version}) { |
| 136 | if (componentId && softwareProductId) { |
| 137 | SoftwareProductComponentProcessesActionHelper.fetchProcessesList(dispatch, {componentId, softwareProductId, version}); |
| 138 | } |
| 139 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, {softwareProductId, componentId}); |
| 140 | }, |
| 141 | |
| 142 | navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, componentId}){ |
| 143 | if (componentId && softwareProductId) { |
| 144 | SoftwareProductComponentsMonitoringAction.fetchExistingFiles(dispatch, {componentId, softwareProductId}); |
| 145 | } |
| 146 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING, {softwareProductId, componentId}); |
| 147 | }, |
| 148 | |
| 149 | navigateToComponentStorage(dispatch, {softwareProductId, componentId}) { |
| 150 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE, {softwareProductId, componentId}); |
| 151 | }, |
| 152 | |
| 153 | navigateToComponentCompute(dispatch, {softwareProductId, componentId}) { |
| 154 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, {softwareProductId, componentId}); |
| 155 | }, |
| 156 | |
| 157 | navigateToComponentNetwork(dispatch, {softwareProductId, componentId, version}) { |
| 158 | SoftwareProductComponentsNetworkActionHelper.fetchNICsList(dispatch, {softwareProductId, componentId, version}); |
| 159 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK, {softwareProductId, componentId}); |
| 160 | }, |
| 161 | |
| 162 | navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version}) { |
| 163 | if (componentId && softwareProductId) { |
| 164 | SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); |
| 165 | SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(dispatch, { |
| 166 | softwareProductId, |
| 167 | vspComponentId: componentId, |
| 168 | version |
| 169 | }); |
| 170 | } |
| 171 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL, {softwareProductId, componentId}); |
| 172 | }, |
| 173 | |
| 174 | navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version}) { |
| 175 | this.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version}); |
| 176 | dispatch({ |
| 177 | type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM, |
| 178 | mapOfExpandedIds: { |
| 179 | [SoftwareProductNavigationItems.COMPONENTS]: true, |
| 180 | [SoftwareProductNavigationItems.COMPONENTS + '|' + componentId]: true |
| 181 | } |
| 182 | }); |
| 183 | }, |
| 184 | |
| 185 | navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId}) { |
| 186 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, {softwareProductId, componentId}); |
| 187 | } |
| 188 | }; |