Minor fixes for the Bazel build of GUI2
Change-Id: I55431b30b2c1a87165b6235b8f88436adc775457
diff --git a/web/gui/BUILD b/web/gui/BUILD
index 82c7e20..34aa8fa 100644
--- a/web/gui/BUILD
+++ b/web/gui/BUILD
@@ -108,7 +108,7 @@
" 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,6 +205,15 @@
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 adfce11..f2a6013 100644
--- a/web/gui2/BUILD
+++ b/web/gui2/BUILD
@@ -120,10 +120,11 @@
" 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 install --no-cache --loglevel=error > $$ROOT/$(location onos-gui2-npm-install.log) 2>&1 &&" +
+ " $$NPM $$NPM_ARGS 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"],
@@ -300,9 +301,9 @@
osgi_jar_with_tests(
name = "_onos-gui2-base-jar",
- exclude_tests = [
- "org.onosproject.ui.impl.AbstractUiImplTest",
- "org.onosproject.ui.impl.topo.model.AbstractTopoModelTest",
+ srcs = [
+ "src/main/java/org/onosproject/ui/impl/gui2/LogoutResource.java",
+ "//web/gui:onos-gui-java-for-gui2",
],
test_deps = TEST_DEPS,
web_context = "/onos/ui2",
@@ -319,6 +320,7 @@
":_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` &&" +
@@ -329,7 +331,7 @@
" (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/classes",
+ " jar cmf META-INF/MANIFEST.MF $$ROOT/$@ WEB-INF/web.xml WEB-INF/classes",
output_to_bindir = 1,
visibility = ["//visibility:public"],
)
diff --git a/web/gui2/README.md b/web/gui2/README.md
index 9883467..3064b76 100644
--- a/web/gui2/README.md
+++ b/web/gui2/README.md
@@ -81,11 +81,7 @@
## 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 (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/ )
+It runs ```ng build --prod --extract-css``` and copies everything over in 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
deleted file mode 100644
index 643e597..0000000
--- a/web/gui2/src/main/java/org/onosproject/ui/impl/DummyClass.java
+++ /dev/null
@@ -1,34 +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;
-
-/**
- * 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
new file mode 100644
index 0000000..19c606d
--- /dev/null
+++ b/web/gui2/src/main/java/org/onosproject/ui/impl/gui2/LogoutResource.java
@@ -0,0 +1,46 @@
+/*
+ * 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/package-info.java b/web/gui2/src/main/java/org/onosproject/ui/impl/gui2/package-info.java
similarity index 87%
rename from web/gui2/src/main/java/org/onosproject/ui/impl/package-info.java
rename to web/gui2/src/main/java/org/onosproject/ui/impl/gui2/package-info.java
index 3fe40b2..df962e5 100644
--- a/web/gui2/src/main/java/org/onosproject/ui/impl/package-info.java
+++ b/web/gui2/src/main/java/org/onosproject/ui/impl/gui2/package-info.java
@@ -15,6 +15,6 @@
*/
/**
- * Set of resources providing data for the ONOS GUI.
+ * Set of resources providing data for the ONOS GUI2.
*/
-package org.onosproject.ui.impl;
\ No newline at end of file
+package org.onosproject.ui.impl.gui2;
\ 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 ae8c650..60c222b 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 @@
<!--<url-pattern>/raw/*</url-pattern>-->
<!--</servlet-mapping>-->
- <!--<servlet>-->
- <!--<servlet-name>JAX-RS Service</servlet-name>-->
- <!--<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>-->
- <!--<init-param>-->
- <!--<param-name>jersey.config.server.provider.classnames</param-name>-->
- <!--<param-value>-->
- <!--org.glassfish.jersey.media.multipart.MultiPartFeature,-->
- <!--org.onosproject.ui.impl.LogoutResource,-->
+ <servlet>
+ <servlet-name>JAX-RS Service</servlet-name>
+ <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
+ <init-param>
+ <param-name>jersey.config.server.provider.classnames</param-name>
+ <param-value>
+ org.glassfish.jersey.media.multipart.MultiPartFeature,
+ org.onosproject.ui.impl.gui2.LogoutResource,
<!--org.onosproject.ui.impl.TopologyResource,-->
- <!--org.onosproject.ui.impl.ApplicationResource-->
- <!--</param-value>-->
- <!--</init-param>-->
- <!--<load-on-startup>1</load-on-startup>-->
- <!--</servlet>-->
+ org.onosproject.ui.impl.ApplicationResource
+ </param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
- <!--<servlet-mapping>-->
- <!--<servlet-name>JAX-RS Service</servlet-name>-->
- <!--<url-pattern>/rs/*</url-pattern>-->
- <!--</servlet-mapping>-->
+ <servlet-mapping>
+ <servlet-name>JAX-RS Service</servlet-name>
+ <url-pattern>/rs/*</url-pattern>
+ </servlet-mapping>
<!--<servlet>-->
<!--<servlet-name>Web Socket Service</servlet-name>-->
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 9aa9584..230263d 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 @@
</td>
<td class="table-icon">
<!-- The path below gets the app icon from the old GUI path -->
- <img src="../../ui/rs/applications/{{app.icon}}/icon"
+ <img src="rs/applications/{{app.icon}}/icon"
height="24px" width="24px" />
</td>
<td>{{ app.title }}</td>
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 b2f6231..3a8e2a8 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 DRAGDROPMSGEXT = 'Only files ending in .oar can be dropped';
/** Prefix to access the REST service for applications */
-export const APPURLPREFIX = '../../ui/rs/applications/'; // TODO: This is a hack to work off GUIv1 URL
+export const APPURLPREFIX = 'rs/applications/';
/** 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 a5ce1d9..6e7b732 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 @@
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
- * This is just a dummy file to get BUCK going.
+ * This is just a dummy file to satisfy Bazel's need for a file to be present.
*/
public class DummyTest {
@Test
public void dummyTest() {
- assertEquals("test", DummyClass.getDummyAttribute());
+ assertTrue(true);
}
}