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 | |
| 158 | SoftwareProductActionHelper.loadSoftwareProductDetailsData(dispatch, {licenseModelId, licensingVersion}); |
| 159 | SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 160 | SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 161 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, {softwareProductId, licenseModelId, version}); |
| 162 | }); |
| 163 | }, |
| 164 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 165 | navigateToSoftwareProductDetails(dispatch, {softwareProductId, version}) { |
| 166 | SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}); |
| 167 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, {softwareProductId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 168 | }, |
| 169 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 170 | navigateToSoftwareProductAttachments(dispatch, {softwareProductId, version}) { |
| 171 | SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version}); |
| 172 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, {softwareProductId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 173 | }, |
| 174 | |
| 175 | navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version}) { |
| 176 | if (softwareProductId) { |
| 177 | SoftwareProductProcessesActionHelper.fetchProcessesList(dispatch, {softwareProductId, version}); |
| 178 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 179 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES, {softwareProductId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 180 | }, |
| 181 | |
| 182 | navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version}) { |
| 183 | if (softwareProductId) { |
| 184 | SoftwareProductNetworksActionHelper.fetchNetworksList(dispatch, {softwareProductId, version}); |
| 185 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 186 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS, {softwareProductId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 187 | }, |
| 188 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 189 | navigateToSoftwareProductDependencies(dispatch, {softwareProductId, version}) { |
| 190 | SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version}); |
| 191 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES, {softwareProductId, version}); |
| 192 | }, |
| 193 | |
| 194 | navigateToSoftwareProductComponents(dispatch, {softwareProductId, version}) { |
| 195 | SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version}); |
| 196 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, {softwareProductId, version}); |
| 197 | }, |
| 198 | |
| 199 | navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version}){ |
| 200 | ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: softwareProductId, versionId: version.id}); |
| 201 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG, {softwareProductId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 202 | }, |
| 203 | |
| 204 | navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId, version}) { |
| 205 | if (componentId && softwareProductId) { |
| 206 | SoftwareProductComponentProcessesActionHelper.fetchProcessesList(dispatch, {componentId, softwareProductId, version}); |
| 207 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 208 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, {softwareProductId, componentId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 209 | }, |
| 210 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 211 | navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, version, componentId}){ |
| 212 | if (componentId && softwareProductId && version) { |
| 213 | SoftwareProductComponentsMonitoringAction.fetchExistingFiles(dispatch, {componentId, softwareProductId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 214 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 215 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING, {softwareProductId, componentId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 216 | }, |
| 217 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 218 | navigateToComponentStorage(dispatch, {softwareProductId, componentId, version}) { |
| 219 | SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); |
| 220 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE, {softwareProductId, version, componentId}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 221 | }, |
| 222 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 223 | navigateToComponentCompute(dispatch, {softwareProductId, componentId, version}) { |
| 224 | SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); |
| 225 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, {softwareProductId, version, componentId}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 226 | }, |
| 227 | |
| 228 | navigateToComponentNetwork(dispatch, {softwareProductId, componentId, version}) { |
| 229 | SoftwareProductComponentsNetworkActionHelper.fetchNICsList(dispatch, {softwareProductId, componentId, version}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 230 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK, {softwareProductId, version, componentId}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 231 | }, |
| 232 | |
| 233 | navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version}) { |
| 234 | if (componentId && softwareProductId) { |
| 235 | SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 236 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 237 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL, {softwareProductId, version, componentId}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 238 | }, |
| 239 | |
| 240 | navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version}) { |
| 241 | this.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version}); |
| 242 | dispatch({ |
| 243 | type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM, |
| 244 | mapOfExpandedIds: { |
| 245 | [SoftwareProductNavigationItems.COMPONENTS]: true, |
| 246 | [SoftwareProductNavigationItems.COMPONENTS + '|' + componentId]: true |
| 247 | } |
| 248 | }); |
| 249 | }, |
| 250 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 251 | navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId, version}) { |
| 252 | SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); |
| 253 | setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, {softwareProductId, version, componentId}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 254 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 255 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 256 | }; |