diff --git a/web/gui/BUILD b/web/gui/BUILD index 34aa8fa183..82c7e208e1 100644 --- a/web/gui/BUILD +++ b/web/gui/BUILD @@ -108,7 +108,7 @@ genrule( " export HOME=. &&" + " export XDG_CONFIG_HOME=$(@D)/config &&" + # npm config cache to the sandbos " export BABEL_DISABLE_CACHE=1 &&" + # turn off babel cache - " if [[ ! -z $${HTTP_PROXY-} ]]; then NPM_ARGS='--proxy $$HTTP_PROXY --without-ssl --insecure'; else NPM_ARGS=''; fi &&" + + ' if [[ ! -z $${HTTP_PROXY-} ]]; then NPM_ARGS="--proxy $$HTTP_PROXY --without-ssl --insecure"; else NPM_ARGS=""; fi &&' + " NPM=$$ROOT/$(location @nodejs//:bin/npm) &&" + " mkdir -p tools/gui &&" + " cd tools/gui &&" + @@ -205,15 +205,6 @@ osgi_jar_with_tests( deps = COMPILE_DEPS, ) -filegroup( - name = "onos-gui-java-for-gui2", - srcs = glob([ - "src/main/java/org/onosproject/ui/impl/Main*Resource.java", - "src/main/java/org/onosproject/ui/impl/ApplicationResource.java", - ]), - visibility = ["//visibility:public"], -) - """ Builds the tar ball for the ONOS GUI """ diff --git a/web/gui2/BUILD b/web/gui2/BUILD index f2a6013148..adfce1199e 100644 --- a/web/gui2/BUILD +++ b/web/gui2/BUILD @@ -120,11 +120,10 @@ genrule( " export HOME=. &&" + " export XDG_CONFIG_HOME=$(@D)/config &&" + # npm config cache to the sandbox " export BABEL_DISABLE_CACHE=1 &&" + # turn off babel cache - " if [[ ! -z $${HTTP_PROXY-} ]]; then NPM_ARGS='--proxy $$HTTP_PROXY --without-ssl --insecure'; else NPM_ARGS=''; fi &&" + " NPM=$$ROOT/$(location @nodejs//:bin/npm) &&" + " mkdir -p web/gui2 &&" + " cd web/gui2 &&" + - " $$NPM $$NPM_ARGS install --no-cache --loglevel=error > $$ROOT/$(location onos-gui2-npm-install.log) 2>&1 &&" + + " $$NPM install --no-cache --loglevel=error > $$ROOT/$(location onos-gui2-npm-install.log) 2>&1 &&" + " jar Mcf $$ROOT/$(location onos-gui2-npm-install.jar) . &&" + " touch $$ROOT/$(location onos-gui2-npm-install.log)", # to get the log always as the 2nd file visibility = ["//visibility:public"], @@ -301,9 +300,9 @@ genrule( osgi_jar_with_tests( name = "_onos-gui2-base-jar", - srcs = [ - "src/main/java/org/onosproject/ui/impl/gui2/LogoutResource.java", - "//web/gui:onos-gui-java-for-gui2", + exclude_tests = [ + "org.onosproject.ui.impl.AbstractUiImplTest", + "org.onosproject.ui.impl.topo.model.AbstractTopoModelTest", ], test_deps = TEST_DEPS, web_context = "/onos/ui2", @@ -320,7 +319,6 @@ genrule( ":_onos-gui2-ng-build", ":_onos-gui2-base-jar", ":_web_inf_classes_files", - "src/main/webapp/WEB-INF/web.xml", ], outs = ["onos-gui2.jar"], cmd = " ROOT=`pwd` &&" + @@ -331,7 +329,7 @@ genrule( " (cd WEB-INF/classes && jar xf $$ROOT/$${BUILD_FILES[1]}) &&" + " jar xf $$ROOT/$(location :_onos-gui2-base-jar) &&" + " find . -type f -exec touch -t 201808280000 {} \; &&" + - " jar cmf META-INF/MANIFEST.MF $$ROOT/$@ WEB-INF/web.xml WEB-INF/classes", + " jar cmf META-INF/MANIFEST.MF $$ROOT/$@ WEB-INF/classes", output_to_bindir = 1, visibility = ["//visibility:public"], ) diff --git a/web/gui2/README.md b/web/gui2/README.md index 3064b762d9..9883467181 100644 --- a/web/gui2/README.md +++ b/web/gui2/README.md @@ -81,7 +81,11 @@ Run `ng generate component component-name` to generate a new component. You can ## Build The build is handled through the web/gui2/BUCK file. This downloads Node, NPM and Angular CLI -It runs ```ng build --prod --extract-css``` and copies everything over in to WEB-INF/classes/dist +It runs ```ng build --prod --extract-css``` and copies everything over in to WEB-INF/classes/dist (there +is something weird in BUCK resources - if there is a file in the root dir of the +outputted folder this is copied to the sources root directory, where as files +are copied to WEB-INF/classes. To get around this I put all the outputted stuff in to +```dist``` and it gets copied to /WEB-INF/classes/dist/ ) To run it manually in Angular CLI run `ng build` (and add on --prod --extract-css --watch as necessary to alter its behaviour) diff --git a/web/gui2/src/main/java/org/onosproject/ui/impl/DummyClass.java b/web/gui2/src/main/java/org/onosproject/ui/impl/DummyClass.java new file mode 100644 index 0000000000..643e597039 --- /dev/null +++ b/web/gui2/src/main/java/org/onosproject/ui/impl/DummyClass.java @@ -0,0 +1,34 @@ +/* + * Copyright 2018-present Open Networking Foundation + * + * 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. + */ + +package org.onosproject.ui.impl; + +/** + * A dummy class to satisfy Bazel build. + * Since all classes implementing the REST interface to the GUI framework for GUI2 + * are in the /web/gui project, no classes are needed here. + */ +public final class DummyClass { + private static final String DUMMY_ATTRIBUTE = "test"; + + private DummyClass() { + //Hidden + } + + static String getDummyAttribute() { + return DUMMY_ATTRIBUTE; + } +} diff --git a/web/gui2/src/main/java/org/onosproject/ui/impl/gui2/LogoutResource.java b/web/gui2/src/main/java/org/onosproject/ui/impl/gui2/LogoutResource.java deleted file mode 100644 index 19c606da68..0000000000 --- a/web/gui2/src/main/java/org/onosproject/ui/impl/gui2/LogoutResource.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2018-present Open Networking Foundation - * - * 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. - */ -package org.onosproject.ui.impl.gui2; - -import org.onlab.rest.BaseResource; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; - -/** - * Application upload resource for GUI 2. - */ -@Path("logout") -public class LogoutResource extends BaseResource { - - @Context - private HttpServletRequest servletRequest; - - @GET - public Response logout() throws IOException, URISyntaxException { - servletRequest.getSession().invalidate(); - String url = servletRequest.getRequestURL().toString(); - url = url.replaceFirst("/onos/ui2/.*", "/onos/ui2/login.html"); - return Response.temporaryRedirect(new URI(url)).build(); - } - -} diff --git a/web/gui2/src/main/java/org/onosproject/ui/impl/gui2/package-info.java b/web/gui2/src/main/java/org/onosproject/ui/impl/package-info.java similarity index 87% rename from web/gui2/src/main/java/org/onosproject/ui/impl/gui2/package-info.java rename to web/gui2/src/main/java/org/onosproject/ui/impl/package-info.java index df962e5f07..3fe40b2993 100644 --- a/web/gui2/src/main/java/org/onosproject/ui/impl/gui2/package-info.java +++ b/web/gui2/src/main/java/org/onosproject/ui/impl/package-info.java @@ -15,6 +15,6 @@ */ /** - * Set of resources providing data for the ONOS GUI2. + * Set of resources providing data for the ONOS GUI. */ -package org.onosproject.ui.impl.gui2; \ No newline at end of file +package org.onosproject.ui.impl; \ No newline at end of file diff --git a/web/gui2/src/main/webapp/WEB-INF/web.xml b/web/gui2/src/main/webapp/WEB-INF/web.xml index 60c222b0e4..ae8c650b49 100644 --- a/web/gui2/src/main/webapp/WEB-INF/web.xml +++ b/web/gui2/src/main/webapp/WEB-INF/web.xml @@ -135,25 +135,25 @@ - - JAX-RS Service - org.glassfish.jersey.servlet.ServletContainer - - jersey.config.server.provider.classnames - - org.glassfish.jersey.media.multipart.MultiPartFeature, - org.onosproject.ui.impl.gui2.LogoutResource, + + + + + + + + - org.onosproject.ui.impl.ApplicationResource - - - 1 - + + + + + - - JAX-RS Service - /rs/* - + + + + diff --git a/web/gui2/src/main/webapp/app/view/apps/apps/apps.component.html b/web/gui2/src/main/webapp/app/view/apps/apps/apps.component.html index 230263d2f5..9aa9584239 100644 --- a/web/gui2/src/main/webapp/app/view/apps/apps/apps.component.html +++ b/web/gui2/src/main/webapp/app/view/apps/apps/apps.component.html @@ -118,7 +118,7 @@ - {{ app.title }} diff --git a/web/gui2/src/main/webapp/app/view/apps/apps/apps.component.ts b/web/gui2/src/main/webapp/app/view/apps/apps/apps.component.ts index 3a8e2a838f..b2f62311fb 100644 --- a/web/gui2/src/main/webapp/app/view/apps/apps/apps.component.ts +++ b/web/gui2/src/main/webapp/app/view/apps/apps/apps.component.ts @@ -39,7 +39,7 @@ const DRAGDROPMSG1 = 'Drag and drop one file at a time'; const DRAGDROPMSGEXT = 'Only files ending in .oar can be dropped'; /** Prefix to access the REST service for applications */ -export const APPURLPREFIX = 'rs/applications/'; +export const APPURLPREFIX = '../../ui/rs/applications/'; // TODO: This is a hack to work off GUIv1 URL /** Suffix to access the icon of the application - gives back an image */ export const ICONURLSUFFIX = '/icon'; diff --git a/web/gui2/src/test/java/org/onosproject/ui/impl/DummyTest.java b/web/gui2/src/test/java/org/onosproject/ui/impl/DummyTest.java index 6e7b7327b1..a5ce1d9248 100644 --- a/web/gui2/src/test/java/org/onosproject/ui/impl/DummyTest.java +++ b/web/gui2/src/test/java/org/onosproject/ui/impl/DummyTest.java @@ -17,15 +17,15 @@ package org.onosproject.ui.impl; import org.junit.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; /** - * This is just a dummy file to satisfy Bazel's need for a file to be present. + * This is just a dummy file to get BUCK going. */ public class DummyTest { @Test public void dummyTest() { - assertTrue(true); + assertEquals("test", DummyClass.getDummyAttribute()); } }