diff options
author | Herbert Eiselt <herbert.eiselt@highstreet-technologies.com> | 2019-02-28 15:23:42 +0100 |
---|---|---|
committer | Herbert Eiselt <herbert.eiselt@highstreet-technologies.com> | 2019-02-28 15:24:28 +0100 |
commit | 7446f23b3abc30d7c53f2eaa951742371c071171 (patch) | |
tree | b76a8d2e64c7aa850c09f8e69f01e7a262ab5cd5 /sdnr/wt/odlux/apps | |
parent | 49b155ec687cdf58fb51fe8245a2f5f4582b68f0 (diff) |
UX extensions
UX Maintenance client and further changes
Change-Id: I7643661d17db5fc3d3f94b58cb42ed0be558c64f
Issue-ID: SDNC-583
Signed-off-by: Herbert Eiselt <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/odlux/apps')
57 files changed, 2996 insertions, 896 deletions
diff --git a/sdnr/wt/odlux/apps/apiDemo/pom.xml b/sdnr/wt/odlux/apps/apiDemo/pom.xml index 797c3166c..8e7559e55 100644 --- a/sdnr/wt/odlux/apps/apiDemo/pom.xml +++ b/sdnr/wt/odlux/apps/apiDemo/pom.xml @@ -1,110 +1,166 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <groupId>org.onap.ccsdk.parent</groupId> - <artifactId>odlparent</artifactId> - <version>1.2.1-SNAPSHOT</version> - <relativePath /> - </parent> - <modelVersion>4.0.0</modelVersion> - <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> - <artifactId>sdnr-wt-odlux-app-apiDemo</artifactId> - <version>0.4.1-SNAPSHOT</version> - <packaging>bundle</packaging> - <name>sdnr-wt-odlux-app-apiDemo</name> - <licenses> - <license> - <name>Apache License, Version 2.0</name> - <url>http://www.apache.org/licenses/LICENSE-2.0</url> - </license> - </licenses> - <dependencies> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>sdnr-wt-odlux-core-model</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - <build> - <sourceDirectory>src2/main/java</sourceDirectory> - <plugins> - <plugin> - <artifactId>maven-clean-plugin</artifactId> - <version>2.5</version> - <configuration> - <filesets> + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>odlparent</artifactId> + <version>1.2.1-SNAPSHOT</version> + <relativePath /> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> + <artifactId>sdnr-wt-odlux-app-apiDemo</artifactId> + <version>0.4.1-SNAPSHOT</version> + <packaging>bundle</packaging> + <name>sdnr-wt-odlux-app-apiDemo</name> + <licenses> + <license> + <name>Apache License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0</url> + </license> + </licenses> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-model</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-provider</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.compendium</artifactId> + </dependency> + </dependencies> + <build> + <sourceDirectory>src2/main/java</sourceDirectory> + <plugins> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <configuration> + <filesets> + <fileset> + <directory>dist</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>../node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <!-- eclipse bug build bin folder in basedir --> <fileset> - <directory>dist</directory> + <directory>bin</directory> <followSymlinks>false</followSymlinks> </fileset> - </filesets> - </configuration> - </plugin> - <plugin> - <groupId>com.github.eirslett</groupId> - <artifactId>frontend-maven-plugin</artifactId> - <version>1.8.1-SNAPSHOT</version> - <executions> - <execution> - <id>install node and yarn</id> - <goals> - <goal>install-node-and-yarn</goal> - </goals> - <!-- optional: default phase is "generate-resources" --> - <phase>initialize</phase> - <configuration> - <nodeVersion>v8.10.0</nodeVersion> - <yarnVersion>v1.12.3</yarnVersion> - </configuration> - </execution> - <execution> - <id>yarn build</id> - <goals> - <goal>yarn</goal> - </goals> - <configuration> - <arguments>run build</arguments> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> - <Private-Package></Private-Package> - </instructions> - </configuration> - </plugin> - </plugins> - <resources> - <resource> - <directory>dist</directory> - <targetPath>odlux</targetPath> - </resource> - <resource> - <directory>src2/main/resources</directory> - </resource> - </resources> - </build> - <pluginRepositories> - <pluginRepository> - <id>highstreet repo</id> - <url>https://cloud-highstreet-technologies.com/mvn/</url> - <snapshots> - <enabled>true</enabled> - <updatePolicy>always</updatePolicy> - </snapshots> - </pluginRepository> - </pluginRepositories> -</project>
\ No newline at end of file + </filesets> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-test-source</id> + <phase>generate-test-sources</phase> + <goals> + <goal>add-test-source</goal> + </goals> + <configuration> + <sources> + <source>src2/test/java</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <version>1.8.1-SNAPSHOT</version> + <executions> + <execution> + <id>install node and yarn</id> + <goals> + <goal>install-node-and-yarn</goal> + </goals> + <!-- optional: default phase is "generate-resources" --> + <phase>initialize</phase> + <configuration> + <nodeVersion>v8.10.0</nodeVersion> + <yarnVersion>v1.12.3</yarnVersion> + </configuration> + </execution> + <execution> + <id>yarn build</id> + <goals> + <goal>yarn</goal> + </goals> + <configuration> + <arguments>run build</arguments> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> + <Private-Package></Private-Package> + </instructions> + </configuration> + </plugin> + </plugins> + <resources> + <resource> + <directory>dist</directory> + <targetPath>odlux</targetPath> + </resource> + <resource> + <directory>src2/main/resources</directory> + </resource> + <resource> + <directory>src2/test/resources</directory> + </resource> + </resources> + </build> + <pluginRepositories> + <pluginRepository> + <id>highstreet repo</id> + <url>https://cloud-highstreet-technologies.com/mvn/</url> + <snapshots> + <enabled>true</enabled> + <updatePolicy>always</updatePolicy> + </snapshots> + </pluginRepository> + </pluginRepositories> +</project> diff --git a/sdnr/wt/odlux/apps/apiDemo/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/apiDemo/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java new file mode 100644 index 000000000..e2ffb596b --- /dev/null +++ b/sdnr/wt/odlux/apps/apiDemo/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * 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========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.odlux.OdluxBundleLoaderImpl; +import org.onap.ccsdk.features.sdnr.wt.odlux.bundles.MyOdluxBundle; +import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundleLoader; + +public class TestBundleRes { + + @Test + public void test() { + OdluxBundleLoader loader = OdluxBundleLoaderImpl.getInstance(); + MyOdluxBundle b = new MyOdluxBundle(); + b.setLoader(loader); + b.setIndex(0); + b.setBundleName("abc"); + b.initialize(); + assertTrue(loader.getNumberOfBundles() == 1); + assertNotNull(b.getLoader()); + assertEquals("abc",b.getBundleName()); + assertTrue(b.hasResource("test.js")); + assertNotNull(b.getResourceFileContent("test.js")); + b.clean(); + assertTrue(loader.getNumberOfBundles() == 0); + } + +} diff --git a/sdnr/wt/odlux/apps/apiDemo/src2/test/resources/test.js b/sdnr/wt/odlux/apps/apiDemo/src2/test/resources/test.js new file mode 100644 index 000000000..b47fdc39f --- /dev/null +++ b/sdnr/wt/odlux/apps/apiDemo/src2/test/resources/test.js @@ -0,0 +1,5 @@ +asdac sad +as +d +sad + sadfa
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/app-feature/pom.xml b/sdnr/wt/odlux/apps/app-feature/pom.xml index aadee5580..6c4e138f0 100644 --- a/sdnr/wt/odlux/apps/app-feature/pom.xml +++ b/sdnr/wt/odlux/apps/app-feature/pom.xml @@ -62,5 +62,10 @@ <artifactId>sdnr-wt-odlux-app-mediatorApp</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-app-maintenanceApp</artifactId> + <version>${project.version}</version> + </dependency> </dependencies> </project> diff --git a/sdnr/wt/odlux/apps/app-installer/pom.xml b/sdnr/wt/odlux/apps/app-installer/pom.xml index 999082fcb..a91cc35ba 100755 --- a/sdnr/wt/odlux/apps/app-installer/pom.xml +++ b/sdnr/wt/odlux/apps/app-installer/pom.xml @@ -82,6 +82,11 @@ <artifactId>sdnr-wt-odlux-app-mediatorApp</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-app-maintenanceApp</artifactId> + <version>${project.version}</version> + </dependency> </dependencies> <build> diff --git a/sdnr/wt/odlux/apps/connectApp/pom.xml b/sdnr/wt/odlux/apps/connectApp/pom.xml index d5216ca5f..858b32abc 100644 --- a/sdnr/wt/odlux/apps/connectApp/pom.xml +++ b/sdnr/wt/odlux/apps/connectApp/pom.xml @@ -1,110 +1,158 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <groupId>org.onap.ccsdk.parent</groupId> - <artifactId>odlparent</artifactId> - <version>1.2.1-SNAPSHOT</version> - <relativePath /> - </parent> - <modelVersion>4.0.0</modelVersion> - <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> - <artifactId>sdnr-wt-odlux-app-connectApp</artifactId> - <version>0.4.1-SNAPSHOT</version> - <packaging>bundle</packaging> - <name>sdnr-wt-odlux-app-connectApp</name> - <licenses> - <license> - <name>Apache License, Version 2.0</name> - <url>http://www.apache.org/licenses/LICENSE-2.0</url> - </license> - </licenses> - <dependencies> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>sdnr-wt-odlux-core-model</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - <build> - <sourceDirectory>src2/main/java</sourceDirectory> - <plugins> - <plugin> - <artifactId>maven-clean-plugin</artifactId> - <version>2.5</version> - <configuration> - <filesets> + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>odlparent</artifactId> + <version>1.2.1-SNAPSHOT</version> + <relativePath /> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> + <artifactId>sdnr-wt-odlux-app-connectApp</artifactId> + <version>0.4.1-SNAPSHOT</version> + <packaging>bundle</packaging> + <name>sdnr-wt-odlux-app-connectApp</name> + <licenses> + <license> + <name>Apache License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0</url> + </license> + </licenses> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-model</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-provider</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <sourceDirectory>src2/main/java</sourceDirectory> + <plugins> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <configuration> + <filesets> + <fileset> + <directory>dist</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>../node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <!-- eclipse bug build bin folder in basedir --> <fileset> - <directory>dist</directory> + <directory>bin</directory> <followSymlinks>false</followSymlinks> </fileset> - </filesets> - </configuration> - </plugin> - <plugin> - <groupId>com.github.eirslett</groupId> - <artifactId>frontend-maven-plugin</artifactId> - <version>1.8.1-SNAPSHOT</version> - <executions> - <execution> - <id>install node and yarn</id> - <goals> - <goal>install-node-and-yarn</goal> - </goals> - <!-- optional: default phase is "generate-resources" --> - <phase>initialize</phase> - <configuration> - <nodeVersion>v8.10.0</nodeVersion> - <yarnVersion>v1.12.3</yarnVersion> - </configuration> - </execution> - <execution> - <id>yarn build</id> - <goals> - <goal>yarn</goal> - </goals> - <configuration> - <arguments>run build</arguments> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> - <Private-Package></Private-Package> - </instructions> - </configuration> - </plugin> - </plugins> - <resources> - <resource> - <directory>dist</directory> - <targetPath>odlux</targetPath> - </resource> - <resource> - <directory>src2/main/resources</directory> - </resource> - </resources> - </build> - <pluginRepositories> - <pluginRepository> - <id>highstreet repo</id> - <url>https://cloud-highstreet-technologies.com/mvn/</url> - <snapshots> - <enabled>true</enabled> - <updatePolicy>always</updatePolicy> - </snapshots> - </pluginRepository> - </pluginRepositories> -</project>
\ No newline at end of file + </filesets> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-test-source</id> + <phase>generate-test-sources</phase> + <goals> + <goal>add-test-source</goal> + </goals> + <configuration> + <sources> + <source>src2/test/java</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <version>1.8.1-SNAPSHOT</version> + <executions> + <execution> + <id>install node and yarn</id> + <goals> + <goal>install-node-and-yarn</goal> + </goals> + <!-- optional: default phase is "generate-resources" --> + <phase>initialize</phase> + <configuration> + <nodeVersion>v8.10.0</nodeVersion> + <yarnVersion>v1.12.3</yarnVersion> + </configuration> + </execution> + <execution> + <id>yarn build</id> + <goals> + <goal>yarn</goal> + </goals> + <configuration> + <arguments>run build</arguments> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> + <Private-Package></Private-Package> + </instructions> + </configuration> + </plugin> + </plugins> + <resources> + <resource> + <directory>dist</directory> + <targetPath>odlux</targetPath> + </resource> + <resource> + <directory>src2/main/resources</directory> + </resource> + <resource> + <directory>src2/test/resources</directory> + </resource> + </resources> + </build> + <pluginRepositories> + <pluginRepository> + <id>highstreet repo</id> + <url>https://cloud-highstreet-technologies.com/mvn/</url> + <snapshots> + <enabled>true</enabled> + <updatePolicy>always</updatePolicy> + </snapshots> + </pluginRepository> + </pluginRepositories> +</project> diff --git a/sdnr/wt/odlux/apps/connectApp/src/actions/mountedNetworkElementsActions.ts b/sdnr/wt/odlux/apps/connectApp/src/actions/mountedNetworkElementsActions.ts index e342f6314..1cf528aa7 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/actions/mountedNetworkElementsActions.ts +++ b/sdnr/wt/odlux/apps/connectApp/src/actions/mountedNetworkElementsActions.ts @@ -21,7 +21,7 @@ export class AllMountedNetworkElementsLoadedAction extends BaseAction { } /** Represents an action causing the store to update all mounted network elements. */ -export class AddMountedNetworkElement extends BaseAction { +export class AddOrUpdateMountedNetworkElement extends BaseAction { constructor(public mountedNetworkElement: MountedNetworkElementType | null, public error?: string) { super(); } @@ -47,43 +47,58 @@ export class UpdateRequiredMountedNetworkElement extends BaseAction { } /** - * An actioncrator for a async thunk action to add an allready mounted element to the state of this app. - * Note: Use this action to add created object notified by the websocket. + * Represents an action crator for a async thunk action to add an allready mounted element to the state of this app. + * Note: Use this action to add created object notified by the websocket. */ export const addMountedNetworkElementAsyncActionCreator = (mountId: string) => async (dispatch: Dispatch) => { - connectService.getMountedNetworkElementByMountId(mountId).then(mountedNetworkElement => { - mountedNetworkElement && dispatch(new AddMountedNetworkElement(mountedNetworkElement)); + return connectService.getMountedNetworkElementByMountId(mountId).then(mountedNetworkElement => { + mountedNetworkElement && dispatch(new AddOrUpdateMountedNetworkElement(mountedNetworkElement)); }).catch(error => { - dispatch(new AddMountedNetworkElement(null, error)); + dispatch(new AddOrUpdateMountedNetworkElement(null, error)); + }); +}; + +export const updateMountedNetworkElementAsyncActionCreator = (mountId: string) => async (dispatch: Dispatch) => { + return connectService.getMountedNetworkElementByMountId(mountId).then(mountedNetworkElement => { + if (mountedNetworkElement) { + dispatch(new AddOrUpdateMountedNetworkElement(mountedNetworkElement)); + } else { + dispatch(new RemoveMountedNetworkElement(mountId)); + } + }).catch(error => { + dispatch(new AddOrUpdateMountedNetworkElement(null, error)); }); }; /** Represents an async thunk action to load all mounted network elements. */ export const loadAllMountedNetworkElementsAsync = (dispatch: Dispatch) => { dispatch(new LoadAllMountedNetworkElementsAction()); - connectService.getMountedNetworkElementsList().then(mountedNetworkElements => { + return connectService.getMountedNetworkElementsList().then(mountedNetworkElements => { mountedNetworkElements && dispatch(new AllMountedNetworkElementsLoadedAction(mountedNetworkElements)); }).catch(error => { dispatch(new AllMountedNetworkElementsLoadedAction(null, error)); }); }; -/** Represents an async thunk action to load all mounted network elements. */ -export const mountNetworkElementActionCreatorAsync = (networkElement: RequiredNetworkElementType) => (dispatch: Dispatch) => { - connectService.mountNetworkElement(networkElement).then((success) => { - success && dispatch(new AddSnackbarNotification({ message: `Requesting mount [${ networkElement.mountId }]`, options: { variant: 'info' } })) - || dispatch(new AddSnackbarNotification({ message: `Failed to mount [${ networkElement.mountId }]`, options: { variant: 'warning' } })); +/** Represents an action crator for a async thunk action to mount a network element. */ +export const mountNetworkElementAsyncActionCreator = (networkElement: RequiredNetworkElementType) => (dispatch: Dispatch) => { + return connectService.mountNetworkElement(networkElement).then((success) => { + success && ( + dispatch(addMountedNetworkElementAsyncActionCreator(networkElement.mountId)) && + dispatch(new AddSnackbarNotification({ message: `Requesting mount [${networkElement.mountId}]`, options: { variant: 'info' } })) + ) || dispatch(new AddSnackbarNotification({ message: `Failed to mount [${ networkElement.mountId }]`, options: { variant: 'warning' } })); }).catch(error => { - dispatch(new AddMountedNetworkElement(null, error)); + dispatch(new AddOrUpdateMountedNetworkElement(null, error)); }); }; -export const unmountNetworkElementActionCreatorAsync = (mountId: string) => (dispatch: Dispatch) => { - connectService.unmountNetworkElement(mountId).then((success) => { +/** Represents an action crator for a async thunk action to unmount a network element. */ +export const unmountNetworkElementAsyncActionCreator = (mountId: string) => (dispatch: Dispatch) => { + return connectService.unmountNetworkElement(mountId).then((success) => { success && dispatch(new AddSnackbarNotification({ message: `Requesting unmount [${ mountId }]`, options: { variant: 'info' } })) || dispatch(new AddSnackbarNotification({ message: `Failed to unmount [${ mountId }]`, options: { variant: 'warning' } })); }).catch(error => { - dispatch(new AddMountedNetworkElement(null, error)); + dispatch(new AddOrUpdateMountedNetworkElement(null, error)); }); }; diff --git a/sdnr/wt/odlux/apps/connectApp/src/actions/requiredNetworkElementsActions.ts b/sdnr/wt/odlux/apps/connectApp/src/actions/requiredNetworkElementsActions.ts index 979321957..387ab8f54 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/actions/requiredNetworkElementsActions.ts +++ b/sdnr/wt/odlux/apps/connectApp/src/actions/requiredNetworkElementsActions.ts @@ -12,7 +12,7 @@ import { connectService } from '../services/connectService'; export class BaseAction extends Action { } -/** Represents an async thunk action that will add an element to the required network elements. */ +/** Represents an async thunk action creator to add an element to the required network elements. */ export const addToRequiredNetworkElementsAsyncActionCreator = (element: RequiredNetworkElementType) => (dispatch: Dispatch) => { connectService.insertRequiredNetworkElement(element).then(_ => { window.setTimeout(() => { @@ -23,7 +23,7 @@ export const addToRequiredNetworkElementsAsyncActionCreator = (element: Required }); }; -/** Represents an async thunk action that will delete an element from the required network elements. */ +/** Represents an async thunk action creator to delete an element from the required network elements. */ export const removeFromRequiredNetworkElementsAsyncActionCreator = (element: RequiredNetworkElementType) => (dispatch: Dispatch) => { connectService.deleteRequiredNetworkElement(element).then(_ => { window.setTimeout(() => { diff --git a/sdnr/wt/odlux/apps/connectApp/src/components/editNetworkElementDialog.tsx b/sdnr/wt/odlux/apps/connectApp/src/components/editNetworkElementDialog.tsx index ee876e854..c2db266d1 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/components/editNetworkElementDialog.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/components/editNetworkElementDialog.tsx @@ -15,8 +15,9 @@ import { removeFromRequiredNetworkElementsAsyncActionCreator } from '../actions/requiredNetworkElementsActions'; +import { unmountNetworkElementAsyncActionCreator, mountNetworkElementAsyncActionCreator } from '../actions/mountedNetworkElementsActions'; import { RequiredNetworkElementType } from '../models/requiredNetworkElements'; -import { unmountNetworkElementActionCreatorAsync, mountNetworkElementActionCreatorAsync } from '../actions/mountedNetworkElementsActions'; + export enum EditNetworkElementDialogMode { None = "none", UnknownNetworkElementToRequiredNetworkElements = "unknownNetworkElementToRequiredNetworkElements", @@ -35,14 +36,14 @@ const mapDispatch = (dispatcher: IDispatcher) => ({ dispatcher.dispatch(removeFromRequiredNetworkElementsAsyncActionCreator(element)); }, mountNetworkElement: (element: RequiredNetworkElementType) => { - dispatcher.dispatch(mountNetworkElementActionCreatorAsync(element)); + dispatcher.dispatch(mountNetworkElementAsyncActionCreator(element)); }, mountAndRquireNetworkElement: (element: RequiredNetworkElementType) => { dispatcher.dispatch(addToRequiredNetworkElementsAsyncActionCreator(element)); - dispatcher.dispatch(mountNetworkElementActionCreatorAsync(element)); + dispatcher.dispatch(mountNetworkElementAsyncActionCreator(element)); }, unmountNetworkElement: (element: RequiredNetworkElementType) => { - dispatcher.dispatch(unmountNetworkElementActionCreatorAsync(element && element.mountId)); + dispatcher.dispatch(unmountNetworkElementAsyncActionCreator(element && element.mountId)); } } ); @@ -70,7 +71,7 @@ const settings: { [key: string]: DialogSettings } = { [EditNetworkElementDialogMode.UnknownNetworkElementToRequiredNetworkElements] : { dialogTitle: "Add to required network elements" , dialogDescription: "Create a new NetworkElement in planning database as clone of existing real NetworkElement." , - applyButtonText: "Add to required network elements" , + applyButtonText: "Add to required network elements" , cancelButtonText: "Cancel", enableMountIdEditor: false, enableUsernameEditor: true, @@ -136,7 +137,7 @@ type EditNetworkElementDialogComponentState = RequiredNetworkElementType & { class EditNetworkElementDialogComponent extends React.Component<EditNetworkElementDialogComponentProps, EditNetworkElementDialogComponentState> { constructor(props: EditNetworkElementDialogComponentProps) { super(props); - + this.state = { mountId: this.props.initialNetworkElement.mountId, host: this.props.initialNetworkElement.host, diff --git a/sdnr/wt/odlux/apps/connectApp/src/components/requiredNetworkElements.tsx b/sdnr/wt/odlux/apps/connectApp/src/components/requiredNetworkElements.tsx index 13f5fec20..9cbc368cb 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/components/requiredNetworkElements.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/components/requiredNetworkElements.tsx @@ -14,7 +14,6 @@ import { IApplicationStoreState } from '../../../../framework/src/store/applicat import { connect, Connect, IDispatcher } from '../../../../framework/src/flux/connect'; import { NavigateToApplication } from '../../../../framework/src/actions/navigationActions'; - import { RequiredNetworkElementType } from '../models/requiredNetworkElements'; import { createRequiredNetworkElementsActions, createRequiredNetworkElementsProperties } from '../handlers/requiredNetworkElementsHandler'; @@ -27,7 +26,7 @@ const styles = (theme: Theme) => createStyles({ color: 'darkgreen', }, connectionStatusConnecting: { - color: theme.palette.primary.main, + color: 'blue', }, connectionStatusDisconnected: { color: 'red', diff --git a/sdnr/wt/odlux/apps/connectApp/src/components/unknownNetworkElements.tsx b/sdnr/wt/odlux/apps/connectApp/src/components/unknownNetworkElements.tsx index 432103128..fe2c58ced 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/components/unknownNetworkElements.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/components/unknownNetworkElements.tsx @@ -48,7 +48,7 @@ type UnknownNetworkElementDisplayType = NetworkElementBaseType & { type UnknownNetworkElementsListProps = WithStyles<typeof styles> & Connect<typeof mapProps, typeof mapDispatch> & {} type UnknownNetworkElementsListState = { - + unknownNetworkElements: UnknownNetworkElementDisplayType[]; networkElementToEdit: RequiredNetworkElementType; @@ -73,7 +73,7 @@ export class UnknownNetworkElementsListComponent extends React.Component<Unknown static getDerivedStateFromProps(props: UnknownNetworkElementsListProps, state: UnknownNetworkElementsListState & { _mountedNetworkElements: IMountedNetworkElementsState }) { if (props.mountedNetworkElements != state._mountedNetworkElements) { state.unknownNetworkElements = props.mountedNetworkElements.elements.filter(element => !element.required).map(element => { - + // handle onfCoreModelRevision const onfCoreModelRevision = element.capabilities.find((cap) => { return cap.module === 'core-model' || cap.module === 'CoreModel-CoreNetworkModule-ObjectClasses' ; @@ -94,7 +94,7 @@ export class UnknownNetworkElementsListComponent extends React.Component<Unknown } return state; } - + render(): JSX.Element { const { classes } = this.props; const { networkElementToEdit, networkElementEditorMode, unknownNetworkElements } = this.state; @@ -125,7 +125,6 @@ export class UnknownNetworkElementsListComponent extends React.Component<Unknown <div className={ classes.spacer }> <Tooltip title={ "Info" } ><Button className={ classes.button } >I</Button></Tooltip> </div> - <div className={ classes.spacer }> <div className={ classes.spacer }> <Tooltip title={ "Fault" } ><Button className={ classes.button } onClick={ this.navigateToApplicationHandlerCreator("faultApp", rowData) } >F</Button></Tooltip> <Tooltip title={ "Configure" } ><Button className={ classes.button } onClick={ this.navigateToApplicationHandlerCreator("configureApp", rowData) } >C</Button></Tooltip> @@ -133,14 +132,13 @@ export class UnknownNetworkElementsListComponent extends React.Component<Unknown <Tooltip title={ "Performance" } ><Button className={ classes.button } onClick={ this.navigateToApplicationHandlerCreator("performanceApp", rowData) }>P</Button></Tooltip> <Tooltip title={ "Security" } ><Button className={ classes.button } onClick={ this.navigateToApplicationHandlerCreator("securityApp", rowData) }>S</Button></Tooltip> </div> - </div> </> ) }, ] } idProperty="mountId" > </UnknownNetworkElementTable> - - <EditNetworkElementDialog + + <EditNetworkElementDialog mode={ networkElementEditorMode } initialNetworkElement={ networkElementToEdit } onClose={ this.onCloseEditNetworkElementDialog } diff --git a/sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.tsx b/sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.tsx index 26d02c4e9..dd9e3e1df 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.tsx @@ -4,7 +4,6 @@ import { IMountedNetworkElementsState, mountedNetworkElementsActionHandler } fro import { IConnectionStatusLogState, connectionStatusLogActionHandler } from './connectionStatusLogHandler'; export interface IConnectAppStoreState { - requiredNetworkElements: IRequiredNetworkElementsState; mountedNetworkElements: IMountedNetworkElementsState; connectionStatusLog: IConnectionStatusLogState; diff --git a/sdnr/wt/odlux/apps/connectApp/src/handlers/mountedNetworkElementsHandler.tsx b/sdnr/wt/odlux/apps/connectApp/src/handlers/mountedNetworkElementsHandler.tsx index 70b4d8f2a..db86b99c2 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/handlers/mountedNetworkElementsHandler.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/handlers/mountedNetworkElementsHandler.tsx @@ -1,7 +1,7 @@ import { IActionHandler } from '../../../../framework/src/flux/action'; import { - AddMountedNetworkElement, + AddOrUpdateMountedNetworkElement, AllMountedNetworkElementsLoadedAction, LoadAllMountedNetworkElementsAction, RemoveMountedNetworkElement, @@ -28,7 +28,7 @@ export const mountedNetworkElementsActionHandler: IActionHandler<IMountedNetwork ...state, busy: true }; - + } else if (action instanceof AllMountedNetworkElementsLoadedAction) { if (!action.error && action.mountedNetworkElements) { state = { @@ -42,11 +42,24 @@ export const mountedNetworkElementsActionHandler: IActionHandler<IMountedNetwork busy: false }; } - } else if (action instanceof AddMountedNetworkElement) { - action.mountedNetworkElement && (state = { - ...state, - elements: [...state.elements, action.mountedNetworkElement], - }); + } else if (action instanceof AddOrUpdateMountedNetworkElement) { + if (!action.mountedNetworkElement) return state; // should handle error here + const index = state.elements.findIndex(el => el.mountId === (action.mountedNetworkElement && action.mountedNetworkElement.mountId)); + if (index > -1) { + state = { + ...state, + elements: [ + ...state.elements.slice(0, index), + action.mountedNetworkElement, + ...state.elements.slice(index + 1) + ] + } + } else { + state = { + ...state, + elements: [...state.elements, action.mountedNetworkElement], + } + }; } else if (action instanceof RemoveMountedNetworkElement) { state = { ...state, diff --git a/sdnr/wt/odlux/apps/connectApp/src/index.html b/sdnr/wt/odlux/apps/connectApp/src/index.html index c28708a83..0f95005de 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/index.html +++ b/sdnr/wt/odlux/apps/connectApp/src/index.html @@ -6,7 +6,7 @@ <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="./vendor.css" > - <title>Document</title> + <title>connectApp</title> </head> <body> @@ -18,7 +18,7 @@ require(["app","connectApp", "faultApp"], function (app, connectApp, faultApp) { connectApp.register(); faultApp.register(); - app("./app.tsx") + app("./app.tsx").runApplication(); }); </script> </body> diff --git a/sdnr/wt/odlux/apps/connectApp/src/plugin.tsx b/sdnr/wt/odlux/apps/connectApp/src/plugin.tsx index 4e61c326b..4a02b9f35 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/plugin.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/plugin.tsx @@ -6,7 +6,12 @@ import { subscribe, IFormatedMessage } from '../../../framework/src/services/not import connectAppRootHandler from './handlers/connectAppRootHandler'; import ConnectApplication from './views/connectView'; -import { RemoveMountedNetworkElement, addMountedNetworkElementAsyncActionCreator } from './actions/mountedNetworkElementsActions' ; + +import { + addMountedNetworkElementAsyncActionCreator, + updateMountedNetworkElementAsyncActionCreator +} from './actions/mountedNetworkElementsActions'; + import { AddSnackbarNotification } from '../../../framework/src/actions/snackbarActions'; type ObjectNotification = { @@ -32,8 +37,8 @@ export function register() { store.dispatch(addMountedNetworkElementAsyncActionCreator(msg.objectId)); store.dispatch(new AddSnackbarNotification({ message: `Adding network element [${ msg.objectId }]`, options: { variant: 'info' } })); } else if (msg && msg.notifType === "ObjectDeletionNotification" && store) { - store.dispatch(new AddSnackbarNotification({ message: `Removing network element [${ msg.objectId }]`, options: { variant: 'info' } })); - store.dispatch(new RemoveMountedNetworkElement(msg.objectId)); + store.dispatch(new AddSnackbarNotification({ message: `Updating network element [${ msg.objectId }]`, options: { variant: 'info' } })); + store.dispatch(updateMountedNetworkElementAsyncActionCreator(msg.objectId)); } })); -}
\ No newline at end of file +}
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts b/sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts index 0adcd49c6..91891deb6 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts +++ b/sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts @@ -1,6 +1,6 @@ import { RequiredNetworkElementType } from '../models/requiredNetworkElements'; -import { MountedNetworkElementType } from 'models/mountedNetworkElements'; -import { Topology, TopologyNode } from 'models/topologyNetconf'; +import { MountedNetworkElementType } from '../models/mountedNetworkElements'; +import { Topology, TopologyNode } from '../models/topologyNetconf'; import { requestRest } from '../../../../framework/src/services/restService'; import { Result, HitEntry } from '../../../../framework/src/models/elasticSearch'; @@ -40,7 +40,6 @@ class ConnectService { username: result._source.username, password: result._source.password, } || null; - } /** @@ -61,13 +60,9 @@ class ConnectService { return result || null; } - - private static mapTopologyNode = (mountPoint: TopologyNode, required: boolean ) => { // handle onfCapabilities let onfCapabilities: { module: string, revision: string }[] | undefined = undefined; - let onfCoreModelRevision: string[] | undefined = undefined; - let onfAirInterfaceRevision: string[] | undefined = undefined; const capId = 'netconf-node-topology:available-capabilities'; if (mountPoint[capId] && mountPoint[capId]['available-capability']) { @@ -161,17 +156,16 @@ class ConnectService { '</node>'].join(''); try { - const result = await requestRest<{}>(path, { + const result = await requestRest<string>(path, { method: 'PUT', headers: { 'Content-Type': 'application/xml', - 'Accept': 'application/xml', - 'Authorization': 'Basic YWRtaW46YWRtaW4=' + 'Accept': 'application/xml' }, body: mountXml }, true); // expect an empty answer - return result === null; + return result !== null; } catch { return false; } @@ -182,16 +176,15 @@ class ConnectService { const path = 'restconf/config/network-topology:network-topology/topology/topology-netconf/node/' + mountId; try { - const result = await requestRest<{}>(path, { + const result = await requestRest<string>(path, { method: 'DELETE', headers: { 'Content-Type': 'application/xml', - 'Accept': 'application/xml', - 'Authorization': 'Basic YWRtaW46YWRtaW4=' + 'Accept': 'application/xml' }, }, true); // expect an empty answer - return result === null; + return result !== null; } catch { return false; diff --git a/sdnr/wt/odlux/apps/connectApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/connectApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java new file mode 100644 index 000000000..edf68e096 --- /dev/null +++ b/sdnr/wt/odlux/apps/connectApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * 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========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.odlux.OdluxBundleLoaderImpl; +import org.onap.ccsdk.features.sdnr.wt.odlux.bundles.MyOdluxBundle; + +public class TestBundleRes { + + @Test + public void test() { + OdluxBundleLoaderImpl loader = OdluxBundleLoaderImpl.getInstance(); + MyOdluxBundle b = new MyOdluxBundle(); + b.setLoader(loader); + b.setIndex(0); + b.setBundleName("abc"); + b.initialize(); + assertTrue(loader.getNumberOfBundles()==1); + assertNotNull(b.getLoader()); + assertEquals("abc",b.getBundleName()); + assertTrue(b.hasResource("test.js")); + assertNotNull(b.getResourceFileContent("test.js")); + b.clean(); + assertTrue(loader.getNumberOfBundles()==0); + } + +} diff --git a/sdnr/wt/odlux/apps/connectApp/src2/test/resources/test.js b/sdnr/wt/odlux/apps/connectApp/src2/test/resources/test.js new file mode 100644 index 000000000..b47fdc39f --- /dev/null +++ b/sdnr/wt/odlux/apps/connectApp/src2/test/resources/test.js @@ -0,0 +1,5 @@ +asdac sad +as +d +sad + sadfa
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/demoApp/pom.xml b/sdnr/wt/odlux/apps/demoApp/pom.xml index 1c7a121b0..be518d58f 100644 --- a/sdnr/wt/odlux/apps/demoApp/pom.xml +++ b/sdnr/wt/odlux/apps/demoApp/pom.xml @@ -1,110 +1,158 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <groupId>org.onap.ccsdk.parent</groupId> - <artifactId>odlparent</artifactId> - <version>1.2.1-SNAPSHOT</version> - <relativePath /> - </parent> - <modelVersion>4.0.0</modelVersion> - <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> - <artifactId>sdnr-wt-odlux-app-demoApp</artifactId> - <version>0.4.1-SNAPSHOT</version> - <packaging>bundle</packaging> - <name>sdnr-wt-odlux-app-demoApp</name> - <licenses> - <license> - <name>Apache License, Version 2.0</name> - <url>http://www.apache.org/licenses/LICENSE-2.0</url> - </license> - </licenses> - <dependencies> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>sdnr-wt-odlux-core-model</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - <build> - <sourceDirectory>src2/main/java</sourceDirectory> - <plugins> - <plugin> - <artifactId>maven-clean-plugin</artifactId> - <version>2.5</version> - <configuration> - <filesets> + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>odlparent</artifactId> + <version>1.2.1-SNAPSHOT</version> + <relativePath /> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> + <artifactId>sdnr-wt-odlux-app-demoApp</artifactId> + <version>0.4.1-SNAPSHOT</version> + <packaging>bundle</packaging> + <name>sdnr-wt-odlux-app-demoApp</name> + <licenses> + <license> + <name>Apache License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0</url> + </license> + </licenses> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-model</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-provider</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <sourceDirectory>src2/main/java</sourceDirectory> + <plugins> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <configuration> + <filesets> + <fileset> + <directory>dist</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>../node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <!-- eclipse bug build bin folder in basedir --> <fileset> - <directory>dist</directory> + <directory>bin</directory> <followSymlinks>false</followSymlinks> </fileset> - </filesets> - </configuration> - </plugin> - <plugin> - <groupId>com.github.eirslett</groupId> - <artifactId>frontend-maven-plugin</artifactId> - <version>1.8.1-SNAPSHOT</version> - <executions> - <execution> - <id>install node and yarn</id> - <goals> - <goal>install-node-and-yarn</goal> - </goals> - <!-- optional: default phase is "generate-resources" --> - <phase>initialize</phase> - <configuration> - <nodeVersion>v8.10.0</nodeVersion> - <yarnVersion>v1.12.3</yarnVersion> - </configuration> - </execution> - <execution> - <id>yarn build</id> - <goals> - <goal>yarn</goal> - </goals> - <configuration> - <arguments>run build</arguments> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> - <Private-Package></Private-Package> - </instructions> - </configuration> - </plugin> - </plugins> - <resources> - <resource> - <directory>dist</directory> - <targetPath>odlux</targetPath> - </resource> - <resource> - <directory>src2/main/resources</directory> - </resource> - </resources> - </build> - <pluginRepositories> - <pluginRepository> - <id>highstreet repo</id> - <url>https://cloud-highstreet-technologies.com/mvn/</url> - <snapshots> - <enabled>true</enabled> - <updatePolicy>always</updatePolicy> - </snapshots> - </pluginRepository> - </pluginRepositories> -</project>
\ No newline at end of file + </filesets> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-test-source</id> + <phase>generate-test-sources</phase> + <goals> + <goal>add-test-source</goal> + </goals> + <configuration> + <sources> + <source>src2/test/java</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <version>1.8.1-SNAPSHOT</version> + <executions> + <execution> + <id>install node and yarn</id> + <goals> + <goal>install-node-and-yarn</goal> + </goals> + <!-- optional: default phase is "generate-resources" --> + <phase>initialize</phase> + <configuration> + <nodeVersion>v8.10.0</nodeVersion> + <yarnVersion>v1.12.3</yarnVersion> + </configuration> + </execution> + <execution> + <id>yarn build</id> + <goals> + <goal>yarn</goal> + </goals> + <configuration> + <arguments>run build</arguments> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> + <Private-Package></Private-Package> + </instructions> + </configuration> + </plugin> + </plugins> + <resources> + <resource> + <directory>dist</directory> + <targetPath>odlux</targetPath> + </resource> + <resource> + <directory>src2/main/resources</directory> + </resource> + <resource> + <directory>src2/test/resources</directory> + </resource> + </resources> + </build> + <pluginRepositories> + <pluginRepository> + <id>highstreet repo</id> + <url>https://cloud-highstreet-technologies.com/mvn/</url> + <snapshots> + <enabled>true</enabled> + <updatePolicy>always</updatePolicy> + </snapshots> + </pluginRepository> + </pluginRepositories> +</project> diff --git a/sdnr/wt/odlux/apps/demoApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/demoApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java new file mode 100644 index 000000000..edf68e096 --- /dev/null +++ b/sdnr/wt/odlux/apps/demoApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * 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========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.odlux.OdluxBundleLoaderImpl; +import org.onap.ccsdk.features.sdnr.wt.odlux.bundles.MyOdluxBundle; + +public class TestBundleRes { + + @Test + public void test() { + OdluxBundleLoaderImpl loader = OdluxBundleLoaderImpl.getInstance(); + MyOdluxBundle b = new MyOdluxBundle(); + b.setLoader(loader); + b.setIndex(0); + b.setBundleName("abc"); + b.initialize(); + assertTrue(loader.getNumberOfBundles()==1); + assertNotNull(b.getLoader()); + assertEquals("abc",b.getBundleName()); + assertTrue(b.hasResource("test.js")); + assertNotNull(b.getResourceFileContent("test.js")); + b.clean(); + assertTrue(loader.getNumberOfBundles()==0); + } + +} diff --git a/sdnr/wt/odlux/apps/demoApp/src2/test/resources/test.js b/sdnr/wt/odlux/apps/demoApp/src2/test/resources/test.js new file mode 100644 index 000000000..b47fdc39f --- /dev/null +++ b/sdnr/wt/odlux/apps/demoApp/src2/test/resources/test.js @@ -0,0 +1,5 @@ +asdac sad +as +d +sad + sadfa
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/faultApp/pom.xml b/sdnr/wt/odlux/apps/faultApp/pom.xml index dc5485a1b..b81e3b9d8 100644 --- a/sdnr/wt/odlux/apps/faultApp/pom.xml +++ b/sdnr/wt/odlux/apps/faultApp/pom.xml @@ -1,111 +1,159 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <groupId>org.onap.ccsdk.parent</groupId> - <artifactId>odlparent</artifactId> - <version>1.2.1-SNAPSHOT</version> - <relativePath /> - </parent> + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>odlparent</artifactId> + <version>1.2.1-SNAPSHOT</version> + <relativePath /> + </parent> - <modelVersion>4.0.0</modelVersion> - <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> - <artifactId>sdnr-wt-odlux-app-faultApp</artifactId> - <version>0.4.1-SNAPSHOT</version> - <packaging>bundle</packaging> - <name>sdnr-wt-odlux-app-faultApp</name> - <licenses> - <license> - <name>Apache License, Version 2.0</name> - <url>http://www.apache.org/licenses/LICENSE-2.0</url> - </license> - </licenses> - <dependencies> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>sdnr-wt-odlux-core-model</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - <build> - <sourceDirectory>src2/main/java</sourceDirectory> - <plugins> - <plugin> - <artifactId>maven-clean-plugin</artifactId> - <version>2.5</version> - <configuration> - <filesets> + <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> + <artifactId>sdnr-wt-odlux-app-faultApp</artifactId> + <version>0.4.1-SNAPSHOT</version> + <packaging>bundle</packaging> + <name>sdnr-wt-odlux-app-faultApp</name> + <licenses> + <license> + <name>Apache License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0</url> + </license> + </licenses> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-model</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-provider</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <sourceDirectory>src2/main/java</sourceDirectory> + <plugins> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <configuration> + <filesets> + <fileset> + <directory>dist</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>../node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <!-- eclipse bug build bin folder in basedir --> <fileset> - <directory>dist</directory> + <directory>bin</directory> <followSymlinks>false</followSymlinks> </fileset> - </filesets> - </configuration> - </plugin> - <plugin> - <groupId>com.github.eirslett</groupId> - <artifactId>frontend-maven-plugin</artifactId> - <version>1.8.1-SNAPSHOT</version> - <executions> - <execution> - <id>install node and yarn</id> - <goals> - <goal>install-node-and-yarn</goal> - </goals> - <!-- optional: default phase is "generate-resources" --> - <phase>initialize</phase> - <configuration> - <nodeVersion>v8.10.0</nodeVersion> - <yarnVersion>v1.12.3</yarnVersion> - </configuration> - </execution> - <execution> - <id>yarn build</id> - <goals> - <goal>yarn</goal> - </goals> - <configuration> - <arguments>run build</arguments> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> - <Private-Package></Private-Package> - </instructions> - </configuration> - </plugin> - </plugins> - <resources> - <resource> - <directory>dist</directory> - <targetPath>odlux</targetPath> - </resource> - <resource> - <directory>src2/main/resources</directory> - </resource> - </resources> - </build> - <pluginRepositories> - <pluginRepository> - <id>highstreet repo</id> - <url>https://cloud-highstreet-technologies.com/mvn/</url> - <snapshots> - <enabled>true</enabled> - <updatePolicy>always</updatePolicy> - </snapshots> - </pluginRepository> - </pluginRepositories> -</project>
\ No newline at end of file + </filesets> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-test-source</id> + <phase>generate-test-sources</phase> + <goals> + <goal>add-test-source</goal> + </goals> + <configuration> + <sources> + <source>src2/test/java</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <version>1.8.1-SNAPSHOT</version> + <executions> + <execution> + <id>install node and yarn</id> + <goals> + <goal>install-node-and-yarn</goal> + </goals> + <!-- optional: default phase is "generate-resources" --> + <phase>initialize</phase> + <configuration> + <nodeVersion>v8.10.0</nodeVersion> + <yarnVersion>v1.12.3</yarnVersion> + </configuration> + </execution> + <execution> + <id>yarn build</id> + <goals> + <goal>yarn</goal> + </goals> + <configuration> + <arguments>run build</arguments> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> + <Private-Package></Private-Package> + </instructions> + </configuration> + </plugin> + </plugins> + <resources> + <resource> + <directory>dist</directory> + <targetPath>odlux</targetPath> + </resource> + <resource> + <directory>src2/main/resources</directory> + </resource> + <resource> + <directory>src2/test/resources</directory> + </resource> + </resources> + </build> + <pluginRepositories> + <pluginRepository> + <id>highstreet repo</id> + <url>https://cloud-highstreet-technologies.com/mvn/</url> + <snapshots> + <enabled>true</enabled> + <updatePolicy>always</updatePolicy> + </snapshots> + </pluginRepository> + </pluginRepositories> +</project> diff --git a/sdnr/wt/odlux/apps/faultApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/faultApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java new file mode 100644 index 000000000..edf68e096 --- /dev/null +++ b/sdnr/wt/odlux/apps/faultApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * 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========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.odlux.OdluxBundleLoaderImpl; +import org.onap.ccsdk.features.sdnr.wt.odlux.bundles.MyOdluxBundle; + +public class TestBundleRes { + + @Test + public void test() { + OdluxBundleLoaderImpl loader = OdluxBundleLoaderImpl.getInstance(); + MyOdluxBundle b = new MyOdluxBundle(); + b.setLoader(loader); + b.setIndex(0); + b.setBundleName("abc"); + b.initialize(); + assertTrue(loader.getNumberOfBundles()==1); + assertNotNull(b.getLoader()); + assertEquals("abc",b.getBundleName()); + assertTrue(b.hasResource("test.js")); + assertNotNull(b.getResourceFileContent("test.js")); + b.clean(); + assertTrue(loader.getNumberOfBundles()==0); + } + +} diff --git a/sdnr/wt/odlux/apps/faultApp/src2/test/resources/test.js b/sdnr/wt/odlux/apps/faultApp/src2/test/resources/test.js new file mode 100644 index 000000000..b47fdc39f --- /dev/null +++ b/sdnr/wt/odlux/apps/faultApp/src2/test/resources/test.js @@ -0,0 +1,5 @@ +asdac sad +as +d +sad + sadfa
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/helpApp/pom.xml b/sdnr/wt/odlux/apps/helpApp/pom.xml index 1c1b99c87..5fd94f5fd 100644 --- a/sdnr/wt/odlux/apps/helpApp/pom.xml +++ b/sdnr/wt/odlux/apps/helpApp/pom.xml @@ -1,110 +1,158 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <groupId>org.onap.ccsdk.parent</groupId> - <artifactId>odlparent</artifactId> - <version>1.2.1-SNAPSHOT</version> - <relativePath /> - </parent> - <modelVersion>4.0.0</modelVersion> - <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> - <artifactId>sdnr-wt-odlux-app-helpApp</artifactId> - <version>0.4.1-SNAPSHOT</version> - <packaging>bundle</packaging> - <name>sdnr-wt-odlux-app-helpApp</name> - <licenses> - <license> - <name>Apache License, Version 2.0</name> - <url>http://www.apache.org/licenses/LICENSE-2.0</url> - </license> - </licenses> - <dependencies> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>sdnr-wt-odlux-core-model</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - <build> - <sourceDirectory>src2/main/java</sourceDirectory> - <plugins> - <plugin> - <artifactId>maven-clean-plugin</artifactId> - <version>2.5</version> - <configuration> - <filesets> + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>odlparent</artifactId> + <version>1.2.1-SNAPSHOT</version> + <relativePath /> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> + <artifactId>sdnr-wt-odlux-app-helpApp</artifactId> + <version>0.4.1-SNAPSHOT</version> + <packaging>bundle</packaging> + <name>sdnr-wt-odlux-app-helpApp</name> + <licenses> + <license> + <name>Apache License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0</url> + </license> + </licenses> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-model</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-provider</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <sourceDirectory>src2/main/java</sourceDirectory> + <plugins> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <configuration> + <filesets> + <fileset> + <directory>dist</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>../node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <!-- eclipse bug build bin folder in basedir --> <fileset> - <directory>dist</directory> + <directory>bin</directory> <followSymlinks>false</followSymlinks> </fileset> - </filesets> - </configuration> - </plugin> - <plugin> - <groupId>com.github.eirslett</groupId> - <artifactId>frontend-maven-plugin</artifactId> - <version>1.8.1-SNAPSHOT</version> - <executions> - <execution> - <id>install node and yarn</id> - <goals> - <goal>install-node-and-yarn</goal> - </goals> - <!-- optional: default phase is "generate-resources" --> - <phase>initialize</phase> - <configuration> - <nodeVersion>v8.10.0</nodeVersion> - <yarnVersion>v1.12.3</yarnVersion> - </configuration> - </execution> - <execution> - <id>yarn build</id> - <goals> - <goal>yarn</goal> - </goals> - <configuration> - <arguments>run build</arguments> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> - <Private-Package></Private-Package> - </instructions> - </configuration> - </plugin> - </plugins> - <resources> - <resource> - <directory>dist</directory> - <targetPath>odlux</targetPath> - </resource> - <resource> - <directory>src2/main/resources</directory> - </resource> - </resources> - </build> - <pluginRepositories> - <pluginRepository> - <id>highstreet repo</id> - <url>https://cloud-highstreet-technologies.com/mvn/</url> - <snapshots> - <enabled>true</enabled> - <updatePolicy>always</updatePolicy> - </snapshots> - </pluginRepository> - </pluginRepositories> -</project>
\ No newline at end of file + </filesets> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-test-source</id> + <phase>generate-test-sources</phase> + <goals> + <goal>add-test-source</goal> + </goals> + <configuration> + <sources> + <source>src2/test/java</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <version>1.8.1-SNAPSHOT</version> + <executions> + <execution> + <id>install node and yarn</id> + <goals> + <goal>install-node-and-yarn</goal> + </goals> + <!-- optional: default phase is "generate-resources" --> + <phase>initialize</phase> + <configuration> + <nodeVersion>v8.10.0</nodeVersion> + <yarnVersion>v1.12.3</yarnVersion> + </configuration> + </execution> + <execution> + <id>yarn build</id> + <goals> + <goal>yarn</goal> + </goals> + <configuration> + <arguments>run build</arguments> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> + <Private-Package></Private-Package> + </instructions> + </configuration> + </plugin> + </plugins> + <resources> + <resource> + <directory>dist</directory> + <targetPath>odlux</targetPath> + </resource> + <resource> + <directory>src2/main/resources</directory> + </resource> + <resource> + <directory>src2/test/resources</directory> + </resource> + </resources> + </build> + <pluginRepositories> + <pluginRepository> + <id>highstreet repo</id> + <url>https://cloud-highstreet-technologies.com/mvn/</url> + <snapshots> + <enabled>true</enabled> + <updatePolicy>always</updatePolicy> + </snapshots> + </pluginRepository> + </pluginRepositories> +</project> diff --git a/sdnr/wt/odlux/apps/helpApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/helpApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java new file mode 100644 index 000000000..d0fbe63c0 --- /dev/null +++ b/sdnr/wt/odlux/apps/helpApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * 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========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.odlux.OdluxBundleLoaderImpl; +import org.onap.ccsdk.features.sdnr.wt.odlux.bundles.MyOdluxBundle; + +public class TestBundleRes { + + @Test + public void test() { + OdluxBundleLoaderImpl loader = OdluxBundleLoaderImpl.getInstance(); + MyOdluxBundle b = new MyOdluxBundle(); + b.setLoader(loader); + b.setIndex(0); + b.setBundleName("abc"); + b.initialize(); + assertTrue(loader.getNumberOfBundles()==1); + assertNotNull(b.getLoader()); + assertEquals("abc",b.getBundleName()); + assertTrue(b.hasResource("test.js")); + assertNotNull(b.getResourceFileContent("test.js")); + b.clean(); + assertTrue(loader.getNumberOfBundles()==0); + } + +} diff --git a/sdnr/wt/odlux/apps/helpApp/src2/test/resources/test.js b/sdnr/wt/odlux/apps/helpApp/src2/test/resources/test.js new file mode 100644 index 000000000..b47fdc39f --- /dev/null +++ b/sdnr/wt/odlux/apps/helpApp/src2/test/resources/test.js @@ -0,0 +1,5 @@ +asdac sad +as +d +sad + sadfa
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/inventoryApp/pom.xml b/sdnr/wt/odlux/apps/inventoryApp/pom.xml index cbc2f6376..6ff095845 100644 --- a/sdnr/wt/odlux/apps/inventoryApp/pom.xml +++ b/sdnr/wt/odlux/apps/inventoryApp/pom.xml @@ -1,110 +1,158 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <groupId>org.onap.ccsdk.parent</groupId> - <artifactId>odlparent</artifactId> - <version>1.2.1-SNAPSHOT</version> - <relativePath /> - </parent> - <modelVersion>4.0.0</modelVersion> - <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> - <artifactId>sdnr-wt-odlux-app-inventoryApp</artifactId> - <version>0.4.1-SNAPSHOT</version> - <packaging>bundle</packaging> - <name>sdnr-wt-odlux-app-inventoryApp</name> - <licenses> - <license> - <name>Apache License, Version 2.0</name> - <url>http://www.apache.org/licenses/LICENSE-2.0</url> - </license> - </licenses> - <dependencies> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>sdnr-wt-odlux-core-model</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - <build> - <sourceDirectory>src2/main/java</sourceDirectory> - <plugins> - <plugin> - <artifactId>maven-clean-plugin</artifactId> - <version>2.5</version> - <configuration> - <filesets> + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>odlparent</artifactId> + <version>1.2.1-SNAPSHOT</version> + <relativePath /> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> + <artifactId>sdnr-wt-odlux-app-inventoryApp</artifactId> + <version>0.4.1-SNAPSHOT</version> + <packaging>bundle</packaging> + <name>sdnr-wt-odlux-app-inventoryApp</name> + <licenses> + <license> + <name>Apache License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0</url> + </license> + </licenses> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-model</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-provider</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <sourceDirectory>src2/main/java</sourceDirectory> + <plugins> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <configuration> + <filesets> + <fileset> + <directory>dist</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>../node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <!-- eclipse bug build bin folder in basedir --> <fileset> - <directory>dist</directory> + <directory>bin</directory> <followSymlinks>false</followSymlinks> </fileset> - </filesets> - </configuration> - </plugin> - <plugin> - <groupId>com.github.eirslett</groupId> - <artifactId>frontend-maven-plugin</artifactId> - <version>1.8.1-SNAPSHOT</version> - <executions> - <execution> - <id>install node and yarn</id> - <goals> - <goal>install-node-and-yarn</goal> - </goals> - <!-- optional: default phase is "generate-resources" --> - <phase>initialize</phase> - <configuration> - <nodeVersion>v8.10.0</nodeVersion> - <yarnVersion>v1.12.3</yarnVersion> - </configuration> - </execution> - <execution> - <id>yarn build</id> - <goals> - <goal>yarn</goal> - </goals> - <configuration> - <arguments>run build</arguments> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> - <Private-Package></Private-Package> - </instructions> - </configuration> - </plugin> - </plugins> - <resources> - <resource> - <directory>dist</directory> - <targetPath>odlux</targetPath> - </resource> - <resource> - <directory>src2/main/resources</directory> - </resource> - </resources> - </build> - <pluginRepositories> - <pluginRepository> - <id>highstreet repo</id> - <url>https://cloud-highstreet-technologies.com/mvn/</url> - <snapshots> - <enabled>true</enabled> - <updatePolicy>always</updatePolicy> - </snapshots> - </pluginRepository> - </pluginRepositories> -</project>
\ No newline at end of file + </filesets> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-test-source</id> + <phase>generate-test-sources</phase> + <goals> + <goal>add-test-source</goal> + </goals> + <configuration> + <sources> + <source>src2/test/java</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <version>1.8.1-SNAPSHOT</version> + <executions> + <execution> + <id>install node and yarn</id> + <goals> + <goal>install-node-and-yarn</goal> + </goals> + <!-- optional: default phase is "generate-resources" --> + <phase>initialize</phase> + <configuration> + <nodeVersion>v8.10.0</nodeVersion> + <yarnVersion>v1.12.3</yarnVersion> + </configuration> + </execution> + <execution> + <id>yarn build</id> + <goals> + <goal>yarn</goal> + </goals> + <configuration> + <arguments>run build</arguments> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> + <Private-Package></Private-Package> + </instructions> + </configuration> + </plugin> + </plugins> + <resources> + <resource> + <directory>dist</directory> + <targetPath>odlux</targetPath> + </resource> + <resource> + <directory>src2/main/resources</directory> + </resource> + <resource> + <directory>src2/test/resources</directory> + </resource> + </resources> + </build> + <pluginRepositories> + <pluginRepository> + <id>highstreet repo</id> + <url>https://cloud-highstreet-technologies.com/mvn/</url> + <snapshots> + <enabled>true</enabled> + <updatePolicy>always</updatePolicy> + </snapshots> + </pluginRepository> + </pluginRepositories> +</project> diff --git a/sdnr/wt/odlux/apps/inventoryApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/inventoryApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java new file mode 100644 index 000000000..d0fbe63c0 --- /dev/null +++ b/sdnr/wt/odlux/apps/inventoryApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * 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========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.odlux.OdluxBundleLoaderImpl; +import org.onap.ccsdk.features.sdnr.wt.odlux.bundles.MyOdluxBundle; + +public class TestBundleRes { + + @Test + public void test() { + OdluxBundleLoaderImpl loader = OdluxBundleLoaderImpl.getInstance(); + MyOdluxBundle b = new MyOdluxBundle(); + b.setLoader(loader); + b.setIndex(0); + b.setBundleName("abc"); + b.initialize(); + assertTrue(loader.getNumberOfBundles()==1); + assertNotNull(b.getLoader()); + assertEquals("abc",b.getBundleName()); + assertTrue(b.hasResource("test.js")); + assertNotNull(b.getResourceFileContent("test.js")); + b.clean(); + assertTrue(loader.getNumberOfBundles()==0); + } + +} diff --git a/sdnr/wt/odlux/apps/inventoryApp/src2/test/resources/test.js b/sdnr/wt/odlux/apps/inventoryApp/src2/test/resources/test.js new file mode 100644 index 000000000..b47fdc39f --- /dev/null +++ b/sdnr/wt/odlux/apps/inventoryApp/src2/test/resources/test.js @@ -0,0 +1,5 @@ +asdac sad +as +d +sad + sadfa
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/.babelrc b/sdnr/wt/odlux/apps/maintenanceApp/.babelrc new file mode 100644 index 000000000..3d8cd1260 --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/.babelrc @@ -0,0 +1,17 @@ +{ + "presets": [ + ["@babel/preset-react"], + ["@babel/preset-env", { + "targets": { + "chrome": "66" + }, + "spec": true, + "loose": false, + "modules": false, + "debug": false, + "useBuiltIns": "usage", + "forceAllTransforms": true + }] + ], + "plugins": [] +} diff --git a/sdnr/wt/odlux/apps/maintenanceApp/package.json b/sdnr/wt/odlux/apps/maintenanceApp/package.json new file mode 100644 index 000000000..617dde2d9 --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/package.json @@ -0,0 +1,41 @@ +{ + "name": "@odlux/maintenance-app", + "version": "0.1.0", + "description": "A react based modular UI for the maintenance app.", + "main": "index.js", + "scripts": { + "start": "webpack-dev-server --env debug", + "build": "webpack --env release --config webpack.config.js", + "build:dev": "webpack --env debug --config webpack.config.js" + }, + "repository": { + "type": "git", + "url": "https://git.mfico.de/highstreet-technologies/odlux.git" + }, + "keywords": [ + "reactjs", + "redux", + "ui", + "framework" + ], + "author": "Matthias Fischer", + "license": "MIT", + "dependencies": { + "@odlux/framework": "*", + "@odlux/connect-app": "*" + }, + "peerDependencies": { + "@types/react": "16.4.14", + "@types/react-dom": "16.0.8", + "@types/react-router-dom": "4.3.1", + "@material-ui/core": "3.8.3", + "@material-ui/icons": "3.0.2", + "@types/classnames": "2.2.6", + "@types/flux": "3.1.8", + "@types/jquery": "3.3.10", + "jquery": "3.3.1", + "react": "16.5.2", + "react-dom": "16.5.2", + "react-router-dom": "4.3.1" + } +} diff --git a/sdnr/wt/odlux/apps/maintenanceApp/pom.xml b/sdnr/wt/odlux/apps/maintenanceApp/pom.xml new file mode 100644 index 000000000..18db101e0 --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/pom.xml @@ -0,0 +1,158 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>odlparent</artifactId> + <version>1.2.1-SNAPSHOT</version> + <relativePath /> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> + <artifactId>sdnr-wt-odlux-app-maintenanceApp</artifactId> + <version>0.4.1-SNAPSHOT</version> + <packaging>bundle</packaging> + <name>sdnr-wt-odlux-app-maintenanceApp</name> + <licenses> + <license> + <name>Apache License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0</url> + </license> + </licenses> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-model</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-provider</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <sourceDirectory>src2/main/java</sourceDirectory> + <plugins> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <configuration> + <filesets> + <fileset> + <directory>dist</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>../node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <!-- eclipse bug build bin folder in basedir --> + <fileset> + <directory>bin</directory> + <followSymlinks>false</followSymlinks> + </fileset> + </filesets> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-test-source</id> + <phase>generate-test-sources</phase> + <goals> + <goal>add-test-source</goal> + </goals> + <configuration> + <sources> + <source>src2/test/java</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <version>1.8.1-SNAPSHOT</version> + <executions> + <execution> + <id>install node and yarn</id> + <goals> + <goal>install-node-and-yarn</goal> + </goals> + <!-- optional: default phase is "generate-resources" --> + <phase>initialize</phase> + <configuration> + <nodeVersion>v8.10.0</nodeVersion> + <yarnVersion>v1.12.3</yarnVersion> + </configuration> + </execution> + <execution> + <id>yarn build</id> + <goals> + <goal>yarn</goal> + </goals> + <configuration> + <arguments>run build</arguments> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> + <Private-Package></Private-Package> + </instructions> + </configuration> + </plugin> + </plugins> + <resources> + <resource> + <directory>dist</directory> + <targetPath>odlux</targetPath> + </resource> + <resource> + <directory>src2/main/resources</directory> + </resource> + <resource> + <directory>src2/test/resources</directory> + </resource> + </resources> + </build> + <pluginRepositories> + <pluginRepository> + <id>highstreet repo</id> + <url>https://cloud-highstreet-technologies.com/mvn/</url> + <snapshots> + <enabled>true</enabled> + <updatePolicy>always</updatePolicy> + </snapshots> + </pluginRepository> + </pluginRepositories> +</project> diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/actions/maintenenceActions.ts b/sdnr/wt/odlux/apps/maintenanceApp/src/actions/maintenenceActions.ts new file mode 100644 index 000000000..753c1183f --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/src/actions/maintenenceActions.ts @@ -0,0 +1,95 @@ +import { Action } from '../../../../framework/src/flux/action'; +import { Dispatch } from '../../../../framework/src/flux/store'; +import { MaintenenceEntry, spoofSymbol } from '../models/maintenenceEntryType'; + +import { AddSnackbarNotification } from '../../../../framework/src/actions/snackbarActions'; +import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore'; + +import { maintenenceService } from '../services/maintenenceService'; + +export class BaseAction extends Action { } + +export class LoadAllMainteneceEntriesAction extends BaseAction { } + +export class AllMainteneceEntriesLoadedAction extends BaseAction { + + constructor (public maintenenceEntries: MaintenenceEntry[] | null, error?:string) { + super(); + + } +} + + +export const loadAllMainteneceEntriesAsyncAction = (dispatch: Dispatch , getState: () => IApplicationStoreState) => { + dispatch(new LoadAllMainteneceEntriesAction()); + // frist get all entries from the maintenance index + maintenenceService.getAllMaintenenceEntries().then(entries => { + if (!entries) { + dispatch(new AddSnackbarNotification({ message: `Error reading maintenece sessings.`, options: { variant: 'error' } })); + return; + } + + // combine ell entries from the maintenance index with all networkelements + const networkElements = getState().connectApp.mountedNetworkElements; + const maintenenceEntries = networkElements.elements.reduce((acc, cur) => { + const entry = entries.find(e => e.mountId === cur.mountId); + acc.push(entry || { + [spoofSymbol]: true, + _id: cur.mountId, + mountId: cur.mountId, + description : "", + start: "", + end: "", + active: false + }); + return acc; + }, [] as MaintenenceEntry[]); + + // all all entries from the maintenance index which are not in all networkelements + entries.forEach(entry => { + if (maintenenceEntries.findIndex(e => e.mountId === entry.mountId) < 0) { + maintenenceEntries.push(entry); + }; + }); + + dispatch(new AllMainteneceEntriesLoadedAction(maintenenceEntries)); + }).catch(error => dispatch(new AllMainteneceEntriesLoadedAction(null, error))); +} + +export class UpdateMaintenanceEntry extends BaseAction { + constructor(public maintenenceEntry: MaintenenceEntry) { + super(); + } +} + +/** Represents an async thunk action creator to add an element to the maintenence entries. */ +export const addOrUpdateMaintenenceEntryAsyncActionCreator = (entry: MaintenenceEntry) => (dispatch: Dispatch) => { + maintenenceService.writeMaintenenceEntry(entry).then(result => { + result && window.setTimeout(() => { + // dispatch(loadAllMountedNetworkElementsAsync); + dispatch(new UpdateMaintenanceEntry(entry)); + dispatch(new AddSnackbarNotification({ message: `Successfully ${result && result.created ? "created" : "updated"} maintenece sessings for [${entry.mountId}]`, options: { variant: 'success' } })); + }, 900); + }); +}; + +/** Represents an async thunk action creator to delete an element from the maintenence entries. */ +export const removeFromMaintenenceEntrysAsyncActionCreator = (entry: MaintenenceEntry) => (dispatch: Dispatch) => { + maintenenceService.deleteMaintenenceEntry(entry).then(result => { + result && window.setTimeout(() => { + //dispatch(loadAllMountedNetworkElementsAsync); + dispatch(new UpdateMaintenanceEntry({ + [spoofSymbol]: true, + _id: entry._id, + mountId: entry.mountId, + description : "", + start: "", + end: "", + active: false + })); + dispatch(new AddSnackbarNotification({ message: `Successfully removed [${entry.mountId}]`, options: { variant: 'success' } })); + }, 900); + }); +}; + +// Hint: since there is no notification of changed required network elements, this code is not aware of changes caused outiside of this browser.
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/components/editMaintenenceEntryDialog.tsx b/sdnr/wt/odlux/apps/maintenanceApp/src/components/editMaintenenceEntryDialog.tsx new file mode 100644 index 000000000..04f6d2d41 --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/src/components/editMaintenenceEntryDialog.tsx @@ -0,0 +1,177 @@ +import * as React from 'react'; + +import Button from '@material-ui/core/Button'; +import TextField from '@material-ui/core/TextField'; +import Dialog from '@material-ui/core/Dialog'; +import DialogActions from '@material-ui/core/DialogActions'; +import DialogContent from '@material-ui/core/DialogContent'; +import DialogContentText from '@material-ui/core/DialogContentText'; +import DialogTitle from '@material-ui/core/DialogTitle'; + +import { IDispatcher, connect, Connect } from '../../../../framework/src/flux/connect'; + +import { + addOrUpdateMaintenenceEntryAsyncActionCreator, + removeFromMaintenenceEntrysAsyncActionCreator +} from '../actions/maintenenceActions'; + +import { MaintenenceEntry } from '../models/maintenenceEntryType'; +import { FormControl, InputLabel, Select, MenuItem } from '@material-ui/core'; + +export enum EditMaintenenceEntryDialogMode { + None = "none", + AddMaintenenceEntry = "addMaintenenceEntry", + EditMaintenenceEntry = "editMaintenenceEntry", + RemoveMaintenenceEntry = "removeMaintenenceEntry" +} + +const mapDispatch = (dispatcher: IDispatcher) => ({ + addOrUpdateMaintenenceEntry: (entry: MaintenenceEntry) => { + dispatcher.dispatch(addOrUpdateMaintenenceEntryAsyncActionCreator(entry)); + }, + removeMaintenenceEntry: (entry: MaintenenceEntry) => { + dispatcher.dispatch(removeFromMaintenenceEntrysAsyncActionCreator(entry)); + }, +}); + +type DialogSettings = { + dialogTitle: string, + dialogDescription: string, + applyButtonText: string, + cancelButtonText: string, + enableMountIdEditor: boolean, + enableTimeEditor: boolean, +} + +const settings: { [key: string]: DialogSettings } = { + [EditMaintenenceEntryDialogMode.None]: { + dialogTitle: "", + dialogDescription: "", + applyButtonText: "", + cancelButtonText: "", + enableMountIdEditor: false, + enableTimeEditor: false, + }, + [EditMaintenenceEntryDialogMode.AddMaintenenceEntry]: { + dialogTitle: "Add new maintenence entry", + dialogDescription: "", + applyButtonText: "Add", + cancelButtonText: "Cancel", + enableMountIdEditor: true, + enableTimeEditor: true, + }, + [EditMaintenenceEntryDialogMode.EditMaintenenceEntry]: { + dialogTitle: "Edit maintenence entry", + dialogDescription: "", + applyButtonText: "Save", + cancelButtonText: "Cancel", + enableMountIdEditor: false, + enableTimeEditor: true, + }, + [EditMaintenenceEntryDialogMode.RemoveMaintenenceEntry]: { + dialogTitle: "Remove maintenence entry", + dialogDescription: "", + applyButtonText: "Remove", + cancelButtonText: "Cancel", + enableMountIdEditor: false, + enableTimeEditor: false, + }, +} + +type EditMaintenenceEntryDIalogComponentProps = Connect<undefined, typeof mapDispatch> & { + mode: EditMaintenenceEntryDialogMode; + initialMaintenenceEntry: MaintenenceEntry; + onClose: () => void; +}; + +type EditMaintenenceEntryDIalogComponentState = MaintenenceEntry; + +class EditMaintenenceEntryDIalogComponent extends React.Component<EditMaintenenceEntryDIalogComponentProps, EditMaintenenceEntryDIalogComponentState> { + constructor (props: EditMaintenenceEntryDIalogComponentProps) { + super(props); + + this.state = { + ...this.props.initialMaintenenceEntry + }; + } + + render(): JSX.Element { + const setting = settings[this.props.mode]; + return ( + <Dialog open={this.props.mode !== EditMaintenenceEntryDialogMode.None}> + <DialogTitle id="form-dialog-title">{setting.dialogTitle}</DialogTitle> + <DialogContent> + <DialogContentText> + {setting.dialogDescription} + </DialogContentText> + <TextField disabled={!setting.enableMountIdEditor} spellCheck={false} autoFocus margin="dense" id="name" label="Name" type="text" fullWidth value={this.state.mountId} onChange={(event) => { this.setState({ mountId: event.target.value }); }} /> + <TextField disabled={!setting.enableTimeEditor} spellCheck={false} autoFocus margin="dense" id="start" label="Start" type="datetime-local" fullWidth value={this.state.start} onChange={(event) => { this.setState({ start: event.target.value }); }} /> + <TextField disabled={!setting.enableTimeEditor} spellCheck={false} autoFocus margin="dense" id="end" label="End" type="datetime-local" fullWidth value={this.state.end} onChange={(event) => { this.setState({ end: event.target.value }); }} /> + <FormControl fullWidth disabled={!setting.enableTimeEditor}> + <InputLabel htmlFor="active">Active</InputLabel> + <Select value={ this.state.active || false } onChange={(event) => { + this.setState({ active: event.target.value as any as boolean }); + }} inputProps={{ name: 'active', id: 'active' }} fullWidth > + <MenuItem value={true as any as string}>active</MenuItem> + <MenuItem value={false as any as string}>not active</MenuItem> + </Select> + </FormControl> + </DialogContent> + <DialogActions> + <Button onClick={(event) => { + this.onApply({ + _id: this.state._id || this.state.mountId, + mountId: this.state.mountId, + description: this.state.description, + start: this.state.start, + end: this.state.end, + active: this.state.active + }); + event.preventDefault(); + event.stopPropagation(); + }} > {setting.applyButtonText} </Button> + <Button onClick={(event) => { + this.onCancel(); + event.preventDefault(); + event.stopPropagation(); + }} color="secondary"> {setting.cancelButtonText} </Button> + </DialogActions> + </Dialog> + ) + } + + private onApply = (entry: MaintenenceEntry) => { + this.props.onClose && this.props.onClose(); + switch (this.props.mode) { + case EditMaintenenceEntryDialogMode.AddMaintenenceEntry: + entry && this.props.addOrUpdateMaintenenceEntry(entry); + break; + case EditMaintenenceEntryDialogMode.EditMaintenenceEntry: + entry && this.props.addOrUpdateMaintenenceEntry(entry); + break; + case EditMaintenenceEntryDialogMode.RemoveMaintenenceEntry: + entry && this.props.removeMaintenenceEntry(entry); + break; + } + }; + + + private onCancel = () => { + this.props.onClose && this.props.onClose(); + } + + static getDerivedStateFromProps(props: EditMaintenenceEntryDIalogComponentProps, state: EditMaintenenceEntryDIalogComponentState & { _initialMaintenenceEntry: MaintenenceEntry }): EditMaintenenceEntryDIalogComponentState & { _initialMaintenenceEntry: MaintenenceEntry } { + if (props.initialMaintenenceEntry !== state._initialMaintenenceEntry) { + state = { + ...state, + ...props.initialMaintenenceEntry, + _initialMaintenenceEntry: props.initialMaintenenceEntry, + }; + } + return state; + } + +} + +export const EditMaintenenceEntryDIalog = connect(undefined, mapDispatch)(EditMaintenenceEntryDIalogComponent); +export default EditMaintenenceEntryDIalog;
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenanceAppRootHandler.ts b/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenanceAppRootHandler.ts new file mode 100644 index 000000000..956d05843 --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenanceAppRootHandler.ts @@ -0,0 +1,27 @@ +// main state handler + +import { combineActionHandler } from '../../../../framework/src/flux/middleware'; + +import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore'; + +import { IConnectAppStoreState } from '../../../connectApp/src/handlers/connectAppRootHandler'; + +import { IMaintenenceEntriesState, maintenenceEntriesActionHandler } from './maintenenceEntriesHandler'; + +export interface IMaintenanceAppStoreState { + maintenenceEntries : IMaintenenceEntriesState +} + +declare module '../../../../framework/src/store/applicationStore' { + interface IApplicationStoreState { + maintenanceApp: IMaintenanceAppStoreState, + connectApp: IConnectAppStoreState + } +} + +const actionHandlers = { + maintenenceEntries: maintenenceEntriesActionHandler +}; + +export const maintenanceAppRootHandler = combineActionHandler<IMaintenanceAppStoreState>(actionHandlers); +export default maintenanceAppRootHandler; diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenenceEntriesHandler.ts b/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenenceEntriesHandler.ts new file mode 100644 index 000000000..13f4a3b6d --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenenceEntriesHandler.ts @@ -0,0 +1,40 @@ +import { IActionHandler } from '../../../../framework/src/flux/action'; + +import { MaintenenceEntry } from '../models/maintenenceEntryType'; +import { LoadAllMainteneceEntriesAction, AllMainteneceEntriesLoadedAction, UpdateMaintenanceEntry } from '../actions/maintenenceActions'; + +export interface IMaintenenceEntriesState { + entries: MaintenenceEntry[]; + busy: boolean; +} + +const maintenanceEntriesStateInit: IMaintenenceEntriesState = { + entries: [], + busy: false +}; + +export const maintenenceEntriesActionHandler: IActionHandler<IMaintenenceEntriesState> = (state = maintenanceEntriesStateInit, action) => { + if (action instanceof LoadAllMainteneceEntriesAction){ + state = { + ...state, + busy: true, + } + } else if (action instanceof AllMainteneceEntriesLoadedAction){ + state = { + ...state, + entries: action.maintenenceEntries || [], + busy: false, + } + } else if (action instanceof UpdateMaintenanceEntry) { + const index = state.entries.findIndex(e => action.maintenenceEntry.mountId === e.mountId); + state = { + ...state, + entries: index > -1 ? [ + ...state.entries.slice(0, index), + action.maintenenceEntry, + ...state.entries.slice(index+1), + ] : [...state.entries, action.maintenenceEntry] + } + } + return state; +}
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/index.html b/sdnr/wt/odlux/apps/maintenanceApp/src/index.html new file mode 100644 index 000000000..c84aecee1 --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/src/index.html @@ -0,0 +1,26 @@ +<!DOCTYPE html> +<html lang="en"> + +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <meta http-equiv="X-UA-Compatible" content="ie=edge"> + <!-- <link rel="stylesheet" href="./vendor.css"> --> + <title>Minimal App</title> +</head> + +<body> + <div id="app"></div> + <script type="text/javascript" src="./require.js"></script> + <script type="text/javascript" src="./config.js"></script> + <script> + // run the application + require(["app","connectApp", "maintenanceApp"], function (app, connectApp, maintenanceApp) { + connectApp.register(); + maintenanceApp.register(); + app("./app.tsx").runApplication(); + }); + </script> +</body> + +</html>
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/models/maintenenceEntryType.ts b/sdnr/wt/odlux/apps/maintenanceApp/src/models/maintenenceEntryType.ts new file mode 100644 index 000000000..fca70f2af --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/src/models/maintenenceEntryType.ts @@ -0,0 +1,28 @@ +/** Represents the elestic search db type for maintenence enrties */ +export type MaintenenceEntryType = { + node: string; + // According to the arrangement from 2019.02.15 there will be currently only one element in the filters array. + filter: [{ + definition: { "object-id-ref": string ,problem: string}, + description: string, + /** The end date for the maintenence mode formated as ISO date string in UTC. */ + end: string, + /** The start date for the maintenence mode formated as ISO date string in UTC. */ + start: string + }], + /** Determines if the filter set is activated or not. */ + active: boolean; +} + +export const spoofSymbol = Symbol("Spoof"); + +/** Represents the type for an maintenence entry. */ +export type MaintenenceEntry = { + [spoofSymbol]?: boolean; + _id: string; + mountId: string; + description: string; + start: string; + end: string; + active: boolean; +}
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/plugin.tsx b/sdnr/wt/odlux/apps/maintenanceApp/src/plugin.tsx new file mode 100644 index 000000000..19e188ec2 --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/src/plugin.tsx @@ -0,0 +1,27 @@ +// app configuration and main entry point for the app + +import * as React from "react"; + +import { faLock } from '@fortawesome/free-solid-svg-icons'; // select app icon + +import applicationManager from '../../../framework/src/services/applicationManager'; + +import { maintenanceAppRootHandler } from './handlers/maintenanceAppRootHandler'; + +import MaintenenceView from "./views/maintenenceView"; + +const App : React.SFC = (props) => { + return <MaintenenceView /> +}; + +export function register() { + applicationManager.registerApplication({ + name: "maintenanceApp", + icon: faLock, + rootComponent: App, + rootActionHandler: maintenanceAppRootHandler, + menuEntry: "Maintenance App" + }); +} + + diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/services/maintenenceService.ts b/sdnr/wt/odlux/apps/maintenanceApp/src/services/maintenenceService.ts new file mode 100644 index 000000000..5e15a4c78 --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/src/services/maintenenceService.ts @@ -0,0 +1,82 @@ +import { requestRest } from '../../../../framework/src/services/restService'; +import { Result, HitEntry, PostResponse, DeleteResponse } from '../../../../framework/src/models/elasticSearch'; + +import { MaintenenceEntryType, MaintenenceEntry } from '../models/maintenenceEntryType'; +import { convertToLocaleString, convertToGMTString } from '../utils/timeUtils'; + +export const maintenenceEntryDatabasePath = "mwtn/maintenancemode"; + +/** + * Represents a web api accessor service for all maintenence entries related actions. + */ +class MaintenenceService { + /** + * Gets all maintenence entries from the backend. + */ + public async getAllMaintenenceEntries(): Promise<(MaintenenceEntry[]) | null> { + const path = `database/${maintenenceEntryDatabasePath}/_search`; + const query = { "query": { "match_all": {} } }; + + const result = await requestRest<Result<MaintenenceEntryType>>(path, { method: "POST", body: JSON.stringify(query) }); + return result && result.hits && result.hits.hits && result.hits.hits.map(me => me._source && me._source.filter[0] && ({ + _id: me._id, + mountId: me._source.node, + description: me._source.filter[0].description, + start: me._source.filter[0].start && convertToLocaleString(me._source.filter[0].start), + end: me._source.filter[0].end && convertToLocaleString(me._source.filter[0].end), + active: me._source.active + })) || null; + } + + /** + * Gets one maintenence entry by its mountId from the backend. + */ + public async getMaintenenceEntryByMountId(mountId: string): Promise<(MaintenenceEntry) | null> { + const path = `database/${maintenenceEntryDatabasePath}/${mountId}`; + + const result = await requestRest<HitEntry<MaintenenceEntryType> & { found: boolean }>(path, { method: "GET" }); + return result && result.found && result._source && result._source.filter[0] && { + _id: result._id, + mountId: result._source.node, + description: result._source.filter[0].description, + start: result._source.filter[0].start && convertToLocaleString(result._source.filter[0].start), + end: result._source.filter[0].end && convertToLocaleString(result._source.filter[0].end), + active: result._source.active + } || null; + } + + /** + * Adds or updates one maintenence entry to the backend. + */ + public async writeMaintenenceEntry(maintenenceEntry: MaintenenceEntry): Promise<PostResponse | null> { + const path = `database/${maintenenceEntryDatabasePath}/${maintenenceEntry._id}`; + const data: MaintenenceEntryType = { + node: maintenenceEntry.mountId, + filter: [ + { + definition: { "object-id-ref": "", problem: "" }, + description: "", + start: convertToGMTString(maintenenceEntry.start), + end: convertToGMTString(maintenenceEntry.end) + } + ], + active: maintenenceEntry.active + }; + + const result = await requestRest<PostResponse>(path, { method: "POST", body: JSON.stringify(data) }); + return result || null; + } + + /** + * Deletes one maintenence entry by its mountId from the backend. + */ + public async deleteMaintenenceEntry(maintenenceEntry: MaintenenceEntry): Promise<(DeleteResponse) | null> { + const path = `database/${maintenenceEntryDatabasePath}/${maintenenceEntry._id}`; + + const result = await requestRest<DeleteResponse>(path, { method: "DELETE" }); + return result || null; + } +} + +export const maintenenceService = new MaintenenceService(); +export default maintenenceService;
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/utils/timeUtils.ts b/sdnr/wt/odlux/apps/maintenanceApp/src/utils/timeUtils.ts new file mode 100644 index 000000000..92bc2ba8b --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/src/utils/timeUtils.ts @@ -0,0 +1,22 @@ +export function convertToGMTString(dateString: string): string { + const date = new Date(dateString); + const pad = (n: number) => (n < 10) ? '0' + n : n; + + return date.getUTCFullYear() + + '-' + pad(date.getUTCMonth() + 1) + + '-' + pad(date.getUTCDate()) + + 'T' + pad(date.getUTCHours()) + + ':' + pad(date.getUTCMinutes()) + + '+00:00'; +} + +export function convertToLocaleString(rawDate: string| number): string { + const date = new Date(rawDate); + const pad = (n: number) => (n < 10) ? '0' + n : n; + + return date.getFullYear() + + '-' + pad(date.getMonth() + 1) + + '-' + pad(date.getDate()) + + 'T' + pad(date.getHours()) + + ':' + pad(date.getMinutes()); +}
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/views/maintenenceView.tsx b/sdnr/wt/odlux/apps/maintenanceApp/src/views/maintenenceView.tsx new file mode 100644 index 000000000..f048d6cc5 --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/src/views/maintenenceView.tsx @@ -0,0 +1,200 @@ +import * as React from 'react'; + +import { Theme, createStyles, WithStyles, withStyles, Tooltip } from '@material-ui/core'; + +import AddIcon from '@material-ui/icons/Add'; +import EditIcon from '@material-ui/icons/Edit'; +import RemoveIcon from '@material-ui/icons/RemoveCircleOutline'; + +import Button from '@material-ui/core/Button'; +import IconButton from '@material-ui/core/IconButton'; + +import connect, { IDispatcher, Connect } from '../../../../framework/src/flux/connect'; +import MaterialTable, { MaterialTableCtorType, ColumnType } from '../../../../framework/src/components/material-table'; +import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore'; + +import { loadAllMountedNetworkElementsAsync } from '../../../connectApp/src/actions/mountedNetworkElementsActions'; + +import { loadAllMainteneceEntriesAsyncAction } from '../actions/maintenenceActions'; +import { MaintenenceEntry, spoofSymbol } from '../models/maintenenceEntryType'; + +import EditMaintenenceEntryDialog, { EditMaintenenceEntryDialogMode } from '../components/editMaintenenceEntryDialog'; +import { convertToLocaleString } from '../utils/timeUtils'; + +const styles = (theme: Theme) => createStyles({ + button: { + margin: 0, + padding: "6px 6px", + minWidth: 'unset' + }, + spacer: { + marginLeft: theme.spacing.unit, + marginRight: theme.spacing.unit, + display: "inline" + } +}); + +const MaintenenceEntriesTable = MaterialTable as MaterialTableCtorType<MaintenenceEntry>; + +const mapProps = (state: IApplicationStoreState) => ({ + maintenenceEntries: state.maintenanceApp.maintenenceEntries.entries, + busy: state.maintenanceApp.maintenenceEntries.busy +}); + +const mapDispatcher = (dispatcher: IDispatcher) => ({ + onLoadMenteneceEntries: async () => { + await dispatcher.dispatch(loadAllMountedNetworkElementsAsync) + dispatcher.dispatch(loadAllMainteneceEntriesAsyncAction); + } +}); + +const emptyMaintenenceEntry: MaintenenceEntry = { + _id: '', + mountId: '', + description: '', + start: convertToLocaleString(new Date().valueOf()), + end: convertToLocaleString(new Date().valueOf()), + active: false, +}; + +type MaintenenceViewComponentProps = Connect<typeof mapProps, typeof mapDispatcher> & WithStyles<typeof styles> & { + +} + +type MaintenenceViewComponentState = { + maintenenceEntryToEdit: MaintenenceEntry; + maintenenceEntryEditorMode: EditMaintenenceEntryDialogMode; +} + +class MaintenenceViewComponent extends React.Component<MaintenenceViewComponentProps, MaintenenceViewComponentState> { + + constructor (props: MaintenenceViewComponentProps) { + super(props); + + this.state = { + maintenenceEntryToEdit: emptyMaintenenceEntry, + maintenenceEntryEditorMode: EditMaintenenceEntryDialogMode.None, + }; + + } + + render() { + const { classes } = this.props; + const addMaintenenceEntryAction = { + icon: AddIcon, tooltip: 'Add', onClick: () => { + const startTime = (new Date().valueOf()); + const endTime = startTime; + this.setState({ + maintenenceEntryToEdit: { + ...emptyMaintenenceEntry, + start: convertToLocaleString(startTime), + end: convertToLocaleString(endTime), + }, + maintenenceEntryEditorMode: EditMaintenenceEntryDialogMode.AddMaintenenceEntry + }); + } + }; + return ( + <> + <MaintenenceEntriesTable asynchronus rows={this.props.maintenenceEntries} customActionButtons={[ addMaintenenceEntryAction ]} columns={ + [ + { property: "mountId", title: "Mount Id", type: ColumnType.text }, + { property: "active", title: "Active", type: ColumnType.boolean, labels: { "true": "active", "false": "not active" }, }, + { property: "start", title: "Start Date", type: ColumnType.text }, + { property: "end", title: "End Date", type: ColumnType.text }, + { property: "actions", title: "Actions", type: ColumnType.custom, customControl : ({ rowData })=>( + <> + <div className={classes.spacer}> + <Tooltip title={"1h from now"} ><Button className={classes.button} onClick={ (event) => this.onOpenPlus1hEditMaintenenceEntryDialog(event, rowData)} >+1h</Button></Tooltip> + <Tooltip title={"8h from now"} ><Button className={classes.button} onClick={(event) => this.onOpenPlus8hEditMaintenenceEntryDialog(event, rowData)} >+8h</Button></Tooltip> + </div> + <div className={classes.spacer}> + <Tooltip title={"Edit"} ><IconButton className={classes.button} onClick={(event) => this.onOpenEditMaintenenceEntryDialog(event, rowData)} ><EditIcon /></IconButton></Tooltip> + <Tooltip title={"Remove"} ><IconButton disabled={ !!rowData[spoofSymbol] } className={classes.button} onClick={(event) => this.onOpenRemoveMaintenenceEntryDialog(event, rowData)} ><RemoveIcon /></IconButton></Tooltip> + </div> + </> + ) }, + ] + } idProperty={'_id'}> </MaintenenceEntriesTable> + <EditMaintenenceEntryDialog initialMaintenenceEntry={this.state.maintenenceEntryToEdit} mode={this.state.maintenenceEntryEditorMode} + onClose={ this.onCloseEditMaintenenceEntryDialog } /> + </> + ); + } + + componentDidMount(){ + this.props.onLoadMenteneceEntries(); + } + + private onOpenPlus1hEditMaintenenceEntryDialog = (event: React.MouseEvent<HTMLElement>, entry: MaintenenceEntry) => { + event.preventDefault(); + event.stopPropagation(); + const startTime = (new Date().valueOf()); + const endTime = startTime + (1 * 60 * 60 * 1000); + this.setState({ + maintenenceEntryToEdit: { + ...entry, + start: convertToLocaleString(startTime), + end: convertToLocaleString(endTime), + }, + maintenenceEntryEditorMode: EditMaintenenceEntryDialogMode.EditMaintenenceEntry + }); + } + + private onOpenPlus8hEditMaintenenceEntryDialog = (event: React.MouseEvent<HTMLElement>, entry: MaintenenceEntry) => { + event.preventDefault(); + event.stopPropagation(); + const startTime = (new Date().valueOf()); + const endTime = startTime + (8 * 60 * 60 * 1000); + this.setState({ + maintenenceEntryToEdit: { + ...entry, + start: convertToLocaleString(startTime), + end: convertToLocaleString(endTime), + }, + maintenenceEntryEditorMode: EditMaintenenceEntryDialogMode.EditMaintenenceEntry + }); + } + + private onOpenEditMaintenenceEntryDialog = (event: React.MouseEvent<HTMLElement>, entry: MaintenenceEntry) => { + event.preventDefault(); + event.stopPropagation(); + const startTime = (new Date().valueOf()); + const endTime = startTime ; + this.setState({ + maintenenceEntryToEdit: { + ...entry, + ...(entry.start && endTime) + ? { start: entry.start, end: entry.end } + : { start: convertToLocaleString(startTime), end: convertToLocaleString(endTime)} + }, + maintenenceEntryEditorMode: EditMaintenenceEntryDialogMode.EditMaintenenceEntry + }); + } + + private onOpenRemoveMaintenenceEntryDialog = (event: React.MouseEvent<HTMLElement>, entry: MaintenenceEntry) => { + event.preventDefault(); + event.stopPropagation(); + const startTime = (new Date().valueOf()); + const endTime = startTime; + this.setState({ + maintenenceEntryToEdit: { + ...entry, + ...(entry.start && endTime) + ? { start: entry.start, end: entry.end } + : { start: convertToLocaleString(startTime), end: convertToLocaleString(endTime) } + }, + maintenenceEntryEditorMode: EditMaintenenceEntryDialogMode.RemoveMaintenenceEntry + }); + } + + private onCloseEditMaintenenceEntryDialog = () => { + this.setState({ + maintenenceEntryToEdit: emptyMaintenenceEntry, + maintenenceEntryEditorMode: EditMaintenenceEntryDialogMode.None, + }); + } +} + +export const MaintenenceView = withStyles(styles)(connect(mapProps, mapDispatcher)(MaintenenceViewComponent)); +export default MaintenenceView;
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java b/sdnr/wt/odlux/apps/maintenanceApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java new file mode 100644 index 000000000..1e882fc69 --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * 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========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.odlux.bundles; + +import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundle; +import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundleLoader; + +public class MyOdluxBundle extends OdluxBundle { + + @Override + public void initialize() { + super.initialize(); + } + + @Override + public void clean() { + super.clean(); + } + + @Override + public String getResourceFileContent(String filename) { + return super.getResourceFileContent(filename); + } + + @Override + public boolean hasResource(String filename) { + return super.hasResource(filename); + } + + @Override + public void setBundleName(String bundleName) { + super.setBundleName(bundleName); + } + + @Override + public void setLoader(OdluxBundleLoader loader) { + super.setLoader(loader); + } + + @Override + public String getBundleName() { + return super.getBundleName(); + } + + @Override + public OdluxBundleLoader getLoader() { + return super.getLoader(); + } + + public MyOdluxBundle() { + super(); + } +} diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src2/main/resources/OSGI-INF/blueprint/blueprint.xml b/sdnr/wt/odlux/apps/maintenanceApp/src2/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 000000000..2dd79d781 --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/src2/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,9 @@ +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> + <reference id="loadersvc" availability="mandatory" activation="eager" interface="org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundleLoader"/> + + <bean id="bundle" init-method="initialize" destroy-method="clean" class="org.onap.ccsdk.features.sdnr.wt.odlux.bundles.MyOdluxBundle"> + <property name="loader" ref="loadersvc"/> + <property name="bundleName" value="maintenanceApp"/> + <property name="index" value="20" /> + </bean> +</blueprint> diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/maintenanceApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java new file mode 100644 index 000000000..d0fbe63c0 --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * 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========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.odlux.OdluxBundleLoaderImpl; +import org.onap.ccsdk.features.sdnr.wt.odlux.bundles.MyOdluxBundle; + +public class TestBundleRes { + + @Test + public void test() { + OdluxBundleLoaderImpl loader = OdluxBundleLoaderImpl.getInstance(); + MyOdluxBundle b = new MyOdluxBundle(); + b.setLoader(loader); + b.setIndex(0); + b.setBundleName("abc"); + b.initialize(); + assertTrue(loader.getNumberOfBundles()==1); + assertNotNull(b.getLoader()); + assertEquals("abc",b.getBundleName()); + assertTrue(b.hasResource("test.js")); + assertNotNull(b.getResourceFileContent("test.js")); + b.clean(); + assertTrue(loader.getNumberOfBundles()==0); + } + +} diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src2/test/resources/test.js b/sdnr/wt/odlux/apps/maintenanceApp/src2/test/resources/test.js new file mode 100644 index 000000000..b47fdc39f --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/src2/test/resources/test.js @@ -0,0 +1,5 @@ +asdac sad +as +d +sad + sadfa
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/tsconfig.json b/sdnr/wt/odlux/apps/maintenanceApp/tsconfig.json new file mode 100644 index 000000000..a66b5d828 --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/tsconfig.json @@ -0,0 +1,37 @@ +{ + "compilerOptions": { + "baseUrl": "./src", + "outDir": "./dist", + "sourceMap": true, + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": false, + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "strictNullChecks": true, + "pretty": true, + "newLine": "LF", + "module": "es2015", + "target": "es2016", + "moduleResolution": "node", + "experimentalDecorators": true, + "jsx": "preserve", + "lib": [ + "dom", + "es2015", + "es2016" + ], + "types": [ + "prop-types", + "react", + "react-dom" + ] + }, + "exclude": [ + "dist", + "node_modules" + ] +} diff --git a/sdnr/wt/odlux/apps/maintenanceApp/webpack.config.js b/sdnr/wt/odlux/apps/maintenanceApp/webpack.config.js new file mode 100644 index 000000000..0a2f5abb8 --- /dev/null +++ b/sdnr/wt/odlux/apps/maintenanceApp/webpack.config.js @@ -0,0 +1,140 @@ +/** + * Webpack 4 configuration file + * see https://webpack.js.org/configuration/ + * see https://webpack.js.org/configuration/dev-server/ + */ + +"use strict"; + +const path = require("path"); +const webpack = require("webpack"); +const CopyWebpackPlugin = require("copy-webpack-plugin"); +const TerserPlugin = require('terser-webpack-plugin'); + +// const __dirname = (path => path.replace(/^([a-z]\:)/, c => c.toUpperCase()))(process.__dirname()); + +module.exports = (env) => { + const distPath = path.resolve(__dirname, env === "release" ? "." : "../..", "dist"); + const frameworkPath = path.resolve(__dirname, env === "release" ? "../../framework" : "../..", "dist"); + return [{ + name: "App", + + mode: "none", //disable default behavior + + target: "web", + + context: path.resolve(__dirname, "src"), + + entry: { + maintenanceApp: ["./plugin.tsx"] + }, + + devtool: env === "release" ? false : "source-map", + + resolve: { + extensions: [".ts", ".tsx", ".js", ".jsx"] + }, + + output: { + path: distPath, + filename: "[name].js", + library: "[name]", + libraryTarget: "umd2", + chunkFilename: "[name].js" + }, + module: { + rules: [{ + test: /\.tsx?$/, + exclude: /node_modules/, + use: [{ + loader: "babel-loader" + }, { + loader: "ts-loader" + }] + }, { + test: /\.jsx?$/, + exclude: /node_modules/, + use: [{ + loader: "babel-loader" + }] + }] + }, + + optimization: { + noEmitOnErrors: true, + namedModules: env !== "release", + minimize: env === "release", + minimizer: env !== "release" ? [] : [new TerserPlugin({ + terserOptions: { + warnings: false, // false, true, "verbose" + compress: { + drop_console: true, + drop_debugger: true, + } + } + })], + }, + + plugins: [ + new webpack.DllReferencePlugin({ + context: path.resolve(__dirname, "../../framework/src"), + manifest: require(path.resolve(frameworkPath, "vendor-manifest.json")), + sourceType: "umd2" + }), + new webpack.DllReferencePlugin({ + context: path.resolve(__dirname, "../../framework/src"), + manifest: require(path.resolve(frameworkPath, "app-manifest.json")), + sourceType: "umd2" + }), + ...(env === "release") ? [ + new webpack.DefinePlugin({ + "process.env": { + NODE_ENV: "'production'", + VERSION: JSON.stringify(require("./package.json").version) + } + }), + ] : [ + new webpack.DefinePlugin({ + "process.env": { + NODE_ENV: "'development'", + VERSION: JSON.stringify(require("./package.json").version) + } + }), + new CopyWebpackPlugin([{ + from: 'index.html', + to: distPath + }]), + ] + ], + + devServer: { + public: "http://localhost:3100", + contentBase: frameworkPath, + + compress: true, + headers: { + "Access-Control-Allow-Origin": "*" + }, + host: "0.0.0.0", + port: 3100, + disableHostCheck: true, + historyApiFallback: true, + inline: true, + hot: false, + quiet: false, + stats: { + colors: true + }, + proxy: { + "/restconf": { + target: "http://localhost:8181", + secure: false + }, + "/database": { + target: "http://localhost:8181", + secure: false + } + } + } + }]; +} diff --git a/sdnr/wt/odlux/apps/mediatorApp/pom.xml b/sdnr/wt/odlux/apps/mediatorApp/pom.xml index 8bec6d536..8bdf42a46 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/pom.xml +++ b/sdnr/wt/odlux/apps/mediatorApp/pom.xml @@ -1,111 +1,159 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <groupId>org.onap.ccsdk.parent</groupId> - <artifactId>odlparent</artifactId> - <version>1.1.2</version> - <relativePath /> - </parent> + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>odlparent</artifactId> + <version>1.1.2</version> + <relativePath /> + </parent> - <modelVersion>4.0.0</modelVersion> - <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> - <artifactId>sdnr-wt-odlux-app-mediatorApp</artifactId> - <version>0.4.1-SNAPSHOT</version> - <packaging>bundle</packaging> - <name>sdnr-wt-odlux-app-mediatorApp</name> - <licenses> - <license> - <name>Apache License, Version 2.0</name> - <url>http://www.apache.org/licenses/LICENSE-2.0</url> - </license> - </licenses> - <dependencies> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>sdnr-wt-odlux-core-model</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - <build> - <sourceDirectory>src2/main/java</sourceDirectory> - <plugins> - <plugin> - <artifactId>maven-clean-plugin</artifactId> - <version>2.5</version> - <configuration> - <filesets> + <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> + <artifactId>sdnr-wt-odlux-app-mediatorApp</artifactId> + <version>0.4.1-SNAPSHOT</version> + <packaging>bundle</packaging> + <name>sdnr-wt-odlux-app-mediatorApp</name> + <licenses> + <license> + <name>Apache License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0</url> + </license> + </licenses> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-model</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-provider</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <sourceDirectory>src2/main/java</sourceDirectory> + <plugins> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <configuration> + <filesets> + <fileset> + <directory>dist</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>../node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <!-- eclipse bug build bin folder in basedir --> <fileset> - <directory>dist</directory> + <directory>bin</directory> <followSymlinks>false</followSymlinks> </fileset> - </filesets> - </configuration> - </plugin> - <plugin> - <groupId>com.github.eirslett</groupId> - <artifactId>frontend-maven-plugin</artifactId> - <version>1.8.1-SNAPSHOT</version> - <executions> - <execution> - <id>install node and yarn</id> - <goals> - <goal>install-node-and-yarn</goal> - </goals> - <!-- optional: default phase is "generate-resources" --> - <phase>initialize</phase> - <configuration> - <nodeVersion>v8.10.0</nodeVersion> - <yarnVersion>v1.12.3</yarnVersion> - </configuration> - </execution> - <execution> - <id>yarn build</id> - <goals> - <goal>yarn</goal> - </goals> - <configuration> - <arguments>run build</arguments> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> - <Private-Package></Private-Package> - </instructions> - </configuration> - </plugin> - </plugins> - <resources> - <resource> - <directory>dist</directory> - <targetPath>odlux</targetPath> - </resource> - <resource> - <directory>src2/main/resources</directory> - </resource> - </resources> - </build> - <pluginRepositories> - <pluginRepository> - <id>highstreet repo</id> - <url>https://cloud-highstreet-technologies.com/mvn/</url> - <snapshots> - <enabled>true</enabled> - <updatePolicy>always</updatePolicy> - </snapshots> - </pluginRepository> - </pluginRepositories> -</project>
\ No newline at end of file + </filesets> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-test-source</id> + <phase>generate-test-sources</phase> + <goals> + <goal>add-test-source</goal> + </goals> + <configuration> + <sources> + <source>src2/test/java</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <version>1.8.1-SNAPSHOT</version> + <executions> + <execution> + <id>install node and yarn</id> + <goals> + <goal>install-node-and-yarn</goal> + </goals> + <!-- optional: default phase is "generate-resources" --> + <phase>initialize</phase> + <configuration> + <nodeVersion>v8.10.0</nodeVersion> + <yarnVersion>v1.12.3</yarnVersion> + </configuration> + </execution> + <execution> + <id>yarn build</id> + <goals> + <goal>yarn</goal> + </goals> + <configuration> + <arguments>run build</arguments> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> + <Private-Package></Private-Package> + </instructions> + </configuration> + </plugin> + </plugins> + <resources> + <resource> + <directory>dist</directory> + <targetPath>odlux</targetPath> + </resource> + <resource> + <directory>src2/main/resources</directory> + </resource> + <resource> + <directory>src2/test/resources</directory> + </resource> + </resources> + </build> + <pluginRepositories> + <pluginRepository> + <id>highstreet repo</id> + <url>https://cloud-highstreet-technologies.com/mvn/</url> + <snapshots> + <enabled>true</enabled> + <updatePolicy>always</updatePolicy> + </snapshots> + </pluginRepository> + </pluginRepositories> +</project> diff --git a/sdnr/wt/odlux/apps/mediatorApp/src/components/editMediatorConfigDialog.tsx b/sdnr/wt/odlux/apps/mediatorApp/src/components/editMediatorConfigDialog.tsx index 889b05eb5..c1167c4a7 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/src/components/editMediatorConfigDialog.tsx +++ b/sdnr/wt/odlux/apps/mediatorApp/src/components/editMediatorConfigDialog.tsx @@ -112,7 +112,7 @@ const settings: { [key: string]: DialogSettings } = { readonlyName: true, }, [EditMediatorConfigDialogMode.AddMediatorConfig]: { - dialogTitle: "Add Medator Configuration", + dialogTitle: "Add Mediator Configuration", dialogDescription: "", applyButtonText: "Add", cancelButtonText: "Cancel", @@ -120,7 +120,7 @@ const settings: { [key: string]: DialogSettings } = { readonlyName: false, }, [EditMediatorConfigDialogMode.EditMediatorConfig]: { - dialogTitle: "Edit Medator Configuration", + dialogTitle: "Edit Mediator Configuration", dialogDescription: "", applyButtonText: "Update", cancelButtonText: "Cancel", diff --git a/sdnr/wt/odlux/apps/mediatorApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/mediatorApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java new file mode 100644 index 000000000..d0fbe63c0 --- /dev/null +++ b/sdnr/wt/odlux/apps/mediatorApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * 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========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.odlux.OdluxBundleLoaderImpl; +import org.onap.ccsdk.features.sdnr.wt.odlux.bundles.MyOdluxBundle; + +public class TestBundleRes { + + @Test + public void test() { + OdluxBundleLoaderImpl loader = OdluxBundleLoaderImpl.getInstance(); + MyOdluxBundle b = new MyOdluxBundle(); + b.setLoader(loader); + b.setIndex(0); + b.setBundleName("abc"); + b.initialize(); + assertTrue(loader.getNumberOfBundles()==1); + assertNotNull(b.getLoader()); + assertEquals("abc",b.getBundleName()); + assertTrue(b.hasResource("test.js")); + assertNotNull(b.getResourceFileContent("test.js")); + b.clean(); + assertTrue(loader.getNumberOfBundles()==0); + } + +} diff --git a/sdnr/wt/odlux/apps/mediatorApp/src2/test/resources/test.js b/sdnr/wt/odlux/apps/mediatorApp/src2/test/resources/test.js new file mode 100644 index 000000000..b47fdc39f --- /dev/null +++ b/sdnr/wt/odlux/apps/mediatorApp/src2/test/resources/test.js @@ -0,0 +1,5 @@ +asdac sad +as +d +sad + sadfa
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/minimumApp/.fbExcludeFilterFile b/sdnr/wt/odlux/apps/minimumApp/.fbExcludeFilterFile new file mode 100644 index 000000000..3cd2303d3 --- /dev/null +++ b/sdnr/wt/odlux/apps/minimumApp/.fbExcludeFilterFile @@ -0,0 +1,25 @@ +<FindBugsFilter> + <Match> + <Or> + <Package name="~.*protobuff\.messages.*" /> + <Package name="~org\.opendaylight\.yang\.gen\..*" /> + <Package name="~org\.opendaylight\.controller\.config\.yang\.config\..*" /> + </Or> + </Match> + + <Match> + <Or> + <!-- Anonymous inner classes are very common in ODL. --> + <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON" /> + + <!-- We use static slf4j Logger (this rule is from KengoTODA/findbugs-slf4j jp.skypencil.findbugs.slf4:bug-pattern) --> + <Bug pattern="SLF4J_LOGGER_SHOULD_BE_NON_STATIC" /> + + <!-- Guava 23.6+ uses @NullableDecl which FindBugs doesn't know about; fixed in SpotBugs 3.1.2+ --> + <Bug pattern="NP_NONNULL_PARAM_VIOLATION" /> + <Bug pattern="NP_NULL_PARAM_DEREF" /> + <Bug pattern="NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE" /> + <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" /> + </Or> + </Match> +</FindBugsFilter> diff --git a/sdnr/wt/odlux/apps/minimumApp/pom.xml b/sdnr/wt/odlux/apps/minimumApp/pom.xml index f5ceb9d1c..cdc354f9f 100644 --- a/sdnr/wt/odlux/apps/minimumApp/pom.xml +++ b/sdnr/wt/odlux/apps/minimumApp/pom.xml @@ -1,110 +1,158 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <groupId>org.onap.ccsdk.parent</groupId> - <artifactId>odlparent</artifactId> - <version>1.2.1-SNAPSHOT</version> - <relativePath /> - </parent> - <modelVersion>4.0.0</modelVersion> - <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> - <artifactId>sdnr-wt-odlux-app-minimumApp</artifactId> - <version>0.4.1-SNAPSHOT</version> - <packaging>bundle</packaging> - <name>sdnr-wt-odlux-app-minimumApp</name> - <licenses> - <license> - <name>Apache License, Version 2.0</name> - <url>http://www.apache.org/licenses/LICENSE-2.0</url> - </license> - </licenses> - <dependencies> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>sdnr-wt-odlux-core-model</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - <build> - <sourceDirectory>src2/main/java</sourceDirectory> - <plugins> - <plugin> - <artifactId>maven-clean-plugin</artifactId> - <version>2.5</version> - <configuration> - <filesets> + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>odlparent</artifactId> + <version>1.2.1-SNAPSHOT</version> + <relativePath /> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> + <artifactId>sdnr-wt-odlux-app-minimumApp</artifactId> + <version>0.4.1-SNAPSHOT</version> + <packaging>bundle</packaging> + <name>sdnr-wt-odlux-app-minimumApp</name> + <licenses> + <license> + <name>Apache License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0</url> + </license> + </licenses> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-model</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-odlux-core-provider</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <sourceDirectory>src2/main/java</sourceDirectory> + <plugins> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <configuration> + <filesets> + <fileset> + <directory>dist</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>../node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <!-- eclipse bug build bin folder in basedir --> <fileset> - <directory>dist</directory> + <directory>bin</directory> <followSymlinks>false</followSymlinks> </fileset> - </filesets> - </configuration> - </plugin> - <plugin> - <groupId>com.github.eirslett</groupId> - <artifactId>frontend-maven-plugin</artifactId> - <version>1.8.1-SNAPSHOT</version> - <executions> - <execution> - <id>install node and yarn</id> - <goals> - <goal>install-node-and-yarn</goal> - </goals> - <!-- optional: default phase is "generate-resources" --> - <phase>initialize</phase> - <configuration> - <nodeVersion>v8.10.0</nodeVersion> - <yarnVersion>v1.12.3</yarnVersion> - </configuration> - </execution> - <execution> - <id>yarn build</id> - <goals> - <goal>yarn</goal> - </goals> - <configuration> - <arguments>run build</arguments> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> - <Private-Package></Private-Package> - </instructions> - </configuration> - </plugin> - </plugins> - <resources> - <resource> - <directory>dist</directory> - <targetPath>odlux</targetPath> - </resource> - <resource> - <directory>src2/main/resources</directory> - </resource> - </resources> - </build> - <pluginRepositories> - <pluginRepository> - <id>highstreet repo</id> - <url>https://cloud-highstreet-technologies.com/mvn/</url> - <snapshots> - <enabled>true</enabled> - <updatePolicy>always</updatePolicy> - </snapshots> - </pluginRepository> - </pluginRepositories> -</project>
\ No newline at end of file + </filesets> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-test-source</id> + <phase>generate-test-sources</phase> + <goals> + <goal>add-test-source</goal> + </goals> + <configuration> + <sources> + <source>src2/test/java</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <version>1.8.1-SNAPSHOT</version> + <executions> + <execution> + <id>install node and yarn</id> + <goals> + <goal>install-node-and-yarn</goal> + </goals> + <!-- optional: default phase is "generate-resources" --> + <phase>initialize</phase> + <configuration> + <nodeVersion>v8.10.0</nodeVersion> + <yarnVersion>v1.12.3</yarnVersion> + </configuration> + </execution> + <execution> + <id>yarn build</id> + <goals> + <goal>yarn</goal> + </goals> + <configuration> + <arguments>run build</arguments> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package> + <Private-Package></Private-Package> + </instructions> + </configuration> + </plugin> + </plugins> + <resources> + <resource> + <directory>dist</directory> + <targetPath>odlux</targetPath> + </resource> + <resource> + <directory>src2/main/resources</directory> + </resource> + <resource> + <directory>src2/test/resources</directory> + </resource> + </resources> + </build> + <pluginRepositories> + <pluginRepository> + <id>highstreet repo</id> + <url>https://cloud-highstreet-technologies.com/mvn/</url> + <snapshots> + <enabled>true</enabled> + <updatePolicy>always</updatePolicy> + </snapshots> + </pluginRepository> + </pluginRepositories> +</project> diff --git a/sdnr/wt/odlux/apps/minimumApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/minimumApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java new file mode 100644 index 000000000..d0fbe63c0 --- /dev/null +++ b/sdnr/wt/odlux/apps/minimumApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * 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========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.odlux.OdluxBundleLoaderImpl; +import org.onap.ccsdk.features.sdnr.wt.odlux.bundles.MyOdluxBundle; + +public class TestBundleRes { + + @Test + public void test() { + OdluxBundleLoaderImpl loader = OdluxBundleLoaderImpl.getInstance(); + MyOdluxBundle b = new MyOdluxBundle(); + b.setLoader(loader); + b.setIndex(0); + b.setBundleName("abc"); + b.initialize(); + assertTrue(loader.getNumberOfBundles()==1); + assertNotNull(b.getLoader()); + assertEquals("abc",b.getBundleName()); + assertTrue(b.hasResource("test.js")); + assertNotNull(b.getResourceFileContent("test.js")); + b.clean(); + assertTrue(loader.getNumberOfBundles()==0); + } + +} diff --git a/sdnr/wt/odlux/apps/minimumApp/src2/test/resources/test.js b/sdnr/wt/odlux/apps/minimumApp/src2/test/resources/test.js new file mode 100644 index 000000000..b47fdc39f --- /dev/null +++ b/sdnr/wt/odlux/apps/minimumApp/src2/test/resources/test.js @@ -0,0 +1,5 @@ +asdac sad +as +d +sad + sadfa
\ No newline at end of file |