diff options
author | Michael Dürre <michael.duerre@highstreet-technologies.com> | 2019-08-02 06:45:49 +0200 |
---|---|---|
committer | Timoney, Dan (dt5972) <dtimoney@att.com> | 2019-08-09 08:21:40 -0400 |
commit | b4fce004a40753e396f100ac9abdbe876de5865e (patch) | |
tree | 88daa991a9aada177c8356c81b32aa9323ecb750 /sdnr/wt/odlux/apps/mediatorApp/src | |
parent | f60b704c23ffb6df5ceb3b6d5b43729a5434f375 (diff) |
fixed mediator app
route requests through apigateway
Issue-ID: SDNC-824
Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
Change-Id: Ief159a71888f271a7751884260f85be01efdd6b4
Diffstat (limited to 'sdnr/wt/odlux/apps/mediatorApp/src')
13 files changed, 332 insertions, 91 deletions
diff --git a/sdnr/wt/odlux/apps/mediatorApp/src/actions/avaliableMediatorServersActions.ts b/sdnr/wt/odlux/apps/mediatorApp/src/actions/avaliableMediatorServersActions.ts index 4cbad42dd..3f56b05e1 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/src/actions/avaliableMediatorServersActions.ts +++ b/sdnr/wt/odlux/apps/mediatorApp/src/actions/avaliableMediatorServersActions.ts @@ -1,3 +1,20 @@ +/** + * ============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 { AddSnackbarNotification } from '../../../../framework/src/actions/snackbarActions'; diff --git a/sdnr/wt/odlux/apps/mediatorApp/src/actions/mediatorConfigActions.ts b/sdnr/wt/odlux/apps/mediatorApp/src/actions/mediatorConfigActions.ts index 058110614..516515ab2 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/src/actions/mediatorConfigActions.ts +++ b/sdnr/wt/odlux/apps/mediatorApp/src/actions/mediatorConfigActions.ts @@ -1,3 +1,20 @@ +/** + * ============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'; @@ -12,25 +29,25 @@ import { MediatorConfig, MediatorConfigResponse } from '../models/mediatorServer export class BaseAction extends Action { } export class SetMediatorBusyByName extends BaseAction { - constructor (public name: string, public isBusy: boolean) { + constructor(public name: string, public isBusy: boolean) { super(); } } export class AddMediatorConfig extends BaseAction { - constructor (public mediatorConfig: MediatorConfigResponse) { + constructor(public mediatorConfig: MediatorConfigResponse) { super(); } } export class UpdateMediatorConfig extends BaseAction { - constructor (public name: string, public mediatorConfig: MediatorConfigResponse) { + constructor(public name: string, public mediatorConfig: MediatorConfigResponse) { super(); } } export class RemoveMediatorConfig extends BaseAction { - constructor (public name: string) { + constructor(public name: string) { super(); } } @@ -38,13 +55,13 @@ export class RemoveMediatorConfig extends BaseAction { export const startMediatorByNameAsyncActionCreator = (name: string) => (dispatch: Dispatch, getState: () => IApplicationStoreState) => { dispatch(new SetMediatorBusyByName(name, true)); - const { mediator: { mediatorServerState: { url } } } = getState(); - if (url) { - mediatorService.startMediatorByName(url, name).then(msg => { + const { mediator: { mediatorServerState: { id } } } = getState(); + if (id) { + mediatorService.startMediatorByName(id, name).then(msg => { dispatch(new AddSnackbarNotification({ message: msg + ' ' + name, options: { variant: 'info' } })); // since there is no notification, a timeout will be need here window.setTimeout(() => { - mediatorService.getMediatorServerConfigByName(url, name).then(config => { + mediatorService.getMediatorServerConfigByName(id, name).then(config => { if (config) { dispatch(new UpdateMediatorConfig(name, config)); } else { @@ -62,13 +79,13 @@ export const startMediatorByNameAsyncActionCreator = (name: string) => (dispatch export const stopMediatorByNameAsyncActionCreator = (name: string) => (dispatch: Dispatch, getState: () => IApplicationStoreState) => { dispatch(new SetMediatorBusyByName(name, true)); - const { mediator: { mediatorServerState: { url } } } = getState(); - if (url) { - mediatorService.stopMediatorByName(url, name).then(msg => { + const { mediator: { mediatorServerState: { id } } } = getState(); + if (id) { + mediatorService.stopMediatorByName(id, name).then(msg => { dispatch(new AddSnackbarNotification({ message: msg + ' ' + name, options: { variant: 'info' } })); // since there is no notification, a timeout will be need here window.setTimeout(() => { - mediatorService.getMediatorServerConfigByName(url, name).then(config => { + mediatorService.getMediatorServerConfigByName(id, name).then(config => { if (config) { dispatch(new UpdateMediatorConfig(name, config)); } else { @@ -86,13 +103,13 @@ export const stopMediatorByNameAsyncActionCreator = (name: string) => (dispatch: export const addMediatorConfigAsyncActionCreator = (config: MediatorConfig) => (dispatch: Dispatch, getState: () => IApplicationStoreState) => { const { Name: name } = config; - const { mediator: { mediatorServerState: { url } } } = getState(); - if (url) { - mediatorService.createMediatorConfig(url, config).then(msg => { + const { mediator: { mediatorServerState: { id } } } = getState(); + if (id) { + mediatorService.createMediatorConfig(id, config).then(msg => { dispatch(new AddSnackbarNotification({ message: msg + ' ' + name, options: { variant: 'info' } })); // since there is no notification, a timeout will be need here window.setTimeout(() => { - mediatorService.getMediatorServerConfigByName(url, name).then(config => { + mediatorService.getMediatorServerConfigByName(id, name).then(config => { if (config) { dispatch(new AddMediatorConfig(config)); } else { @@ -112,13 +129,13 @@ export const updateMediatorConfigAsyncActionCreator = (config: MediatorConfig) = export const removeMediatorConfigAsyncActionCreator = (config: MediatorConfig) => (dispatch: Dispatch, getState: () => IApplicationStoreState) => { const { Name: name } = config; - const { mediator: { mediatorServerState: { url } } } = getState(); - if (url) { - mediatorService.deleteMediatorConfigByName(url, name).then(msg => { + const { mediator: { mediatorServerState: { id } } } = getState(); + if (id) { + mediatorService.deleteMediatorConfigByName(id, name).then(msg => { dispatch(new AddSnackbarNotification({ message: msg + ' ' + name, options: { variant: 'info' } })); // since there is no notification, a timeout will be need here window.setTimeout(() => { - mediatorService.getMediatorServerConfigByName(url, config.Name).then(config => { + mediatorService.getMediatorServerConfigByName(id, config.Name).then(config => { if (!config) { dispatch(new RemoveMediatorConfig(name)); } else { diff --git a/sdnr/wt/odlux/apps/mediatorApp/src/actions/mediatorServerActions.ts b/sdnr/wt/odlux/apps/mediatorApp/src/actions/mediatorServerActions.ts index e7719aac5..143dd7d4a 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/src/actions/mediatorServerActions.ts +++ b/sdnr/wt/odlux/apps/mediatorApp/src/actions/mediatorServerActions.ts @@ -1,3 +1,20 @@ +/** + * ============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'; @@ -11,7 +28,7 @@ import { IApplicationStoreState } from '../../../../framework/src/store/applicat export class BaseAction extends Action { } export class SetMediatorServerBusy extends BaseAction { - constructor (public isBusy: boolean) { + constructor(public isBusy: boolean) { super(); } } @@ -20,7 +37,7 @@ export class SetMediatorServerInfo extends BaseAction { /** * Initializes a new instance of this class. */ - constructor (public name: string | null, public url: string | null) { + constructor(public id: string | null, public name: string | null, public url: string | null) { super(); } @@ -30,7 +47,7 @@ export class SetMediatorServerVersion extends BaseAction { /** * Initializes a new instance of this class. */ - constructor (public versionInfo: MediatorServerVersionInfo | null) { + constructor(public versionInfo: MediatorServerVersionInfo | null) { super(); } @@ -40,7 +57,7 @@ export class SetAllMediatorServerConfigurations extends BaseAction { /** * Initializes a new instance of this class. */ - constructor (public allConfigurations: MediatorConfigResponse[] | null) { + constructor(public allConfigurations: MediatorConfigResponse[] | null) { super(); } @@ -50,7 +67,7 @@ export class SetMediatorServerSupportedDevices extends BaseAction { /** * Initializes a new instance of this class. */ - constructor (public devices: MediatorServerDevice[] | null) { + constructor(public devices: MediatorServerDevice[] | null) { super(); } @@ -65,16 +82,16 @@ export const initializeMediatorServerAsyncActionCreator = (serverId: string) => dispatch(new NavigateToApplication("mediator")); return; } - dispatch(new SetMediatorServerInfo(mediatorServer.name, mediatorServer.url)); + dispatch(new SetMediatorServerInfo(mediatorServer._id, mediatorServer.name, mediatorServer.url)); - mediatorService.getMediatorServerVersion(mediatorServer.url).then(versionInfo => { + mediatorService.getMediatorServerVersion(mediatorServer._id).then(versionInfo => { dispatch(new SetMediatorServerVersion(versionInfo)); }); Promise.all([ - mediatorService.getMediatorServerAllConfigs(mediatorServer.url), - mediatorService.getMediatorServerSupportedDevices(mediatorServer.url) - ]).then(([configurations,supportedDevices]) => { + mediatorService.getMediatorServerAllConfigs(mediatorServer._id), + mediatorService.getMediatorServerSupportedDevices(mediatorServer._id) + ]).then(([configurations, supportedDevices]) => { dispatch(new SetAllMediatorServerConfigurations(configurations)); dispatch(new SetMediatorServerSupportedDevices(supportedDevices)); dispatch(new SetMediatorServerBusy(false)); diff --git a/sdnr/wt/odlux/apps/mediatorApp/src/components/editMediatorConfigDialog.tsx b/sdnr/wt/odlux/apps/mediatorApp/src/components/editMediatorConfigDialog.tsx index ef12ee253..20ece4c22 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/src/components/editMediatorConfigDialog.tsx +++ b/sdnr/wt/odlux/apps/mediatorApp/src/components/editMediatorConfigDialog.tsx @@ -1,3 +1,20 @@ +/** + * ============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 * as React from 'react'; import { Theme, createStyles, WithStyles, withStyles, Typography, FormControlLabel, Checkbox } from '@material-ui/core'; diff --git a/sdnr/wt/odlux/apps/mediatorApp/src/components/editMediatorServerDialog.tsx b/sdnr/wt/odlux/apps/mediatorApp/src/components/editMediatorServerDialog.tsx index 39f9036a6..d38fb0b6e 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/src/components/editMediatorServerDialog.tsx +++ b/sdnr/wt/odlux/apps/mediatorApp/src/components/editMediatorServerDialog.tsx @@ -1,3 +1,20 @@ +/** + * ============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 * as React from 'react'; import Button from '@material-ui/core/Button'; diff --git a/sdnr/wt/odlux/apps/mediatorApp/src/handlers/avaliableMediatorServersHandler.ts b/sdnr/wt/odlux/apps/mediatorApp/src/handlers/avaliableMediatorServersHandler.ts index 244a9d185..c22252d20 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/src/handlers/avaliableMediatorServersHandler.ts +++ b/sdnr/wt/odlux/apps/mediatorApp/src/handlers/avaliableMediatorServersHandler.ts @@ -1,3 +1,20 @@ +/** + * ============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 { createExternal,IExternalTableState } from '../../../../framework/src/components/material-table/utilities'; import { createSearchDataHandler } from '../../../../framework/src/utilities/elasticSearch'; diff --git a/sdnr/wt/odlux/apps/mediatorApp/src/handlers/mediatorAppRootHandler.ts b/sdnr/wt/odlux/apps/mediatorApp/src/handlers/mediatorAppRootHandler.ts index b64c0a72a..2642ec8cd 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/src/handlers/mediatorAppRootHandler.ts +++ b/sdnr/wt/odlux/apps/mediatorApp/src/handlers/mediatorAppRootHandler.ts @@ -1,3 +1,20 @@ +/** + * ============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========================================================================== + */ // main state handler import { combineActionHandler } from '../../../../framework/src/flux/middleware'; diff --git a/sdnr/wt/odlux/apps/mediatorApp/src/handlers/mediatorServerHandler.ts b/sdnr/wt/odlux/apps/mediatorApp/src/handlers/mediatorServerHandler.ts index 2d3f71c82..0d137b396 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/src/handlers/mediatorServerHandler.ts +++ b/sdnr/wt/odlux/apps/mediatorApp/src/handlers/mediatorServerHandler.ts @@ -1,3 +1,20 @@ +/** + * ============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 { XmlFileInfo, MediatorConfig, BusySymbol, MediatorConfigResponse, MediatorServerDevice } from "../models/mediatorServer"; import { IActionHandler } from "../../../../framework/src/flux/action"; import { SetMediatorServerVersion, SetMediatorServerInfo, SetAllMediatorServerConfigurations, SetMediatorServerBusy, SetMediatorServerSupportedDevices } from "../actions/mediatorServerActions"; @@ -5,12 +22,13 @@ import { SetMediatorBusyByName, UpdateMediatorConfig, AddMediatorConfig, RemoveM export type MediatorServerState = { busy: boolean; - name: string| null ; + name: string | null; url: string | null; - serverVersion: string| null; - mediatorVersion: string| null; - nexmls: XmlFileInfo[]; - configurations: MediatorConfigResponse[]; + id: string | null; + serverVersion: string | null; + mediatorVersion: string | null; + nexmls: XmlFileInfo[]; + configurations: MediatorConfigResponse[]; supportedDevices: MediatorServerDevice[]; } @@ -18,10 +36,11 @@ const mediatorServerInit: MediatorServerState = { busy: false, name: null, url: null, - serverVersion : null, + id: null, + serverVersion: null, mediatorVersion: null, nexmls: [], - configurations: [], + configurations: [], supportedDevices: [] } @@ -36,60 +55,61 @@ export const mediatorServerHandler: IActionHandler<MediatorServerState> = (state ...state, name: action.name, url: action.url, + id: action.id, }; } else if (action instanceof SetMediatorServerVersion) { state = { ...state, - serverVersion: action.versionInfo && action.versionInfo.server , - mediatorVersion: action.versionInfo && action.versionInfo.mediator , - nexmls: action.versionInfo && [...action.versionInfo.nexmls] || [], + serverVersion: action.versionInfo && action.versionInfo.server, + mediatorVersion: action.versionInfo && action.versionInfo.mediator, + nexmls: action.versionInfo && [...action.versionInfo.nexmls] || [], }; } else if (action instanceof SetAllMediatorServerConfigurations) { state = { ...state, - configurations: action.allConfigurations && action.allConfigurations.map(config => ({...config, busy: false}) ) || [], + configurations: action.allConfigurations && action.allConfigurations.map(config => ({ ...config, busy: false })) || [], }; } else if (action instanceof SetMediatorServerSupportedDevices) { state = { ...state, - supportedDevices: action.devices || [], + supportedDevices: action.devices || [], }; } else if (action instanceof SetMediatorBusyByName) { const index = state.configurations.findIndex(config => config.Name === action.name); if (index > -1) state = { ...state, - configurations:[ + configurations: [ ...state.configurations.slice(0, index), - { ...state.configurations[index], [BusySymbol]: action.isBusy }, + { ...state.configurations[index], [BusySymbol]: action.isBusy }, ...state.configurations.slice(index + 1) - ] + ] }; } else if (action instanceof AddMediatorConfig) { - state = { + state = { ...state, configurations: [ - ...state.configurations, - action.mediatorConfig - ] + ...state.configurations, + action.mediatorConfig + ] }; } else if (action instanceof UpdateMediatorConfig) { const index = state.configurations.findIndex(config => config.Name === action.name); if (index > -1) state = { ...state, - configurations:[ + configurations: [ ...state.configurations.slice(0, index), - { ...action.mediatorConfig, [BusySymbol]: state.configurations[index][BusySymbol] }, + { ...action.mediatorConfig, [BusySymbol]: state.configurations[index][BusySymbol] }, ...state.configurations.slice(index + 1) - ] + ] }; } else if (action instanceof RemoveMediatorConfig) { const index = state.configurations.findIndex(config => config.Name === action.name); if (index > -1) state = { ...state, - configurations:[ + configurations: [ ...state.configurations.slice(0, index), ...state.configurations.slice(index + 1) - ] + ] }; } return state; diff --git a/sdnr/wt/odlux/apps/mediatorApp/src/models/mediatorServer.ts b/sdnr/wt/odlux/apps/mediatorApp/src/models/mediatorServer.ts index ff084b0c1..a2b54599c 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/src/models/mediatorServer.ts +++ b/sdnr/wt/odlux/apps/mediatorApp/src/models/mediatorServer.ts @@ -1,3 +1,20 @@ +/** + * ============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========================================================================== + */ export type MediatorServer = { _id: string; name: string; diff --git a/sdnr/wt/odlux/apps/mediatorApp/src/plugin.tsx b/sdnr/wt/odlux/apps/mediatorApp/src/plugin.tsx index 7f440a2ae..5ffd0124b 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/src/plugin.tsx +++ b/sdnr/wt/odlux/apps/mediatorApp/src/plugin.tsx @@ -1,3 +1,20 @@ +/** + * ============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========================================================================== + */ // app configuration and main entry point for the app import * as React from "react"; diff --git a/sdnr/wt/odlux/apps/mediatorApp/src/services/mediatorService.ts b/sdnr/wt/odlux/apps/mediatorApp/src/services/mediatorService.ts index 50fd869b1..b257fa92c 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/src/services/mediatorService.ts +++ b/sdnr/wt/odlux/apps/mediatorApp/src/services/mediatorService.ts @@ -1,13 +1,30 @@ +/** + * ============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 * as $ from 'jquery'; -import { requestRest } from '../../../../framework/src/services/restService'; +import { requestRest, formEncode } from '../../../../framework/src/services/restService'; import { MediatorServer, MediatorServerVersionInfo, MediatorConfig, MediatorServerDevice, MediatorConfigResponse } from '../models/mediatorServer'; import { HitEntry } from '../../../../framework/src/models'; export const mediatorServerResourcePath = "mwtn/mediator-server"; type MediatorServerResponse<TData> = { code: number, data: TData }; -type IndexableMediatorServer = MediatorServer & { [key: string]: any; } ; +type IndexableMediatorServer = MediatorServer & { [key: string]: any; }; /** * Represents a web api accessor service for all mediator server actions. @@ -60,13 +77,29 @@ class MediatorService { // https://cloud-highstreet-technologies.com/wiki/doku.php?id=att:ms:api - private accassMediatorServer<TData ={}>(mediatorServerUrl: string, task: string, data?: {}): Promise<MediatorServerResponse<TData> | null> { - const url = `${mediatorServerUrl}/api/?task=${task}`; - // return (await requestRest<{ code: number, data: TData}>(path, { method: "POST" })) || null ; + private async accassMediatorServer<TData = {}>(mediatorServerId: string, task: string, data?: {}): Promise<MediatorServerResponse<TData> | null> { + const path = `ms/${mediatorServerId}/api/'?task=${task}`; + const result = (await requestRest<string>(path, { + method: data ? "POST" : "GET", + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + body: data ? formEncode({ + ...data, + ...{ task: task } + }) : null + }, true)) || null; + + return result ? JSON.parse(result) as { code: number, data: TData } : null; + } + /* + private accassMediatorServer<TData = {}>(mediatorServerId: string, task: string, data?: {}): Promise<MediatorServerResponse<TData> | null> { + const path = `ms/${mediatorServerId}/api/?task=${task}`; return new Promise<{ code: number, data: TData }>((resolve, reject) => { - $.post({ - url, - data: data, + $.ajax({ + method: data ? 'POST' : 'GET', + url: path, + data: { ...{ task: task }, ...data }, //contentType: 'application/json' }).then((result: any) => { if (typeof result === "string") { @@ -76,70 +109,70 @@ class MediatorService { }; }); }); - } + }*/ - public async getMediatorServerVersion(mediatorServerUrl: string): Promise<MediatorServerVersionInfo | null> { - const result = await this.accassMediatorServer<MediatorServerVersionInfo>(mediatorServerUrl, 'version'); + public async getMediatorServerVersion(mediatorServerId: string): Promise<MediatorServerVersionInfo | null> { + const result = await this.accassMediatorServer<MediatorServerVersionInfo>(mediatorServerId, 'version'); if (result && result.code === 1) return result.data; return null; } - public async getMediatorServerAllConfigs(mediatorServerUrl: string): Promise<MediatorConfigResponse[] | null> { - const result = await this.accassMediatorServer<MediatorConfigResponse[]>(mediatorServerUrl, 'getconfig'); + public async getMediatorServerAllConfigs(mediatorServerId: string): Promise<MediatorConfigResponse[] | null> { + const result = await this.accassMediatorServer<MediatorConfigResponse[]>(mediatorServerId, 'getconfig'); if (result && result.code === 1) return result.data; return null; } - public async getMediatorServerConfigByName(mediatorServerUrl: string, name: string): Promise<MediatorConfigResponse | null> { - const result = await this.accassMediatorServer<MediatorConfigResponse[]>(mediatorServerUrl, 'getconfig', { name } ); + public async getMediatorServerConfigByName(mediatorServerId: string, name: string): Promise<MediatorConfigResponse | null> { + const result = await this.accassMediatorServer<MediatorConfigResponse[]>(mediatorServerId, `getconfig&name=${name}`); if (result && result.code === 1 && result.data && result.data.length === 1) return result.data[0]; return null; } - public async getMediatorServerSupportedDevices(mediatorServerUrl: string): Promise<MediatorServerDevice[] | null> { - const result = await this.accassMediatorServer<MediatorServerDevice[]>(mediatorServerUrl, 'getdevices' ); + public async getMediatorServerSupportedDevices(mediatorServerId: string): Promise<MediatorServerDevice[] | null> { + const result = await this.accassMediatorServer<MediatorServerDevice[]>(mediatorServerId, 'getdevices'); if (result && result.code === 1) return result.data; return null; } - public async startMediatorByName(mediatorServerUrl: string, name: string): Promise<string | null> { - const result = await this.accassMediatorServer<string>(mediatorServerUrl, 'start', { name } ); + public async startMediatorByName(mediatorServerId: string, name: string): Promise<string | null> { + const result = await this.accassMediatorServer<string>(mediatorServerId, `start&name=${name}`); if (result && result.code === 1) return result.data; return null; } - public async stopMediatorByName(mediatorServerUrl: string, name: string): Promise<string | null> { - const result = await this.accassMediatorServer<string>(mediatorServerUrl, 'stop', { name } ); + public async stopMediatorByName(mediatorServerId: string, name: string): Promise<string | null> { + const result = await this.accassMediatorServer<string>(mediatorServerId, `stop&name=${name}`); if (result && result.code === 1) return result.data; return null; } - public async createMediatorConfig(mediatorServerUrl: string, config: MediatorConfig): Promise<string | null> { - const result = await this.accassMediatorServer<string>(mediatorServerUrl, 'create', { config: JSON.stringify(config) } ); + public async createMediatorConfig(mediatorServerId: string, config: MediatorConfig): Promise<string | null> { + const result = await this.accassMediatorServer<string>(mediatorServerId, 'create', { config: JSON.stringify(config) }); if (result && result.code === 1) return result.data; return null; } - public async updateMediatorConfigByName(mediatorServerUrl: string, config: MediatorConfig): Promise<string | null> { - const result = await this.accassMediatorServer<string>(mediatorServerUrl, 'update', { config: JSON.stringify(config) } ); + public async updateMediatorConfigByName(mediatorServerId: string, config: MediatorConfig): Promise<string | null> { + const result = await this.accassMediatorServer<string>(mediatorServerId, 'update', { config: JSON.stringify(config) }); if (result && result.code === 1) return result.data; return null; } - public async deleteMediatorConfigByName(mediatorServerUrl: string, name: string): Promise<string | null> { - const result = await this.accassMediatorServer<string>(mediatorServerUrl, 'delete', { name } ); + public async deleteMediatorConfigByName(mediatorServerId: string, name: string): Promise<string | null> { + const result = await this.accassMediatorServer<string>(mediatorServerId, `delete&name=${name}`); if (result && result.code === 1) return result.data; return null; } - public async getMediatorServerFreeNcPorts(mediatorServerUrl: string, limit?: number): Promise<number[] | null> { - const result = await this.accassMediatorServer<number[]>(mediatorServerUrl, 'getncports', { limit } ); + public async getMediatorServerFreeNcPorts(mediatorServerId: string, limit?: number): Promise<number[] | null> { + const result = await this.accassMediatorServer<number[]>(mediatorServerId, 'getncports', { limit }); if (result && result.code === 1) return result.data; return null; } - - public async getMediatorServerFreeSnmpPorts(mediatorServerUrl: string, limit?: number): Promise<number[] | null> { - const result = await this.accassMediatorServer<number[]>(mediatorServerUrl, 'getsnmpports', { limit } ); + + public async getMediatorServerFreeSnmpPorts(mediatorServerId: string, limit?: number): Promise<number[] | null> { + const result = await this.accassMediatorServer<number[]>(mediatorServerId, 'getsnmpports', { limit }); if (result && result.code === 1) return result.data; return null; } diff --git a/sdnr/wt/odlux/apps/mediatorApp/src/views/mediatorApplication.tsx b/sdnr/wt/odlux/apps/mediatorApp/src/views/mediatorApplication.tsx index 95dee8df7..fcb3fe46f 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/src/views/mediatorApplication.tsx +++ b/sdnr/wt/odlux/apps/mediatorApp/src/views/mediatorApplication.tsx @@ -1,3 +1,20 @@ +/** + * ============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 * as React from 'react'; import { Theme, createStyles, WithStyles, withStyles, Tooltip } from '@material-ui/core'; @@ -52,6 +69,7 @@ const styles = (theme: Theme) => createStyles({ const mapProps = (state: IApplicationStoreState) => ({ serverName: state.mediator.mediatorServerState.name, serverUrl: state.mediator.mediatorServerState.url, + serverId: state.mediator.mediatorServerState.id, serverVersion: state.mediator.mediatorServerState.serverVersion, mediatorVersion: state.mediator.mediatorServerState.mediatorVersion, configurations: state.mediator.mediatorServerState.configurations, @@ -89,7 +107,7 @@ type MediatorServerSelectionComponentState = { class MediatorApplicationComponent extends React.Component<MediatorApplicationComponentProps, MediatorServerSelectionComponentState> { - constructor (props: MediatorApplicationComponentProps) { + constructor(props: MediatorApplicationComponentProps) { super(props); this.state = { @@ -120,7 +138,7 @@ class MediatorApplicationComponent extends React.Component<MediatorApplicationCo <Tooltip title={"Info"} ><IconButton className={classes.button}><InfoIcon /></IconButton></Tooltip> </div> <div className={classes.spacer}> - { process.env.NODE_ENV === "development" ? <Tooltip title={"Edit"} ><IconButton disabled={rowData[BusySymbol]} className={classes.button} onClick={event => this.onOpenEditConfigurationDialog(event, rowData)}><EditIcon /></IconButton></Tooltip> : null} + {process.env.NODE_ENV === "development" ? <Tooltip title={"Edit"} ><IconButton disabled={rowData[BusySymbol]} className={classes.button} onClick={event => this.onOpenEditConfigurationDialog(event, rowData)}><EditIcon /></IconButton></Tooltip> : null} <Tooltip title={"Remove"} ><IconButton disabled={rowData[BusySymbol]} className={classes.button} onClick={event => this.onOpenRemoveConfigutationDialog(event, rowData)}><DeleteIcon /></IconButton></Tooltip> </div> </> @@ -166,9 +184,9 @@ class MediatorApplicationComponent extends React.Component<MediatorApplicationCo this.setState({ busy: true, }); - this.props.serverUrl && Promise.all([ - mediatorService.getMediatorServerFreeNcPorts(this.props.serverUrl, 1), - mediatorService.getMediatorServerFreeSnmpPorts(this.props.serverUrl, 1), + this.props.serverId && Promise.all([ + mediatorService.getMediatorServerFreeNcPorts(this.props.serverId, 1), + mediatorService.getMediatorServerFreeSnmpPorts(this.props.serverId, 1), ]).then(([freeNcPorts, freeSnmpPorts]) => { if (freeNcPorts && freeSnmpPorts && freeNcPorts.length > 0 && freeSnmpPorts.length > 0) { this.setState({ diff --git a/sdnr/wt/odlux/apps/mediatorApp/src/views/mediatorServerSelection.tsx b/sdnr/wt/odlux/apps/mediatorApp/src/views/mediatorServerSelection.tsx index 4e221b613..a23afb5f6 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/src/views/mediatorServerSelection.tsx +++ b/sdnr/wt/odlux/apps/mediatorApp/src/views/mediatorServerSelection.tsx @@ -1,3 +1,20 @@ +/** + * ============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 * as React from 'react'; import { WithStyles, withStyles, createStyles, Theme, Tooltip } from '@material-ui/core'; |