summaryrefslogtreecommitdiffstats
path: root/cds-ui/client/src/app/common/core/store
diff options
context:
space:
mode:
Diffstat (limited to 'cds-ui/client/src/app/common/core/store')
-rw-r--r--cds-ui/client/src/app/common/core/store/actions/catalog.action.ts77
-rw-r--r--cds-ui/client/src/app/common/core/store/effects/catalog.effect.ts37
-rw-r--r--cds-ui/client/src/app/common/core/store/models/catalog-http.model.ts25
-rw-r--r--cds-ui/client/src/app/common/core/store/models/catalog.model.ts29
-rw-r--r--cds-ui/client/src/app/common/core/store/models/catalogState.model.ts28
-rw-r--r--cds-ui/client/src/app/common/core/store/reducers/app.reducer.ts5
-rw-r--r--cds-ui/client/src/app/common/core/store/reducers/catalog.reducer.ts39
-rw-r--r--cds-ui/client/src/app/common/core/store/selectors/catalog.selectors.ts31
-rw-r--r--cds-ui/client/src/app/common/core/store/state/app.state.ts9
-rw-r--r--cds-ui/client/src/app/common/core/store/state/catalog.state.ts29
10 files changed, 304 insertions, 5 deletions
diff --git a/cds-ui/client/src/app/common/core/store/actions/catalog.action.ts b/cds-ui/client/src/app/common/core/store/actions/catalog.action.ts
new file mode 100644
index 000000000..938cdb110
--- /dev/null
+++ b/cds-ui/client/src/app/common/core/store/actions/catalog.action.ts
@@ -0,0 +1,77 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : CDS
+* ================================================================================
+* Copyright (C) 2019 TechMahindra
+*=================================================================================
+* 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=========================================================
+*/
+
+import { Injectable } from '@angular/core';
+import { Action, Store } from '@ngrx/store';
+import { ICatalog } from '../models/catalog.model';
+import { ICatalogState } from '../models/catalogState.model';
+
+export const LOAD_CATALOG = 'LOAD_CATALOG';
+export const LOAD_CATALOG_SUCCESS = 'LOAD_CATALOG_SUCCESS';
+export const LOAD_CATALOG_FAILURE = 'LOAD_CATALOG_FAILURE';
+export const UPDATE_CATALOG ='UPDATE_CATALOG';
+export const UPDATE_CATALOG_SUCCESS = 'UPDATE_CATALOG_SUCCESS';
+export const UPDATE_CATALOG_FAILURE = 'UPDATE_CATALOG_FAILURE';
+export const SAVE_CATALOG = 'SAVE_CATALOG';
+export const SAVE_CATALOG_SUCCESS = 'SAVE_CATALOG_SUCCESS';
+export const SAVE_CATALOG_FAILURE = 'SAVE_CATALOG_FAILURE';
+
+export const SET_CATALOG = 'SET CATALOG';
+export const REMOVE_CATALOG = 'Remove CATALOG';
+
+export const SET_CATALOG_STATE = 'SET CATALOG state';
+
+
+export class LoadCatalog implements Action {
+ readonly type = LOAD_CATALOG;
+ constructor(public startLoadSuccess?: boolean) {}
+}
+
+export class LoadCatalogSuccess implements Action {
+ readonly type = LOAD_CATALOG_SUCCESS;
+ constructor(public payload: ICatalog) {}
+}
+
+export class LoadCatalogFailure implements Action {
+ readonly type = LOAD_CATALOG_FAILURE;
+ constructor(public error: any) {}
+}
+
+export class SetCatalogState implements Action {
+ readonly type = SET_CATALOG_STATE;
+ constructor(public payload: ICatalogState) {}
+}
+
+// export class SetCatalog implements Action {
+// readonly type = SET_CATALOG;
+// constructor(public payload: Catalog) {}
+// }
+
+// export class RemoveCatalog implements Action {
+// readonly type = REMOVE_CATALOG;
+// constructor(public payload: Catalog) {}
+// }
+
+export class UpdateCatalog implements Action {
+ readonly type = UPDATE_CATALOG;
+ constructor(public payload: ICatalog) {}
+}
+
+export type Actions = LoadCatalog | LoadCatalogSuccess | LoadCatalogFailure | SetCatalogState; \ No newline at end of file
diff --git a/cds-ui/client/src/app/common/core/store/effects/catalog.effect.ts b/cds-ui/client/src/app/common/core/store/effects/catalog.effect.ts
new file mode 100644
index 000000000..db2296eb7
--- /dev/null
+++ b/cds-ui/client/src/app/common/core/store/effects/catalog.effect.ts
@@ -0,0 +1,37 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : CDS
+* ================================================================================
+* Copyright (C) 2019 TechMahindra
+*=================================================================================
+* 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=========================================================
+*/
+
+import { Injectable } from '@angular/core';
+import { Effect, ofType, Actions } from '@ngrx/effects';
+import { Store, select } from '@ngrx/store';
+import { of } from 'rxjs';
+import { switchMap, map, withLatestFrom, catchError } from 'rxjs/operators';
+
+import { IAppState } from '../state/app.state';
+import * as CatalogActions from '../actions/catalog.action';
+
+@Injectable()
+export class CatalogEffects {
+
+ constructor(
+ private _actions$: Actions,
+ private _store: Store<IAppState>
+ ) {}
+} \ No newline at end of file
diff --git a/cds-ui/client/src/app/common/core/store/models/catalog-http.model.ts b/cds-ui/client/src/app/common/core/store/models/catalog-http.model.ts
new file mode 100644
index 000000000..dde1f979c
--- /dev/null
+++ b/cds-ui/client/src/app/common/core/store/models/catalog-http.model.ts
@@ -0,0 +1,25 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : CDS
+* ================================================================================
+* Copyright (C) 2019 TechMahindra
+*=================================================================================
+* 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=========================================================
+*/
+
+import { ICatalog } from './catalog.model';
+
+export interface ICatalogHttp {
+ catalog: ICatalog;
+} \ No newline at end of file
diff --git a/cds-ui/client/src/app/common/core/store/models/catalog.model.ts b/cds-ui/client/src/app/common/core/store/models/catalog.model.ts
new file mode 100644
index 000000000..2344f3336
--- /dev/null
+++ b/cds-ui/client/src/app/common/core/store/models/catalog.model.ts
@@ -0,0 +1,29 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : CDS
+* ================================================================================
+* Copyright (C) 2019 TechMahindra
+*=================================================================================
+* 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=========================================================
+*/
+
+export interface ICatalog {
+ Model_Name: string;
+ User_id: string;
+ _tags: string;
+ _type: string;
+ Derived_From: string;
+ _description : string;
+ definition: object[];
+} \ No newline at end of file
diff --git a/cds-ui/client/src/app/common/core/store/models/catalogState.model.ts b/cds-ui/client/src/app/common/core/store/models/catalogState.model.ts
new file mode 100644
index 000000000..937dd87e0
--- /dev/null
+++ b/cds-ui/client/src/app/common/core/store/models/catalogState.model.ts
@@ -0,0 +1,28 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : CDS
+* ================================================================================
+* Copyright (C) 2019 TechMahindra
+*=================================================================================
+* 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=========================================================
+*/
+
+import { ICatalog } from './catalog.model';
+
+export interface ICatalogState {
+ catalog: ICatalog,
+ isLoadSuccess?: boolean;
+ isUpdateSuccess?: boolean;
+ isSaveSuccess?: boolean;
+} \ No newline at end of file
diff --git a/cds-ui/client/src/app/common/core/store/reducers/app.reducer.ts b/cds-ui/client/src/app/common/core/store/reducers/app.reducer.ts
index 6f583202c..785939040 100644
--- a/cds-ui/client/src/app/common/core/store/reducers/app.reducer.ts
+++ b/cds-ui/client/src/app/common/core/store/reducers/app.reducer.ts
@@ -21,13 +21,14 @@ limitations under the License.
import { ActionReducerMap } from '@ngrx/store';
import { routerReducer } from '@ngrx/router-store';
-
import { IAppState } from '../state/app.state';
import { blueprintReducer } from '../reducers/blueprint.reducer';
import { resourcesReducer } from '../reducers/resources.reducer';
+import { catalogReducer } from '../reducers/catalog.reducer';
export const appReducers: ActionReducerMap<IAppState, any> = {
router: routerReducer,
blueprint: blueprintReducer,
- resources:resourcesReducer
+ resources:resourcesReducer,
+ catalog: catalogReducer
}; \ No newline at end of file
diff --git a/cds-ui/client/src/app/common/core/store/reducers/catalog.reducer.ts b/cds-ui/client/src/app/common/core/store/reducers/catalog.reducer.ts
new file mode 100644
index 000000000..ae5ca4e1e
--- /dev/null
+++ b/cds-ui/client/src/app/common/core/store/reducers/catalog.reducer.ts
@@ -0,0 +1,39 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : CDS
+* ================================================================================
+* Copyright (C) 2019 TechMahindra
+*=================================================================================
+* 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=========================================================
+*/
+
+import { Action } from '@ngrx/store';
+import { initialCatalogState } from '../state/catalog.state';
+import * as CatalogActions from '../actions/catalog.action';
+import { ICatalogState } from '../models/catalogState.model';
+
+export function catalogReducer(state: ICatalogState = initialCatalogState, action: CatalogActions.Actions) : ICatalogState {
+ switch(action.type) {
+ case CatalogActions.LOAD_CATALOG_SUCCESS:
+ return {...state,
+ catalog: action.payload
+ }
+ case CatalogActions.SET_CATALOG_STATE:
+ return {...state,
+ catalog: action.payload.catalog
+ }
+ default:
+ return state;
+ }
+}
diff --git a/cds-ui/client/src/app/common/core/store/selectors/catalog.selectors.ts b/cds-ui/client/src/app/common/core/store/selectors/catalog.selectors.ts
new file mode 100644
index 000000000..172448f53
--- /dev/null
+++ b/cds-ui/client/src/app/common/core/store/selectors/catalog.selectors.ts
@@ -0,0 +1,31 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : CDS
+* ================================================================================
+* Copyright (C) 2019 TechMahindra
+*=================================================================================
+* 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=========================================================
+*/
+
+import { createSelector } from '@ngrx/store';
+
+import { IAppState } from '../state/app.state';
+import { ICatalogState } from '../models/catalogState.model';
+
+const selectCatalogFromAppState = (state: IAppState) => state.catalog;
+
+export const selectCatalog = createSelector(
+ selectCatalogFromAppState,
+ (state: ICatalogState) => state.catalog
+); \ No newline at end of file
diff --git a/cds-ui/client/src/app/common/core/store/state/app.state.ts b/cds-ui/client/src/app/common/core/store/state/app.state.ts
index 052eb2c5b..c08edce1e 100644
--- a/cds-ui/client/src/app/common/core/store/state/app.state.ts
+++ b/cds-ui/client/src/app/common/core/store/state/app.state.ts
@@ -24,14 +24,17 @@ import { IBlueprintState } from '../models/blueprintState.model';
import { initialBlueprintState } from './blueprint.state';
import { IResourcesState } from '../models/resourcesState.model';
import { initialResourcesState } from './resources.state';
+import { ICatalogState } from '../models/catalogState.model';
+import { initialCatalogState } from './catalog.state';
export interface IAppState {
router? : RouterReducerState,
blueprint: IBlueprintState,
- resources: IResourcesState
+ resources: IResourcesState,
+ catalog: ICatalogState
}
-
export const initialAppState: IAppState = {
blueprint: initialBlueprintState,
- resources: initialResourcesState
+ resources: initialResourcesState,
+ catalog: initialCatalogState
} \ No newline at end of file
diff --git a/cds-ui/client/src/app/common/core/store/state/catalog.state.ts b/cds-ui/client/src/app/common/core/store/state/catalog.state.ts
new file mode 100644
index 000000000..a780269c5
--- /dev/null
+++ b/cds-ui/client/src/app/common/core/store/state/catalog.state.ts
@@ -0,0 +1,29 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : CDS
+* ================================================================================
+* Copyright (C) 2019 TechMahindra
+*=================================================================================
+* 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=========================================================
+*/
+
+import { ICatalogState } from '../models/catalogState.model';
+import { ICatalog } from '../models/catalog.model';
+
+export const initialCatalogState : ICatalogState = {
+ catalog : {} as ICatalog,
+ isLoadSuccess: false,
+ isUpdateSuccess: false,
+ isSaveSuccess: false,
+} \ No newline at end of file