From a2b6dd34d73bf432846dc59c6f57dd59a03aff9b Mon Sep 17 00:00:00 2001 From: Michael Dürre Date: Thu, 8 Sep 2022 09:45:06 +0200 Subject: update odlux sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update basic odlux functionality for kohn Issue-ID: CCSDK-3765 Signed-off-by: Michael Dürre Change-Id: I3723c9c2f35b9012ba537920b294a54bb556cbc6 Signed-off-by: Michael Dürre --- .../configurationApp/src/actions/deviceActions.ts | 50 +++++++++++----------- .../handlers/connectedNetworkElementsHandler.ts | 2 +- .../configurationApp/src/services/yangService.ts | 4 +- .../src/views/configurationApplication.tsx | 4 +- .../src/views/networkElementSelector.tsx | 2 +- .../apps/configurationApp/src/yang/yangParser.ts | 7 +-- .../odlux/apps/configurationApp/webpack.config.js | 22 +++++----- 7 files changed, 45 insertions(+), 46 deletions(-) (limited to 'sdnr/wt/odlux/apps/configurationApp') diff --git a/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts b/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts index 0dd42e3b7..2846dba06 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts +++ b/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts @@ -1,21 +1,3 @@ -/** - * ============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 { IApplicationStoreState } from "../../../../framework/src/store/applicationStore"; @@ -65,6 +47,22 @@ export class UpdatOutputData extends Action { } } +type HttpResult = { + status: number; + message?: string | undefined; + data: { + [key: string]: any; + } | null | undefined; +}; + +const checkResponseCode = (restResult: HttpResult) =>{ + + //403 gets handled by the framework from now on + + return restResult.status !== 403 && ( restResult.status < 200 || restResult.status > 299); + +} + export const updateNodeIdAsyncActionCreator = (nodeId: string) => async (dispatch: Dispatch, getState: () => IApplicationStoreState ) => { dispatch(new UpdateDeviceDescription("", {}, [])); @@ -81,8 +79,8 @@ export const updateNodeIdAsyncActionCreator = (nodeId: string) => async (dispatc })); throw new Error(`NetworkElement : [${nodeId}] has no capabilities.`); } - - const parser = new YangParser(unavailableCapabilities || undefined, importOnlyModules || undefined); + + const parser = new YangParser(unavailableCapabilities || undefined, importOnlyModules || undefined, nodeId); for (let i = 0; i < availableCapabilities.length; ++i){ const capRaw = availableCapabilities[i]; @@ -146,7 +144,7 @@ const getReferencedDataList = async (refPath: string, dataPath: string, modules: for (let j = 0; j < dataUrls.length; ++j) { const dataUrl = dataUrls[j]; const restResult = (await restService.getConfigData(dataUrl)); - if (restResult.data == null || restResult.status < 200 || restResult.status > 299) { + if (restResult.data == null || checkResponseCode(restResult)) { const message = restResult.data && restResult.data.errors && restResult.data.errors.error && restResult.data.errors.error[0] && restResult.data.errors.error[0]["error-message"] || ""; throw new Error(`Server Error. Status: [${restResult.status}]\n${message || restResult.message || ''}`); } @@ -178,7 +176,7 @@ const getReferencedDataList = async (refPath: string, dataPath: string, modules: for (let j = 0; j < dataUrls.length; ++j) { const dataUrl = dataUrls[j]; const restResult = (await restService.getConfigData(dataUrl)); - if (restResult.data == null || restResult.status < 200 || restResult.status > 299) { + if (restResult.data == null || checkResponseCode(restResult)) { const message = restResult.data && restResult.data.errors && restResult.data.errors.error && restResult.data.errors.error[0] && restResult.data.errors.error[0]["error-message"] || ""; throw new Error(`Server Error. Status: [${restResult.status}]\n${message || restResult.message || ''}`); } @@ -426,7 +424,7 @@ export const updateViewActionAsyncCreator = (vPath: string) => async (dispatch: return dispatch(new UpdatViewDescription(vPath, [], ds)); } throw new Error(`Did not get response from Server. Status: [${restResult.status}]`); - } else if (restResult.status < 200 || restResult.status > 299) { + } else if (checkResponseCode(restResult)) { const message = restResult.data.errors && restResult.data.errors.error && restResult.data.errors.error[0] && restResult.data.errors.error[0]["error-message"] || ""; throw new Error(`Server Error. Status: [${restResult.status}]\n${message}`); } else { @@ -581,7 +579,7 @@ export const updateDataActionAsyncCreator = (vPath: string, data: any) => async // do not extract root member (0) if (viewSpecification && viewSpecification.id !== "0") { const updateResult = await restService.setConfigData(dataPath, { [`${currentNS}:${dataMember!}`]: data }); // addDataMember using currentNS - if (updateResult.status < 200 || updateResult.status > 299) { + if (checkResponseCode(updateResult)) { const message = updateResult.data && updateResult.data.errors && updateResult.data.errors.error && updateResult.data.errors.error[0] && updateResult.data.errors.error[0]["error-message"] || ""; throw new Error(`Server Error. Status: [${updateResult.status}]\n${message || updateResult.message || ''}`); } @@ -653,7 +651,7 @@ export const removeElementActionAsyncCreator = (vPath: string) => async (dispatc } const updateResult = await restService.removeConfigElement(dataPath); - if (updateResult.status < 200 || updateResult.status > 299) { + if (checkResponseCode(updateResult)) { const message = updateResult.data && updateResult.data.errors && updateResult.data.errors.error && updateResult.data.errors.error[0] && updateResult.data.errors.error[0]["error-message"] || ""; throw new Error(`Server Error. Status: [${updateResult.status}]\n${message || updateResult.message || ''}`); } @@ -747,7 +745,7 @@ export const executeRpcActionAsyncCreator = (vPath: string, data: any) => async // do not post root member (0) if ((viewSpecification && viewSpecification.id !== "0") || (dataMember! && !data)) { const updateResult = await restService.executeRpc(dataPath, { [`${defaultNS}:input`]: data || {} }); - if (updateResult.status < 200 || updateResult.status > 299) { + if (checkResponseCode(updateResult)) { const message = updateResult.data && updateResult.data.errors && updateResult.data.errors.error && updateResult.data.errors.error[0] && updateResult.data.errors.error[0]["error-message"] || ""; throw new Error(`Server Error. Status: [${updateResult.status}]\n${message || updateResult.message || ''}`); } diff --git a/sdnr/wt/odlux/apps/configurationApp/src/handlers/connectedNetworkElementsHandler.ts b/sdnr/wt/odlux/apps/configurationApp/src/handlers/connectedNetworkElementsHandler.ts index 02f2929cd..8ca8fdf27 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/handlers/connectedNetworkElementsHandler.ts +++ b/sdnr/wt/odlux/apps/configurationApp/src/handlers/connectedNetworkElementsHandler.ts @@ -26,7 +26,7 @@ import { restService } from '../services/restServices'; export interface IConnectedNetworkElementsState extends IExternalTableState { } // create eleactic search material data fetch handler -const connectedNetworkElementsSearchHandler = createSearchDataHandler('network-element-connection', { status: "Connected" }); +const connectedNetworkElementsSearchHandler = createSearchDataHandler('network-element-connection', false, { status: "Connected" }); export const { actionHandler: connectedNetworkElementsActionHandler, diff --git a/sdnr/wt/odlux/apps/configurationApp/src/services/yangService.ts b/sdnr/wt/odlux/apps/configurationApp/src/services/yangService.ts index cf4677bc9..b81a92c14 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/services/yangService.ts +++ b/sdnr/wt/odlux/apps/configurationApp/src/services/yangService.ts @@ -24,8 +24,8 @@ const cache: { [path: string]: string } = { class YangService { - public async getCapability(capability: string, version?: string) { - const url = `/yang-schema/${capability}${version ? `/${version}` : ""}`; + public async getCapability(capability: string, nodeId: string, version?: string) { + const url = `/yang-schema/${capability}${version ? `/${version}` : ""}?node=${nodeId}`; const cacheHit = cache[url]; if (cacheHit) return cacheHit; diff --git a/sdnr/wt/odlux/apps/configurationApp/src/views/configurationApplication.tsx b/sdnr/wt/odlux/apps/configurationApp/src/views/configurationApplication.tsx index 2879899a5..12815a517 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/views/configurationApplication.tsx +++ b/sdnr/wt/odlux/apps/configurationApp/src/views/configurationApplication.tsx @@ -639,7 +639,7 @@ class ConfigurationApplicationComponent extends React.Component[]>((acc, cur) => { const elm = listElements[cur]; if (elm.uiType !== "object" && listData.every(entry => entry[elm.label] != null)) { @@ -822,7 +822,7 @@ class ConfigurationApplicationComponent extends React.Component - []>((acc, cur) => { const elm = listSpecification.elements[cur]; if (elm.uiType !== "object" && listData.every(entry => entry[elm.label] != null)) { diff --git a/sdnr/wt/odlux/apps/configurationApp/src/views/networkElementSelector.tsx b/sdnr/wt/odlux/apps/configurationApp/src/views/networkElementSelector.tsx index 5cac22eba..1a1008dad 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/views/networkElementSelector.tsx +++ b/sdnr/wt/odlux/apps/configurationApp/src/views/networkElementSelector.tsx @@ -54,7 +54,7 @@ class NetworkElementSelectorComponent extends React.Component { this.props.history.push(`${this.props.match.path}/${row.nodeId}`) }} columns={[ + { this.props.history.push(`${this.props.match.path}/${row.nodeId}`) }} columns={[ { property: "nodeId", title: "Node Name", type: ColumnType.text }, { property: "isRequired", title: "Required", type: ColumnType.boolean }, { property: "host", title: "Host", type: ColumnType.text }, diff --git a/sdnr/wt/odlux/apps/configurationApp/src/yang/yangParser.ts b/sdnr/wt/odlux/apps/configurationApp/src/yang/yangParser.ts index c80bd4c84..965935a5c 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/yang/yangParser.ts +++ b/sdnr/wt/odlux/apps/configurationApp/src/yang/yangParser.ts @@ -286,7 +286,7 @@ export class YangParser { public static ResolveStack = Symbol("ResolveStack"); - constructor(private _unavailableCapabilities: { failureReason: string; capability: string; }[] = [], private _importOnlyModules: { name: string; revision: string; }[] = []) { + constructor(private _unavailableCapabilities: { failureReason: string; capability: string; }[] = [], private _importOnlyModules: { name: string; revision: string; }[] = [], private nodeId: string) { } @@ -310,8 +310,7 @@ export class YangParser { // // console.warn(`Skipped capability: ${capability} since it is marked as unavailable.` ); // return; // } - - const data = await yangService.getCapability(capability, version); + const data = await yangService.getCapability(capability, this.nodeId, version); if (!data) { throw new Error(`Could not load yang file for ${capability}.`); } @@ -409,6 +408,8 @@ export class YangParser { // import all required files and set module state if (imports) for (let ind = 0; ind < imports.length; ++ind) { const moduleName = imports[ind].arg!; + + //TODO: Fix imports getting loaded without revision await this.addCapability(moduleName, undefined, module.state === ModuleState.importOnly); const importedModule = this._modules[imports[ind].arg!]; if (importedModule && importedModule.state > ModuleState.stable) { diff --git a/sdnr/wt/odlux/apps/configurationApp/webpack.config.js b/sdnr/wt/odlux/apps/configurationApp/webpack.config.js index 5461c14f2..57caf079f 100644 --- a/sdnr/wt/odlux/apps/configurationApp/webpack.config.js +++ b/sdnr/wt/odlux/apps/configurationApp/webpack.config.js @@ -135,49 +135,49 @@ module.exports = (env) => { }, proxy: { "/about": { - target: "http://localhost:18181", + target: "http://sdnr:8181", secure: false }, "/yang-schema/": { - target: "http://localhost:18181", + target: "http://sdnr:8181", secure: false }, "/oauth/": { - target: "http://localhost:18181", + target: "http://sdnr:8181", secure: false }, "/database/": { - target: "http://localhost:18181", + target: "http://sdnr:8181", secure: false }, "/restconf/": { - target: "http://localhost:18181", + target: "http://sdnr:8181", secure: false }, "/rests/": { - target: "http://localhost:18181", + target: "http://sdnr:8181", secure: false }, "/help/": { - target: "http://localhost:18181", + target: "http://sdnr:8181", secure: false }, "/about/": { - target: "http://localhost:18181", + target: "http://sdnr:8181", secure: false }, "/tree/": { - target: "http://localhost:18181", + target: "http://sdnr:8181", secure: false }, "/websocket": { - target: "http://localhost:18181", + target: "http://sdnr:8181", ws: true, changeOrigin: true, secure: false }, "/apidoc": { - target: "http://localhost:18181", + target: "http://sdnr:8181", ws: true, changeOrigin: true, secure: false -- cgit 1.2.3-korg