AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 1 | /*! |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 2 | * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 3 | * |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 13 | * or implied. See the License for the specific language governing |
| 14 | * permissions and limitations under the License. |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 15 | */ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 16 | import LicenseModelActionHelper from './licenseModel/LicenseModelActionHelper.js'; |
| 17 | import LicenseAgreementActionHelper from './licenseModel/licenseAgreement/LicenseAgreementActionHelper.js'; |
| 18 | import FeatureGroupsActionHelper from './licenseModel/featureGroups/FeatureGroupsActionHelper.js'; |
| 19 | import LicenseKeyGroupsActionHelper from './licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js'; |
| 20 | import EntitlementPoolsActionHelper from './licenseModel/entitlementPools/EntitlementPoolsActionHelper.js'; |
| 21 | import SoftwareProductActionHelper from './softwareProduct/SoftwareProductActionHelper.js'; |
| 22 | import SoftwareProductProcessesActionHelper from './softwareProduct/processes/SoftwareProductProcessesActionHelper.js'; |
| 23 | import SoftwareProductNetworksActionHelper from './softwareProduct/networks/SoftwareProductNetworksActionHelper.js'; |
| 24 | import SoftwareProductComponentsActionHelper from './softwareProduct/components/SoftwareProductComponentsActionHelper.js'; |
| 25 | import SoftwareProductComponentProcessesActionHelper from './softwareProduct/components/processes/SoftwareProductComponentProcessesActionHelper.js'; |
| 26 | import SoftwareProductComponentsNetworkActionHelper from './softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 27 | import SoftwareProductDependenciesActionHelper from './softwareProduct/dependencies/SoftwareProductDependenciesActionHelper.js'; |
| 28 | import OnboardActionHelper from './onboard/OnboardActionHelper.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 29 | import SoftwareProductComponentsMonitoringAction from './softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringActionHelper.js'; |
| 30 | import {actionTypes, enums} from './OnboardingConstants.js'; |
| 31 | import {navigationItems as SoftwareProductNavigationItems, actionTypes as SoftwareProductActionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 32 | import ActivityLogActionHelper from 'nfvo-components/activity-log/ActivityLogActionHelper.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 33 | import store from 'sdc-app/AppStore.js'; |
| 34 | |
| 35 | function setCurrentScreen(dispatch, screen, props = {}) { |
| 36 | dispatch({ |
| 37 | type: actionTypes.SET_CURRENT_SCREEN, |
| 38 | currentScreen: { |
| 39 | screen, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 40 | props, |
| 41 | forceBreadCrumbsUpdate: true |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 42 | } |
| 43 | }); |
| 44 | } |
| 45 | |
| 46 | function getCurrentLicenseModelVersion(licenseModelId) { |
| 47 | return store.getState().licenseModelList.find(({id}) => id === licenseModelId).version; |
| 48 | } |
| 49 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 50 | function getCurrentSoftwareProductVersion(softwareProductId) { |
| 51 | return store.getState().softwareProductList.find(({id}) => id === softwareProductId).version; |
| 52 | } |
| 53 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 54 | export default { |
| 55 | |
| 56 | navigateToOnboardingCatalog(dispatch) { |
| 57 | LicenseModelActionHelper.fetchLicenseModels(dispatch); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 58 | LicenseModelActionHelper.fetchFinalizedLicenseModels(dispatch); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 59 | SoftwareProductActionHelper.fetchSoftwareProductList(dispatch); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 60 | SoftwareProductActionHelper.fetchFinalizedSoftwareProductList(dispatch); |
| 61 | OnboardActionHelper.resetOnboardStore(dispatch); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 62 | setCurrentScreen(dispatch, enums.SCREEN.ONBOARDING_CATALOG); |
| 63 | }, |
| 64 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 65 | autoSaveBeforeNavigate(dispatch, {softwareProductId, version, vspComponentId, dataToSave}) { |
| 66 | if(softwareProductId) { |
| 67 | if(vspComponentId) { |
| 68 | return SoftwareProductComponentsActionHelper.updateSoftwareProductComponent(dispatch, { |
| 69 | softwareProductId, version, vspComponentId, |
| 70 | componentData: dataToSave.componentData, |
| 71 | qdata: dataToSave.qdata |
| 72 | }); |
| 73 | } |
| 74 | return SoftwareProductActionHelper.updateSoftwareProduct(dispatch, { |
| 75 | softwareProduct: dataToSave.softwareProduct, |
| 76 | qdata: dataToSave.qdata |
| 77 | }); |
| 78 | } |
| 79 | return Promise.resolve(); |
| 80 | }, |
| 81 | |
| 82 | navigateToLicenseModelOverview(dispatch, {licenseModelId, version}) { |
| 83 | if (!version) { |
| 84 | version = getCurrentLicenseModelVersion(licenseModelId); |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * TODO change to specific rest |
| 89 | */ |
| 90 | |
| 91 | LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => { |
| 92 | LicenseModelActionHelper.fetchLicenseModelItems(dispatch, {licenseModelId, version}).then(() =>{ |
| 93 | setCurrentScreen(dispatch, enums.SCREEN.LICENSE_MODEL_OVERVIEW, {licenseModelId, version}); |
| 94 | }); |
| 95 | |
| 96 | }); |
| 97 | }, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 98 | navigateToLicenseAgreements(dispatch, {licenseModelId, version}) { |
| 99 | if(!version) { |
| 100 | version = getCurrentLicenseModelVersion(licenseModelId); |
| 101 | } |
| 102 | LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version}); |
| 103 | LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 104 | setCurrentScreen(dispatch, enums.SCREEN.LICENSE_AGREEMENTS, {licenseModelId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 105 | }); |
| 106 | }, |
| 107 | |
| 108 | navigateToFeatureGroups(dispatch, {licenseModelId, version}) { |
| 109 | if(!version) { |
| 110 | version = getCurrentLicenseModelVersion(licenseModelId); |
| 111 | } |
| 112 | FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 113 | setCurrentScreen(dispatch, enums.SCREEN.FEATURE_GROUPS, {licenseModelId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 114 | }, |
| 115 | |
| 116 | navigateToEntitlementPools(dispatch, {licenseModelId, version}) { |
| 117 | if(!version) { |
| 118 | version = getCurrentLicenseModelVersion(licenseModelId); |
| 119 | } |
| 120 | EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 121 | setCurrentScreen(dispatch, enums.SCREEN.ENTITLEMENT_POOLS, {licenseModelId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 122 | }, |
| 123 | |
| 124 | navigateToLicenseKeyGroups(dispatch, {licenseModelId, version}) { |
| 125 | if(!version) { |
| 126 | version = getCurrentLicenseModelVersion(licenseModelId); |
| 127 | } |
| 128 | LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 129 | setCurrentScreen(dispatch, enums.SCREEN.LICENSE_KEY_GROUPS, {licenseModelId, version}); |
| 130 | }, |
| 131 | |
| 132 | navigateToLicenseModelActivityLog(dispatch, {licenseModelId, version}){ |
| 133 | if(!version) { |
| 134 | version = getCurrentLicenseModelVersion(licenseModelId); |
| 135 | } |
| 136 | ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: licenseModelId, versionId: version.id}); |
| 137 | setCurrentScreen(dispatch, enums.SCREEN.ACTIVITY_LOG, {licenseModelId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 138 | }, |
| 139 | |
| 140 | navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, licenseModelId, version, licensingVersion}) { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 141 | |
| 142 | if (!version) { |
| 143 | version = getCurrentSoftwareProductVersion(softwareProductId); |
| 144 | } |
| 145 | |
| 146 | SoftwareProductComponentsActionHelper.clearComponentsStore(dispatch); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 147 | SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}).then(response => { |
| 148 | if(!licensingVersion) { |
| 149 | licensingVersion = response[0].licensingVersion; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 150 | if (!licensingVersion) { |
| 151 | licensingVersion = {id: '1.0', label: '1.0'}; |
| 152 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 153 | } |
| 154 | if (!licenseModelId) { |
| 155 | licenseModelId = response[0].vendorId; |
| 156 | } |
| 157 | |
Michael Lando | b3d4898 | 2017-06-11 14:22:02 +0300 | [diff] [blame^] | 158 | const newVersion = response[0].version ? response[0].version : version; |
| 159 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 160 | SoftwareProductActionHelper.loadSoftwareProductDetailsData(dispatch, {licenseModelId, licensingVersion}); |
Michael Lando | b3d4898 | 2017-06-11 14:22:02 +0300 | [diff] [blame^] | 161 | SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version: newVersion}); |
| 162 | SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version: newVersion}); |
| 163 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, {softwareProductId, licenseModelId, version: newVersion}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 164 | }); |
| 165 | }, |
| 166 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 167 | navigateToSoftwareProductDetails(dispatch, {softwareProductId, version}) { |
| 168 | SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}); |
| 169 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, {softwareProductId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 170 | }, |
| 171 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 172 | navigateToSoftwareProductAttachments(dispatch, {softwareProductId, version}) { |
| 173 | SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version}); |
| 174 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, {softwareProductId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 175 | }, |
| 176 | |
| 177 | navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version}) { |
| 178 | if (softwareProductId) { |
| 179 | SoftwareProductProcessesActionHelper.fetchProcessesList(dispatch, {softwareProductId, version}); |
| 180 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 181 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES, {softwareProductId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 182 | }, |
| 183 | |
| 184 | navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version}) { |
| 185 | if (softwareProductId) { |
| 186 | SoftwareProductNetworksActionHelper.fetchNetworksList(dispatch, {softwareProductId, version}); |
| 187 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 188 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS, {softwareProductId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 189 | }, |
| 190 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 191 | navigateToSoftwareProductDependencies(dispatch, {softwareProductId, version}) { |
| 192 | SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version}); |
| 193 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES, {softwareProductId, version}); |
| 194 | }, |
| 195 | |
| 196 | navigateToSoftwareProductComponents(dispatch, {softwareProductId, version}) { |
| 197 | SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version}); |
| 198 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, {softwareProductId, version}); |
| 199 | }, |
| 200 | |
| 201 | navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version}){ |
| 202 | ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: softwareProductId, versionId: version.id}); |
| 203 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG, {softwareProductId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 204 | }, |
| 205 | |
| 206 | navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId, version}) { |
| 207 | if (componentId && softwareProductId) { |
| 208 | SoftwareProductComponentProcessesActionHelper.fetchProcessesList(dispatch, {componentId, softwareProductId, version}); |
| 209 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 210 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, {softwareProductId, componentId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 211 | }, |
| 212 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 213 | navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, version, componentId}){ |
| 214 | if (componentId && softwareProductId && version) { |
| 215 | SoftwareProductComponentsMonitoringAction.fetchExistingFiles(dispatch, {componentId, softwareProductId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 216 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 217 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING, {softwareProductId, componentId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 218 | }, |
| 219 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 220 | navigateToComponentStorage(dispatch, {softwareProductId, componentId, version}) { |
| 221 | SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); |
| 222 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE, {softwareProductId, version, componentId}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 223 | }, |
| 224 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 225 | navigateToComponentCompute(dispatch, {softwareProductId, componentId, version}) { |
| 226 | SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); |
| 227 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, {softwareProductId, version, componentId}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 228 | }, |
| 229 | |
| 230 | navigateToComponentNetwork(dispatch, {softwareProductId, componentId, version}) { |
| 231 | SoftwareProductComponentsNetworkActionHelper.fetchNICsList(dispatch, {softwareProductId, componentId, version}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 232 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK, {softwareProductId, version, componentId}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 233 | }, |
| 234 | |
| 235 | navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version}) { |
| 236 | if (componentId && softwareProductId) { |
| 237 | SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 238 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 239 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL, {softwareProductId, version, componentId}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 240 | }, |
| 241 | |
| 242 | navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version}) { |
| 243 | this.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version}); |
| 244 | dispatch({ |
| 245 | type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM, |
| 246 | mapOfExpandedIds: { |
| 247 | [SoftwareProductNavigationItems.COMPONENTS]: true, |
| 248 | [SoftwareProductNavigationItems.COMPONENTS + '|' + componentId]: true |
| 249 | } |
| 250 | }); |
| 251 | }, |
| 252 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 253 | navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId, version}) { |
| 254 | SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); |
| 255 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, {softwareProductId, version, componentId}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 256 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 257 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 258 | }; |