summaryrefslogtreecommitdiffstats
path: root/src/app/configurableViews
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/configurableViews')
-rw-r--r--src/app/configurableViews/ConfigurableViewActions.js48
-rw-r--r--src/app/configurableViews/ConfigurableViewConstants.js11
-rw-r--r--src/app/configurableViews/ConfigurableViewManager.js27
-rw-r--r--src/app/configurableViews/ConfigurableViewReducer.js26
-rw-r--r--src/app/configurableViews/index.js27
5 files changed, 139 insertions, 0 deletions
diff --git a/src/app/configurableViews/ConfigurableViewActions.js b/src/app/configurableViews/ConfigurableViewActions.js
new file mode 100644
index 0000000..7cffacc
--- /dev/null
+++ b/src/app/configurableViews/ConfigurableViewActions.js
@@ -0,0 +1,48 @@
+import {
+ GET,
+ POST_HEADER
+} from 'app/networking/NetworkConstants.js';
+import {
+ GET_LAYOUTS_URL,
+ configurableViewsActionTypes
+} from './ConfigurableViewConstants.js';
+
+function createConfigReceivedEvent(config) {
+ return {
+ type: configurableViewsActionTypes.CONFIGURABLE_VIEWS_CONFIG_RECEIVED,
+ data: config
+ };
+}
+
+export function newCustomComponentsEvent(components) {
+ return {
+ type: configurableViewsActionTypes.CUSTOM_COMPONENTS_RECEIVED,
+ data: components
+ };
+}
+
+export function setCustomRoutes(routes) {
+ return {
+ type: configurableViewsActionTypes.CUSTOM_ROUTES,
+ data: routes
+ };
+}
+
+export function getConfigurableViewConfigs() {
+ return dispatch => {
+ return fetch(GET_LAYOUTS_URL, {
+ method: GET,
+ headers: POST_HEADER
+ }).then(
+ (response) => response.json()
+ ).then(
+ (responseJson) => {
+ dispatch(createConfigReceivedEvent(responseJson));
+ }
+ ).catch(
+ (err) => {
+ console.log(`problems fetching configurable view configs: ${err}`);
+ }
+ );
+ };
+}
diff --git a/src/app/configurableViews/ConfigurableViewConstants.js b/src/app/configurableViews/ConfigurableViewConstants.js
new file mode 100644
index 0000000..202dd18
--- /dev/null
+++ b/src/app/configurableViews/ConfigurableViewConstants.js
@@ -0,0 +1,11 @@
+import keyMirror from 'utils/KeyMirror.js';
+import {BASE_URL} from 'app/networking/NetworkConstants.js';
+
+export const configurableViewsActionTypes = keyMirror({
+ CONFIGURABLE_VIEWS_CONFIG_RECEIVED: null,
+ CONFIGURABLE_VIEWS_DATA_RECEIVED: null,
+ CUSTOM_ROUTES: null,
+ CUSTOM_COMPONENTS_RECEIVED: null
+});
+
+export const GET_LAYOUTS_URL = BASE_URL + '/layouts';
diff --git a/src/app/configurableViews/ConfigurableViewManager.js b/src/app/configurableViews/ConfigurableViewManager.js
new file mode 100644
index 0000000..71cc6cf
--- /dev/null
+++ b/src/app/configurableViews/ConfigurableViewManager.js
@@ -0,0 +1,27 @@
+import React from 'react';
+import {
+ Route
+} from 'react-router-dom';
+import { fetchConfigurableViewRequest } from 'app/networking/NetworkCalls';
+
+export function getConfigurableRoutes(config, components) {
+ let routes = [];
+ if (config && Object.keys(config).length > 0 && components && Object.keys(components).length > 0) {
+ config.layouts.forEach( (viewConfig) => {
+ let ConfigurableView = components[viewConfig.viewType];
+ if (ConfigurableView) {
+ routes.push(
+ <Route key={viewConfig.id} path={`/${viewConfig.id}`} render={ () => {
+ return (
+ <ConfigurableView
+ config={ viewConfig }
+ networkAPI={ fetchConfigurableViewRequest }/>
+ );
+ }}/>
+ );
+ }
+ });
+ }
+
+ return routes;
+}
diff --git a/src/app/configurableViews/ConfigurableViewReducer.js b/src/app/configurableViews/ConfigurableViewReducer.js
new file mode 100644
index 0000000..9a5eee0
--- /dev/null
+++ b/src/app/configurableViews/ConfigurableViewReducer.js
@@ -0,0 +1,26 @@
+import {
+ configurableViewsActionTypes
+} from './ConfigurableViewConstants.js';
+
+export default (state = {}, action) => {
+ let data = action.data;
+ switch (action.type) {
+ case configurableViewsActionTypes.CONFIGURABLE_VIEWS_CONFIG_RECEIVED:
+ return {
+ ...state,
+ configurableViewsConfig: data
+ };
+ case configurableViewsActionTypes.CUSTOM_COMPONENTS_RECEIVED:
+ return {
+ ...state,
+ customComponents: data
+ };
+ case configurableViewsActionTypes.CUSTOM_ROUTES:
+ return {
+ ...state,
+ customRoutes: data
+ };
+ }
+
+ return state;
+};
diff --git a/src/app/configurableViews/index.js b/src/app/configurableViews/index.js
new file mode 100644
index 0000000..3490fef
--- /dev/null
+++ b/src/app/configurableViews/index.js
@@ -0,0 +1,27 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
+ * ================================================================================
+ * 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 section (used as anchor to add extension imports)
+export function getConfiguredComponentList() {
+ let components = {};
+
+ // Components section (used as an anchor to add extension components)
+ return components;
+}