From da4fd6169717cfa04d644d0af0d23dd089a6e373 Mon Sep 17 00:00:00 2001 From: herbert Date: Sat, 14 Dec 2019 00:06:42 +0100 Subject: remove old version of devicemodel devicemanager oldux featureaggregator Issue-ID: SDNC-1004 Signed-off-by: herbert Change-Id: I5337643181e2398e5a8097e4ee14fa4ac96d0d4c --- .../src/actions/configurationActions.ts | 154 --------------------- 1 file changed, 154 deletions(-) delete mode 100644 sdnr/wt/odlux/apps/configurationApp/src/actions/configurationActions.ts (limited to 'sdnr/wt/odlux/apps/configurationApp/src/actions') diff --git a/sdnr/wt/odlux/apps/configurationApp/src/actions/configurationActions.ts b/sdnr/wt/odlux/apps/configurationApp/src/actions/configurationActions.ts deleted file mode 100644 index 9a4c92bc6..000000000 --- a/sdnr/wt/odlux/apps/configurationApp/src/actions/configurationActions.ts +++ /dev/null @@ -1,154 +0,0 @@ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * 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 '../../../../framework/src/flux/action'; -import { Dispatch } from '../../../../framework/src/flux/store'; - -import { CoreModelNetworkElement, LpResponse } from '../models/coreModel'; -import configurationService, { getValueByName } from '../services/configurationService'; -import { ViewSpecification } from 'models/uiModels'; -import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore'; -import { AddSnackbarNotification } from '../../../../framework/src/actions/snackbarActions'; - -export class ConfigurationApplicationBaseAction extends Action { } - -export class UpdateLoading extends ConfigurationApplicationBaseAction { - constructor (public loading: boolean) { - super(); - - } -} - -export class UpdateCoreModel extends ConfigurationApplicationBaseAction { - constructor (public nodeId?: string, public coreModel?: CoreModelNetworkElement) { - super(); - - } -} - -export class UpdateLp extends ConfigurationApplicationBaseAction { - constructor (public lpId?: string, public capability?: string, public conditionalPackage?: string, public viewSpecifications: ViewSpecification[] = []) { - super(); - - } -} - -export class UpdateViewData extends ConfigurationApplicationBaseAction { - constructor (public viewId?: string, public indexValues: string = "", public viewData: {} = {}) { - super(); - - } -} - - -export const updateMountIdAsyncActionCreator = (nodeId: string | undefined) => async (dispatch: Dispatch) => { - if (!nodeId) { - dispatch(new UpdateCoreModel()); - return; - } - dispatch(new UpdateLoading(true)); - const coreModel = await configurationService.getCoreModelByNodeId(nodeId); - dispatch(new UpdateLoading(false)); - - return coreModel - ? dispatch(new UpdateCoreModel(nodeId, coreModel)) - : dispatch(new UpdateCoreModel()); -} - -export const updateLpIdAsyncActionCreator = (lpId: string | undefined) => async (dispatch: Dispatch, getState: () => IApplicationStoreState) => { - const { configuration: { coreModel: coreModel, nodeId: nodeId } } = getState(); - if (! nodeId || !lpId || !coreModel) { - dispatch(new UpdateLp()); - return; - } - - // find the lp with its unique uuid - let lpData: LpResponse | null = null; - for (let ltp of coreModel.ltp) { - const lp = ltp.lp.find(pl => pl.uuid === lpId); - if (lp) { - lpData = lp; - break; - } - } - - // urn:onf:params:xml:ns:yang:microwave-model?module=microwave-model => microwave-model - let capability: string | null = lpData && getValueByName("capability", lpData.extension, null); - if (capability) { - const paramIndex = capability.indexOf('?'); - if (paramIndex > -1) { - capability = capability.slice(paramIndex+1); - } - const params = capability.split("&").map(p => (p || "=").split("=")); - const capParam = params.find(p => p[0] === "module") || null; - capability = capParam && capParam[1] || null; - } - - const revision: string | null = lpData && getValueByName("revision", lpData.extension, null); - const conditionalPackage: string | null = lpData && getValueByName("conditional-package", lpData.extension, null); - - dispatch(new UpdateLoading(true)); - const viewSpecifications = capability && await configurationService.getUIDescriptionByCapability(capability, revision) || []; - dispatch(new UpdateLoading(false)); - - return coreModel ? - dispatch(new UpdateLp(lpId, capability || undefined, conditionalPackage || undefined, viewSpecifications)) : - dispatch(new UpdateLp()); -} - -export const updateViewDataAsyncActionCreator = (viewId: string | undefined, indexValues: string[] = []) => async (dispatch: Dispatch, getState: () => IApplicationStoreState) => { - const { configuration: { nodeId, lpId, capability, conditionalPackage, viewSpecifications } } = getState(); - if (!viewId || !capability || !nodeId || !lpId || !conditionalPackage) { - // dispatch(new AddSnackbarNotification({ message: `Error invalid parameter !${JSON.stringify({capability ,nodeId ,lpId ,conditionalPackage}, null,2)}`, options: { variant: 'error' } })); - dispatch(new UpdateViewData()); - return; - } - - const viewSpecification = viewSpecifications.find(desc => desc.id === viewId); - if (!viewSpecification) { - dispatch(new AddSnackbarNotification({ message: `Error viewId ${viewId} not found !`, options: { variant: 'error' } })); - dispatch(new UpdateViewData()); - return; - } - - const url = viewSpecification.url.replace(/\$\$NODEID\$\$/g, nodeId).replace(/\$\$LPUUID\$\$/g, lpId); - - dispatch(new UpdateLoading(true)); - const data = capability && await configurationService.getViewData(url) || { }; - dispatch(new UpdateLoading(false)); - - let viewData: { [path: string]: {} } = data; - - const pathElements = viewSpecification.dataPath && - viewSpecification.dataPath.replace( - /\/\$\$INDEX:(\d+):?([a-z\-]+)?\$\$/ig, - (_, indexStr, keyStr) => { - const index = +indexStr; - return indexValues[index] && '/' + indexValues[index] || ''; - }).split("/") || []; - - for (let path of pathElements) { - if (path === "") { - break; - } - viewData = viewData[path]; - } - - return viewData != null ? - dispatch(new UpdateViewData(viewId, indexValues.length > 0 ? indexValues.join("/") : "", viewData)) : - dispatch(new UpdateViewData()); -} \ No newline at end of file -- cgit 1.2.3-korg