summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/services/aaiService/aai.epics.ts
diff options
context:
space:
mode:
authorSonsino, Ofir (os0695) <os0695@intl.att.com>2018-07-10 15:57:37 +0300
committerSonsino, Ofir (os0695) <os0695@intl.att.com>2018-07-10 15:57:37 +0300
commitff76b5ed0aa91d5fdf9dc4f95e8b20f91ed9d072 (patch)
treeaae42404a93fdffdd16ff050eaa28129959f7577 /vid-webpack-master/src/app/services/aaiService/aai.epics.ts
parentc72d565bb58226b20625b2bce5f0019046bee649 (diff)
New Angular UI from 1806
Change-Id: I39c160db0e0a6ec2e587ccf007ee1b23c6a08666 Issue-ID: VID-208 Signed-off-by: Sonsino, Ofir (os0695) <os0695@intl.att.com>
Diffstat (limited to 'vid-webpack-master/src/app/services/aaiService/aai.epics.ts')
-rw-r--r--vid-webpack-master/src/app/services/aaiService/aai.epics.ts81
1 files changed, 81 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/services/aaiService/aai.epics.ts b/vid-webpack-master/src/app/services/aaiService/aai.epics.ts
new file mode 100644
index 00000000..5249cea8
--- /dev/null
+++ b/vid-webpack-master/src/app/services/aaiService/aai.epics.ts
@@ -0,0 +1,81 @@
+import {updateServiceInstance} from './../../service.actions';
+import {Injectable} from '@angular/core';
+import {createEpicMiddleware} from 'redux-observable';
+import 'rxjs/add/operator/catch';
+import 'rxjs/add/operator/map';
+import 'rxjs/add/operator/do';
+import 'rxjs/add/operator/startWith';
+import {
+ LOAD_PRODUCT_FAMILIES,
+ LOAD_LCP_TENANT,
+ LOAD_AIC_ZONES,
+ LOAD_CATEGORY_PARAMETERS,
+ LOAD_SERVICE_MDOEL_BY_UUID,
+ LOAD_NETWORK_ACCORDING_TO_NF,
+ LOAD_USER_ID
+} from "./aai.actions";
+import {AaiService} from "./aai.service";
+import {
+ updateAicZones, updateCategoryParameters, updateLcpRegionsAndTenants, updateNetworkCollectionFunction,
+ updateProductFamilies, updateUserId
+} from "../../service.actions";
+import {AppState} from "../../store/reducers";
+
+const notFetchedAlready = (state: AppState): boolean => state.service.productFamilies !== null;
+
+@Injectable()
+export class AAIEpics {
+ constructor(private aaiService: AaiService) {
+ }
+
+ public createEpic() {
+ return [createEpicMiddleware(this.loadProductFamiliesEpic)
+ , createEpicMiddleware(this.loadLcpTenants)
+ , createEpicMiddleware(this.loadAicZones)
+ , createEpicMiddleware(this.loadCategoryParameters)
+ , createEpicMiddleware(this.loadServiceAccordingToUuid)
+ , createEpicMiddleware(this.loadNetworkAccordingToNetworkFunction)
+ , createEpicMiddleware(this.loadUserId)
+ ];
+ }
+
+ private loadLcpTenants = (action$, store) =>
+ action$
+ .ofType(LOAD_LCP_TENANT)
+ .switchMap(() => this
+ .aaiService
+ .getLcpRegionsAndTenants('e433710f-9217-458d-a79d-1c7aff376d89', 'VIRTUAL USP')
+ .map(data => updateLcpRegionsAndTenants(data)));
+
+ private loadProductFamiliesEpic = (action$, store) => action$
+ .ofType(LOAD_PRODUCT_FAMILIES)
+ .switchMap(() => this.aaiService.getProductFamilies().map(data => updateProductFamilies(data)));
+
+ private loadCategoryParameters = (action$, store) => action$
+ .ofType(LOAD_CATEGORY_PARAMETERS)
+ .switchMap(() => this.aaiService.getCategoryParameters(null).map(data => updateCategoryParameters(data)));
+
+
+ private loadNetworkAccordingToNetworkFunction = (action$, store) => action$
+ .ofType(LOAD_NETWORK_ACCORDING_TO_NF)
+ .flatMap((action) => this.aaiService.getCRAccordingToNetworkFunctionId(action.networkFunctions, action.cloudOwner, action.cloudRegionId).map((res) =>
+ updateNetworkCollectionFunction(action.networkFunctions, res)));
+
+ private loadServiceAccordingToUuid = (action$, store) => action$
+ .ofType(LOAD_SERVICE_MDOEL_BY_UUID)
+ .switchMap((action) => this.aaiService.getServiceModelById(action.modelId)
+ .map(data => updateServiceInstance(action.uuid, data)));
+
+ private loadUserId = (action$, store) => action$
+ .ofType(LOAD_USER_ID)
+ .switchMap(() => this.aaiService.getUserId()
+ .map(res => updateUserId(res)));
+
+
+ private loadAicZones = (action$, store) => action$
+ .ofType(LOAD_AIC_ZONES)
+ .switchMap(() => this.aaiService.getAicZones().map(data => updateAicZones(data)));
+ // .catch(response => of(this.actions.loadFailed(status)))
+ // .startWith(this.actions.loadStarted()));
+
+}